Skip to content

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

FitLife - AI Fitness and Nutrition Coach

Scan food labels, review workout form, and ask FitLife Coach for meal and recovery guidance.

Python Next.js Flask Tailwind


Live Demo

  • Frontend: https://fit-life-ai-1eqx.vercel.app
  • Backend API: https://shinzobolte-fitlife-ai.hf.space

Overview

FitLife is a full-stack fitness product with three core surfaces:

  • Fuel Scan - upload a nutrition label photo and get extracted nutrition data, scoring, and profile-aware recommendations.
  • Form Coach - upload a workout clip and receive rep counting, movement scoring, and coaching cues powered by YOLO pose checkpoints.
  • FitLife Coach - ask nutrition and recovery questions through a profile-aware AI assistant.

This repo is deployed with:

  • Vercel for the Next.js frontend
  • Hugging Face Spaces (Docker) for the Flask backend

Tech Stack

Layer Technology
Frontend Next.js 15, React 19, Tailwind CSS 4, TypeScript
Backend API Flask, SQLAlchemy, PyJWT, Flask-Login
AI / ML YOLOv8 pose, Groq vision/text models, RAG retrieval
Async Tasks Celery + Redis (optional)
Database SQLite (dev), PostgreSQL / Neon (prod)
Deployment Vercel (frontend) + Hugging Face Spaces (backend)

Project Structure

fitlife/
|-- frontend/                # Next.js frontend
|-- gateway/                 # Flask API gateway
|-- services/
|   |-- muscle_ai_service/   # Workout analysis service
|   |-- nutri_ai_service/    # Nutrition / RAG service
|   `-- shared/database/     # Shared SQLAlchemy models
|-- data/
|   `-- nutri-ai/            # Knowledge base JSON files
|-- model/
|   `-- models/              # Tracked YOLO workout checkpoints
|-- docs/                    # Resume + deployment docs
`-- web/                     # Legacy Jinja templates / static output

Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • Groq API key for nutrition OCR / chat features

1. Clone the repo

git clone https://github.com/shinzoxD/FitLife-AI.git
cd FitLife-AI

2. Backend setup

python -m venv .venv

# Windows
.\.venv\Scripts\Activate.ps1

# macOS / Linux
source .venv/bin/activate

pip install -r requirements.txt
copy env.example .env

Edit .env and set at least:

  • SECRET_KEY
  • JWT_SECRET_KEY
  • GROQ_API_KEY
  • DATABASE_URL for PostgreSQL in production

3. Frontend setup

cd frontend
npm install
copy .env.example .env.local
cd ..

Set this in frontend/.env.local:

NEXT_PUBLIC_API_URL=http://localhost:5000

4. Run locally

Open two terminals:

# Terminal 1
python gateway/app.py

# Terminal 2
cd frontend && npm run dev

Open http://localhost:3000.


Workout Models

The workout checkpoints are tracked in:

  • model/models

Current checkpoints:

  • best.pt
  • sumo_best.pt
  • squats_best.pt
  • best_romanian.pt
  • zercher_best.pt
  • front_squats_best.pt

The workout service auto-resolves these from:

  • services/muscle_ai_service/config/settings.py

To inspect embedded validation metrics:

G:\fitlife\.venv\Scripts\python.exe scripts\evaluate_muscle_models.py

To run a fresh validation pass once you have the dataset YAML:

G:\fitlife\.venv\Scripts\python.exe scripts\evaluate_muscle_models.py --data path\to\config.yaml

API Endpoints

All API routes are prefixed with /api/v1/.

Method Endpoint Auth Description
POST /auth/register - Create account
POST /auth/login - Get JWT tokens
POST /auth/refresh - Refresh access token
GET /user JWT Get user profile
PUT /user/settings JWT Update profile
GET /user/scans JWT Scan history
GET /user/workouts JWT Workout history
GET /dashboard/stats JWT Dashboard statistics
POST /nutri-ai/upload Optional Upload nutrition label
POST /nutri-ai/analyze Optional Analyze extracted nutrition data
POST /muscle-ai/upload Optional Upload workout video
GET /muscle-ai/task/:id - Poll async task status
POST /ana/chat Optional Chat with FitLife Coach

Environment Variables

Use env.example as the base. The important ones are:

Variable Required Description
SECRET_KEY Yes Flask session secret
JWT_SECRET_KEY Yes JWT signing secret
DATABASE_URL Production PostgreSQL connection string (Neon works well)
GROQ_API_KEY For nutrition/chat Groq API key
FRONTEND_URL In production Public Vercel frontend URL
NEXT_PUBLIC_API_URL Frontend Public backend URL

Deployment

Current Deployment: Vercel + Hugging Face Space

1. Deploy the backend on Hugging Face Spaces

Use a Docker Space and point it at this repo.

The root Dockerfile is now prepared for Spaces:

  • installs the full backend + workout-model dependencies
  • copies the tracked YOLO checkpoints from model/models
  • serves the Flask gateway on port 7860

Space variables to set:

  • SECRET_KEY
  • JWT_SECRET_KEY
  • DATABASE_URL=postgresql://...
  • GROQ_API_KEY
  • FRONTEND_URL=https://your-vercel-app.vercel.app
  • GOOGLE_CLIENT_ID (optional)
  • GOOGLE_CLIENT_SECRET (optional)

Use the template in docs/HUGGINGFACE_SPACE_README.md for the Space repo README.md metadata.

2. Deploy the frontend on Vercel

  • Import the GitHub repo into Vercel
  • Keep the existing root directory from vercel.json:
    • frontend
  • Set:
    • NEXT_PUBLIC_API_URL=https://shinzobolte-fitlife-ai.hf.space

3. Final wiring

  • After Vercel gives you the frontend URL, set FRONTEND_URL in the Hugging Face Space to that exact URL
  • Redeploy the Space once after updating FRONTEND_URL

Notes:

  • Hugging Face free Spaces can sleep when idle
  • The backend is public at the .hf.space URL, which is required for the Vercel frontend to call it directly
  • For durable user accounts and settings, use PostgreSQL instead of the default SQLite fallback

GitHub Actions CI/CD

This repo now includes:

  • ci.yml for frontend build, gateway smoke tests, and workout model loading
  • cd.yml for production deployment from main

Required GitHub Secrets

For the Vercel deployment job:

  • VERCEL_TOKEN
  • VERCEL_ORG_ID
  • VERCEL_PROJECT_ID

For the Hugging Face Space deployment job:

  • HF_TOKEN
  • HF_SPACE_REPO

Example HF_SPACE_REPO value:

shinzobolte/fitlife-ai

How the pipeline works

  • Pull requests and pushes run CI
  • A successful CI run on main triggers CD
  • CD deploys the frontend to Vercel
  • CD syncs a Space-ready backend bundle to your Hugging Face Space repo

If you use the GitHub Actions Vercel deploy, disable duplicate auto-deploy behavior in Vercel if you do not want both Git integration and Actions creating separate production deployments.


Resume Positioning

Use docs/RESUME_PROJECT.md for resume bullets, a portfolio summary, and interview talking points.


Acknowledgments

  • Ultralytics YOLOv8 for pose estimation
  • Groq for nutrition OCR and text inference
  • Harvard Medical School nutrition research used in the knowledge base

License

This project is licensed under the MIT License.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages