People who track nutrition face two brutal realities: manually logging food takes 10+ minutes per meal, and generic AI nutrition apps hallucinate calorie data — giving you 200 kcal for a meal that's actually 800. For anyone managing weight, fitness, or medical conditions, that's not an inconvenience — it's dangerous.
The Cost: Missed goals, broken trust in AI tools, and zero behavior change.
What I Built
A production-grade Telegram bot that logs any meal in seconds — text description, voice message, photo, or barcode scan — powered by a five-layer AI recognition pipeline with a built-in anti-hallucination validator. The system doesn't just identify food; it mathematically verifies every nutritional value before writing it to your diary.
Validation method: Atwater formula + physical nutrient limits
Test coverage: 248 async tests across all layers
Worker memory footprint: 50–80 MB per container
API response latency: < 500ms (immediate task offload)
Stats
How It Works (The Value Pipeline)
1. Five-Layer Recognition — Speed Without Hallucination
Every food query travels through an explicit fallback chain: Redis cache hit (~0ms) → Rapidfuzz local DB match (~2–5ms) → Pinecone semantic vector search (~50–100ms) → GPT-4o structured JSON fallback (~1–3s) → automatic background indexing back into Redis + Pinecone. The system always finds an answer and always learns from it.
2. Anti-Hallucination Validator
Before any nutrition data reaches your diary, it passes two checks: physical limits (protein + fat + carbs ≤ 100g/100g; calories ≤ 950 kcal/100g) and the Atwater formula cross-check. If the deviation between reported calories and the calculated formula exceeds 30%, the system auto-recalculates. No phantom macros, ever.
System Architecture
3. Multi-Modal Input Processing
Voice messages are transcribed via OpenAI Whisper. Photos are analyzed via GPT Vision with OCR fallback. Barcodes are decoded via zxing-cpp and cross-referenced with the Open Food Facts API. Text is pre-parsed by a custom NLP pipeline (pymorphy3 + NLTK) that normalizes quantities, units, and detects complex multi-item meals.
Text Input
Voice Input
Photo Recognition
Barcode Scanning
4. Intelligent AI Mentor
Beyond logging, the system analyzes daily macro patterns and delivers contextual coaching — not generic advice. GPT generates personalized recommendations based on the user's actual intake history, calorie goals, and trend data across 7 and 30-day windows.