Skip to content

Dakshin10/NutriCrew

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯— NutriCrew AI

Your Intelligent Personal Nutritionist β€” Powered by Multi-Agent RAG Orchestration, Llama-3/4 Vision Systems, and a premium Glassmorphism client.

Flutter FastAPI CrewAI Groq Cloud Platform Support License


πŸ“± About the App

NutriCrew AI is a state-of-the-art intelligent nutritionist companion designed to replace manual, tedious food tracking databases with a frictionless visual experience. By combining high-speed computer vision and a collaborative team of specialized AI agents, NutriCrew analyzes any dish from a single photograph and offers deep culinary advice and recipes.

✨ Key Features

  • πŸ“Έ Snapshot Analysis: Take a photo of your meal or upload it from your gallery to automatically detect ingredients, estimate calories, and score its overall health rating.
  • 🧠 Multi-Agent RAG: Leverages a structured, sequential team of specialized AI agents (Ingredient Analysts, Nutrition Experts, and Chefs) to analyze composition, point out hidden allergens/additives, and formulate healthier alternatives.
  • ✨ Premium Glassmorphic UI: Experience a fluid interface inspired by modern design trendsβ€”complete with dynamic breathing background orbs, smooth sliding tab controls, micro-interactions, and built-in device haptic feedback.
  • πŸ’Ύ Offline History Tracking: Revisit your past meal analysis reports anytime with local offline persistence and intuitive swipe-to-dismiss feed management.

πŸ“ System Architecture

NutriCrew AI is designed with a decoupled architecture. A high-performance Flutter client manages layout rendering, local state persistence, and capture mechanisms. The backend uses an asynchronous FastAPI server to coordinate vision detection and run a sequential multi-agent intelligence pipeline to deliver structural nutritionist insights.

graph TD
    A[Flutter Mobile Client] -->|1. POST Uploaded Image| B(FastAPI Gateway)
    B -->|2. Analyze Image| C[Groq Llama-4-Scout-17b]
    C -->|3. Food Segmentation JSON| B
    B -->|4. Kickoff Sequential Crew| D[CrewAI Sequencer]
    
    subgraph Multi-Agent Crew [Multi-Agent Analysis Team]
        D -->|Task 1: Composition| E[Ingredient Analyst]
        D -->|Task 2: Nutri Insights| F[Nutrition Expert]
        D -->|Task 3: Healthy Recipes| G[Recipe Generator]
        E -->|Output| F
        F -->|Output| G
    end

    E & F & G -->|5. Structured Outputs| D
    D -->|6. Merge Payload| B
    B -->|7. JSON Response| A
    A -->|8. Store Query Local| H[(SharedPreferences)]
Loading

πŸ“Έ Screen Walkthroughs & UX Highlights

The mobile application utilizes a Dark Mode Glassmorphic Design System built on custom layout widgets, linear gradients, backdrop-blur components, and haptic feedback triggers.

1. Immersive Home & Capture Portal

Launch into a gorgeous dark canvas featuring glowing background orbs that scale and reposition dynamically to keep the workspace alive.

Welcome Portal Upload Bottom Sheet Image Loaded State
Welcome Portal
Picker Sheet
Loaded State
  • Animated Backgrounds: Breathing floating orbs with linear gradients shift softly in the background using flutter_animate triggers.
  • Micro-Animations: Capture portals pulse softly when empty, and CTA cards elevate with drop-shadow glow overlays upon loading.

2. Intelligent Overview & Macronutrient Breakdown

A central analytical dashboard presenting immediate ratings, total caloric estimations, and macro balances.

Overview Tab

  • Circular Macro Gauges: Carbohydrates, proteins, and fats are visualised in proportional ring systems.
  • Dynamic Health score: Features a rating gauge (1-10) color-coded on the fly (🟒 Green for high health-index, 🟑 Orange for moderate, πŸ”΄ Red for cautionary items).

3. Dynamic Insights & Culinary Alternatives

A detailed section dissecting composition tables, specific nutritional advice, and actionable alternatives.

Composition & Allergens Nutritionist Advice Alternative Recommendations
Ingredient Table
Nutritionist Advice
Healthy Alternatives
  • Nested Key-Value Tables: Automatically formats nested food JSON maps into clean, legible styling components.
  • Interactive Navigation: Clicking on a suggested healthy alternative card fires a device haptic vibrate and automatically slides to the Recipes tab.

4. Smart Recipe Recommendations

Provides detailed, healthy alternatives with lists of ingredients and checklists of preparation steps.

Recipe Recommendations Checklist Steps
Recipes Cards
Steps Checklist
  • Color-Coded Badges: Shows critical recipe insights like prep times and high-protein indicators.
  • Functional Checklist: Interactive steps that keep tracking simple.

5. Persistent Scan History

Offline history tracking ensures that all scanned analysis reports can be accessed instantly from the local database.

Scan History Feed

  • Swipe-To-Dismiss: Swipe left on items to delete records permanently from the cache with soft haptic vibrations.
  • Dynamic Indicators: A real-time notification badge counts and displays the active scan history total on the Home Screen.

πŸ€– Multi-Agent RAG Pipeline

NutriCrew segments food diagnostics and recipe formulation across specific specialized roles.

1. Vision Engine (Llama-4-Scout-17b)

Acts as the initial segmenter. It parses the base64 image data payload and returns metadata including estimated calories and health rankings.

  • Constraint: Output is configured as strict JSON:
    {
        "food_name": "String",
        "ingredients": ["Array of Strings"],
        "calories": 450,
        "health_rating": 7
    }

2. Ingredient Analyst (Llama-3.3-70b-versatile)

  • Role: Ingredient Analyst
  • Goal: Analyze the food composition and ingredients list for artificial additives, hidden sugars, high-sodium products, or allergens.
  • Backstory: An expert food scientist specializing in chemical analysis and dietetics.

3. Nutrition Expert (Llama-3.3-70b-versatile)

  • Role: Nutrition Expert
  • Goal: Evaluate the caloric footprint and provide clear diet advice, highlighting why this food is rated the way it is and suggesting general alternatives.
  • Backstory: A certified clinical nutritionist with deep experience in macro balancing and athletic diets.

4. Chef Recipe Generator (Llama-3.3-70b-versatile)

  • Role: Recipe Generator (Professional Chef)
  • Goal: Develop detailed, step-by-step recipes for a healthier replacement for the detected food item.
  • Backstory: A Michelin-star chef focused on converting calorie-dense comfort food into highly nutritious dishes.

πŸ”Œ API Documentation & Schema

The backend is built with FastAPI exposing an asynchronous post routing mechanism.

Endpoint: POST /analyze

Accepts a raw image file upload, processes it with the Vision Engine, feeds it into the sequential Crew, and returns the merged analytical payload.

Request Schema

  • Content-Type: multipart/form-data
  • Payload: file (Binary Image File)

Response Schema (JSON)

{
  "food_name": "Spaghetti Carbonara",
  "ingredients": ["Spaghetti", "Pecorino Romano", "Guanciale", "Egg Yolks", "Black Pepper"],
  "calories": 650,
  "health_rating": 4,
  "ingredient_analysis": "Refined wheat pasta causes rapid glucose spikes. Guanciale contains high levels of saturated fat and sodium...",
  "nutrition_advice": "High in caloric density with low fiber. Increase micronutrients by adding roasted vegetables. Good protein source from eggs, but offset by high saturated fats.",
  "healthy_alternative": "Zucchini Noodle Carbonara using Turkey Bacon and Light Pecorino.",
  "recipes": [
    {
      "recipe_name": "Zucchini Noodle Carbonara",
      "prep_time": "15 mins",
      "ingredients": "3 medium zucchinis (spiraled), 4 slices turkey bacon (chopped), 2 large eggs, 1/4 cup light Pecorino Romano, Cracked black pepper",
      "instructions": "1. Spiralize zucchinis and pat dry. 2. Crisp turkey bacon in a pan. 3. Whisk eggs and cheese in a bowl. 4. Toss zucchini noodles in the pan for 1-2 mins. 5. Remove from heat, stir in egg mixture quickly to avoid scrambling, and serve with fresh pepper."
    }
  ]
}

πŸ“ Project Layout

NutriCrew/
β”‚
β”œβ”€β”€ backend/                  # Asynchronous FastAPI Gateway
β”‚   β”œβ”€β”€ api/                  # Route routers
β”‚   β”‚   └── routes.py         # /analyze endpoints & runner hookups
β”‚   β”œβ”€β”€ crew/                 # CrewAI configuration
β”‚   β”‚   β”œβ”€β”€ agents.py         # Multi-Agent configurations
β”‚   β”‚   β”œβ”€β”€ tasks.py          # Structured task mappings
β”‚   β”‚   └── runner.py         # Crew sequencer & parser
β”‚   β”œβ”€β”€ tools/                # Vision integrations
β”‚   β”‚   └── vision_tool.py    # Llama-4-Scout API runner
β”‚   β”œβ”€β”€ uploads/              # Temporary file cache
β”‚   β”œβ”€β”€ app.py                # Server entry file
β”‚   β”œβ”€β”€ requirements.txt      # Backend Python dependencies
β”‚   └── .env                  # API keys
β”‚
└── frontend/                 # Flutter UI Application
    β”œβ”€β”€ lib/                  
    β”‚   β”œβ”€β”€ models/           
    β”‚   β”‚   └── nutrition_model.dart # Resilient data converters
    β”‚   β”œβ”€β”€ screens/          
    β”‚   β”‚   β”œβ”€β”€ home_screen.dart     # Home & image upload interface
    β”‚   β”‚   β”œβ”€β”€ result_screen.dart   # Premium sliding result panels
    β”‚   β”‚   └── history_screen.dart  # Offline storage swipe-to-dismiss feed
    β”‚   β”œβ”€β”€ services/         
    β”‚   β”‚   β”œβ”€β”€ api_service.dart     # Dio client settings
    β”‚   β”‚   └── history_service.dart # SharedPreferences interface
    β”‚   β”œβ”€β”€ theme/            
    β”‚   β”‚   └── app_theme.dart       # Colors, gradients, typography
    β”‚   β”œβ”€β”€ widgets/          
    β”‚   β”‚   β”œβ”€β”€ glass_card.dart      # Custom BackdropFilter widget
    β”‚   β”‚   └── animated_background.dart # Floating breathing backdrop orbs
    β”‚   └── main.dart         # Client entrypoint
    └── pubspec.yaml          # Flutter dependencies

πŸ“± Client Architecture & Type Resilience

One of the highlights of the Flutter client is its Type Resilience Parser. In typical LLM integrations, formatting can vary (e.g. returning list objects, maps, or string arrays). To prevent client crashes, NutriCrew filters data using clean parsing logic in nutrition_model.dart:

static String _parseString(dynamic value) {
  if (value == null) return "";
  if (value is String) return value;
  if (value is List) {
    return value.map((e) => _parseString(e)).join("\n");
  }
  if (value is Map) {
    final keys = value.keys.toList();
    if (keys.length == 1) {
      final val = value[keys.first];
      if (val is String) return val;
    }
    return value.entries
        .map((entry) => "${entry.key}: ${_parseString(entry.value)}")
        .join("\n");
  }
  return value.toString();
}

This prevents any _Map<String, dynamic> is not a subtype of String errors at runtime.


βš™οΈ Local Deployment & Configuration

Prerequisites

  • Flutter SDK (3.22+)
  • Python (3.10+)
  • Groq Cloud API Key

1. Backend Server Setup

  1. Navigate to the backend folder:
    cd backend
  2. Set up a virtual environment:
    python -m venv venv
    # Activate on Windows:
    venv\Scripts\activate
    # Activate on macOS/Linux:
    source venv/bin/activate
  3. Install dependencies:
    pip install -r requirements.txt
  4. Create a .env file in the root of the backend/ directory:
    GROQ_API_KEY=gsk_your_groq_api_key_goes_here
  5. Spin up the development server:
    uvicorn app:app --reload --host 0.0.0.0 --port 8000

2. Frontend Client Setup

  1. Navigate to the frontend folder:
    cd frontend
  2. Verify package dependencies:
    flutter pub get
  3. Check emulator connection (e.g., Android Emulator or physical device):
    flutter devices
  4. Run the debug client:
    flutter run

Note

If using an Android Emulator, the API service points to http://10.0.2.2:8000 (which loops back to localhost on the host PC). If testing on a physical device, update the base URL in api_service.dart to match your host PC's local IP address (e.g. http://192.168.1.XX:8000).


🀝 Contribution & Guidelines

Feel free to open pull requests or file issues to enhance:

  • Additional specialized CrewAI agents (like personal trainers or macro planners).
  • SQLite-backed robust database synchronization.
  • On-device ML classification.
Developed with ❀️ by the Dakshin.

About

πŸ₯— AI-powered nutrition coach that analyzes food images using Groq Vision and CrewAI multi-agent systems to deliver ingredient analysis, nutrition insights, healthy alternatives, and recipe recommendations.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors