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
- π 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)
- π Smart Shopping List: Automatically generate a checklist of ingredients from your meal plan
- πΈ 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
MacroMate_AI_Demo.mp4
Main dashboard, AI food logging, and tracking features
Firebase images with store data
Note: Demo videos showcase the application's key features including AI-powered food logging, real-time macro tracking, weight trends, meal planning, 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 Cloud Firestore
The project comes with placeholder credentials in lib/firebase_options.dart. You need to replace them with your own:
- In Firebase Console, go to Project Settings β Your apps
- Add apps for the platforms you want to support (Web, Android, iOS, etc.)
- Open
lib/firebase_options.dart - Replace the dummy values (e.g.,
YOUR_WEB_API_KEY_HERE) with your actual credentials from Firebase Console
Note: For Android/iOS, you also need to download google-services.json / GoogleService-Info.plist and place them in the respective folders.
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)
- Find "Gemini API Key" section
- 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
- Click "Add Food" β "AI Analysis"
- Type a food description or take a photo
- If configured correctly, you'll see macro analysis results
β οΈ Current Status: MacroMate currently uses Google Gemini AI. ChatGPT integration would require code modifications.
If you want to use OpenAI's ChatGPT instead:
What You'll Need:
- OpenAI API Key from OpenAI Platform
- Replace
google_generative_aipackage withdart_openaiinpubspec.yaml - Modify the AI service implementation in
lib/services/
Steps for Integration:
# In pubspec.yaml, replace:
google_generative_ai: ^0.4.6
# With:
dart_openai: ^5.1.0Then update the AI service to use OpenAI's API. If you need help with this integration, feel free to open an issue!
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 constants
β βββ features/ # Feature modules (dashboard, meals, weight, etc.)
β β βββ auth/ # Authentication screens
β β βββ dashboard/ # Main dashboard
β β βββ food/ # Food logging and AI analysis
β β βββ meals/ # Meal planning
β β βββ trends/ # Charts and analytics
β β βββ weight/ # Weight tracking
β β βββ settings/ # App settings
β βββ models/ # Data models (Food, User, Meal, etc.)
β βββ providers/ # Riverpod state providers
β βββ services/ # API services (Firebase, Gemini AI, etc.)
β βββ firebase_options.dart # Firebase configuration
β βββ 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
βββ pubspec.yaml # Dependencies
| File | Purpose |
|---|---|
lib/main.dart |
Application entry point, Firebase initialization |
lib/firebase_options.dart |
Firebase platform configurations |
lib/services/gemini_service.dart |
Google Gemini AI integration |
lib/services/firebase_service.dart |
Firebase 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
- firebase_core
^4.2.1- Firebase initialization - firebase_auth
^6.1.2- User authentication - cloud_firestore
^6.1.0- NoSQL database
- google_generative_ai
^0.4.6- Gemini AI integration
- fl_chart
^0.68.0- Interactive charts - cupertino_icons
^1.0.6- iOS-style icons
- shared_preferences
^2.2.3- Local data persistence - image_picker
^1.0.7- Camera/gallery access - mobile_scanner
^5.1.0- Barcode scanning - openfoodfacts
^3.4.0- Food database API - http
^1.1.0- HTTP requests - intl
^0.19.0- Internationalization - uuid
^4.4.0- Unique ID generation
- build_runner
^2.4.9- Code generation - freezed
^2.5.2- Immutable data classes - json_serializable
^6.8.0- JSON serialization
π΄ 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_options.dartexists inlib/ - Check that
Firebase.initializeApp()is called inmain.dart - Ensure platform-specific files are in place:
- Android:
android/app/google-services.json - iOS:
ios/Runner/GoogleService-Info.plist
- Android:
π΄ Gemini API not working
Symptoms: AI food analysis returns errors or nothing happens
Solutions:
- Verify API key is correct in Settings
- Check API key has Gemini API enabled in Google Cloud Console
- Ensure you haven't exceeded free tier quota
- Test API key independently: Gemini API Docs
π΄ 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
Solution:
- Install Visual Studio 2022 with "Desktop development with C++"
- Run
flutter doctorto verify - May need to restart terminal/IDE after installation
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.
This project is licensed under the MIT License.