MacroMate is a premium, AI-powered macro tracking application that revolutionizes the way you monitor nutrition, weight, and daily habits. Built with Flutter and powered by Google Gemini AI, it offers a sleek, modern dark-mode interface with intelligent food logging capabilities.
Features β’ Demo β’ Installation β’ Configuration
- β¨ Features
- π¬ Demo
- π§ Prerequisites
- β‘ Installation & Setup
- π Configuration
- π Running the Application
- π± Building for Release
- ποΈ Project Structure
- π οΈ Tech Stack
- β Troubleshooting
- π€ Contributing
- π License
- π AI Food Logging: Simply snap a photo or type a description (e.g., "Oatmeal with blueberries") and get instant macro analysis using Google Gemini AI
- π¬ AI Nutrition Coach: Chat with your personal AI nutritionist for personalized advice, meal suggestions, and dietary guidance
- π§ AI Diet Strategy: Get AI-generated meal strategies and recommendations based on your fitness goals
- π Smart Dashboard: Real-time tracking of Calories, Protein, Carbs, and Fat against your personalized TDEE targets
- βοΈ Weight Tracker: Log your weight daily and visualize trends over time with beautiful interactive charts
- π§ Habit Tracking: Track daily water intake with quick-add buttons and visual progress indicators
- π Trends & Insights: Analyze your nutrition patterns with detailed charts powered by fl_chart
- ποΈ Weekly Meal Planner: Plan your entire week with organized meals (Breakfast, Lunch, Dinner, Snacks)
- π³ Recipe Builder: Create and save custom recipes with ingredient tracking
- π Recipe Library: Browse and manage your collection of favorite recipes
- πΈ Barcode Scanner: Quickly log packaged foods by scanning barcodes (Mobile only)
- π Dark Mode Interface: Beautiful, modern dark-themed UI designed for extended use
- π― Intuitive UX: Smooth animations and responsive design across all platforms
- π± Cross-Platform: Seamlessly works on Windows, Android, iOS, Web, macOS, and Linux
- π Secure Authentication: Firebase-powered login with email/password and Google Sign-In
πDemo Video if below video not play
- π Note: Click the sound icon to enable audio.
part1.mp4
- π Note: Click the sound icon to enable audio.
part2.mp4
Main dashboard, AI food logging, and tracking features
Firebase data storage and cloud sync

Note: Demo videos showcase the application's key features including AI-powered food logging, real-time macro tracking, weight trends, meal planning, recipe management, and the AI nutrition coach.
Before you begin, ensure you have the following installed:
-
Flutter SDK (version 3.0.0 or higher)
- Download Flutter
- Verify installation:
flutter --version
-
Dart SDK (comes with Flutter)
-
Git (for cloning the repository)
| Platform | Requirements |
|---|---|
| Windows | Windows 10/11, Visual Studio 2022 with C++ tools |
| Android | Android Studio, Android SDK (API 21+) |
| iOS | macOS, Xcode 14+, CocoaPods |
| macOS | macOS 10.14+, Xcode 14+ |
| Linux | Linux development packages, GTK 3.0+ |
| Web | Chrome browser (for testing) |
-
Firebase Account (free tier available)
-
Google AI Studio Account (for Gemini API)
# Clone the repository
git clone https://github.com/yourusername/macro_tracker_ai.git
# Navigate to project directory
cd macro_tracker_ai# Install Flutter packages
flutter pub get
# Run code generation for Riverpod and JSON serialization
flutter pub run build_runner build --delete-conflicting-outputs# Check for any issues
flutter doctor
# List available devices
flutter devicesTip: If
flutter doctorshows any issues, follow the suggested fixes before proceeding.
MacroMate requires two main configurations: Firebase for data storage and Google Gemini AI for intelligent food logging.
Firebase is used for user authentication and storing all user data.
- Go to Firebase Console
- Create a new project (e.g., "MacroMate-AI")
- Enable Authentication (Email/Password and Google Sign-In)
- Enable Cloud Firestore
- In Firebase Console, go to Firestore Database
- Click "Create database"
- Select Production mode or Test mode (for development)
- Choose a Cloud Firestore location
- Update Firestore security rules (example for development):
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}For Web:
- In Firebase Console, go to Project Settings β Your apps
- Click the Web icon
</> - Register your app (nickname: "MacroMate Web")
- Copy the Firebase config
- Update
web/index.htmlwith your credentials
For Android:
- Add an Android app in Firebase Console
- Enter package name:
com.example.macro_tracker_ai - Download
google-services.json - Place in
android/app/folder
For iOS:
- Add an iOS app in Firebase Console
- Enter bundle ID:
com.example.macroTrackerAi - Download
GoogleService-Info.plist - Place in
ios/Runner/folder
The AI food logging and nutrition coach features require a Google Gemini API key.
- Visit Google AI Studio
- Sign in with your Google account
- Click "Get API Key" in the top navigation
- Click "Create API key"
- Select your Google Cloud project (or create a new one)
- Copy the generated API key
Option 1: Configure in App (Recommended)
- Launch MacroMate
- Navigate to Settings page (bottom navigation)
- Scroll to AI Provider section
- Select "Google Gemini"
- Paste your API key
- Click "Save"
- API key is securely stored locally on your device
Option 2: Environment Variables (Advanced)
# Windows PowerShell
$env:GEMINI_API_KEY="your-api-key-here"
flutter run
# macOS/Linux
export GEMINI_API_KEY="your-api-key-here"
flutter runSecurity Note: Never commit API keys to version control. They are stored locally using
shared_preferencesand never transmitted except to Google AI services.
- Go to the Dashboard or Logging screen
- Click "Add Food" β "AI Analysis"
- Type a food description or take a photo
- If configured correctly, you'll see macro analysis results
MacroMate also supports ChatGPT as an alternative AI provider.
- Visit OpenAI Platform
- Sign in or create an account
- Navigate to API Keys section
- Click "Create new secret key"
- Copy the generated key
- Launch MacroMate
- Go to Settings β AI Provider
- Select "ChatGPT"
- Paste your OpenAI API key
- Choose your preferred model (e.g., GPT-4, GPT-4o)
- Click "Save"
Available Models:
gpt-4o- Latest multimodal model (recommended)gpt-4-turbo- Fast and cost-effectivegpt-3.5-turbo- Budget-friendly option
Note: ChatGPT API usage is billed by OpenAI. Check their pricing at openai.com/pricing
Once configuration is complete, you can run MacroMate on any platform:
# Windows
flutter run -d windows
# Android (with device/emulator connected)
flutter run -d android
# iOS (macOS only, with simulator/device)
flutter run -d ios
# Web
flutter run -d chrome
# macOS
flutter run -d macos
# Linux
flutter run -d linux# List all available devices
flutter devices
# Run and select device
flutter runWhile the app is running:
- Press
rto hot reload - Press
Rto hot restart - Press
qto quit
# Build APK (for direct installation)
flutter build apk --release
# Output: build/app/outputs/flutter-apk/app-release.apk
# Build App Bundle (for Play Store)
flutter build appbundle --release# Build for iOS (requires macOS)
flutter build ios --release
# Open in Xcode for signing and distribution
open ios/Runner.xcworkspace# Build Windows executable
flutter build windows --release
# Output: build\windows\runner\Release\# Build for web deployment
flutter build web --release
# Output: build/web/# Build for macOS
flutter build macos --releasemacro_tracker_ai/
βββ lib/
β βββ core/ # Core utilities and theme
β βββ features/ # Feature modules
β β βββ auth/ # Authentication screens
β β βββ dashboard/ # Main dashboard
β β βββ logging/ # Food logging and AI analysis
β β βββ food_search/ # Food database search
β β βββ meal_planner/ # Meal planning
β β βββ recipes/ # Recipe builder & library
β β βββ weight/ # Weight tracking
β β βββ trends/ # Charts and analytics
β β βββ nutrition/ # Nutrition insights
β β βββ coach/ # AI nutrition coach
β β βββ strategy/ # Diet strategy planner
β β βββ history/ # Food log history
β β βββ settings/ # App settings
β βββ models/ # Data models (Food, User, Meal, etc.)
β βββ providers/ # Riverpod state providers
β βββ services/ # API services
β β βββ ai_service.dart # Google Gemini integration
β β βββ auth_service.dart # Firebase authentication
β β βββ firestore_service.dart # Cloud Firestore
β β βββ food_log_service.dart # Food logging
β β βββ meal_planner_service.dart
β β βββ recipe_service.dart
β β βββ user_service.dart
β β βββ weight_service.dart
β β βββ water_service.dart
β βββ main.dart # App entry point
βββ android/ # Android-specific code
βββ ios/ # iOS-specific code
βββ windows/ # Windows-specific code
βββ web/ # Web-specific code
βββ macos/ # macOS-specific code
βββ linux/ # Linux-specific code
βββ assets/ # Images and resources
β βββ app_icon.png # App icon
βββ pubspec.yaml # Dependencies
| File | Purpose |
|---|---|
lib/main.dart |
Application entry point, Firebase initialization |
lib/services/ai_service.dart |
Google Gemini AI integration with HTTP fallback |
lib/services/auth_service.dart |
Firebase Authentication (Email + Google Sign-In) |
lib/services/firestore_service.dart |
Cloud Firestore operations |
lib/providers/ |
Riverpod state management |
lib/models/ |
Data models with JSON serialization |
- flutter_riverpod
^2.5.1- Reactive state management - riverpod_annotation
^2.3.5- Code generation for Riverpod - state_notifier
^1.0.0- State change notifier
- firebase_core
^3.1.0- Firebase initialization - firebase_auth
^5.1.0- User authentication - cloud_firestore
^5.0.0- NoSQL cloud database - google_sign_in
^6.2.1- Google OAuth integration
- Google Gemini API (HTTP fallback) - Vision and text analysis for food recognition
- ChatGPT API Support - Alternative AI provider for food analysis and coaching
- go_router
^14.0.0- Declarative routing
- fl_chart
^0.68.0- Interactive charts and graphs - cupertino_icons
^1.0.6- iOS-style icons
- shared_preferences
^2.2.3- Local data persistence - image_picker
^1.0.7- Camera/gallery access - image_picker_windows
^0.2.2- Windows image picker support - mobile_scanner
^5.1.0- Barcode scanning - openfoodfacts
^3.1.0- Food database API - http
^1.1.0- HTTP requests - intl
^0.19.0- Internationalization - uuid
^4.4.0- Unique ID generation - json_annotation
^4.9.0- JSON serialization annotations
- build_runner
^2.4.9- Code generation - riverpod_generator
^2.4.0- Riverpod code generation - freezed
^2.5.2- Immutable data classes - json_serializable
^6.8.0- JSON serialization - flutter_launcher_icons
^0.13.1- App icon generation
π΄ Build failed: "Plugin not found"
Solution:
# Clean Flutter
flutter clean
# Remove existing symlinks (Windows only)
Remove-Item -Recurse -Force windows/flutter/ephemeral
# Reinstall dependencies
flutter pub get
# Rebuild
flutter runπ΄ Firebase not initialized
Error: [core/no-app] No Firebase App '[DEFAULT]' has been created
Solution:
- Verify Firebase configuration files exist:
- Web: Check
web/index.htmlhas Firebase config - Android:
android/app/google-services.json - iOS:
ios/Runner/GoogleService-Info.plist
- Web: Check
- Check that
Firebase.initializeApp()is called inmain.dart - Run
flutter cleanand rebuild
π΄ Gemini API not working
Symptoms: AI food analysis returns errors or nothing happens
Solutions:
- Verify API key is correct in Settings
- Check API key is enabled in Google Cloud Console
- Ensure you haven't exceeded free tier quota (60 requests/minute)
- Test API key: Gemini API Docs
- Try switching to ChatGPT as alternative AI provider
π΄ ChatGPT API not working
Solutions:
- Verify OpenAI API key is correct
- Check your account has credits/billing enabled
- Ensure selected model is available (try
gpt-3.5-turbo) - Check for rate limit errors in logs
π΄ Charts not displaying
Solution:
- Ensure you have data logged (weight, meals)
- Try pulling down to refresh
- Check date range filters
- Restart the app
π΄ Barcode scanner not working
Solution:
- Grant camera permissions in device settings
- Barcode scanner only works on mobile (Android/iOS)
- Ensure
mobile_scannerplugin is properly installed
π΄ Windows build issues
Error: C++ build tools not found or CMake errors
Solution:
- Install Visual Studio 2022 with "Desktop development with C++"
- Ensure CMake is installed and accessible
- Run
flutter doctorto verify - Restart terminal/IDE after installation
- Try
flutter cleanand rebuild
π΄ Google Sign-In not working
Solution:
- Ensure
google_sign_inis configured in Firebase Console - For Android: Check SHA-1 fingerprint is added to Firebase
- For iOS: Check URL schemes are configured in Xcode
- Verify Google Sign-In is enabled in Firebase Authentication
If you encounter other issues:
- Check Flutter Doctor: Run
flutter doctor -vfor diagnostic info - Review logs: Use
flutter run --verbosefor detailed output - Search issues: Check GitHub Issues
- Ask for help: Open a new issue with:
- Flutter version (
flutter --version) - Platform (Windows, Android, etc.)
- Error logs
- Steps to reproduce
- Flutter version (
Contributions are welcome!
- This project is a comprehensive example of building a production-grade Flutter AI application using Clean Architecture, Riverpod, and Google Gemini for image recognition and natural language processing.
This project is licensed under the MIT License.