Separate Go backend service for Flippy.
- Go
- PostgreSQL
- SQL migrations
- Layered architecture with
handler,service, andrepository
backend/
cmd/api/
docs/
internal/
config/
domain/
handler/http/
repository/
server/
service/
migrations/
cp .env.example .env
go mod tidy
go run ./cmd/apiServer health endpoint:
GET /health
GET /health
GET /api/v1/courses
POST /api/v1/auth/register
POST /api/v1/auth/login
GET /api/v1/auth/me
GET /api/v1/flashcard-sets
GET /api/v1/flashcard-sets/:slug
GET /api/v1/flashcard-sets/:slug/cards
POST /api/v1/flashcard-sets
PATCH /api/v1/flashcard-sets/:slug
DELETE /api/v1/flashcard-sets/:slug
POST /api/v1/flashcard-sets/:slug/cards
PATCH /api/v1/flashcards/:id
DELETE /api/v1/flashcards/:id
/api/v1/auth/me expects:
Authorization: Bearer <access_token>
Protected flashcard-set write routes also require the same Bearer token. Flashcard create, update, and delete routes require the same Bearer token.
Most hosts will only need these:
APP_ENV=production
PORT=8080
APP_BASE_URL=https://your-api-host.com
CORS_ALLOWED_ORIGINS=https://flippy-playground.vercel.app,http://localhost:3000
DATABASE_URL=postgres://...
JWT_ACCESS_SECRET=...
JWT_REFRESH_SECRET=...
Notes:
DATABASE_URLis preferred in production.PORTis supported automatically for Railway/Render/Fly-style platforms.CORS_ALLOWED_ORIGINSshould include your Vercel frontend URL.
Core schema is defined in:
migrations/000001_init_schema.up.sqlmigrations/000001_init_schema.down.sqldocs/database-schema.md
Apply the migration before starting the API in production.
Recommended setup:
- frontend: Vercel
- backend: Railway, Render, or Fly.io
- database: Railway Postgres, Neon, Supabase Postgres, or Render Postgres
Suggested flow for the separate Flippy-Backend repo:
- Copy this
backend/directory into the root ofFlippy-Backend. - Push the repo.
- Provision PostgreSQL.
- Run
migrations/000001_init_schema.up.sqlon that database. - Set the environment variables listed above.
- Deploy using the included
Dockerfileor native Go buildpack support. - Point the frontend to
https://your-api-host.com/api/v1.
- auth
- users
- courses
- flashcard sets
- flashcards
- learning progress
Point the Next.js frontend services to the Go backend base URL, for example:
http://localhost:8080/api/v1
Production example:
https://your-api-host.com/api/v1
Good first integrations:
- login
- register
- fetch current user
- fetch courses
Recommended setup with Resend API:
[email protected]
RESEND_API_KEY=re_your_resend_api_key
Notes:
RESEND_API_KEYis used directly by the backend to send reset emails through Resend.[email protected]is fine for testing. For production, verify your own domain in Resend and use a sender like[email protected].
Optional SMTP fallback:
SMTP_HOST=smtp.resend.com
SMTP_PORT=587
SMTP_USER=resend
SMTP_PASS=your_resend_smtp_password