← Build Log

$ cat caltab.md

CalTab

A privacy-first calorie and macronutrient tracker that keeps all personal health data strictly on-device. Powered by Flutter and Riverpod, it combines Open Food Facts search, on-device barcode scanning, and multimodal Gemini AI features for effortless nutrition tracking.

Spec sheet

type
mobile app
stack
Flutter, Dart, Riverpod, Gemini AI, Open Food Facts, Google ML kit, Mobile App
status
● stable · since 2026
caltab — preview
CalTab preview
fig. 01 · interface previewscale 1:1 · rev 2026

Overview

Many commercial calorie tracking applications require cloud accounts, paywall essential metrics, and monetize personal health information. CalTab was engineered as a privacy-first, local-first mobile application developed during the Mobile Applications module (THWS / TAMK). The primary goal was to provide an intuitive, high-performance nutrition and macro tracker where all personal logs, profile metrics, and body progress history remain strictly stored on the user’s physical device. Network traffic is reserved exclusively for food database queries and optional AI enhancements.

Key Features

  • Smart Onboarding & Target Calculation: Automatically calculates Basal Metabolic Rate (BMR), Total Daily Energy Expenditure (TDEE), and tailored macronutrient targets based on user biometric data and fitness goals.
  • Open Food Facts & Barcode Scanning: Real-time, paginated food search backed by the Open Food Facts API, accompanied by rapid on-device barcode recognition powered by Google ML Kit.
  • Snap2Cal & AI Assistant (BYOK): Multimodal photo-to-macro estimation (“Snap2Cal”) and an interactive in-app nutrition coach utilizing the Google Gemini API with secure on-device API key storage (Bring Your Own Key).
  • Dynamic Weight & Progress Analytics: Interactive weight logs that dynamically recalibrate daily caloric needs, coupled with 7-day trend visualizations, macro distribution averages, and meal consistency statistics.
  • Custom Meals & Data Portability: Custom recipe and food creation with strict macro validation rules, complemented by JSON export/import (v1.1) for offline backups.

Architecture & Tech Stack

  • Framework: Flutter (Dart 3.11+) with Material Design 3 and persisted theme switching.
  • State Management: Flutter Riverpod 3 utilizing modern Notifier and AsyncNotifier patterns for predictable, asynchronous state synchronization.
  • Navigation: go_router with declarative routes and strongly typed argument passing.
  • APIs & Services: Open Food Facts REST API and Google Generative AI SDK (Gemini Vision & Chat).
  • Hardware & ML: camera and google_mlkit_barcode_scanning for offline barcode detection.
  • Storage & Security: shared_preferences for structured offline logs and flutter_secure_storage for cryptographic isolation of API credentials.
  • Testing: Comprehensive test suite spanning unit models, validators, repository layers, Riverpod providers, and screen widget tests.

Highlights & Learnings

  • Local-First Reactive Architecture: Structuring complex, interconnected state—such as weight updates automatically propagating through user profiles to recalibrate active daily targets across the UI—demonstrated the power and clean separation of concerns enabled by Riverpod 3 async notifiers.
  • Defensive Error & Quota Handling: Integrating external REST endpoints alongside multimodal LLMs required robust fallback mechanisms, strict input validation (ensuring macro totals never exceed physical meal weight), and graceful handling of rate limits and offline network conditions.

Keynote