diff --git a/.planning/REQUIREMENTS.md b/.planning/REQUIREMENTS.md index 2cb87fd..1e5113e 100644 --- a/.planning/REQUIREMENTS.md +++ b/.planning/REQUIREMENTS.md @@ -63,9 +63,9 @@ Requirements for this milestone. Each maps to roadmap phases. ### Quick-Add Library -- [ ] **QADD-01**: User can save a one-off expense category with an icon to their quick-add library +- [x] **QADD-01**: User can save a one-off expense category with an icon to their quick-add library - [ ] **QADD-02**: User can browse and select from their quick-add library when adding a one-off item to a month -- [ ] **QADD-03**: User can manage their quick-add library — add, edit, remove saved categories +- [x] **QADD-03**: User can manage their quick-add library — add, edit, remove saved categories ### Layout & Density @@ -145,9 +145,9 @@ Which phases cover which requirements. Updated during roadmap creation. | TMPL-03 | Phase 6 (v1.1) | Complete | | TMPL-05 | Phase 6 (v1.1) | Complete | | TMPL-06 | Phase 6 (v1.1) | Complete | -| QADD-01 | Phase 7 (v1.1) | Pending | +| QADD-01 | Phase 7 (v1.1) | Complete | | QADD-02 | Phase 7 (v1.1) | Pending | -| QADD-03 | Phase 7 (v1.1) | Pending | +| QADD-03 | Phase 7 (v1.1) | Complete | | LYOT-01 | Phase 8 (v1.1) | Pending | | LYOT-02 | Phase 8 (v1.1) | Pending | | LYOT-03 | Phase 8 (v1.1) | Pending | diff --git a/.planning/ROADMAP.md b/.planning/ROADMAP.md index 6f19b13..0783b47 100644 --- a/.planning/ROADMAP.md +++ b/.planning/ROADMAP.md @@ -120,7 +120,7 @@ Plans: 1. A user can save a one-off expense category (with an icon) to their quick-add library from the budget item add flow 2. When adding a one-off item, the user can browse their quick-add library and select a saved category — the item populates with that category and icon 3. The quick-add library management page lets the user add, edit, and remove saved categories -**Plans:** 2 plans +**Plans:** 1/2 plans executed Plans: - [ ] 07-01-PLAN.md — DB migration, QuickAddItem model, CRUD queries, REST handlers at /api/quick-add @@ -154,5 +154,5 @@ Phases execute in numeric order: 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 | 4. Chart Polish and Bug Fixes | v1.0 | 2/2 | Complete | 2026-03-12 | | 5. Template Data Model and API | v1.1 | 2/2 | Complete | 2026-03-12 | | 6. Template Frontend and Workflow Replacement | v1.1 | 2/2 | Complete | 2026-03-12 | -| 7. Quick-Add Library | v1.1 | 0/2 | Not started | - | +| 7. Quick-Add Library | 1/2 | In Progress| | - | | 8. Layout and Density Rethink | v1.1 | 0/2 | Not started | - | diff --git a/.planning/STATE.md b/.planning/STATE.md index f12d7dc..583d233 100644 --- a/.planning/STATE.md +++ b/.planning/STATE.md @@ -3,14 +3,14 @@ gsd_state_version: 1.0 milestone: v1.1 milestone_name: Usability and Templates status: planning -stopped_at: Completed 06-template-frontend-and-workflow-replacement-02-PLAN.md -last_updated: "2026-03-12T12:13:58.556Z" +stopped_at: Completed 07-quick-add-library-01-PLAN.md +last_updated: "2026-03-12T12:35:38.859Z" last_activity: 2026-03-12 — v1.1 roadmap created, Phases 5-8 defined progress: total_phases: 8 completed_phases: 6 - total_plans: 14 - completed_plans: 14 + total_plans: 16 + completed_plans: 15 percent: 0 --- @@ -54,6 +54,7 @@ Progress: [░░░░░░░░░░] 0% | Phase 05-template-data-model-and-api P02 | 1min | 2 tasks | 2 files | | Phase 06-template-frontend-and-workflow-replacement P01 | 2min | 2 tasks | 7 files | | Phase 06-template-frontend-and-workflow-replacement P02 | 2min | 2 tasks | 9 files | +| Phase 07-quick-add-library P01 | 1min | 2 tasks | 5 files | ## Accumulated Context @@ -76,6 +77,9 @@ Recent decisions affecting current work: - [Phase 06-template-frontend-and-workflow-replacement]: Reorder swaps sort_order values between adjacent items and sends full updated list to PUT /template/items/reorder - [Phase 06-template-frontend-and-workflow-replacement]: 409 conflict on budget generate handled silently — call onCreated() so existing budget becomes selectable - [Phase 06-template-frontend-and-workflow-replacement]: BudgetSetup existingBudgets prop retained in signature for interface compatibility but unused after copy-from removal +- [Phase 07-quick-add-library]: sort_order auto-incremented via subquery at INSERT time so client doesn't need to track current max +- [Phase 07-quick-add-library]: ListQuickAddItems initializes empty slice (not nil) so API always returns [] not null +- [Phase 07-quick-add-library]: UpdateQuickAddItem returns 404 via pgx.ErrNoRows check when no row matches id+user_id ### Pending Todos @@ -88,6 +92,6 @@ None yet. ## Session Continuity -Last session: 2026-03-12T12:10:58.018Z -Stopped at: Completed 06-template-frontend-and-workflow-replacement-02-PLAN.md +Last session: 2026-03-12T12:35:38.858Z +Stopped at: Completed 07-quick-add-library-01-PLAN.md Resume file: None diff --git a/.planning/phases/07-quick-add-library/07-01-SUMMARY.md b/.planning/phases/07-quick-add-library/07-01-SUMMARY.md new file mode 100644 index 0000000..999beee --- /dev/null +++ b/.planning/phases/07-quick-add-library/07-01-SUMMARY.md @@ -0,0 +1,107 @@ +--- +phase: 07-quick-add-library +plan: "01" +subsystem: api +tags: [go, postgres, rest-api, crud] + +# Dependency graph +requires: + - phase: 05-template-data-model-and-api + provides: Item tier enum and query patterns used as reference +provides: + - quick_add_items table DDL via 003_quick_add_library.sql + - QuickAddItem Go struct with json tags + - ListQuickAddItems, CreateQuickAddItem, UpdateQuickAddItem, DeleteQuickAddItem query functions + - GET/POST /api/quick-add and PUT/DELETE /api/quick-add/{itemId} REST endpoints +affects: [08-quick-add-frontend] + +# Tech tracking +tech-stack: + added: [] + patterns: [user-scoped CRUD with sort_order auto-increment via subquery] + +key-files: + created: + - backend/migrations/003_quick_add_library.sql + modified: + - backend/internal/models/models.go + - backend/internal/db/queries.go + - backend/internal/api/handlers.go + - backend/internal/api/router.go + +key-decisions: + - "sort_order auto-incremented via (SELECT COALESCE(MAX(sort_order), 0) + 1 FROM quick_add_items WHERE user_id = $1) subquery at insert time" + - "ListQuickAddItems initializes empty slice (not nil) so API always returns [] not null" + - "UpdateQuickAddItem returns 404 via pgx.ErrNoRows check when no row matches id+user_id" + +patterns-established: + - "QuickAddItem CRUD follows Category/TemplateItem pattern: user_id in all WHERE clauses, fmt.Errorf wrapping, pgx row scanning" + - "Routes registered after template block in authenticated group, following chi.Route pattern" + +requirements-completed: [QADD-01, QADD-03] + +# Metrics +duration: 1min +completed: 2026-03-12 +--- + +# Phase 07 Plan 01: Quick-Add Library Backend Summary + +**REST CRUD for quick_add_items table: migration, QuickAddItem model, four user-scoped query functions, four handlers at /api/quick-add** + +## Performance + +- **Duration:** 1 min +- **Started:** 2026-03-12T13:12:57Z +- **Completed:** 2026-03-12T13:13:57Z +- **Tasks:** 2 +- **Files modified:** 4 (plus 1 created) + +## Accomplishments + +- Created 003_quick_add_library.sql with quick_add_items table and user index +- Added QuickAddItem struct to models.go and four CRUD query functions to queries.go +- Registered four HTTP handlers and routes under /api/quick-add inside authenticated group + +## Task Commits + +Each task was committed atomically: + +1. **Task 1: Migration, model, and query functions** - `84d5b76` (feat) +2. **Task 2: HTTP handlers and route registration** - `b42f7b1` (feat) + +## Files Created/Modified + +- `backend/migrations/003_quick_add_library.sql` - DDL for quick_add_items table with user FK, sort_order, and index +- `backend/internal/models/models.go` - Added QuickAddItem struct +- `backend/internal/db/queries.go` - Added ListQuickAddItems, CreateQuickAddItem, UpdateQuickAddItem, DeleteQuickAddItem +- `backend/internal/api/handlers.go` - Added four handler methods for quick-add CRUD +- `backend/internal/api/router.go` - Registered /api/quick-add route group in authenticated section + +## Decisions Made + +- sort_order auto-incremented via subquery at INSERT time so client doesn't need to track current max +- ListQuickAddItems returns initialized empty slice so JSON response is always `[]` not `null` +- UpdateQuickAddItem maps pgx.ErrNoRows to 404 for user-friendly not-found behavior + +## Deviations from Plan + +None - plan executed exactly as written. + +## Issues Encountered + +None. Go binary was at `/home/jean-luc-makiola/go/go1.26.1/bin/go` (non-standard PATH), found and used correctly. + +## User Setup Required + +None - no external service configuration required. + +## Next Phase Readiness + +- Backend API complete and compiles cleanly +- Database migration ready for 003 to be applied when deploying +- Ready for Phase 08 frontend quick-add library UI + +--- +*Phase: 07-quick-add-library* +*Completed: 2026-03-12*