Building MyFatnessPal: How I Made Nutrition Tracking Effortless
Thesis: Food logging fails because it fights human behaviour. An AI that understands plain English makes tracking fast enough to stick.
The Problem We All Ignore
I’ve tried MyFitnessPal, Cronometer, and a dozen others. Same pattern every time: great intentions, abandoned in weeks.
The reason? Food logging sucks.
Not the idea, tracking what you eat is valuable. The process is the problem: hunting through databases, guessing portions, adding oils and sauces as separate entries. Five minutes later, you’ve logged one “simple” salad.
Plenty of user research points to high early abandonment for nutrition apps. The friction is too high. The payoff feels too far away.
So I built something different.
The Vision: Talk to Your Food Log
What if logging food was as easy as texting?
“Chicken caesar salad with light dressing.”
That’s it. No measuring cups. No barcode scanning. Just describe what you ate. Let AI do the boring parts.
MyFatnessPal (yes, the name is a joke) understands natural language and returns structured nutrition data from plain-English descriptions.
Result: food logging that’s dramatically faster and surprisingly accurate for complex meals.
How It Works (AI-First, Not Database-First)
Under the hood, MyFatnessPal uses a lightweight GPT model to parse your description and:
- Identify ingredients (e.g., romaine, grilled chicken, parmesan, croutons, dressing)
- Estimate reasonable portions from context
- Calculate calories and macros (protein, carbs, fat)
- Return structured data to populate your log
It shines on: – Restaurant meals: “Chipotle bowl with chicken, no rice.” – Home cooking: “Mom’s beef stew, about two cups.” – Snacks: “Handful of almonds and an apple.”
It isn’t perfect, but it’s often more useful than manual database hunting and fast enough to use daily.
Tech Stack (Deliberately Boring)
- Backend: Django 5.1 (Python 3.12)
- DB: SQLite (Postgres later if needed)
- Frontend: Tailwind CSS
- AI: OpenAI API with caching and resilient error handling
- Testing:
pytest
with ~85% coverage (external APIs mocked)
No microservices. No GraphQL. No frontend build maze. Just clean Django and modern tooling.
Why it matters: quick boots, millisecond-fast tests, single-container deploy, ~170 well-tested files.
Features That Reduce Friction
1) Quick-Add Recent Foods
Re-log repeating meals with one click.
2) Recipe Management
Save ingredients → auto per-serving nutrition → log a serving instantly.
3) Visual Daily Summary
Progress bars for calories, quick charts for macros, color-coded guidance.
4) Edit Anything
Fix mistakes, add dessert after dinner—no wrestling with the UI.
Development Philosophy: TDD or Nothing
Every feature started as a test:
- Red → Green → Refactor loop for each behavior
- 170+ tests, ~85% coverage on core apps
- Confidence to refactor aggressively without regressions
What Makes This Different
Versus MyFitnessPal/Cronometer
– Them: database search, manual portions, 5–10 min/meal
– Me: natural language + AI estimation, ~30 sec/meal
Versus Social Fitness Apps
– Them: feeds and gamification
– Me: private by default—honest tracking without judgment
Versus Feature-Heavy Suites
– Them: everything plus the kitchen sink
– Me: one thing done extremely well—effortless logging
The Numbers (Post-MVP)
- 15+ core features
- ~85% test coverage on core apps
- 170+ passing tests
- Sub-second analysis on typical entries
- 2-minute first-run: sign up → log food → see insights
What I Learned
AI isn’t magic, but it’s great at fuzzy tasks.
“Good enough, fast” beats “maybe precise, slow.”TDD feels slow—until it saves your week.
Fewer bugs, safer refactors, cleaner design.Simplicity scales.
Every feature I didn’t build is maintenance I don’t owe.Developer tools matter.
Agent OS turned planning into executable specs.
What’s Next
- Weekly Insights: trend callouts (“more carbs on weekends”)
- Pantry Tracker: reduce waste by tracking what you have
- Exports: CSV/JSON for your data
- Mobile Polish: responsive now; aiming for native-feeling gestures
Truth is, the app is already useful. I use it daily. Friends keep using it. That’s the metric that matters.
Try It (Eventually)
It’s a personal project for now. I may open-source it or offer a hosted version. If you’re into:
- AI-powered nutrition tracking that doesn’t suck
- Production-grade Django with TDD
- Real-world OpenAI integrations
Reach out. I’m happy to share details and war stories.
Next Steps (High-Level): Add MCP Integration
Goal: expose MyFatnessPal to AI assistants via Model Context Protocol (MCP) so they can log meals, fetch summaries, and manage recipes on your behalf.
Plan (no code, just the map):
1. Agree on Capabilities
– Tools: log_food, getdailysummary, recent_entries, logrecipeserving.
– Optional: find_recipe, create_recipe (later).
Stabilize a Minimal API
- One endpoint to accept a free-text meal and return structured nutrition.
- One endpoint to fetch daily summaries by date.
- Endpoints for recent items and recipe logging.
- One endpoint to accept a free-text meal and return structured nutrition.
Choose MCP Transport & Runtime
- Start with stdio for local use; graduate to HTTP if you need remote calls.
- Pick TypeScript or Python—whatever your team can maintain comfortably.
- Start with stdio for local use; graduate to HTTP if you need remote calls.
Define Contracts
- Tight, human-readable JSON schemas for inputs/outputs.
- Clear error shapes (including “AI could not infer portions”).
- Tight, human-readable JSON schemas for inputs/outputs.
Auth & Safety
- Scoped tokens (read vs write).
- Per-token rate limits and audit logs.
- Idempotency keys for create/log operations.
- Scoped tokens (read vs write).
Privacy by Default
- No sharing without explicit user intent.
- Redact PII from logs; short retention for raw prompts if you store them at all.
- No sharing without explicit user intent.
Observability
- Request IDs, structured logs, minimal metrics: success rate, latency, error classes.
- Trace from assistant prompt → MCP tool → app result.
- Request IDs, structured logs, minimal metrics: success rate, latency, error classes.
Resilience
- Retries with backoff on transient failures.
- Circuit breaker if the AI service is degraded.
- Graceful fallbacks (e.g., save raw text entry unparsed).
- Retries with backoff on transient failures.
Testing
- Contract tests against the API.
- Golden-file tests for typical meals (restaurant, home-cooked, snack).
- Load test a “busy evening” scenario.
- Contract tests against the API.
Launch Steps
- Ship v0 privately to power users.
- Collect feedback on tool names and result shapes.
- Iterate, then publish a lightweight “how to connect” guide.
- Ship v0 privately to power users.
Appendix
Tech Stack: Django 5.1, Python 3.12, OpenAI, Tailwind, pytest
Time: Two phases, ~3 weeks
Coverage: ~85% with 170+ tests
Status: Fully functional MVP with recipe management