95 lines
3.7 KiB
Markdown
95 lines
3.7 KiB
Markdown
# Calorie AI
|
|
|
|
Native Android and Dockerized web calorie tracker with meal images, AI nutrition estimates, server-backed plans, and admin-configurable AI models.
|
|
|
|
## Features
|
|
|
|
- Add meals by description, portion estimate, and uploaded image.
|
|
- Analyze meals through OpenAI-compatible chat completions.
|
|
- Uses a vision model for food image calorie and portion estimates.
|
|
- Uses an advice model to normalize calories, protein, carbs, fat, fruit servings, vegetable servings, food groups, and notes.
|
|
- Stores meal entries, settings, plans, and synced activity in PostgreSQL.
|
|
- Imports Garmin Connect and gym app activity through Android Health Connect.
|
|
- Shows daily totals plus charts for macros, 7-day calories, and fruit/vegetable intake.
|
|
- Admin settings control API base URL, API key, image model, and nutrition/advice model. The two model fields can contain the same model name.
|
|
|
|
## Android Build
|
|
|
|
Open this folder in Android Studio and run the `app` configuration, or build with Gradle if available:
|
|
|
|
```bash
|
|
gradle :app:assembleDebug
|
|
```
|
|
|
|
Forgejo Actions builds the debug APK on every push to `main` and uploads it as the `calorie-ai-debug-apk` artifact.
|
|
|
|
Tagged versions also build an installable APK named `calorie-ai-vX.Y.Z.apk` and attach it to a Forgejo release through the Android Release workflow.
|
|
|
|
## Install With Obtainium
|
|
|
|
Use the Forgejo releases page as the source:
|
|
|
|
```text
|
|
https://git.danvics.com/danvics/calorie-ai-android/releases
|
|
```
|
|
|
|
If Obtainium asks for a direct APK URL, use the latest release asset URL pattern:
|
|
|
|
```text
|
|
https://git.danvics.com/danvics/calorie-ai-android/releases/download/v0.1.1/calorie-ai-v0.1.1.apk
|
|
```
|
|
|
|
Recommended Obtainium setup:
|
|
|
|
- App source: `HTML` or `Gitea/Forgejo` if your Obtainium version offers it.
|
|
- URL: `https://git.danvics.com/danvics/calorie-ai-android/releases`
|
|
- APK link filter: `calorie-ai-.*\.apk`
|
|
- Version extraction: release tag, for example `v0.1.1`.
|
|
|
|
The APK is a debug build, so Android may require allowing installs from Obtainium and accepting the debug signing certificate.
|
|
|
|
## Garmin And Gym Activity
|
|
|
|
Calorie AI imports external activity through Android Health Connect:
|
|
|
|
- Garmin: enable Health Connect sync in Garmin Connect, then open Calorie AI on Android and use `Settings -> Sync Health Connect`.
|
|
- Gym machines: use the machine's companion app or gym app to write workouts to Health Connect, then sync from Calorie AI.
|
|
- Imported data includes daily steps, active calories, and exercise sessions when Health Connect exposes them.
|
|
|
|
Direct Garmin Health API sync requires Garmin partner approval and API credentials, so the supported path is Health Connect first.
|
|
|
|
## Web Frontend
|
|
|
|
The web frontend lives in `web/`. It serves an authenticated browser UI and a tiny Node proxy at `/api/chat` so OpenAI-compatible endpoints are called server-side instead of directly from the browser.
|
|
|
|
Run it with Docker:
|
|
|
|
```bash
|
|
cd web
|
|
docker compose up -d --build
|
|
```
|
|
|
|
Then open:
|
|
|
|
```text
|
|
http://127.0.0.1:8095
|
|
```
|
|
|
|
The Docker web stack includes PostgreSQL. Runtime data lives under `web/data/postgres`, and legacy JSON/SQLite data in `web/data` is migrated on startup.
|
|
|
|
The Docker web server creates credentials on first boot if `CALORIE_AI_WEB_PASSWORD` and `CALORIE_AI_SESSION_SECRET` are not supplied. To pin credentials, copy `web/.env.example` to `web/.env` and set strong values before starting Docker Compose.
|
|
|
|
## AI Endpoint
|
|
|
|
The app expects an OpenAI-compatible endpoint at:
|
|
|
|
```text
|
|
{API base URL}/chat/completions
|
|
```
|
|
|
|
Example base URLs:
|
|
|
|
- `https://api.openai.com/v1`
|
|
- An emulator host-loopback URL ending in `:11434/v1` for a local OpenAI-compatible service
|
|
|
|
The web and Android clients use the same authenticated server APIs for entries, settings, plans, models, and synced activity.
|