Archive roadmap, requirements, and phase directories to milestones/. Evolve PROJECT.md with validated requirements and key decisions. Reorganize ROADMAP.md with milestone grouping. Delete REQUIREMENTS.md (fresh for next milestone).
6.9 KiB
6.9 KiB
phase, plan, type, wave, depends_on, files_modified, autonomous, requirements, must_haves
| phase | plan | type | wave | depends_on | files_modified | autonomous | requirements | must_haves | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 03-setups-and-dashboard | 01 | tdd | 1 |
|
true |
|
|
Purpose: Provides the data layer and API that the frontend (Plan 02) will consume. The many-to-many junction table is the only new DB pattern in this project. Output: Working API at /api/setups with full test coverage.
<execution_context> @/home/jean-luc-makiola/.claude/get-shit-done/workflows/execute-plan.md @/home/jean-luc-makiola/.claude/get-shit-done/templates/summary.md </execution_context>
@.planning/PROJECT.md @.planning/ROADMAP.md @.planning/STATE.md @.planning/phases/03-setups-and-dashboard/03-RESEARCH.md@src/db/schema.ts @src/shared/schemas.ts @src/shared/types.ts @src/server/index.ts @tests/helpers/db.ts
From src/server/services/thread.service.ts (pattern reference):
export function getAllThreads(db: Db = prodDb, includeResolved = false) { ... }
export function getThread(db: Db = prodDb, id: number) { ... }
export function createThread(db: Db = prodDb, data: CreateThread) { ... }
export function deleteThread(db: Db = prodDb, id: number) { ... }
From src/server/routes/threads.ts (pattern reference):
const threadRoutes = new Hono<{ Variables: { db: Db } }>();
threadRoutes.get("/", (c) => { ... });
threadRoutes.post("/", zValidator("json", createThreadSchema), (c) => { ... });
From tests/helpers/db.ts:
export function createTestDb() { ... } // Returns in-memory Drizzle instance
API routes (setups.ts):
- GET /api/setups -> list all setups with aggregated totals
- GET /api/setups/:id -> single setup with items
- POST /api/setups -> create setup (validates name via createSetupSchema)
- PUT /api/setups/:id -> update setup name
- DELETE /api/setups/:id -> delete setup
- PUT /api/setups/:id/items -> sync setup items (validates itemIds via syncSetupItemsSchema)
- DELETE /api/setups/:id/items/:itemId -> remove single item from setup
Edge cases:
- Syncing with empty itemIds array clears all items from setup
- Deleting a collection item cascades removal from all setups
- getAllSetups returns 0 for weight/cost when setup has no items (COALESCE)
1. Add setups and setupItems tables to src/db/schema.ts (with cascade FKs)
2. Add Zod schemas (createSetupSchema, updateSetupSchema, syncSetupItemsSchema) to src/shared/schemas.ts
3. Add types (CreateSetup, UpdateSetup, SyncSetupItems, Setup, SetupItem) to src/shared/types.ts
4. Add setups and setup_items CREATE TABLE to tests/helpers/db.ts
5. Implement setup.service.ts following thread.service.ts pattern (db as first param with prod default)
6. Implement setups.ts routes following threads.ts pattern (Hono with zValidator)
7. Mount setupRoutes in src/server/index.ts
8. Use raw SQL in Drizzle sql`` for correlated subqueries in getAllSetups (per Phase 2 decision about table.column refs)
```bash
bun test tests/services/setup.service.test.ts && bun test tests/routes/setups.test.ts && bun test
```
All setup service and route tests pass. Full test suite remains green.
<success_criteria>
- Setup CRUD API responds correctly at all 7 endpoints
- Junction table correctly links items to setups (many-to-many)
- Totals aggregation returns correct weight/cost/count via SQL
- Cascade delete works both directions (setup deletion, item deletion)
- All existing tests still pass </success_criteria>