Skip to content

Repository files navigation

🥗 NutriAI

AI-Powered Personalized Nutrition & Fitness Tracker for Indian Users

React Native Expo FastAPI Gemini AI LangChain LangGraph PostgreSQL Python TypeScript


📌 The Problem

Most nutrition and fitness tracking apps are built around Western dietary databases — think chicken breast, quinoa, and Greek yogurt. For the 300M+ health-conscious Indians, this means:

  • No local food data — Chapati, dal, paneer, and regional dishes are missing or inaccurate
  • Culturally irrelevant workout suggestions — No Surya Namaskar, no yoga-first routines
  • Generic meal plans — AI recommendations ignore vegetarian/vegan preferences common in India
  • Manual effort — Users have to search, estimate, and calculate nutrients for every meal

NutriAI solves this by providing an AI-powered health companion specifically designed for Indian users — with a localized food database, culturally relevant workouts, and personalized meal plans generated by Google Gemini AI.


🎯 What I Built

A full-stack mobile application with an AI-powered backend that delivers:

Feature Description
🤖 AI Health Plan Generator One-tap personalized meal & workout plans powered by Gemini 3.5 Flash orchestrated via LangGraph agents, tailored to user BMI, dietary preference, goals, allergies, and budget
🍛 Indian Food Database Pre-seeded with local foods (Chapati, Rice, Dal, Paneer, Banana, Milk) with per-unit nutrition data, unit conversions, and paginated search, sorting, and macro-filtering capabilities
📊 Smart Dashboard Real-time calorie tracking with 7-day trend charts, net calorie calculations (consumed − burned), and macro breakdowns (protein/carbs/fats)
🏋️ Workout Logging Support for both rep-based (Push-ups, Squats, Surya Namaskar) and time-based (Yoga, Cycling, Plank) workouts with auto-calculated calorie burn
💧 Water & Step Tracking Daily hydration and step counters with circular progress rings and quick-add bottom sheets
👤 Personalized Onboarding 3-step onboarding flow collecting body metrics, dietary preferences, fitness goals, allergies, and budget — auto-calculates BMI
🔐 JWT Authentication Secure register/login with bcrypt password hashing, JWT tokens, and middleware-enforced route protection
📈 Analytics & Trends Daily/weekly nutritional summaries, workout summaries, and calorie trend visualization

📸 Screenshots

Dashboard Screenshot_1783860897 Screenshot_1783354329 Screenshot_1783355489 Screenshot_1783860834

🏗️ Architecture Overview

┌─────────────────────────────────────────────────────────────────┐
│                        MOBILE CLIENT                            │
│              React Native + Expo (TypeScript)                   │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────────┐   │
│  │ Dashboard │  │ Food Log │  │ Workout  │  │  AI Plan     │   │
│  │  Screen   │  │  Screen  │  │  Screen  │  │  Screen      │   │
│  └────┬─────┘  └────┬─────┘  └────┬─────┘  └──────┬───────┘   │
│       └──────────────┴────────────┴────────────────┘           │
│                          Axios HTTP Client                      │
└─────────────────────────────┬───────────────────────────────────┘
                              │ REST API
┌─────────────────────────────┴───────────────────────────────────┐
│                        BACKEND SERVER                           │
│                  FastAPI (Python 3.13)                           │
│  ┌─────────────────────────────────────────────────────────┐   │
│  │  Auth Middleware (JWT decode → User injection)           │   │
│  └─────────────────────────────────────────────────────────┘   │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────────┐   │
│  │ Auth API │  │ Food API │  │Workout   │  │ Dashboard    │   │
│  │          │  │          │  │  API     │  │  API         │   │
│  └──────────┘  └──────────┘  └──────────┘  └──────────────┘   │
│  ┌──────────┐  ┌──────────────────────────────────────────┐    │
│  │Tracking  │  │       AI Health Plan Service (LangGraph) │    │
│  │  API     │  │  (Gemini 3.5 Flash → Meals & Workouts)   │    │
│  └──────────┘  └──────────────────────────────────────────┘    │
│                          SQLAlchemy ORM                         │
└─────────────────────────────┬───────────────────────────────────┘
                              │
                   ┌──────────┴──────────┐
                   │    PostgreSQL DB     │
                   │  (Users, Foods,      │
                   │   Workouts, Plans,   │
                   │   Logs, Tracking)    │
                   └─────────────────────┘

🤖 AI / ML Tech Stack (Highlight)

Technology Role Details
Google Gemini 3.5 Flash Core LLM Generates structured plan data (meals, workouts) based on user profile, constraints, and RAG context
LangGraph Multi-Agent Orchestration Chains multiple specialized nodes (Retrieve, Planners, Critic, Compiler) with a stateful correction loop
LangChain AI integration framework Simplifies prompt templates and async model invocations via ChatGoogleGenerativeAI
RAG (Knowledge Base) Expert Guidance Retrieval Injects static wellness/diet guidelines into the prompt to ground AI recommendations

How AI Health Planning Works (LangGraph Workflow)

graph TD
    Start([User Profile + Available Foods]) --> Retrieve[Retrieve RAG Context]
    Retrieve --> MealPlanner[Meal Planner Agent]
    Retrieve --> WorkoutPlanner[Workout Planner Agent]
    MealPlanner --> Critic{Safety Critic}
    WorkoutPlanner --> Critic
    Critic -- "Feedback Loop (Max 3 iterations)" --> MealPlanner
    Critic -- "Feedback Loop (Max 3 iterations)" --> WorkoutPlanner
    Critic -- Approved --> Compiler[Compiler Agent]
    Compiler --> Database[(Save Complete Plan to DB)]
    Database --> End([Result Saved])
Loading

🛠️ Full Tech Stack

Frontend (Mobile)

Technology Purpose
React Native 0.79 Cross-platform mobile framework
Expo 53 (Managed Workflow) Development toolchain, OTA updates, native module management
TypeScript 5.8 Type-safe development
Expo Router File-based routing with nested layouts
React Navigation Tab-based navigation (bottom tabs)
Formik + Yup Form management and schema validation
React Native Chart Kit 7-day calorie trend line charts
React Native Circular Progress Daily water & step progress rings
Gorhom Bottom Sheet Swipeable bottom sheets for quick data entry
React Native Paper Material Design components (RadioButtons, ProgressBar)
Expo Linear Gradient Gradient card backgrounds for AI plans
React Native Reanimated Smooth micro-animations (loading states)
Axios HTTP client for API communication
AsyncStorage Secure local token persistence

Backend (API Server)

Technology Purpose
FastAPI High-performance async Python API framework
Python 3.13 Latest Python with performance improvements
SQLAlchemy ORM for database models and queries
Alembic Database migration management
PostgreSQL Relational database for all persistent data
Pydantic Request/response schema validation
PyJWT JSON Web Token generation and verification
Passlib (bcrypt) Password hashing and verification
LangChain AI/LLM orchestration framework
LangGraph Multi-agent stateful workflow orchestration
LangChain Google GenAI Gemini model integration via LangChain
Pydantic Settings Environment-based configuration management

📂 Project Structure

NutriAI/
├── nutriai/                          # 📱 React Native Mobile App
│   ├── app/
│   │   ├── (auth)/                   # Auth screens
│   │   │   ├── login.tsx             # Login screen
│   │   │   └── register.tsx          # Registration screen
│   │   ├── (main)/                   # Authenticated screens
│   │   │   ├── onboarding.tsx        # 3-step onboarding flow
│   │   │   ├── success.tsx           # Onboarding completion
│   │   │   └── (dashboard)/          # Tab-based dashboard
│   │   │       ├── dashboard.tsx     # Main dashboard with trends
│   │   │       ├── FoodLog.tsx       # Food logging screen
│   │   │       ├── WorkoutLog.tsx    # Workout logging screen
│   │   │       ├── AIPlan.tsx        # AI meal plan generator
│   │   │       ├── profile.tsx       # User profile & goals
│   │   │       └── plans/            # Plan detail views
│   │   ├── _layout.tsx               # Root layout
│   │   └── index.tsx                 # Entry redirect
│   ├── api/
│   │   └── client.ts                 # Axios HTTP client config
│   ├── components/
│   │   ├── AlertDialog.tsx           # Reusable alert dialog
│   │   ├── FoodLogModal.tsx          # Food logging bottom sheet
│   │   ├── WorkoutLogModal.tsx       # Workout logging bottom sheet
│   │   ├── ProgressRing.tsx          # Circular progress component
│   │   ├── MinimalButton.tsx         # Custom button component
│   │   ├── ProfileModal.tsx          # Profile edit modal
│   │   ├── ProtectedRoute.tsx        # Auth guard component
│   │   └── WorkoutSummaryChart.tsx   # Workout chart component
│   ├── context/
│   │   ├── AuthContext.tsx           # Authentication state management
│   │   └── DashboardContext.tsx      # Dashboard refresh state
│   ├── theme.ts                      # Design tokens (colors, spacing, fonts)
│   └── package.json
│
└── nutriai-backend/                  # ⚡ FastAPI Backend Server
    ├── main.py                       # App entry point + middleware setup
    ├── api/
    │   ├── __init__.py               # API router aggregation
    │   ├── user.py                   # User profile & goals CRUD
    │   ├── food_logs.py              # Food logging + nutrient calculation
    │   ├── workout_logs.py           # Workout logging + calorie estimation
    │   ├── foods.py                  # Food item catalog
    │   ├── workout.py                # Workout catalog
    │   ├── dashboard.py              # Dashboard summary + 7-day trends
    │   ├── tracking.py               # Water & step tracking
    │   ├── plans.py                  # Meal plan CRUD
    │   └── generate_plans.py         # AI meal plan generation endpoint
    ├── services/
    │   └── meal_plan_ai.py           # 🤖 LangChain + Gemini AI service
    ├── auth/
    │   ├── routes.py                 # Register, login, onboarding
    │   ├── hashing.py                # bcrypt password utilities
    │   └── jwt_handler.py            # JWT token creation
    ├── core/
    │   ├── config.py                 # Pydantic settings (env vars)
    │   └── middleware.py             # Auth + onboarding middleware
    ├── db/
    │   ├── models/                   # SQLAlchemy models
    │   │   ├── user.py               # User model (profile + onboarding)
    │   │   ├── food.py               # FoodItem + FoodLog models
    │   │   ├── workout.py            # Workout + WorkoutLog models
    │   │   ├── plan.py               # Plan + PlanItem models
    │   │   └── tracking.py           # WaterLog + StepLog models
    │   ├── session.py                # DB session management
    │   └── base.py                   # SQLAlchemy base
    ├── schemas/                      # Pydantic request/response schemas
    ├── migrations/                   # Alembic migration files
    ├── seed_data.py                  # Indian food + workout seed data
    └── requirements.txt

🚀 Getting Started

Prerequisites

  • Node.js ≥ 18
  • Python 3.13+
  • PostgreSQL 14+
  • Expo CLI (npm install -g expo-cli)
  • Google Gemini API Key (Get one here)

1. Backend Setup

cd nutriai-backend

# Create and activate virtual environment
pip install pipenv
pipenv install

# Configure environment variables
cp .env.example .env
# Edit .env with your values:
#   DATABASE_URL=postgresql://user:pass@localhost:5432/nutriai
#   JWT_SECRET=your-secret-key
#   GEMINI_API_KEY=your-gemini-api-key

# Run database migrations
alembic upgrade head

# Seed the Indian food & workout database
python seed_data.py

# Start the server
fastapi dev

2. Mobile App Setup

cd nutriai

# Install dependencies
npm install

# Start Expo development server
npx expo start

Scan the QR code with Expo Go (Android/iOS) or press a for Android emulator / i for iOS simulator.


🔑 API Endpoints

Method Endpoint Description Auth
POST /api/v1/auth/register Register new user
POST /api/v1/auth/login Login & get JWT token
POST /api/v1/auth/onboarding Complete onboarding (with allergies & budget)
GET /api/v1/user/me Get current user profile
PUT /api/v1/user/me Update profile (name, age, height, weight, diet, allergies, budget)
POST /api/v1/user/goals Set fitness goals & target weight
GET /api/v1/user/goals Get current fitness goals & target weight
GET /api/v1/foods List food items (paginated, with search, sort, and macro-filtering)
POST /api/v1/food-logs Log a food entry (auto-scales nutrients)
GET /api/v1/food-logs List logged food items (optional date=YYYY-MM-DD filter)
GET /api/v1/food-logs/summary?days=7 Get daily nutritional summary
GET /api/v1/workouts List workouts (with search, muscle/difficulty filters)
POST /api/v1/workout-logs Log a workout (reps or time-based)
GET /api/v1/workout-logs List logged workouts (optional date=YYYY-MM-DD filter)
GET /api/v1/workout-logs/summary?days=7 Get daily workout summary
POST /api/v1/generate-plan/ 🤖 Start async AI meal plan generation task
GET /api/v1/generate-plan/status/{task_id} Check AI meal plan task status
POST /api/v1/generate-plan/complete 🤖 Generate complete health plan synchronously (meals + workout + allergies + budget tips)
GET /api/v1/plans List all saved health/meal plans
GET /api/v1/plans/{plan_id} Get detailed health plan by ID (meals, workouts, avoidance, budget)
GET /api/v1/dashboard/summary?days=7 Dashboard summary (calories + macros)
GET /api/v1/dashboard/trends?days=7 7-day calorie trend data
GET /api/v1/tracking/water/today Get today's water intake log
POST /api/v1/tracking/water Log water intake
GET /api/v1/tracking/steps/today Get today's step log
POST /api/v1/tracking/steps Log step count

🔮 Future Roadmap

  • 📷 AI Food Recognition — Snap a photo of your meal to auto-detect food items using vision models
  • 🗣️ Voice Logging — Log food and workouts via voice commands in Hindi/English
  • 📊 Weekly AI Reports — AI-generated weekly nutrition insights and recommendations
  • 🔔 Smart Reminders — Meal time and hydration reminders based on user patterns
  • 🏅 Gamification — Streaks, badges, and social challenges to boost motivation
  • 🌍 Regional Food Expansion — South Indian, Bengali, Gujarati, and Punjabi food databases
  • 🔗 Wearable Integration — Sync with Google Fit / Apple Health for auto step & calorie tracking

🤝 Contributing

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


📄 License

This project is open source and available under the MIT License.


Built with ❤️ for the Indian health & fitness community

If you found this helpful, please ⭐ star the repository!

About

NutriAI is a AI app designed to provide personalized health tracking for Indian users, focusing on dietary habits, local food items, and culturally relevant workout styles. Tech - FastAPI, PostgreSQL, Langchain

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages