Phases 6-7

This commit is contained in:
Aerilyn Weber 2026-05-14 14:47:23 +09:00
parent 76a516a417
commit 029940b079
111 changed files with 17247 additions and 447 deletions

View file

@ -26,33 +26,97 @@ MeshiTrack helps households manage medicines and food. Medicine tracking comes f
| **Monorepo** | Turborepo 2 |
| **Runtime** | Node.js 22+ (ESM-only) |
## Phase Completion Criteria (Mandatory)
Every phase MUST deliver ALL of the following before being considered complete. No phase may be marked done if any layer is missing.
### 1. Shared Package (`packages/shared`)
- [ ] Types defined in `src/types/`
- [ ] Enums defined in `src/enums/` with unit tests
- [ ] Zod validation schemas in `src/validation/` with unit tests
- [ ] Barrel exports updated in `index.ts`
- [ ] 100% line/function/statement coverage, 90% branch coverage
### 2. API Package (`packages/api`)
- [ ] Mongoose schema in `src/schemas/`
- [ ] Repository with `.lean().exec()` on all reads
- [ ] Service with business logic
- [ ] Route plugin registered in `main.ts`
- [ ] Unit tests for repository, service, and routes (100% coverage)
- [ ] All queries scoped to `householdId`
### 3. Web Package (`packages/web`)
- [ ] API client service in `src/services/` with unit tests
- [ ] Page(s) in `src/app/(dashboard)/` implementing the UI spec
- [ ] Component tests (React Testing Library) for every page and interactive component
- [ ] Server Components by default; `'use client'` only where interactivity is needed
### 4. CI Gate (must pass before phase sign-off)
```bash
npm run build # All packages compile
npm run test:cov # Coverage thresholds enforced (100/100/100/90)
npm run lint # Zero lint errors
```
### 5. Documentation
- [ ] Phase spec updated with `[x]` on completed tasks
- [ ] Acceptance criteria verified
---
## Phase Overview
### Medicine Tracking (Phases 1-4)
| Phase | Name | Description | Doc |
| ----- | ------------------------------ | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| 0 | Foundation & Infrastructure | Repo scaffolding, Docker, auth | [phase-0-foundation.md](phases/phase-0-foundation.md) |
| 1 | Medicine Library | Searchable medicine catalog with dosage/form info | [phase-1-medicine-library.md](phases/phase-1-medicine-library.md) |
| 2 | Medicine Cabinet | Inventory tracking with quantity, expiry, low-stock alerts | [phase-2-medicine-cabinet.md](phases/phase-2-medicine-cabinet.md) |
| 3 | Regimens & Pill Organizer | Daily medication schedules, batch-dispense, burn rate | [phase-3-regimens-pill-organizer.md](phases/phase-3-regimens-pill-organizer.md) |
| 4 | Pharmacies, Prices & Refills | Shared store infrastructure, price tracking, refill alerts | [phase-4-pharmacies-prices-refills.md](phases/phase-4-pharmacies-prices-refills.md) |
| Phase | Name | Description | Status | Doc |
| ----- | ------------------------------ | ---------------------------------------------------------------- | ------ | ----------------------------------------------------------------------------------------- |
| 0 | Foundation & Infrastructure | Repo scaffolding, Docker, auth | DONE | [phase-0-foundation.md](phases/phase-0-foundation.md) |
| 1 | Medicine Library | Searchable medicine catalog with dosage/form info | DONE | [phase-1-medicine-library.md](phases/phase-1-medicine-library.md) |
| 2 | Medicine Cabinet | Inventory tracking with quantity, expiry, low-stock alerts | DONE | [phase-2-medicine-cabinet.md](phases/phase-2-medicine-cabinet.md) |
| 3 | Regimens & Pill Organizer | Daily medication schedules, batch-dispense, burn rate | DONE | [phase-3-regimens-pill-organizer.md](phases/phase-3-regimens-pill-organizer.md) |
| 4 | Pharmacies, Prices & Refills | Shared store infrastructure, price tracking, refill alerts | DONE | [phase-4-pharmacies-prices-refills.md](phases/phase-4-pharmacies-prices-refills.md) |
### Food Tracking (Phases 5-9)
| Phase | Name | Description | Doc |
| ----- | ------------------------------ | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| 5 | Product Library | Searchable food product catalog with nutrition data | [phase-5-product-library.md](phases/phase-5-product-library.md) |
| 6 | Recipe Management | Recipe CRUD, nutrition auto-calculation, import | [phase-6-recipes.md](phases/phase-6-recipes.md) |
| 7 | Pantry & Fridge Tracking | Track item lifecycle, freshness, spoilage estimation | [phase-7-pantry.md](phases/phase-7-pantry.md) |
| 8 | Meal Planning & Waste Reduction| Suggest meals from pantry, nutrition targets, weekly planning | [phase-8-meal-planning.md](phases/phase-8-meal-planning.md) |
| 9 | Grocery & Price Tracking | Shopping lists, price analytics, store comparison (reuses Phase 4 stores) | [phase-9-grocery.md](phases/phase-9-grocery.md) |
| Phase | Name | Description | Status | Doc |
| ----- | ------------------------------ | ---------------------------------------------------------------- | ------ | ----------------------------------------------------------------------------------------- |
| 5 | Product Library | Searchable food product catalog with nutrition data | DONE | [phase-5-product-library.md](phases/phase-5-product-library.md) |
| 6 | Recipe Management | Recipe CRUD, nutrition auto-calculation, import | DONE | [phase-6-recipes.md](phases/phase-6-recipes.md) |
| 7 | Pantry & Fridge Tracking | Track item lifecycle, freshness, spoilage estimation | DONE | [phase-7-pantry.md](phases/phase-7-pantry.md) |
| 8 | Meal Planning & Waste Reduction| Suggest meals from pantry, nutrition targets, weekly planning | NOT STARTED | [phase-8-meal-planning.md](phases/phase-8-meal-planning.md) |
| 9 | Grocery & Price Tracking | Shopping lists, price analytics, store comparison (reuses Phase 4 stores) | NOT STARTED | [phase-9-grocery.md](phases/phase-9-grocery.md) |
### Shared (Phase 10)
| Phase | Name | Description | Doc |
| ----- | ------------------------------ | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| 10 | LLM Integration & Smart Features | Wire up LLM providers, enable smart features across both domains | [phase-10-llm.md](phases/phase-10-llm.md) |
| Phase | Name | Description | Status | Doc |
| ----- | ------------------------------ | ---------------------------------------------------------------- | ------ | ----------------------------------------------------------------------------------------- |
| 10 | LLM Integration & Smart Features | Wire up LLM providers, enable smart features across both domains | PARTIAL | [phase-10-llm.md](phases/phase-10-llm.md) |
---
## Current Status & Gaps
### Phase 8 — Meal Planning (Next Priority)
The foundation for food tracking (Phases 5-7) is fully implemented and integrated. The next major milestone is Phase 8, which introduces the meal planning calendar and the algorithmic suggestion engine.
**Immediate Goals:**
- Implement `MealPlan` and `NutritionTarget` schemas.
- Build the `SuggestionEngineService` for pantry-based recipe ranking.
- Create the weekly calendar UI with drag-and-drop support.
### Phase 10 — LLM (PARTIAL)
The `ILlmProvider` interface and `NoOpLlmProvider` are implemented. Actual provider implementations and smart features are deferred.
### Lessons Learned
Previous phases (6 & 7) were completed without finishing Phase 5's full stack (API routes + web UI). This created a gap where the Product Library has no user-facing interface despite being consumed internally. **Going forward, every phase must deliver its complete vertical slice (shared -> API -> web -> tests) before the next phase starts.**
## Cross-Cutting Concerns
@ -121,8 +185,39 @@ MeshiTrack/
## Verification Strategy
- **Per-phase**: each phase ends with a working `docker compose up` that demos the new feature
- **Integration**: Postman/Bruno collection maintained alongside API development
- **E2E smoke test (medicine)**: automated script that creates a user, adds medicines, stocks cabinet, creates regimen, fills organizer, checks refill alerts
- **E2E smoke test (food)**: automated script that adds products, creates a recipe, stocks the pantry, generates a meal plan, and creates a shopping list
- **Performance**: MongoDB indexes reviewed per phase; query profiling before phase sign-off
### Per-Phase Gate (Blocking)
Every phase must pass these checks before sign-off:
1. **Build**: `npm run build` succeeds (all packages compile)
2. **Coverage**: `npm run test:cov` passes with thresholds:
- `packages/api`: 100% lines/functions/statements, 90% branches
- `packages/shared`: 100% lines/functions/statements, 90% branches
- `packages/web`: all component tests pass
3. **Lint**: `npm run lint` reports zero errors
4. **Web UI Exists**: every phase that adds API endpoints also adds corresponding web pages with component tests
5. **Services Tested**: every `*.service.ts` in web has a corresponding `*.test.ts`
### Per-Phase Deliverable Checklist
For each phase, the task breakdown must follow this template order:
```
X.1 — Shared Types & Validation (+ tests)
X.2 — Mongoose Schema & Repository (+ tests)
X.3 — Service (+ tests)
X.4 — Routes (+ tests)
X.5 — Web: API Client Service (+ tests)
X.6 — Web: Pages & Components (+ component tests)
X.7 — CI Verification (build + test:cov + lint)
```
### Integration Testing
- Postman/Bruno collection maintained alongside API development
- E2E smoke test (medicine): creates user, adds medicines, stocks cabinet, creates regimen, fills organizer, checks refill alerts
- E2E smoke test (food): adds products, creates recipe, stocks pantry, generates meal plan, creates shopping list
### Performance
- MongoDB indexes reviewed per phase; query profiling before phase sign-off