Track food, macros, and body metrics. Self-host it yourself or use the managed Cloud Edition.
Dietry is a full-featured Flutter nutrition tracker backed by a PostgreSQL database (Neon) accessed via PostgREST. Authentication uses Google OAuth2 with JWT tokens. It runs on Android, iOS, Web (PWA), and Linux desktop from a single codebase.
- Food diary — log meals from your own food database, the Open Food Facts catalog, or as custom entries
- Macros & calories — daily/weekly breakdown of calories, protein, fat, carbs, fiber, and more
- Personal goals — nutrition targets based on BMR/TDEE (Mifflin-St Jeor), activity level, and body goals
- Activity tracking — log workouts; import from Health Connect (Android) and Apple Health (iOS)
- Body measurements — weight, BMI, and body data tracked over time with charts
- Water tracking — simple daily hydration log
- Open Food Facts — search millions of products, no API key needed
- Offline-capable — queues writes when offline and syncs on reconnect
- Privacy-first — Row Level Security on every table; each user only sees their own data
This repository is the Community Edition — fully open source, self-hosted.
The Cloud Edition adds managed hosting, meal templates, and micronutrient tracking (vitamins, minerals). Its additional features live in a separate private package (dietry_cloud) that slots in via pubspec_overrides.yaml. The app compiles fine without it; the community stub package provides no-op implementations.
| Layer | Technology |
|---|---|
| Frontend | Flutter 3.x / Dart ≥ 3.0.2 |
| Database | PostgreSQL via Neon |
| API | PostgREST (REST → SQL translation) |
| Auth | Google OAuth2 + JWT (Neon Auth / Better Auth) |
| HTTP | Dio with JWT interceptor + auto-retry on 401 |
| Charts | fl_chart |
| Health data | health package (Health Connect / HealthKit) |
| Storage | FlutterSecureStorage (native) / localStorage (web) |
dietry/
├── lib/
│ ├── main.dart # App entry point & routing
│ ├── app_config.dart # Build-time config (dart-define)
│ ├── models/ # Pure data classes
│ ├── services/ # Business logic & backend communication
│ ├── screens/ # 13 screens
│ ├── widgets/ # Reusable UI components
│ └── l10n/ # Localization strings (de, en, es)
├── packages/
│ └── dietry_cloud/ # Community stub (no-op cloud features)
├── sql/ # PostgreSQL schema & migrations
├── config/
│ ├── ce-dev.json # Community Edition dev config
│ ├── ce-prod.json.example # Community Edition production template
│ └── app-dev.json # Cloud Edition dev config
├── web/
│ ├── index.html # Flutter web entry point
│ ├── landing.html # Marketing landing page
│ └── auth_callback.html # OAuth redirect handler
└── build.sh # Build & deploy script
- Flutter SDK ≥ 3.x
- A Neon PostgreSQL project
- A Google OAuth 2.0 Client ID (guide)
git clone https://github.com/tcriess/dietry.git
cd dietry
flutter pub getEdit config/ce-dev.json (or use your own) with your backend details:
{
"DATA_API_URL": "https://<your-neon-project>.neon.tech",
"AUTH_BASE_URL": "https://<your-auth-endpoint>",
"ENVIRONMENT": "dev"
}For production, use config/ce-prod.json.example as a template.
Cloud Edition: If developing with the Cloud Edition, use
config/app-dev.jsoninstead (requires the privatedietry_cloudpackage).
Run the SQL migration files in sql/ in order against your Neon project. Migrations are numbered sequentially:
# In the Neon SQL editor or via psql, run each in order:
\i sql/00_initial_schema.sql
\i sql/01_feedback.sql
\i sql/02_liquid_foods.sql
# … continue through all numbered files in orderEach file is idempotent (CREATE TABLE IF NOT EXISTS, CREATE OR REPLACE, etc.).
# Community Edition
flutter run -d chrome --dart-define-from-file=config/ce-dev.json # Web
flutter run -d linux --dart-define-from-file=config/ce-dev.json # Linux desktop
flutter run -d <device> --dart-define-from-file=config/ce-dev.json # Android / iOS
# Cloud Edition (requires dietry_cloud package)
flutter run -d chrome --dart-define-from-file=config/app-dev.json # Web# Web
flutter build web --release --dart-define-from-file=config/prod.json
# Android APK
flutter build apk --release --dart-define-from-file=config/prod.json
# Linux
flutter build linux --release --dart-define-from-file=config/prod.jsonThe build.sh script builds, packages, and deploys the web build to a server in one step:
./build.sh ce prod # Community Edition, production
./build.sh ce dev # Community Edition, devWeb: LoginScreen → Google OAuth → web/auth_callback.html (handles redirect outside Flutter, stores JWT in localStorage) → Flutter reads JWT back.
Native: Flutter → platform OAuth browser → deep-link callback → JWT stored in FlutterSecureStorage.
JWT auto-refresh runs 5 minutes before expiry; retries on 401 up to 3 times.
Strings live in lib/l10n/intl_*.arb (English, German, Spanish). To add a language, copy intl_en.arb and translate the values, then add the locale to lib/app_localizations.dart.
flutter test # all tests
flutter test test/services/jwt_helper_test.dart # single file
flutter test --name "BMR" # filter by name
flutter test --coverage # with coverage
flutter analyze # static analysis
flutter format lib/ # formatContributions are welcome — bug reports, feature requests, translations, and pull requests.
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Commit your changes
- Open a pull request
Please open an issue first for larger changes so we can discuss the approach.
This project is licensed under the MIT License — see LICENSE for details.
The Cloud Edition's additional features (dietry_cloud package, excluding the community stub in packages/dietry_cloud/) are not open source and are not included in this repository.