2.2 KiB
2.2 KiB
Contributing
Backend (local)
- Copy
.env.exampleto.env.localand setSESSION_SECRET(at least 16 characters). - Start Postgres (and optional Mailhog):
docker compose up -d postgres mailhog. On Apple Silicon, Mailhog is configured forlinux/amd64indocker-compose.yml(clear emulation path). You can usedocker compose up -d postgresonly and read OTPs from the dev server log instead of Mailhog (see.env.example). - Install dependencies:
npm ci - Apply migrations:
npx prisma migrate dev - Run the app:
npm run dev
Use npx prisma studio to inspect the database.
Prisma migrations (important)
- Do not edit migration files that have already been applied to staging, production, or any shared database. Changing history breaks
migrate deployand other environments. - To fix a bad migration, add a new migration that corrects the schema. See docs/backend-roadmap.md §8 for the full policy.
API routes (overview)
| Method | Path | Purpose |
|---|---|---|
| GET | /api/health |
Liveness / DB check |
| GET | /api/auth/session |
Current user or null |
| POST | /api/auth/otp/request |
Send email OTP |
| POST | /api/auth/otp/verify |
Verify OTP, set session cookie |
| POST | /api/auth/logout |
Clear session |
| GET / PUT | /api/drafts/me |
Load or save create-flow JSON (authenticated) |
| GET / POST | /api/rules |
List or publish rules |
| GET | /api/templates |
List curated templates |
Optional draft sync
Set NEXT_PUBLIC_ENABLE_BACKEND_SYNC=true in .env.local so the create flow saves drafts to the server when a user is logged in.
Frontend / tests
See docs/TESTING_GUIDE.md and the root README.md.