ProtoMacro
Grounds a nutrition tracker's 567 foods in Bangladeshi and USDA reference tables instead of unsourced hand-entered values.
TL;DR
Local-first nutrition & fitness PWA backed by a reproducible DuckDB food composition pipeline for Bangladeshi and international foods. Source: README.md:3 @ e635153.
Context & motivation
Bangladeshi foods are thinly covered by the reference databases most trackers build on, and ProtoMacro's original list of 194 foods was hand-entered with no sources. A DuckDB ETL pipeline replaces that list with foods from the Food Composition Table for Bangladesh (FCTB 2013) and USDA FoodData Central, and migrates saved favourites, recents, planner, recipes and saved meals without changing logged history. Source: README.md:21 @ e635153.
My contribution
- Built a tested DuckDB pipeline that extracts, SHA-256-verifies, normalises and validates FCTB 2013 and USDA FoodData Central data into a catalog with provenance on every row.
- Audited the legacy hand-entered values against exact primary-source matches and migrated saved v2 IDs to v3 without altering logged history.
- Shipped an offline-first PWA (Vanilla JS + Workbox) with Vitest, pytest and Playwright checks in CI.
How I used AI tools
Implementation by an AI coding agent (Google Antigravity). I set the scope, approved every plan, ran the checks, and accepted only work that passed automated gates.
Pipeline run
Counts in foods. Each count links to its recorded source in Data sources.
Key decisions
Exact-only replacement: only match_type = exact replaces legacy macros
- Alternatives
- approximate and different_state items keep curated values, linked via related_ids
- Why
- Wrong-dish or wrong-state macros are never silently substituted.
Flag, don’t drop: non-fatal checks annotate rows; hard errors (negative macros, duplicate IDs, missing provenance) fail the build
- Why
- Real foods are never silently dropped.
Model carbs_total and carbs_available separately, with fibre exposed separately
- Why
- FCTB reports available carbohydrate (excluding fibre), whereas USDA FDC reports carbohydrate by difference (including fibre).
Results
Limitations & next steps
- The primary Bangladeshi table (FCTB 2013) is from 2013; newer cultivar and packaged-food data are not covered. source: README.md:147 @ e635153
- 283 of 381 FCTB foods carry the borrowed_value flag (citing secondary or foreign composition tables in the FCTB bibliography). source: README.md:148 @ e635153
- Most Indian and Arab/Middle Eastern dishes lack exact matches in FCTB/FDC and remain curated_estimate entries. source: README.md:149 @ e635153
- FAO/INFOODS lists FCTB 2013 as “free access” with no named open license; redistribution terms remain unconfirmed. source: README.md:151 @ e635153
Next steps
- Expand curated_crosswalk.csv and recipe-calculated dishes for remaining South Asian staples. source: README.md:157 @ e635153
- Surface related_ids (e.g. linking cooked curated dishes to raw FCTB entries) directly in the Food Search detail view. source: README.md:158 @ e635153
- Confirm FCTB redistribution licensing with INFS / FAO INFOODS. source: README.md:159 @ e635153
Data sources
- Data: Real reference dataREADME.md:11, 41–44 @ e635153
- Stage 1: legacy_foods (194 foods)README.md:21, 65 @ e635153
- Stage 2: exact_matches (77 foods)README.md:65 @ e635153
- Stage 3: audited (74 foods)README.md:21 @ e635153 (exact matches with source kcal >= 20)
- Metric: Foods in the sourced catalog, each with row-level provenance (567)README.md:11, 63 @ e635153 · 2026-11
- Metric: Calorie error found in the legacy hand-entered data (n = 74) (2.5% / 34.9%)README.md:21 @ e635153 · 2026-11