Skip to content

soroqn1/foodshot-docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FoodShot Core

A backend platform and logging engine for general health, nutrition tracking, and metabolic management. It allows users to track food intake via photo recognition, maps it against 300,000+ USDA records, logs daily metrics (calories, macros, weight target progress), and exports clean dietary history for medical professionals and health coaches.

Currently, a Telegram bot is implemented as the primary user-facing communication channel for the core backend.

Architecture

FoodShot Architecture

Incoming food photos are processed by OpenAI (GPT-4o) solely to extract the dish name and estimated weight. This textual output is then mapped against the USDA FoodData Central API to retrieve exact macronutrients. This hard boundary is crucial: zero LLM hallucinations for nutrition facts, and zero AI medical advice.

How the bolus calculation works (Optional Diabetes Mode)

No AI involved — pure, transparent math:

def calculate_bolus(carbs, icr, isf, target_bg, current_bg=None):
    carb_dose = carbs / icr
    correction_dose = 0.0
    if current_bg is not None and current_bg > target_bg:
        correction_dose = (current_bg - target_bg) / isf
    return {
        "carb_dose": round(carb_dose, 1),
        "correction_dose": round(correction_dose, 1),
        "total_dose": round(carb_dose + correction_dose, 1),
    }
  1. Carb dose = Carbs ÷ ICR
  2. Correction dose = (Current BG − Target BG) ÷ ISF, applied only if current BG is above target

Tech stack

  • Language & Tooling: Python 3.11–3.13, Poetry, Ruff, Taskfile
  • Communication Frontend: Telegram Bot via aiogram 3.x (FSM, Handlers, i18n with EN/UK locales)
  • External Services: OpenAI API (GPT-4o Vision), USDA FoodData Central API
  • Webhooks & API Gateway: FastAPI
  • Database & Cache: PostgreSQL + async SQLAlchemy, Redis
  • Infrastructure & Hosting: Docker, Docker Compose, Oracle Cloud, Cloudflare Tunnel (secure webhooks), Custom Domain & DNS

What it does

  • Food Logging & Visual Estimation: Users send a photo of a meal, and the vision core identifies the dish and estimated portion size.
  • Nutritional Tracking: Automatically calculates Carbohydrates, Calories, Protein, and Fat for the logged meal.
  • General Health & Calorie Targets: Tracks intake against customizable daily calorie/macro targets, supporting weight loss, weight gain, or general healthy eating.
  • Daily Progress Reports: Sends automated progress reports summarizing daily calorie/macro intake against user-configured targets at a customizable time.
  • Data Export: Generates structured, Excel-compatible CSV reports of meal history, weight target logs, and blood glucose records (all-time or by individual months).
  • Optional Diabetes Mode: Provides a math-based insulin dose estimate (bolus calculator) and blood glucose tracking based on user-provided parameters (ICR, ISF, Target BG).
  • Account Control: Allows users to permanently erase their account and all logged data with /danger.

Commands (Telegram Frontend)

  • /start - Start onboarding (choose language, set daily calorie target, set report time).
  • /settings - Edit settings (Language, Calorie Target, Daily Reports toggle and time, Diabetes Mode settings).
  • /history - View recent meal history (last 10 meals).
  • /export - Export food & glucose history for the doctor.
  • /danger - Permanently delete account and logs.
  • /help - Show helper instructions.
  • /admin - Access admin control panel (admin only).

Limitations

  • Single-Dish Focus: The current vision pipeline struggles with complex, multi-component meals (e.g., a plate with 4 distinct, unmixed sides).
  • No CGM Integration: Continuous Glucose Monitors (Dexcom, Libre) are not yet connected via API; glucose levels must be entered manually.
  • Point-in-Time Accuracy: Nutritional accuracy depends on the LLM's visual weight estimate, which can deviate by 10-20% depending on the photo angle.
  • Localization: Dish recognition is highly optimized for globally recognized cuisines, but may lack precision for hyper-local regional dishes.

Demo

Here’s what the current flow looks like:

FoodShot Demo

⚠️ Medical disclaimer

FoodShot is a data-logging assistant, not a medical device. The AI component is strictly limited to photo recognition. It does not provide medical advice. All insulin calculations rely on transparent mathematical formulas based on user input. Always consult with a qualified healthcare provider for medical decisions.

Status

MVP / Closed Beta. Currently being tested by a community whitelist. Core data pipelines, exports, daily progress reports, and admin panels are fully functional.


Built by: soroqn1 · LinkedIn
If you're a founder, engineer, or health-tech enthusiast—feel free to reach out.

About

A backend engine and logging platform for general health, nutrition, and metabolic tracking (weight, calories, macros) with a Telegram bot interface

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors