HomeDocumentationEnvironment & Deployment
Developer
⚙️

Environment & Deployment

All environment variables, local setup, Vercel deployment, database migrations, and cron configuration.

Last updated 2026-05-15T23:54:42.185064+00:00

Required environment variables

Database:

DATABASE_URL — PostgreSQL via PgBouncer port 6543 with pgbouncer=true&connection_limit=1

DIRECT_URL — Direct port 5432 for migrations only


Auth:

JWT_SECRET — random 64-character string

SUPER_ADMIN_SECRET — random string


Supabase:

NEXT_PUBLIC_SUPABASE_URL — https://xxxx.supabase.co

SUPABASE_SERVICE_ROLE_KEY — eyJ...

NEXT_PUBLIC_SUPABASE_ANON_KEY — eyJ...


App:

NEXT_PUBLIC_APP_URL — https://doctor.clinit.app


Email:

RESEND_API_KEY — re_...


Payments:

PAYMOB_API_KEY — from Paymob dashboard

PAYMOB_INTEGRATION_ID — from Paymob dashboard

PAYMOB_IFRAME_ID — from Paymob dashboard

PAYMOB_HMAC_SECRET — from Paymob webhook settings


Cron:

CRON_SECRET — random string


DATABASE_URL must use port 6543 (PgBouncer) for serverless safety. Use DIRECT_URL port 5432 only for prisma migrate.

Local development setup

  1. Clone and install:

npm install


  1. Configure environment:

cp .env.example .env

Fill in DATABASE_URL, DIRECT_URL, JWT_SECRET, SUPABASE_*, RESEND_API_KEY


  1. Generate Prisma client:

npx prisma generate


  1. Push schema to database:

npx prisma db push


  1. Run Phase migrations in Supabase SQL Editor:

Open SQL Editor > paste phase1_phase2_part1.sql > Run

Open a NEW query tab > paste phase1_phase2_part2.sql > Run

(Two separate transactions required — see note below)


  1. Seed demo data:

npx prisma db seed


  1. Start development server:

npm run dev

App runs at http://localhost:3000

Demo login: owner@demo-dental.com / Demo@1234


Why two migration parts: Postgres requires ALTER TYPE ADD VALUE to commit before the new enum value (ARRIVED) can be referenced in any query or index. Running both in the same transaction causes ERROR 55P04. Part 1 adds the value; Part 2 creates the index in a fresh transaction.

Vercel deployment

Build command (set in Vercel dashboard):

prisma generate && next build (using webpack flag)


After schema changes:

  1. Supabase SQL Editor: run phase1_phase2_part1.sql — wait for Messages panel to show all NOTICE lines
  2. New Supabase SQL Editor tab: run phase1_phase2_part2.sql
  3. npx prisma generate locally
  4. Push to main branch — Vercel auto-deploys

Cron jobs (vercel.json):

Path /api/cron/daily — schedule: 0 2 * * * (02:00 UTC daily)

Path /api/cron/daily?task=reminders — schedule: 0 * * * * (hourly)


Cron routes are protected by Authorization: Bearer CRON_SECRET

Demo credentials

After running npx prisma db seed, 7 demo clinics are created. All use password Demo@1234:


owner@demo-dental.com — Dental

owner@demo-optical.com — Optical

owner@demo-pediatrics.com — Pediatrics

owner@demo-dermatology.com — Dermatology

owner@demo-cardiology.com — Cardiology

owner@demo-physiotherapy.com — Physiotherapy

owner@demo-general.com — General Medicine


Each clinic has: 30 patients, 5 doctors, 45 appointments, and full specialty data including tooth charts, growth records, eye exams, cardiac studies, skin conditions, and treatment plans.

Was this helpful?
Contact support if something isn't clear.