DEV Community

Gurmeet Singh
Gurmeet Singh

Posted on

High-Protein Recipe Remixer: Local AI that Turns "Bhel" into "Soya Bhel" & Counts Macros Offline

Hacktoberfest Weekend Challenge: Build for a Friend Submission 🤝

This is a submission for the Hacktoberfest Weekend Challenge: Build for a Friend

What I Built

Recipe → Macro Calculator + High-Protein Variant Generator — a fully local Streamlit app that:

  1. Extracts ingredients from any recipe URL or photo (OCR + LLM)
  2. Matches to USDA nutrition data → calculates macros per serving
  3. Scales recipes to a target calorie goal
  4. Generates high-protein variants of any dish (e.g., "bhel" → "Soya Bhel Puri" with 28g protein/serving)

Built for: My gym partner Arjun, who meal-preps every Sunday but wastes 30+ min manually calculating macros in spreadsheets and googling "high protein [dish] alternatives." He wants to hit 180g protein/day on a vegetarian Indian diet without eating plain chicken breast.

Problem solved: Paste a recipe URL → get instant macros + grocery list. Type "paneer tikka" → get a 35g-protein version with Greek yogurt marinade + tofu swap. All offline, no accounts, data never leaves his laptop.

Demo

Demo Image 1

Demo Image 2

Result

Code

GitHub Repo: https://github.com/GurmeetsinghRelusinghani28/recipe-macro-calculator
Key files:

  • app.py — Streamlit UI (3 tabs: URL, Photo, High-Protein Swap)
  • scraper.py + parser.py — Trafilatura + Ollama (gemma2:2b) for ingredient extraction
  • matcher.py — RapidFuzz + USDA Foundation Foods CSV (local)
  • suggester.py — LLM prompt for high-protein recipe variants
  • download_usda.py — Downloads & merges USDA nutrient data (one-time)

How I Built It

URL/Photo → Scraper/OCR → LLM Parser → JSON ingredients
↓
RapidFuzz → USDA CSV → Macros
↓
Scale to target kcal → Grocery list
↓
High-Protein Swap: LLM Variant → same pipeline

Models pulled locally:
ollama pull gemma2:2b # text parsing + variant generation
ollama pull llava:7b # photo OCR cleanup

Why Does Open Innovation Matter?

This project only works because every piece is open:

  1. Runs on a 4-year-old laptop (16GB RAM, no GPU) — Gemma 2B + LLaVA 7B quantized to 4-bit. Try that with GPT-4o or Claude.
  2. Zero data leaves the machine — Arjun's recipe photos, dietary goals, and meal plans stay on his disk. No cloud upload, no training data harvesting, no subscription.
  3. Swappable models — I tested qwen2.5:3b, phi3:3.8b, gemma2:2b by changing one line. Closed APIs lock you in.
  4. Fine-tunable — If Arjun wants "Gujarati-style" variants, I can fine-tune Gemma on 50 examples via Tinker. Impossible with closed models.
  5. Costs $0/month forever — No token pricing, no rate limits, no "pricing tier changed" emails.
  6. USDA data is public domain — The nutrition backbone is open government data. Proprietary APIs (Nutritionix, Edamam) cost $100s/month and throttle. Where closed would fail:
  7. Cloud vision API → fails on gym WiFi, uploads friend's food photos
  8. Nutrition API → rate limits kill batch meal-prep (50 recipes at once)
  9. LLM API → $0.01/recipe adds up; can't fine-tune for "Indian vegetarian high-protein"

My Agent Session

Prize Categories

Best Use of Gemma — Core text model (gemma2:2b) for parsing + variant generation

  • Best Use of Ollama — Local inference runtime for both text + vision models
  • Best Use of MongoDB Atlas — Not used (SQLite for logs, USDA CSV for data)
  • Best Use of Render — Not used (runs fully local, but deployable to Render free tier)
  • Best Use of Backboard — Not used (single-file agents, no RAG needed)
  • Best Use of ElevenLabs — Not used (no voice feature yet) Note: Primary entry: Gemma + Ollama (open-weight models + local runtime). Other categories listed for completeness but not claimed.

One-Liner for Socials

Built my gym partner a local AI that turns any recipe into a high-protein version + counts macros — runs offline on his laptop with Gemma 2B + USDA data. No API keys, no cloud, $0/month. 🏋️‍♂️🥗 #Hacktoberfest #BuildForAFriend

Top comments (0)