Skip to content

AI-powered web app to analyze food labels. Upload an image to get instant nutritional facts, ingredient breakdown, and health risks. Built with Next.js & Google Gemini.

Notifications You must be signed in to change notification settings

uffamit/eatinformed

Repository files navigation

EatInformed

Next.js TypeScript Google Gemini Firebase Genkit License

πŸ€– AI-powered web application to analyze food labels with instant insights into nutritional facts, ingredient breakdown, and potential health risks.

πŸ“Έ Upload. πŸ” Analyze. πŸ’ͺ Stay Informed.


🌟 Overview

EatInformed empowers users to make healthier food choices by leveraging advanced AI to decode complex food labels. Simply upload an image of a food product label, and receive comprehensive analysis including nutritional information, ingredient breakdown, allergen warnings, and health risk assessmentsβ€”all powered by Google Gemini AI with Firebase Genkit integration.

Built with modern web technologies and designed for performance, EatInformed delivers real-time analysis with a beautiful, responsive interface optimized for all devices.


✨ Key Features

πŸ€– AI-Powered Intelligence

  • Google Gemini AI Integration: Advanced multimodal AI for accurate image and text analysis
  • Firebase Genkit Framework: Robust AI workflow orchestration and management
  • Real-Time Processing: Instant analysis with streaming responses
  • Multi-Language Support: Analyze labels in various languages

πŸ“Š Comprehensive Analysis

  • Nutritional Facts Extraction: Complete breakdown of calories, macros, vitamins, and minerals
  • Ingredient Analysis: Detailed examination of all ingredients with health implications
  • Allergen Detection: Automatic identification of common allergens (nuts, dairy, gluten, etc.)
  • Health Risk Assessment: AI-powered evaluation of potentially harmful additives
  • Additive Identification: Recognition and explanation of E-numbers and preservatives
  • Dietary Compliance: Check against vegan, vegetarian, keto, and other dietary restrictions

🎨 Modern User Experience

  • Responsive Design: Seamless experience across desktop, tablet, and mobile devices
  • Beautiful UI Components: Built with Radix UI primitives and Tailwind CSS
  • Interactive Visualizations: Charts and graphs using Recharts
  • Smooth Animations: Enhanced with TailwindCSS Animate and TSParticles
  • Dark Mode Support: Eye-friendly interface for all lighting conditions

πŸ” Security & Authentication

  • Firebase Authentication: Secure user sign-up and login
  • Email/Password & Social Auth: Multiple authentication methods
  • Protected Routes: Secure access to user-specific features
  • Admin Panel: Firebase Admin SDK integration for backend operations

πŸ’Ύ Data Management

  • SQLite Database: Efficient local data storage
  • Analysis History: Save and review past scans
  • User Profiles: Personalized dietary preferences and restrictions
  • Offline Support: Access previously analyzed products without internet

πŸš€ Tech Stack

Frontend Framework

Technology Version Purpose
Next.js 15.3.3 React framework with App Router and Turbopack
React 18.3.1 Component-based UI library
TypeScript 5.x Type-safe development

Styling & UI Components

Technology Version Purpose
Tailwind CSS 3.4.1 Utility-first CSS framework
Radix UI Various Accessible component primitives
Lucide React 0.475.0 Beautiful icon library
TailwindCSS Animate 1.0.7 Animation utilities
TSParticles 3.0.0+ Interactive particle effects

AI & Backend Services

Technology Version Purpose
Google Gemini AI Latest Multimodal AI for image and text analysis
Firebase Genkit 1.8.0 AI workflow framework
@genkit-ai/googleai 1.8.0 Google AI plugin for Genkit
@genkit-ai/next 1.8.0 Next.js integration for Genkit

Authentication & Database

Technology Version Purpose
Firebase 10.12.2 Client-side authentication and services
Firebase Admin 12.2.0 Server-side Firebase operations
SQLite Latest Lightweight relational database

Form Management & Validation

Technology Version Purpose
React Hook Form 7.54.2 Performant form management
@hookform/resolvers 4.1.3 Schema validation resolvers
Zod 3.24.2 TypeScript-first schema validation

Data Visualization & Utilities

Technology Version Purpose
Recharts 2.15.1 React charting library
date-fns 3.6.0 Date manipulation library
html2canvas 1.4.1 Screenshot generation
React Day Picker 8.10.1 Date picker component

Development Tools

Technology Version Purpose
ESLint 8.x Code linting and quality
PostCSS 8.x CSS transformations
Genkit CLI 1.8.0 AI development and testing

πŸ“¦ Installation & Setup

Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js 18.0 or higher
  • Yarn 1.22+ (specified package manager)
  • Git for version control

Required API Keys & Services

  1. Google Gemini API Key

    • Visit Google AI Studio
    • Create a new API key
    • Keep it secure for environment configuration
  2. Firebase Project

    • Go to Firebase Console
    • Create a new project or use existing one
    • Enable Authentication (Email/Password, Google Sign-in)
    • Generate Web App credentials
    • Download Firebase Admin Service Account JSON

Step-by-Step Setup

  1. Clone the Repository

    git clone https://github.com/uffamit/eatinformed.git
    cd eatinformed
  2. Install Dependencies

    yarn install
  3. Environment Configuration

    Create a .env.local file in the root directory:

    # Google Gemini AI
    GOOGLE_GEMINI_API_KEY=your_gemini_api_key_here
    GOOGLE_GENAI_API_KEY=your_gemini_api_key_here
    
    # Firebase Client Configuration
    NEXT_PUBLIC_FIREBASE_API_KEY=your_firebase_api_key
    NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
    NEXT_PUBLIC_FIREBASE_PROJECT_ID=your-project-id
    NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
    NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
    NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id
    NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=your_measurement_id
    
    # Firebase Admin SDK (Server-side)
    FIREBASE_PROJECT_ID=your-project-id
    FIREBASE_CLIENT_EMAIL=firebase-adminsdk@your-project.iam.gserviceaccount.com
    FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYourPrivateKeyHere\n-----END PRIVATE KEY-----\n"
    
    # Application Configuration
    NEXT_PUBLIC_APP_URL=http://localhost:9003
    NODE_ENV=development

    Important: Replace all placeholder values with your actual credentials.

  4. Firebase Setup

    • Enable Authentication methods in Firebase Console
    • Set up Firestore Database (if using)
    • Configure Firebase Storage for image uploads
    • Add authorized domains for authentication
  5. Database Initialization

    The SQLite database will be automatically created on first run. To manually initialize:

    # Database file: database.sqlite
    # Schema will be created automatically by the application
  6. Run Development Server

    # Start Next.js development server with Turbopack
    yarn dev

    The application will be available at http://localhost:9003

  7. Run Genkit Development Server (Optional)

    For AI workflow development and testing:

    yarn genkit:watch

    This starts the Genkit Developer UI for testing AI flows.


πŸ› οΈ Available Scripts

# Development
yarn dev                 # Start Next.js dev server with Turbopack on port 9003
yarn genkit:watch       # Watch and run Genkit AI flows in development mode

# Production
yarn build              # Build optimized production bundle
yarn start              # Start production server

# Code Quality
yarn lint               # Run ESLint with strict settings (max-warnings=0)
yarn typecheck          # Run TypeScript compiler checks without emitting files

# Package Management
yarn install            # Install dependencies
yarn add <package>      # Add new dependency

πŸ“ Project Structure

eatinformed/
β”œβ”€β”€ .github/                 # GitHub configuration and workflows
β”œβ”€β”€ .idx/                    # IDX configuration
β”œβ”€β”€ .vscode/                 # VS Code settings
β”œβ”€β”€ docs/                    # Documentation files
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ ai/                  # AI integration layer
β”‚   β”‚   β”œβ”€β”€ flows/          # Genkit AI flows and prompts
β”‚   β”‚   β”œβ”€β”€ dev.ts          # Genkit development configuration
β”‚   β”‚   └── genkit.ts       # Genkit initialization and setup
β”‚   β”œβ”€β”€ app/                 # Next.js App Router pages and layouts
β”‚   β”‚   β”œβ”€β”€ (auth)/         # Authentication routes
β”‚   β”‚   β”œβ”€β”€ (dashboard)/    # Protected dashboard routes
β”‚   β”‚   β”œβ”€β”€ api/            # API routes and endpoints
β”‚   β”‚   β”œβ”€β”€ layout.tsx      # Root layout component
β”‚   β”‚   └── page.tsx        # Home page
β”‚   β”œβ”€β”€ components/          # React components
β”‚   β”‚   β”œβ”€β”€ ui/             # Reusable UI components (Radix UI)
β”‚   β”‚   β”œβ”€β”€ forms/          # Form components
β”‚   β”‚   β”œβ”€β”€ layouts/        # Layout components
β”‚   β”‚   └── features/       # Feature-specific components
β”‚   β”œβ”€β”€ context/            # React Context providers
β”‚   β”‚   β”œβ”€β”€ AuthContext.tsx # Authentication context
β”‚   β”‚   └── ThemeContext.tsx # Theme management
β”‚   β”œβ”€β”€ hooks/              # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ useAuth.ts      # Authentication hook
β”‚   β”‚   β”œβ”€β”€ useFirebase.ts  # Firebase utilities
β”‚   β”‚   └── useAnalysis.ts  # Food analysis hook
β”‚   β”œβ”€β”€ lib/                # Utility libraries and configurations
β”‚   β”‚   β”œβ”€β”€ firebase.ts     # Firebase client initialization
β”‚   β”‚   β”œβ”€β”€ firebase-admin.ts # Firebase Admin SDK setup
β”‚   β”‚   └── utils.ts        # Helper functions
β”‚   β”œβ”€β”€ types/              # TypeScript type definitions
β”‚   β”‚   β”œβ”€β”€ analysis.ts     # Food analysis types
β”‚   β”‚   β”œβ”€β”€ user.ts         # User-related types
β”‚   β”‚   └── index.ts        # Exported types
β”‚   └── utils/              # Utility functions
β”‚       β”œβ”€β”€ validation.ts   # Zod schemas
β”‚       └── formatters.ts   # Data formatting utilities
β”œβ”€β”€ public/                  # Static assets (images, fonts, etc.)
β”œβ”€β”€ .env.local              # Environment variables (create this)
β”œβ”€β”€ .eslintrc.json          # ESLint configuration
β”œβ”€β”€ .gitignore              # Git ignore rules
β”œβ”€β”€ components.json         # shadcn/ui component configuration
β”œβ”€β”€ database.sqlite         # SQLite database file
β”œβ”€β”€ next.config.mjs         # Next.js configuration
β”œβ”€β”€ package.json            # Dependencies and scripts
β”œβ”€β”€ postcss.config.mjs      # PostCSS configuration
β”œβ”€β”€ tailwind.config.ts      # Tailwind CSS configuration
β”œβ”€β”€ tsconfig.json           # TypeScript configuration
└── README.md               

πŸ”§ Configuration Files

Firebase Configuration (src/lib/firebase.ts)

  • Client-side Firebase initialization
  • Authentication setup
  • Firestore configuration

Firebase Admin (src/lib/firebase-admin.ts)

  • Server-side Firebase Admin SDK
  • Secure backend operations
  • Token verification

Genkit Configuration (src/ai/genkit.ts)

  • AI model initialization
  • Google AI plugin setup
  • Flow registration and management

Next.js Config (next.config.mjs)

  • Image optimization settings
  • Environment variable handling
  • Build optimizations

Tailwind Config (tailwind.config.ts)

  • Custom color schemes
  • Component styling extensions
  • Animation configurations

🎯 API Routes & Endpoints

Authentication APIs

POST /api/auth/signup          # Create new user account
POST /api/auth/login           # User login
POST /api/auth/logout          # User logout
POST /api/auth/reset-password  # Password reset request

Analysis APIs

POST /api/analyze/image        # Upload and analyze food label image
GET  /api/analyze/history      # Get user's analysis history
GET  /api/analyze/:id          # Get specific analysis result
DELETE /api/analyze/:id        # Delete analysis result

User APIs

GET  /api/user/profile         # Get user profile
PUT  /api/user/profile         # Update user profile
GET  /api/user/preferences     # Get dietary preferences
PUT  /api/user/preferences     # Update dietary preferences

Genkit AI Flows

POST /api/genkit/analyze-label    # AI-powered label analysis flow
POST /api/genkit/extract-nutrients # Extract nutritional information
POST /api/genkit/identify-allergens # Detect allergens in ingredients

πŸ”₯ Firebase Services Used

Authentication

  • Email/Password Authentication
  • Google Sign-In
  • Password Reset & Email Verification
  • Session Management

Firestore Database (Optional)

  • User Profiles: Store user information and preferences
  • Analysis Results: Save food label analysis history
  • Favorites: Bookmark frequently scanned products

Firebase Storage (Optional)

  • Image Uploads: Store original food label images
  • Report Generation: Save PDF reports of analyses

Firebase Admin SDK

  • Server-side Authentication: Verify user tokens
  • Database Operations: Secure backend data access
  • User Management: Admin operations

πŸ€– AI Integration Details

Google Gemini AI

  • Model: Gemini Pro Vision (multimodal)
  • Capabilities:
    • Image recognition and OCR
    • Natural language understanding
    • Contextual analysis of ingredients
    • Nutritional data extraction

Genkit Framework

  • AI Flow Management: Structured workflows for analysis
  • Prompt Engineering: Optimized prompts for accurate results
  • Streaming Responses: Real-time result delivery
  • Error Handling: Robust fallback mechanisms

Analysis Pipeline

  1. Image Upload β†’ User uploads food label photo
  2. Preprocessing β†’ Image optimization and validation
  3. AI Analysis β†’ Gemini processes image and extracts data
  4. Data Structuring β†’ Genkit organizes results
  5. Health Assessment β†’ AI evaluates nutritional impact
  6. User Presentation β†’ Results displayed with visualizations

πŸ“Š Features in Detail

Nutritional Analysis

  • Calorie breakdown (per serving and per 100g)
  • Macronutrients (carbs, proteins, fats)
  • Micronutrients (vitamins, minerals)
  • Daily value percentages
  • Comparison with recommended intake

Ingredient Intelligence

  • Complete ingredient list extraction
  • Identification of artificial additives
  • E-number explanation and health impacts
  • Natural vs. synthetic ingredient classification
  • Allergen highlighting

Health Risk Assessment

  • Traffic light system (red/yellow/green)
  • Harmful additive warnings
  • Sugar and sodium level alerts
  • Trans fat detection
  • Preservative analysis

Dietary Compliance Checker

  • βœ… Vegan-friendly verification
  • βœ… Vegetarian compatibility
  • βœ… Gluten-free confirmation
  • βœ… Keto/Low-carb suitability
  • βœ… Halal/Kosher compliance
  • βœ… Allergen warnings (nuts, dairy, soy, etc.)

🎨 UI Components

Built with Radix UI primitives for accessibility and Tailwind CSS for styling:

  • Accordion - Collapsible content sections
  • Alert Dialog - Confirmation modals
  • Avatar - User profile images
  • Checkbox - Form selections
  • Dialog - Modal windows
  • Dropdown Menu - Context menus
  • Label - Form labels
  • Menubar - Navigation menus
  • Popover - Floating content
  • Progress - Loading indicators
  • Radio Group - Single selections
  • Scroll Area - Scrollable regions
  • Select - Dropdown selections
  • Separator - Visual dividers
  • Slider - Range inputs
  • Switch - Toggle controls
  • Tabs - Tabbed interfaces
  • Toast - Notifications
  • Tooltip - Hover hints

πŸš€ Deployment

Vercel (Recommended)

# Install Vercel CLI
npm i -g vercel

# Deploy
vercel

# Production deployment
vercel --prod

Environment Variables

Ensure all environment variables are configured in your deployment platform:

  • Vercel Dashboard β†’ Project Settings β†’ Environment Variables
  • Add all variables from .env.local

Build Optimization

  • Automatic image optimization
  • Static page generation where possible
  • API route caching
  • CDN distribution

🀝 Contributing

Contributions make the open-source community thrive! Any contributions you make are greatly appreciated.

How to Contribute

  1. Fork the Project

    # Click the 'Fork' button on GitHub
  2. Clone Your Fork

    git clone https://github.com/your-username/eatinformed.git
    cd eatinformed
  3. Create a Feature Branch

    git checkout -b feature/AmazingFeature
  4. Make Your Changes

    • Follow the existing code style
    • Add tests if applicable
    • Update documentation
  5. Commit Your Changes

    git add .
    git commit -m 'Add some AmazingFeature'
  6. Push to Your Branch

    git push origin feature/AmazingFeature
  7. Open a Pull Request

    • Go to the original repository
    • Click 'New Pull Request'
    • Describe your changes

Code Style Guidelines

  • Use TypeScript strict mode
  • Follow ESLint rules (yarn lint)
  • Write meaningful commit messages
  • Add JSDoc comments for complex functions

πŸ› Known Issues & Limitations

  • Image analysis accuracy depends on photo quality
  • Some obscure ingredients may not be recognized
  • OCR may struggle with handwritten labels
  • Analysis time varies based on image size (typically 3-10 seconds)

πŸ—ΊοΈ Roadmap

  • Multi-language support for international labels
  • Barcode scanning integration
  • Product comparison feature
  • Mobile app (React Native)
  • Recipe suggestions based on dietary preferences
  • Social sharing and community features
  • Integration with fitness tracking apps
  • Offline mode with service workers
  • Voice input for hands-free operation

πŸ“„ License

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


πŸ™ Acknowledgments


πŸ“ž Contact & Support

Admin - @uffamit

Project Link: https://github.com/uffamit/eatinformed

Get Help


πŸ“ˆ Stats

TypeScript CSS Other


Made with ❀️ for healthier food choices
Powered by Google Gemini AI & Firebase

Overview β€’ Setup β€’ API β€’ Contributing β€’ License

About

AI-powered web app to analyze food labels. Upload an image to get instant nutritional facts, ingredient breakdown, and health risks. Built with Next.js & Google Gemini.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages