adilallo/feature/BackendImplementation1 #43
Reference in New Issue
Block a user
Delete Branch "adilallo/feature/BackendImplementation1"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Backend foundation: CR-72–CR-74 (roadmap, CreateFlow validation, magic-link auth)
Overview
This PR delivers the first three items in the documented backend sequence: CR-72 (roadmap aligned with the real stack), CR-73 (
CreateFlowStateformalized + Zod validation and size limits on draft/publish APIs), and CR-74 (magic-link sign-in end-to-end: APIs, Prisma, mail,/login, session-aware header, placeholder/profile).It also includes the supporting repo work that shows up in the same branch: Prisma schema/migrations,
app/api/*route handlers (auth, drafts, rules, templates, health),lib/server/*, Docker/Mailhog, CONTRIBUTING /.env.example, create-flow backend sync wiring, Playwright (standalone e2e server, visual snapshot refresh,visual:updatefix), Vitest fixes, navigation session integration, and Storybook/tests for Login.Out of scope here (next tickets): CR-75 create-flow session UI in CreateFlowTopNav, and later items in the chain (CR-76+).
Changes
CR-72 — Roadmap & contributor truth
docs/backend-roadmap.md: current backend (Postgres/Prisma, APIs, draft sync, build order, operator vs shipped vs remaining).docs/backend-linear-tickets.md: ticket text, Linear mapping table, CR-74 residuals, dependency notes (e.g. CR-84/CR-85/CR-86).CONTRIBUTING.md: API overview, magic-link local testing, Mailhog, env hints..env.example,README.mdtouch-ups as needed for local/backend setup.CR-73 — Create flow types & API validation
app/create/types.ts: structuredCreateFlowState(replacing looseunknownwhere agreed).lib/server/validation/: Zod (and helpers) for draft payload and publish document; plain JSON / size checks; consistent 400 responses on bad input.app/api/drafts/me/route.ts,app/api/rules/route.ts: validate bodies with those schemas.tests/unit/createFlowValidation.test.ts: schema/route-shape coverage.package.json:zod(and lockfile) as required.CR-74 — Magic-link auth & session UX
POST /api/auth/magic-link/request,GET /api/auth/magic-link/verify,GET /api/auth/session,POST /api/auth/logout.prisma/schema.prisma, migrations (MagicLinkToken, etc.),lib/server/(session, mail, hash, rate limit,navAuthfor SSR header).app/login/,Loginmodal stack (LoginForm, container/view/types),app/profile/placeholder.ConditionalNavigation/TopNav: Log in vs Profile from real session; client/server split where needed.lib/create/api.ts(requestMagicLink, session helpers,safeInternalPath),ContentLockup/ModalHeaderadjustments for login/a11y.stories/modals/Login.stories.tsx,tests/components/Login*.tsx.Shared / cross-cutting (supports 72–74)
CreateFlowBackendSync,CreateFlowContext/ layout hooks for optional server draft sync.app/api/for health, templates, and other handlers present in the branch diff.Dockerfile,docker-compose.yml,.dockerignore,.gitea/workflows/ci.yamlupdates.next.config.mjs,playwright.config.ts,package.jsonscripts (start:e2e,visual:updatewith--update-snapshots=all),scripts/seed-snapshots.sh.tests/pages/home.test.jsxdynamic section wait./loginreliability:usePortal={false}for full-page login + ESLint-safe portal readiness (requestAnimationFrame) for modal path.Screenshots
How to Test
.envfrom.env.example, Postgres +npx prisma migrate dev(or deploy) per CONTRIBUTING.PUT /api/drafts/meandPOST /api/ruleswith invalid/oversized JSON; expect 400 with structured error, not 500./login→ request link → complete verify (logs or Mailhog);/api/auth/sessionwith cookie; header Profile →/profile; logout clears session.npm run lint,npm run test,CI= npm run e2e(or CI pipeline with build + standalone server on 127.0.0.1:3010).Notes
Host/ reverse proxy vsrequest.nextUrl.origin); can stay a small follow-up issue.*.pngin the diff if helpful.CI=1is set locally, Playwright may not startwebServer—useCI=or runnpm run build && npm run start:e2eyourself.