Skip to content

πŸ₯‘AI powered nutrition tracking app built with Flutter and Google Gemini/Open AI GPT 🧠🍎

License

Notifications You must be signed in to change notification settings

kamlesh-IY9/Macro-Tracker-AI-V.0.2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯‘ MacroMate

Your AI-Powered Nutrition Companion

Flutter Firebase Gemini AI License Platform

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


πŸ“‹ Table of Contents


✨ Features

πŸ€– AI-Powered Features

  • πŸ” 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

πŸ“Š Tracking & Analytics

  • πŸ“ˆ 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

🍽️ Meal Planning

  • πŸ—“οΈ 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)

🎨 Premium Design

  • πŸŒ™ 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

🎬 Demo

Application Walkthrough

MacroMate_AI_Demo.mp4

Main dashboard, AI food logging, and tracking features

image image image

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.


πŸ”§ Prerequisites

Before you begin, ensure you have the following installed:

Required Software

  • Flutter SDK (version 3.0.0 or higher)

  • Dart SDK (comes with Flutter)

  • Git (for cloning the repository)

Platform-Specific Requirements

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)

Required Accounts


⚑ Installation & Setup

Step 1: Clone the Repository

# Clone the repository
git clone https://github.com/yourusername/macro_tracker_ai.git

# Navigate to project directory
cd macro_tracker_ai

Step 2: Install Dependencies

# Install Flutter packages
flutter pub get

# Run code generation for Riverpod and JSON serialization
flutter pub run build_runner build --delete-conflicting-outputs

Step 3: Verify Flutter Installation

# Check for any issues
flutter doctor

# List available devices
flutter devices

Tip: If flutter doctor shows any issues, follow the suggested fixes before proceeding.


πŸ”‘ Configuration

MacroMate requires two main configurations: Firebase for data storage and Google Gemini AI for intelligent food logging.

1. Firebase Database Setup

Firebase is used for user authentication and storing all user data.

A. Create a Firebase Project

  1. Go to Firebase Console
  2. Create a new project (e.g., "MacroMate-AI")
  3. Enable Authentication (Email/Password) and Cloud Firestore

B. Update Configuration

The project comes with placeholder credentials in lib/firebase_options.dart. You need to replace them with your own:

  1. In Firebase Console, go to Project Settings β†’ Your apps
  2. Add apps for the platforms you want to support (Web, Android, iOS, etc.)
  3. Open lib/firebase_options.dart
  4. 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.


2. Google Gemini AI Setup

The AI food logging and nutrition coach features require a Google Gemini API key.

A. Get Your API Key

  1. Visit Google AI Studio
  2. Sign in with your Google account
  3. Click "Get API Key" in the top navigation
  4. Click "Create API key"
  5. Select your Google Cloud project (or create a new one)
  6. Copy the generated API key

B. Configure in MacroMate

Option 1: Configure in App (Recommended)

  1. Launch MacroMate
  2. Navigate to Settings page (bottom navigation)
  3. Find "Gemini API Key" section
  4. Paste your API key
  5. Click "Save"
  6. 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 run

Security Note: Never commit API keys to version control. They are stored locally using shared_preferences and never transmitted except to Google AI services.

C. Verify AI Features

  1. Go to the Dashboard
  2. Click "Add Food" β†’ "AI Analysis"
  3. Type a food description or take a photo
  4. If configured correctly, you'll see macro analysis results

Alternative: ChatGPT API Integration

⚠️ 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:

  1. OpenAI API Key from OpenAI Platform
  2. Replace google_generative_ai package with dart_openai in pubspec.yaml
  3. 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.0

Then update the AI service to use OpenAI's API. If you need help with this integration, feel free to open an issue!


πŸš€ Running the Application

Run on Specific Platform

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

Select Device Interactively

# List all available devices
flutter devices

# Run and select device
flutter run

Hot Reload During Development

While the app is running:

  • Press r to hot reload
  • Press R to hot restart
  • Press q to quit

πŸ“± Building for Release

Android APK/Bundle

# 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

iOS

# Build for iOS (requires macOS)
flutter build ios --release

# Open in Xcode for signing and distribution
open ios/Runner.xcworkspace

Windows Executable

# Build Windows executable
flutter build windows --release

# Output: build\windows\runner\Release\

Web

# Build for web deployment
flutter build web --release

# Output: build/web/

macOS

# Build for macOS
flutter build macos --release

πŸ—οΈ Project Structure

macro_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

Key Files

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

πŸ› οΈ Tech Stack

Flutter Dart Firebase Google Gemini Riverpod Android Studio

Core Framework

  • Flutter ^3.0.0 - Cross-platform UI framework
  • Dart ^3.0.0 - Programming language

State Management

Backend & Database

AI & Machine Learning

UI & Visualization

Utilities

Development Tools


❓ Troubleshooting

Common Issues

πŸ”΄ 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:

  1. Verify firebase_options.dart exists in lib/
  2. Check that Firebase.initializeApp() is called in main.dart
  3. Ensure platform-specific files are in place:
    • Android: android/app/google-services.json
    • iOS: ios/Runner/GoogleService-Info.plist
πŸ”΄ Gemini API not working

Symptoms: AI food analysis returns errors or nothing happens

Solutions:

  1. Verify API key is correct in Settings
  2. Check API key has Gemini API enabled in Google Cloud Console
  3. Ensure you haven't exceeded free tier quota
  4. Test API key independently: Gemini API Docs
πŸ”΄ Charts not displaying

Solution:

  1. Ensure you have data logged (weight, meals)
  2. Try pulling down to refresh
  3. Check date range filters
  4. Restart the app
πŸ”΄ Barcode scanner not working

Solution:

  1. Grant camera permissions in device settings
  2. Barcode scanner only works on mobile (Android/iOS)
  3. Ensure mobile_scanner plugin is properly installed
πŸ”΄ Windows build issues

Error: C++ build tools not found

Solution:

  1. Install Visual Studio 2022 with "Desktop development with C++"
  2. Run flutter doctor to verify
  3. May need to restart terminal/IDE after installation

Getting Help

If you encounter other issues:

  1. Check Flutter Doctor: Run flutter doctor -v for diagnostic info
  2. Review logs: Use flutter run --verbose for detailed output
  3. Search issues: Check GitHub Issues
  4. Ask for help: Open a new issue with:
    • Flutter version (flutter --version)
    • Platform (Windows, Android, etc.)
    • Error logs
    • Steps to reproduce

🀝 Contributing

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.

πŸ“„ License

This project is licensed under the MIT License.


Made with ❀️ using Flutter

MacroMate - Transform your nutrition journey with AI

⬆ Back to Top