A Simple Demo for GitHub
Getting started
Local dev
docker-compose up -d
npm run db:migrate # prompts for a migration name
npm run dev
Production (Hetzner VM)
- Edit .env on the VM, switch the DATABASE_URL to point at the VM's PostgreSQL.
- Run npm run db:migrate:prod — this runs prisma migrate deploy (no prompts, safe for CI/CD).
Switching environments
Only the DATABASE_URL in .env needs to change. Comment/uncomment the appropriate line:
DATABASE_URL="postgresql://goaltracker:goaltracker@localhost:5432/goaltracker"
Architecture
Browser (useGoals hook) │ client-side penalty logic runs here │ optimistic UI updates │ ├── GET /api/goals?username=X → load goals + logs ├── POST /api/goals → create goal ├── PATCH /api/goals/[id] → update goal state after logging ├── POST /api/goals/[id]/logs → upsert daily log entry └── DELETE /api/goals/[id] → delete goal
API Routes (server-only) └── lib/db.ts (Prisma singleton) └── PostgreSQL
Your repository must be hosted on GitHub, GitLab, or Bitbucket before importing into Vercel.
Choose one of the following options:
- Vercel Postgres (easiest): In your Vercel dashboard go to Storage → Create Database → Postgres. It automatically sets the
DATABASE_URLenvironment variable. - Neon (free tier): Create a project at neon.tech and copy the connection string.
- Supabase (free tier): Create a project at supabase.com and copy the connection string.
- Go to vercel.com → "Add New Project"
- Import your GitHub repository
- Vercel auto-detects Next.js — no framework configuration needed
In your Vercel project settings → Environment Variables, add:
DATABASE_URL=postgresql://user:password@host:5432/dbname?sslmode=require
Most managed Postgres providers require
?sslmode=requireat the end of the connection string.
In Vercel project settings → Build & Development Settings, set the Build Command to:
prisma generate && prisma migrate deploy && next buildAlternatively, add a vercel.json file at the project root:
{
"buildCommand": "prisma generate && prisma migrate deploy && next build"
}This runs prisma migrate deploy (not migrate dev), which applies existing migrations non-interactively — the correct mode for production.
Trigger a deployment. Vercel will run the build command, apply database migrations, and publish the app.
Notes:
- Always use
prisma migrate deployin production, neverprisma migrate dev. - If you experience connection issues at scale, consider using Prisma Accelerate or a connection pooler such as PgBouncer, as Vercel's serverless functions can open many short-lived database connections.
