docs: document unit conversion implementation

- Update implementation-plan.md: mark unit conversion complete
- Update HANDOFF.md: add session notes for 2026-05-24 unit conversion
- Update README.md: list Unit Conversion as a feature
This commit is contained in:
2026-05-24 15:34:16 -07:00
parent fd8ba3c4d2
commit dcdb88595e
3 changed files with 30 additions and 3 deletions
+23
View File
@@ -293,6 +293,29 @@ Trust the tests. Trust the live runs. Don't trust prose claims that something is
---
## New session: 2026-05-24
### Unit conversion implementation
Completed implementation of recipe-to-grocery unit conversion to make cost estimates accurate.
**Files added:**
- `backend/app/utils/units.py` — `UnitConverter` class
- Normalization: maps synonyms to canonical units (e.g. "TBS" → "tbsp", "pounds" → "lb")
- Within-family linear conversion: lb↔oz↔g, cup↔tbsp↔tsp, dozen↔ea
- Cross-family via density tables for ~30 canonical ingredients (e.g. rice cup→lb via 185g/cup / 453.592g/lb)
- Fallback to dimensionless qty when conversion is impossible (preserves monotonic ranking signal)
**Files modified:**
- `backend/app/services/planner/cost.py` — multiplies `current_price` by `convert_qty(qty, recipe_unit, grocery_unit, ingredient_name)`
- `backend/app/services/planner/generate.py` — `_load_match_index` now joins `Ingredient` table and returns `ingredient_name` + `grocery_unit` for each match
- `backend/app/services/orchestrator/steps.py` — both email cost block and shopping-list total now use unit conversion
- `backend/tests/test_planner_cost.py` — updated fixture to include new fields
- `backend/tests/test_units.py` — 19 tests covering normalization, within-family, density, and fallback
**Test results:** `test_units.py` 19/19 pass; planner cost/score/select 36 passed.
---
## New session: 2026-05-23
### Context
+6 -3
View File
@@ -178,9 +178,12 @@ Self-hosted meal planning system that integrates with Lucky California grocery s
- [ ] Support pasting recipe URL for future scraping
### 5.3 Ingredient Mapping
- [ ] Create ingredient matching service
- [ ] Map recipe ingredients to `ingredient` table entries
- [ ] Handle unit conversions (cups → oz, etc.)
- [x] Create ingredient matching service
- [x] Map recipe ingredients to `ingredient` table entries
- [x] Handle unit conversions (cups → oz, lb → g, etc.)
- Implemented in `app/utils/units.py`: normalization, within-family (weight/volume/count), cross-family via density tables for ~30 canonical ingredients, fallback to dimensionless
- Integrated into `planner/cost.py` for accurate cost calculation
- Orchestrator email and shopping list use converted quantities
**Verify**: Can add a recipe manually and retrieve it via API