Capstone implementation plan
What you need to know
Implement the capstone in small vertical slices, each with a tested data contract and visible user outcome. Build the public catalog before private progress, and add mutation consistency before deployment.
By the end, you can: sequence data, UI and mutation work; specify acceptance tests.
An optimistic concurrency predicate
UPDATE progress SET percent = ?, revision = revision + 1WHERE tenant_id = ? AND member_id = ? AND lesson_id = ? AND revision = ?;Expected behavior: One affected row means the expected version matched. Zero rows requires the service to distinguish missing/denied versus conflict under its policy.
How it works
The public catalog needs a deterministic source and explicit published filtering. Give each lesson a stable slug. A generated static route can use a reviewed inventory and return not-found for unknown slugs. The private dashboard uses a verified actor and request-time data. A form sends lesson ID, percent and expected revision; never trusts tenant/member inputs. The server validates integers and checks ownership in the update predicate. A revision mismatch returns a conflict rather than overwriting a newer edit. An idempotency record binds actor, key and payload so a repeated request does not apply the mutation twice. After current authorization succeeds, check an existing matching operation record before rejecting the old expected revision: a successful retry naturally carries the original revision. A different payload under the same key is a conflict. Persist the original outcome and event in the same transaction as the write. In a real deployment the verified session adapter must be supplied and tested; the staged app deliberately refuses access until it is wired. The independent SQLite fixture tests transactions using synthetic identities directly and is not a session implementation. Use semantic forms with labels, error summaries and keyboard-accessible controls. Public metadata and sitemap use published data; the lab uses a reserved example domain, not a real service. Keep the starter incomplete only at a documented service boundary. Use the reference solution and tests for feedback, not code copying.
A mutation response contract
[ { "status": 200, "body": { "percent": 50, "revision": 2 } }, { "status": 400, "body": { "error": "invalid input" } }, { "status": 401, "body": { "error": "session required" } }, { "status": 404, "body": { "error": "not found" } }, { "status": 409, "body": { "error": "conflict" } }]Expected behavior: HTTP examples are the specified interface, not observations of a running Next.js app.
Common mistake
Do not update by lesson ID alone or accept a member ID from a hidden field. A successful form submission in one browser is not evidence that concurrent edits or direct calls are safe.
Practice and verification
Complete the starter service, run the local SQLite contract tests, then review the staged app file tree. Add an invalid percent case and a stale revision case; verify no side effects on the denied or conflicting path.
Scope: Proposed Next.js 16.x / React 19; App Router, Cache Components disabled unless noted. Framework and browser examples are staged, not executed. No exact patched dependency release or live deployment verified.