Skip to content

Meeth-W/FitAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FitAI — Intelligent Health Architecture

An ML-Powered Fitness & Health Recommendation Platform

Python FastAPI React scikit-learn MongoDB Vite TailwindCSS


FitAI replaces generic wellness advice by passing your physiological footprint straight into a Random Forest predictive engine — delivering personalized diet plans, exercise routines, and caloric forecasts through a beautiful, theme-aware dashboard.

Forked and built upon the original project: Fitness and health Recommendation system



Overview

FitAI is a full-stack, AI-powered health and fitness recommendation system designed as a comprehensive mini-project for the Introduction to AI & Data Science open elective. The platform leverages three trained scikit-learn machine learning models to deliver hyper-personalized fitness recommendations based on a user's physiological profile, health goals, and vital statistics.

Key Highlights

  • 3 ML Models — Random Forest Regressor for calorie prediction + 2 Random Forest Classifiers for diet & exercise recommendations
  • Interactive Dashboards — Recharts-powered visualizations including Weight/BMI trends, Caloric breakdown, and Radar fitness profiles
  • Secure Authentication — JWT-based login/register with bcrypt password hashing via SQLite
  • Progress Tracking — Full historical data persistence through MongoDB with time-series analysis
  • 3 Premium Themes — Minimalist White, Space Black, and Cyberpunk Neon with glassmorphism design
  • Animated UI — Framer Motion page transitions, parallax starry backgrounds, and micro-interactions
  • Privacy-First — Complete account and data wiping across both SQLite and MongoDB stores
  • BMR Calculations — Mifflin-St Jeor equation with activity-factor multipliers for precise metabolic estimates

System Architecture

┌─────────────────────────────────────────────────────────────────┐
│                        CLIENT (Browser)                         │
│  React 19 + Vite 8 + Tailwind CSS + Recharts + Framer Motion   │
│                                                                 │
│  ┌──────────┐ ┌───────────┐ ┌──────────┐ ┌────────────┐        │
│  │ Landing  │ │ Dashboard │ │ Progress │ │  Settings  │        │
│  │  Page    │ │   Page    │ │   Page   │ │   Page     │        │
│  └────┬─────┘ └─────┬─────┘ └────┬─────┘ └─────┬──────┘        │
│       │              │            │              │               │
│       └──────────────┴────────────┴──────────────┘               │
│                        Axios HTTP Client                         │
└──────────────────────────────┬───────────────────────────────────┘
                               │ REST API (JSON)
                               ▼
┌──────────────────────────────────────────────────────────────────┐
│                     SERVER (FastAPI + Uvicorn)                    │
│                                                                  │
│  ┌──────────────┐  ┌────────────────┐  ┌──────────────────┐      │
│  │ /auth Router │  │ /recommend     │  │ /dashboard       │      │
│  │  register    │  │   ML Pipeline  │  │   history        │      │
│  │  login       │  │   BMI + BMR    │  │   metrics        │      │
│  │  delete      │  │   Predictions  │  │                  │      │
│  └──────┬───────┘  └───────┬────────┘  └────────┬─────────┘      │
│         │                  │                     │                │
│  ┌──────▼───────┐  ┌───────▼────────┐  ┌────────▼─────────┐      │
│  │   SQLite     │  │  scikit-learn  │  │    MongoDB       │      │
│  │  (auth.db)   │  │  .pkl Models   │  │ (health_tracker) │      │
│  └──────────────┘  └────────────────┘  └──────────────────┘      │
└──────────────────────────────────────────────────────────────────┘

Project Structure

Health Tracker/
├── .gitignore
├── README.md
│
├── backend/                      # FastAPI + ML Backend
│   ├── main.py                   # App entry point, CORS, routers, lifecycle
│   ├── setup.py                  # Synthetic data generation + model training
│   ├── requirements.txt          # Python dependencies
│   │
│   ├── data/                     # Generated CSV datasets
│   │   ├── calories.csv          # 1500 samples: gender, age, height, weight, etc.
│   │   └── recommend.csv         # 1500 samples: goal_code, diet, exercise
│   │
│   ├── models/                   # Trained ML model artifacts
│   │   ├── calorie_model.pkl     # RandomForestRegressor (R² = 0.8786)
│   │   ├── diet_model.pkl        # RandomForestClassifier (Accuracy ≈ 35%)
│   │   ├── exercise_model.pkl    # RandomForestClassifier (Accuracy ≈ 31%)
│   │   └── metrics.json          # Serialized evaluation metrics
│   │
│   ├── database/                 # Database connection modules
│   │   ├── auth_db.py            # SQLite + JWT + bcrypt auth utilities
│   │   └── mongo_db.py           # Motor async MongoDB client
│   │
│   └── routers/                  # FastAPI route handlers
│       ├── auth.py               # Register / Login / Delete Account
│       ├── recommend.py          # ML inference pipeline + BMR + BMI
│       └── dashboard.py          # History retrieval + model metrics
│
└── frontend/                     # React + Vite Frontend
    ├── index.html                # HTML entry point
    ├── package.json              # npm dependencies
    ├── vite.config.js            # Vite dev server + proxy configuration
    ├── tailwind.config.js        # Theme-aware custom design tokens
    │
    └── src/
        ├── main.jsx              # React DOM root
        ├── App.jsx               # Router + global layout shell
        ├── index.css             # Design system: themes, glassmorphism, utilities
        ├── App.css               # Legacy scaffold styles
        │
        ├── hooks/
        │   └── useTheme.js       # Theme persistence hook (localStorage)
        │
        ├── layouts/
        │   └── DashboardLayout.jsx   # Auth-gated outlet wrapper
        │
        ├── pages/
        │   ├── Landing.jsx       # Hero + ML metrics radial charts
        │   ├── Auth.jsx          # Login / Register form
        │   ├── Dashboard.jsx     # Main AI workspace
        │   ├── Progress.jsx      # Historical trend analysis
        │   └── Settings.jsx      # Profile, raw logs table, account deletion
        │
        └── components/
            ├── Header.jsx        # Nav bar + theme switcher + auth controls
            ├── Footer.jsx        # Attribution footer
            ├── StarryBackground.jsx  # Parallax star field animation
            ├── InputForm.jsx     # Health metrics input form
            ├── ResultCards.jsx   # KPI cards (BMI, BMR, Calories, etc.)
            ├── DietCards.jsx     # Recommended diet plan display
            ├── ExerciseCards.jsx # ML workout routine display
            ├── PersonalizationPanel.jsx  # AI explanation panel
            └── Charts.jsx        # WeightChart, CaloriesChart, FitnessRadarChart

Setup & Installation

Prerequisites

Requirement Version
Python 3.10+
Node.js 18+
MongoDB 6.x+ (running on localhost:27017)

1. Clone the Repository

git clone https://github.com/your-username/health-tracker.git
cd health-tracker

2. Backend Setup

cd backend

# Create and activate virtual environment
python -m venv .venv
.venv\Scripts\activate        # Windows
# source .venv/bin/activate   # macOS/Linux

# Install dependencies
pip install -r requirements.txt

# Generate datasets and train ML models
python setup.py

# Start the API server
python -m uvicorn main:app --reload --port 8000

Note: Ensure MongoDB is running on localhost:27017 before starting the server. The API will be available at http://127.0.0.1:8000.

3. Frontend Setup

cd frontend

# Install dependencies
npm install

# Start development server
npm run dev

The frontend dev server runs at http://localhost:5173 and proxies API requests to the backend.


Technology Stack

Layer Technology Purpose
Frontend React 19, Vite 8 Component-based SPA with HMR
Styling Tailwind CSS 3.4, Custom CSS Variables Theme system with glassmorphism utilities
Animations Framer Motion 12 Page transitions & micro-interactions
Charts Recharts 3.8 Line, Composed, Radar, RadialBar charts
Icons Lucide React Consistent SVG icon library
HTTP Client Axios Promise-based API communication
Routing React Router DOM 7 Client-side navigation with auth guards
Backend FastAPI, Uvicorn Async Python web framework with ASGI
ML Engine scikit-learn (RandomForest) Regression + Classification models
Data Processing Pandas, NumPy Feature engineering & dataset generation
Auth Database SQLite 3 User credentials with bcrypt hashing
Health Database MongoDB (Motor async driver) Time-series health history storage
Auth Tokens python-jose (JWT), Passlib Stateless authentication tokens
Serialization Pydantic v2 Request/response validation & schemas

Machine Learning Models

Calorie Burn Regressor

  • Algorithm: RandomForestRegressor (100 estimators)
  • Features: Gender, Age, Height, Weight, Activity Level, Heart Rate, Body Temperature
  • Target: Calories Burned
  • Performance: R² Score = 0.8786, MAE = ±12.68 kcal

Diet Classifier

  • Algorithm: RandomForestClassifier (50 estimators)
  • Features: Goal Code (Weight Loss / Maintenance / Weight Gain)
  • Target: Structured diet plan string
  • Performance: Accuracy = 35.33%

Exercise Classifier

  • Algorithm: RandomForestClassifier (50 estimators)
  • Features: Goal Code (Weight Loss / Maintenance / Weight Gain)
  • Target: Structured exercise routine string
  • Performance: Accuracy = 31.00%

Note: Diet and exercise classifiers are trained on a multi-label text classification task with high cardinality targets, resulting in moderate accuracy. In production, these would be enhanced with NLP-based retrieval or collaborative filtering.


Theme System

FitAI ships with three curated visual themes, switchable in real-time from the header:

Theme Background Accent Style
Minimalist White #FAFAFA Blue #3B82F6 Clean, professional
Space Black #0A0A0C White #FFFFFF Sleek, monochrome
Cyberpunk Neon #0B0914 Violet #8B5CF6 Vibrant, futuristic

All themes use CSS custom properties with a glassmorphism design system featuring backdrop blur, translucent panels, and smooth 300ms transitions.


API Endpoints

Method Endpoint Description
POST /auth/register Register a new user account
POST /auth/login Authenticate and receive JWT token
DELETE /auth/account?username= Delete user account + all data
POST /recommend/ Submit vitals → receive ML predictions
GET /dashboard/history?username= Retrieve health history timeline
GET /dashboard/metrics Fetch ML model performance metrics

License

This project is developed as an academic mini-project for the Introduction to AI & Data Science open elective course.

© 2026 FitAI. All rights reserved.

About

FitAI completely replaces generic wellness advice by passing your physiological footprint straight into our Random Forest predictive engine.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors