Qima is a Flutter + FastAPI nutrition assistant. The mobile app calls the backend only; provider API keys and model integrations stay server-side.
Current user flows include:
- barcode lookup for packaged foods
- food image recognition and nutrition estimation
- inventory-based recipe suggestions with ingredient quantities
- grounded recipe discussion
- profile setup and authentication
- lab report scanning, saved lab marker history, and latest marker summaries
- lab-informed meal planning that uses supported below-range markers as food preferences, not diagnosis or supplement advice
For a command-first setup, see quickstart.md.
Qima/
|-- backend/ FastAPI app, services, schemas, tests, DB setup
|-- mobile/ Flutter app for Android, web, and other Flutter targets
|-- contracts/ Versioned API contract examples/schemas
|-- data/ Local food and recipe datasets
|-- scrappers/ Carrefour scraping pipeline
|-- airflow/ Optional monthly Carrefour refresh orchestration
|-- Docs/ Architecture and decision documents
|-- groqApi.py LLM integration helper used by plan/recipe flows
|-- docker-compose.yml
`-- quickstart.md
The backend is a FastAPI API under backend/app.
Important endpoints include:
GET /v1/healthPOST /v1/auth/signupPOST /v1/auth/loginGET /v1/profile/mePOST /v1/profile/updatePOST /v1/barcode/lookupPOST /v1/vision/identifyPOST /v1/nutrition/estimatePOST /v1/recipes/suggestPOST /v1/recipes/discussPOST /v1/labs/extract-reportPOST /v1/labs/reportsPOST /v1/plans/generate
Backend environment is configured through backend/.env. Start from
backend/.env.example.
Required for normal local development:
DATABASE_URLJWT_SECRET
Required for provider-backed features:
GEMINI_API_KEYfor vision identificationGROQ_API_KEYorOPENAI_API_KEYfor LLM-backed recipe/plan flows, depending on the configured provider
The backend can still return local fallback responses for some flows when an LLM provider is not configured, but provider-backed endpoints will be limited.
The Flutter app lives in mobile/.
The app reads the backend URL from the compile-time define
QIMA_API_BASE_URL. Use an explicit value whenever running against a non-default
backend port or a physical device.
Examples:
flutter run -d chrome --dart-define=QIMA_API_BASE_URL=http://127.0.0.1:8001
flutter run -d emulator-5554 --dart-define=QIMA_API_BASE_URL=http://10.0.2.2:8001
flutter run -d R5CY82RV2RJ --dart-define=QIMA_API_BASE_URL=http://127.0.0.1:8001For a physical Android phone over USB, use adb reverse first:
adb -s <device-id> reverse tcp:8001 tcp:8001This lets the phone call http://127.0.0.1:8001 and have it forward to the
laptop backend.
The backend uses local food and recipe data where available:
data/Food/nutrition.xlsxdata/Food/Egyptian Food.csv- FoodData Central JSON sources under
data/Food/ data/Recipes/13k-recipes.csv
Large/generated datasets are ignored by default unless already tracked.
The included Docker Compose file starts Postgres with pgvector:
docker compose up -d dbDefault local connection from backend/.env.example:
postgresql://qima_user:qima_password@127.0.0.1:15432/qima
backend/app/db.py initializes the app tables on startup.
Carrefour packaged-food data is managed through a DB-first scraper flow.
- scraper:
scrappers/scrape_carrefour_food.py - table:
carrefour_barcode_products - upsert strategy:
ON CONFLICT (barcode) DO UPDATE
Optional Airflow orchestration lives under airflow/.
Backend:
$env:PYTHONPATH = "backend"
pytest backend/app/testsMobile:
cd mobile
flutter analyze
flutter test- Flutter calls FastAPI only.
- Provider keys and provider SDK/API calls stay in the backend.
- API response shapes should remain contract-first and versioned.
- Recipe flows should stay retrieval-grounded when possible.
- Lab-marker-informed guidance must remain food-oriented, supported-marker based, and non-diagnostic.
- Abnormal lab markers are displayed and may inform food focus where supported; they do not automatically mutate safety screening answers.
- quickstart.md
backend/README.mdbackend/AUTH_PROFILE_GUIDE.mdmobile/README.mdmobile/ANDROID_TESTING.mdDocs/Architecture_Updated_260422_v14.docxDocs/Decision_Log_Updated_260422_v14.docx