docs(03-01): complete setup backend plan
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,9 +23,9 @@ Requirements for initial release. Each maps to roadmap phases.
|
||||
|
||||
### Setups
|
||||
|
||||
- [ ] **SETP-01**: User can create named setups (e.g. "Summer Bikepacking")
|
||||
- [ ] **SETP-02**: User can add/remove collection items to a setup
|
||||
- [ ] **SETP-03**: User can see total weight and cost for a setup
|
||||
- [x] **SETP-01**: User can create named setups (e.g. "Summer Bikepacking")
|
||||
- [x] **SETP-02**: User can add/remove collection items to a setup
|
||||
- [x] **SETP-03**: User can see total weight and cost for a setup
|
||||
|
||||
### Dashboard
|
||||
|
||||
@@ -82,9 +82,9 @@ Which phases cover which requirements. Updated during roadmap creation.
|
||||
| THRD-02 | Phase 2 | Complete |
|
||||
| THRD-03 | Phase 2 | Complete |
|
||||
| THRD-04 | Phase 2 | Complete |
|
||||
| SETP-01 | Phase 3 | Pending |
|
||||
| SETP-02 | Phase 3 | Pending |
|
||||
| SETP-03 | Phase 3 | Pending |
|
||||
| SETP-01 | Phase 3 | Complete |
|
||||
| SETP-02 | Phase 3 | Complete |
|
||||
| SETP-03 | Phase 3 | Complete |
|
||||
| DASH-01 | Phase 3 | Pending |
|
||||
|
||||
**Coverage:**
|
||||
|
||||
@@ -61,7 +61,7 @@ Plans:
|
||||
2. User can add and remove collection items from a setup
|
||||
3. User can see total weight and cost for a setup, computed live from current item data
|
||||
4. User sees a dashboard home page with cards linking to their collection, active threads, and setups
|
||||
**Plans:** 3 plans
|
||||
**Plans:** 1/3 plans executed
|
||||
|
||||
Plans:
|
||||
- [ ] 03-01-PLAN.md — Backend TDD: setup schema, service, routes, and tests with junction table
|
||||
@@ -77,4 +77,4 @@ Phases execute in numeric order: 1 -> 2 -> 3
|
||||
|-------|----------------|--------|-----------|
|
||||
| 1. Foundation and Collection | 4/4 | Complete | 2026-03-14 |
|
||||
| 2. Planning Threads | 3/3 | Complete | 2026-03-15 |
|
||||
| 3. Setups and Dashboard | 0/3 | Not started | - |
|
||||
| 3. Setups and Dashboard | 1/3 | In Progress| |
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
gsd_state_version: 1.0
|
||||
milestone: v1.0
|
||||
milestone_name: milestone
|
||||
status: completed
|
||||
stopped_at: Phase 3 context gathered
|
||||
last_updated: "2026-03-15T11:22:28.300Z"
|
||||
last_activity: 2026-03-15 — Completed 02-03 visual verification
|
||||
status: in_progress
|
||||
stopped_at: Completed 03-01-PLAN.md
|
||||
last_updated: "2026-03-15T11:43:11.000Z"
|
||||
last_activity: 2026-03-15 — Completed 03-01 setup backend
|
||||
progress:
|
||||
total_phases: 3
|
||||
completed_phases: 2
|
||||
total_plans: 7
|
||||
completed_plans: 7
|
||||
percent: 100
|
||||
total_plans: 10
|
||||
completed_plans: 8
|
||||
percent: 80
|
||||
---
|
||||
|
||||
# Project State
|
||||
@@ -21,16 +21,16 @@ progress:
|
||||
See: .planning/PROJECT.md (updated 2026-03-14)
|
||||
|
||||
**Core value:** Make it effortless to manage gear and plan new purchases — see how a potential buy affects your total setup weight and cost before committing.
|
||||
**Current focus:** Phase 2: Planning Threads
|
||||
**Current focus:** Phase 3: Setups and Dashboard
|
||||
|
||||
## Current Position
|
||||
|
||||
Phase: 2 of 3 (Planning Threads)
|
||||
Plan: 3 of 3 in current phase (COMPLETE)
|
||||
Status: Phase complete
|
||||
Last activity: 2026-03-15 — Completed 02-03 visual verification
|
||||
Phase: 3 of 3 (Setups and Dashboard)
|
||||
Plan: 1 of 3 in current phase
|
||||
Status: In progress
|
||||
Last activity: 2026-03-15 — Completed 03-01 setup backend
|
||||
|
||||
Progress: [██████████] 100%
|
||||
Progress: [████████░░] 80%
|
||||
|
||||
## Performance Metrics
|
||||
|
||||
@@ -56,6 +56,7 @@ Progress: [██████████] 100%
|
||||
| Phase 02 P01 | 5min | 2 tasks | 9 files |
|
||||
| Phase 02 P02 | 4min | 2 tasks | 10 files |
|
||||
| Phase 02 P03 | 1min | 1 tasks | 0 files |
|
||||
| Phase 03 P01 | 8min | 2 tasks | 9 files |
|
||||
|
||||
## Accumulated Context
|
||||
|
||||
@@ -81,6 +82,8 @@ Recent decisions affecting current work:
|
||||
- [Phase 02-02]: Candidate panel runs as separate SlideOutPanel instance with independent uiStore state
|
||||
- [Phase 02-02]: Resolution invalidates threads, items, and totals queries for cross-tab data freshness
|
||||
- [Phase 02-03]: All four THRD requirements verified working end-to-end in browser
|
||||
- [Phase 03-01]: syncSetupItems uses delete-all + re-insert in transaction for simplicity
|
||||
- [Phase 03-01]: SQL COALESCE ensures 0 returned for empty setups instead of null
|
||||
|
||||
### Pending Todos
|
||||
|
||||
@@ -93,6 +96,6 @@ None yet.
|
||||
|
||||
## Session Continuity
|
||||
|
||||
Last session: 2026-03-15T11:22:28.298Z
|
||||
Stopped at: Phase 3 context gathered
|
||||
Resume file: .planning/phases/03-setups-and-dashboard/03-CONTEXT.md
|
||||
Last session: 2026-03-15T11:43:11.000Z
|
||||
Stopped at: Completed 03-01-PLAN.md
|
||||
Resume file: .planning/phases/03-setups-and-dashboard/03-02-PLAN.md
|
||||
|
||||
107
.planning/phases/03-setups-and-dashboard/03-01-SUMMARY.md
Normal file
107
.planning/phases/03-setups-and-dashboard/03-01-SUMMARY.md
Normal file
@@ -0,0 +1,107 @@
|
||||
---
|
||||
phase: 03-setups-and-dashboard
|
||||
plan: 01
|
||||
subsystem: api
|
||||
tags: [drizzle, hono, sqlite, junction-table, tdd]
|
||||
|
||||
requires:
|
||||
- phase: 01-collection-core
|
||||
provides: items table, categories table, item service pattern, route pattern, test helper
|
||||
provides:
|
||||
- Setup CRUD API at /api/setups
|
||||
- Junction table setup_items (many-to-many items-to-setups)
|
||||
- SQL aggregation for setup totals (weight, cost, item count)
|
||||
- syncSetupItems for batch item assignment
|
||||
affects: [03-02-setup-frontend, 03-03-dashboard]
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns: [junction-table-with-cascade, sql-coalesce-aggregation, delete-all-reinsert-sync]
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- src/server/services/setup.service.ts
|
||||
- src/server/routes/setups.ts
|
||||
- tests/services/setup.service.test.ts
|
||||
- tests/routes/setups.test.ts
|
||||
modified:
|
||||
- src/db/schema.ts
|
||||
- src/shared/schemas.ts
|
||||
- src/shared/types.ts
|
||||
- src/server/index.ts
|
||||
- tests/helpers/db.ts
|
||||
|
||||
key-decisions:
|
||||
- "syncSetupItems uses delete-all + re-insert in transaction for simplicity over diff-based sync"
|
||||
- "SQL COALESCE ensures 0 returned for empty setups instead of null"
|
||||
|
||||
patterns-established:
|
||||
- "Junction table pattern: cascade deletes on both FK sides for clean removal"
|
||||
- "Sync pattern: transactional delete-all + re-insert for many-to-many updates"
|
||||
|
||||
requirements-completed: [SETP-01, SETP-02, SETP-03]
|
||||
|
||||
duration: 8min
|
||||
completed: 2026-03-15
|
||||
---
|
||||
|
||||
# Phase 3 Plan 1: Setup Backend Summary
|
||||
|
||||
**Setup CRUD API with junction table, SQL aggregation for totals, and transactional item sync**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** 8 min
|
||||
- **Started:** 2026-03-15T11:35:17Z
|
||||
- **Completed:** 2026-03-15T11:43:11Z
|
||||
- **Tasks:** 2 (TDD RED + GREEN)
|
||||
- **Files modified:** 9
|
||||
|
||||
## Accomplishments
|
||||
- Setup CRUD with all 7 API endpoints working
|
||||
- Junction table (setup_items) with cascade deletes on both setup and item deletion
|
||||
- SQL aggregation returning itemCount, totalWeight, totalCost via COALESCE subqueries
|
||||
- Full TDD with 24 new tests (13 service + 11 route), all 87 tests passing
|
||||
|
||||
## Task Commits
|
||||
|
||||
Each task was committed atomically:
|
||||
|
||||
1. **Task 1: RED - Failing tests + schema** - `1e4e74f` (test)
|
||||
2. **Task 2: GREEN - Implementation** - `0f115a2` (feat)
|
||||
|
||||
## Files Created/Modified
|
||||
- `src/db/schema.ts` - Added setups and setupItems table definitions
|
||||
- `src/shared/schemas.ts` - Added createSetupSchema, updateSetupSchema, syncSetupItemsSchema
|
||||
- `src/shared/types.ts` - Added CreateSetup, UpdateSetup, SyncSetupItems, Setup, SetupItem types
|
||||
- `src/server/services/setup.service.ts` - Setup business logic with DB injection
|
||||
- `src/server/routes/setups.ts` - Hono API routes for all 7 setup endpoints
|
||||
- `src/server/index.ts` - Mounted setupRoutes at /api/setups
|
||||
- `tests/helpers/db.ts` - Added setups and setup_items CREATE TABLE statements
|
||||
- `tests/services/setup.service.test.ts` - 13 service unit tests
|
||||
- `tests/routes/setups.test.ts` - 11 route integration tests
|
||||
|
||||
## Decisions Made
|
||||
- syncSetupItems uses delete-all + re-insert in transaction for simplicity over diff-based sync
|
||||
- SQL COALESCE ensures 0 returned for empty setups instead of null
|
||||
- removeSetupItem uses raw SQL WHERE clause for compound condition (setupId + itemId)
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
None - plan executed exactly as written.
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
None
|
||||
|
||||
## User Setup Required
|
||||
|
||||
None - no external service configuration required.
|
||||
|
||||
## Next Phase Readiness
|
||||
- Setup API complete and tested, ready for frontend consumption in Plan 02
|
||||
- Junction table pattern established for any future many-to-many relationships
|
||||
|
||||
---
|
||||
*Phase: 03-setups-and-dashboard*
|
||||
*Completed: 2026-03-15*
|
||||
Reference in New Issue
Block a user