Hands-On Lab and Phase Exit
Follow, modify, implement, engineer, and prove Phase 11 understanding
Phase 11 - Persistent Task CRUD API
Volume 03 - Database Engineering
Architecture milestone
Build persistent CRUD
↓
Stress the mental model
↓
Graduate to validation
Phase 11 replaces process memory with durable PostgreSQL-backed application behavior.
Hands-on lab - build persistence without copying
blindly
Use the reference snapshot only after attempting the steps yourself. The goal is to prove that you understand
which layer owns each operation.
Level 1 - Follow
• Apply the additive TaskFlow domain migration.
• Run prisma generate and confirm the NestJS build still succeeds.
• Run prisma/seed.ts and record the generated Project ID.
• Register TasksModule and start the API.
• Create, list, read, update, and delete a Task through HTTP.
Level 2 - Modify
• Create three Tasks with different priorities.
• Update one Task from TODO to IN_PROGRESS, then DONE.
• Give another Task a description, then set description back to null.
• Verify updatedAt changes while createdAt remains stable.
Level 3 - Implement
• Add a service method that returns only Tasks for a given projectId. You may expose it temporarily through a
project-scoped route, but do not add pagination yet.
• Return only the fields the caller needs with Prisma select, then explain what changed in the TypeScript return
shape.
• Write a PowerShell script that creates a Task, updates it, reads it, restarts the verification manually, and finally
deletes it.
Level 4 - Engineer
Suppose production already contains 100,000 legacy Todo rows and the business now wants the new
Project/Task model. Explain why simply dropping Todo is unacceptable. Propose an additive migration, data
backfill/mapping strategy, verification step, and later cleanup migration. No code is required until the migration
plan is coherent.
Phase exit questions
Question What a strong answer should mention
Why is PrismaService not business logic? It exposes DB access; domain behavior belongs in services
Why does Task need projectId? The durable model requires project ownership/relationship
Why preserve the Todo table temporarily? Additive migration avoids accidental destructive change
Why does TypeScript not validate JSON? Types disappear at runtime; Phase 12 adds validation
What proves persistence? Same row survives NestJS process restart
Question What a strong answer should mention
Why return 404 for P2025? Translate storage-specific absence into HTTP resource semantics
Exit checklist
• [ ] prisma validate passes.
• [ ] add_taskflow_domain migration applies.
• [ ] prisma generate runs after schema changes.
• [ ] seed prints a valid Project ID.
• [ ] POST /tasks persists a row.
• [ ] GET collection/detail reads durable rows.
• [ ] PATCH modifies a row.
• [ ] DELETE returns 204 and removes a row.
• [ ] Missing Task returns 404.
• [ ] Restarting NestJS does not erase data.
• [ ] Next.js can render the durable list.
• [ ] You can explain why malformed input remains the next problem.
Phase 11 complete
You now have a real HTTP -> NestJS -> Prisma -> PostgreSQL CRUD path. The next architectural weakness is the
untrusted request body. That becomes Phase 12.