Skip to content

Food Scan AI revolutionizes nutrition management with its smart features: πŸ“Έ Scan food labels or cooked dishes for instant analysis, πŸ€– AI-powered insights into nutritional content, πŸ’¬ Real-time AI chat with scanned food context, 🍽️ personalized dietary advice, and πŸ“Š Daily intake tracking to monitor nutrients and calories effortlessly

Notifications You must be signed in to change notification settings

nikhileshmeher0204/ScanMyFood

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

88 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Food Scan AI

A comprehensive nutrition analysis platform that helps users track their nutritional intake by analyzing food product labels and meals using AI. Built with a Flutter frontend and Spring Boot backend, leveraging Google Cloud's Vertex AI for intelligent food analysis.

Features

  • πŸ“Έ Scan product labels and food items using your device's camera
  • πŸ” AI-powered nutrition analysis using Google Cloud Vertex AI
  • πŸ“Š Track daily nutrient intake with detailed breakdowns
  • πŸ“… View historical food consumption data
  • πŸ“ˆ Visual representations of macronutrient distribution
  • πŸ‘€ User profiles with personalized dietary preferences and health metrics
  • ⚑ Real-time nutritional insights and recommendations
  • πŸ” Secure Firebase authentication integration
  • 🌐 Cross-platform support with synchronized data

Screenshots

FoodScanAI_Recording.mp4
Screenshot 1 Screenshot 2 Screenshot 3
Screenshot 4 Screenshot 5 Screenshot 6

Architecture

Food Scan AI follows a modern, scalable architecture:

  • Frontend: Flutter mobile app with MVVM architecture
  • Backend: Spring Boot RESTful API service
  • Database: PostgreSQL for persistent storage
  • Authentication: Firebase Authentication
  • AI Analysis: Google Cloud Vertex AI (Gemini 2.0 Flash)
  • Cloud Infrastructure: Google Cloud Platform

Project Structure

/
β”œβ”€β”€ flutter-app/              # Flutter frontend application
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ core/             # App-wide constants
β”‚   β”‚   β”œβ”€β”€ config/           # Environment configuration
β”‚   β”‚   β”œβ”€β”€ models/           # Data models
β”‚   β”‚   β”œβ”€β”€ repositories/     # Data access layer with interfaces
β”‚   β”‚   β”œβ”€β”€ services/         # Business logic services
β”‚   β”‚   β”œβ”€β”€ theme/            # App theme definitions  
β”‚   β”‚   β”œβ”€β”€ viewmodels/       # ViewModels for business logic
β”‚   β”‚   β”œβ”€β”€ views/            # UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ screens/      # Full page views
β”‚   β”‚   β”‚   └── widgets/      # Reusable UI components
β”‚   β”‚   └── main.dart         # Application entry point
β”‚   └── assets/               # App resources (images, fonts, etc.)
β”‚
└── spring-backend/           # Spring Boot backend service
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ main/
    β”‚   β”‚   β”œβ”€β”€ java/com/scanmyfood/backend/
    β”‚   β”‚   β”‚   β”œβ”€β”€ configurations/  # App configs
    β”‚   β”‚   β”‚   β”œβ”€β”€ controllers/     # REST API endpoints
    β”‚   β”‚   β”‚   β”œβ”€β”€ models/          # Data entities
    β”‚   β”‚   β”‚   β”œβ”€β”€ repositories/    # Database access
    β”‚   β”‚   β”‚   β”œβ”€β”€ services/        # Business logic
    β”‚   β”‚   β”‚   └── ScanMyFoodBackendApplication.java
    β”‚   β”‚   └── resources/           # Application properties
    β”‚   └── test/                    # Unit and integration tests
    └── pom.xml                      # Maven dependencies

Getting Started

Prerequisites

  • Flutter SDK (>=3.4.3)
  • Java JDK 17+
  • Maven 3.6+
  • PostgreSQL 14+
  • Firebase project with Authentication enabled
  • Google Cloud project with Vertex AI API enabled

Frontend Setup

  1. Clone the repository
git clone https://github.com/nikhileshmeher0204/read_the_label.git
cd read_the_label
  1. Navigate to the Flutter app directory
cd flutter-app
  1. Set up Firebase

    • Create a Firebase project at firebase.google.com
    • Add Android and iOS apps to your project
    • Download and add the configuration files (google-services.json for Android and GoogleService-Info.plist for iOS)
    • Enable Authentication with Email/Password provider
  2. Create a .env file in the Flutter app directory:

# Optional local development URL (if not using default)
API_BASE_URL=http://localhost:8080/api
  1. Install dependencies
flutter pub get
  1. Run the app
flutter run

Backend Setup

  1. Navigate to the Spring Boot backend directory
cd spring-backend
  1. Configure Google Cloud credentials

    • Create a service account in your Google Cloud project
    • Grant it access to Vertex AI API
    • Download the service account key file as firebase-service-account.json
    • Place it in src/main/resources/
  2. Configure PostgreSQL

    • Create a PostgreSQL database named scanmyfood
    • Update database connection details in application.properties if needed:
spring.datasource.url=jdbc:postgresql://localhost:5432/scanmyfood
spring.datasource.username=your_username
spring.datasource.password=your_password
  1. Build and run the Spring Boot application
# Using Maven
mvn spring-boot:run

# Or using the Maven wrapper
./mvnw spring-boot:run

State Management

This application uses a combination of state management approaches:

  • Frontend: Provider for Flutter app state management

    • ViewModels:
      • UiViewModel: Handles UI state and navigation
      • ProductAnalysisViewModel: Manages product scanning and analysis
      • MealAnalysisViewModel: Handles food image analysis
      • DailyIntakeViewModel: Controls daily consumption tracking
      • OnboardingViewModel: Manages user onboarding flow
  • Backend: Spring services for business logic

    • UserService: User profile and preferences management
    • VertexAiServiceImpl: AI analysis implementation
    • Authentication handled via Firebase integration

Technologies Used

Frontend

  • Flutter SDK (>=3.4.3)
  • Dart SDK
  • Firebase Authentication for user management
  • Provider for state management
  • SharedPreferences for local storage
  • Material Design 3 with custom theme
  • Key Flutter packages:
    • image_picker for camera integration
    • flutter_dotenv for environment variables
    • fl_chart for data visualization
    • rive for animations
    • http for API communication

Backend

  • Spring Boot 3.4.5 for RESTful API development
  • Spring Data JPA for database operations
  • PostgreSQL for data persistence
  • Google Cloud Vertex AI for AI-powered analysis
  • Firebase Admin SDK for authentication verification
  • Maven for dependency management

Infrastructure

  • Google Cloud Platform:
    • Vertex AI (Gemini 2.0 Flash model)
    • Firebase Authentication
    • Cloud Storage (optional for production)

Deployment

Frontend

  • Build the Flutter app for production:
flutter build apk --release  # for Android
flutter build ios --release  # for iOS

Backend

  • Package the Spring Boot application:
mvn clean package
  • Deploy the resulting JAR file to your server or cloud provider

Future Enhancements

  • Real-time data synchronization between devices
  • Advanced meal planning with AI recommendations
  • Barcode scanning for quick product lookup
  • Machine learning for personalized nutritional insights
  • Dietary goal tracking and achievement rewards
  • Social sharing and community features

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Google Cloud Vertex AI for powerful AI capabilities
  • Spring Boot team for the excellent backend framework
  • Flutter team for the amazing cross-platform UI toolkit
  • Firebase for seamless authentication
  • PostgreSQL for reliable data storage

About

Food Scan AI revolutionizes nutrition management with its smart features: πŸ“Έ Scan food labels or cooked dishes for instant analysis, πŸ€– AI-powered insights into nutritional content, πŸ’¬ Real-time AI chat with scanned food context, 🍽️ personalized dietary advice, and πŸ“Š Daily intake tracking to monitor nutrients and calories effortlessly

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages