2.9 KiB
2.9 KiB
Contributing
Local backend
- Copy
.env.exampleto.envand setSESSION_SECRET(at least 16 characters). docker compose up -d postgres mailhog— omitmailhogif you only need Postgres. WithoutSMTP_URL, the magic-link verify URL is printed in the dev server log.npm cinpx prisma migrate dev- (Optional)
npx prisma db seed— seeds curated rule templates. Idempotent; rows upsert byslug. npm run dev
Use npx prisma studio to inspect the database.
Prisma migrations
- Never edit a migration that has already been applied to staging, production, or any shared database. Add a new migration that corrects the schema instead. Full policy: docs/guides/backend-roadmap.md §8.
API routes
| Method | Path | Purpose |
|---|---|---|
| GET | /api/health |
Liveness / DB check. |
| GET | /api/auth/session |
Current user or null. |
| POST | /api/auth/magic-link/request |
Send sign-in link email. |
| GET | /api/auth/magic-link/verify |
Validate token, set cookie, redirect. |
| POST | /api/auth/logout |
Clear session. |
| GET / PUT | /api/drafts/me |
Load or save the create-flow draft. |
| GET / POST | /api/rules |
List or publish rules. |
| GET | /api/templates |
List curated templates. |
Magic-link sign-in
- Visit /login or use Log in in the site header.
- Without
SMTP_URL: copy the verify URL from the dev server terminal. - With Mailhog: set
SMTP_URL=smtp://localhost:1025and open the message at http://localhost:8025. - Open the link in the same browser as the app (session cookie).
Optional draft sync
NEXT_PUBLIC_ENABLE_BACKEND_SYNC=true enables Postgres draft persistence
via PUT /api/drafts/me for signed-in users and post-sign-in upload of
anonymous drafts. Without it, anonymous progress stays in localStorage
and signed-in progress stays in memory until Save & Exit.
Create flow
The custom wizard lives under /create/…. Step order, URLs, and Figma
stage mapping are canon in docs/create-flow.md.
Engineering tracking: Linear CR-89 /
docs/guides/backend-linear-tickets.md
Ticket 17.
Frontend & tests
- Code conventions are enforced by
.cursor/rules/*.mdc— Cursor surfaces the relevant rule when editing matching files. - See docs/testing-guide.md for testing
philosophy and
.cursor/rules/testing.mdcfor layout/helpers.
Pull request workflow
- Branch from
main:git checkout -b feature/<short-name>. - Make the change and add/update tests.
npm test && npm run e2e(andnpm run storybook:buildif you touched stories).- Commit using a clear message (
feat:,fix:,chore:, …). - Open a PR; CI runs unit, E2E, visual regression, and Lighthouse.