AI Form Coach Agent is a production-ready, AI-powered fitness coaching web application. It evaluates exercise form in real time using client-side MediaPipe Pose Detection and generates structured weekly coaching progress reports using Google Agent Development Kit (ADK) and a Python MCP Server.
Supported Exercises:
- Squats (Depth, knee valgus collapse, and spine leaning angle)
- Push-Ups (Body alignment, chest depth, and elbow lockout)
- Pull-Ups (Full extension dead hang, chin-over-bar vertical height, and kipping/swinging)
- Strict Rep Counting: Only increments reps if range of motion and core biomechanical postures are correct.
- Real-Time Speech Coaching: Browser-based Web Speech Text-to-Speech voices read form cues and rep alerts dynamically.
- Landmark Confidence Filtering: Average visibility checks of key joints. If visibility is
< 80%, the system hides corrections, pauses reps, and alerts you to adjust the camera. - Weekly AI Reports: Aggregate consistency metrics, calculate form improvement % vs last week, list most common mistakes, and recommend corrective focus drills.
- Privacy First: Video frames are processed entirely client-side in the browser. No video is ever sent to the server. Only rep details, aggregate metrics, and joint landmarks are stored.
graph TD
Client[React Frontend / Vite / TS / Tailwind] -->|Landmarks, Summary & Confidence| Backend[FastAPI Backend]
Client -->|Camera Stream| MediaPipe[MediaPipe Pose client-side]
Backend -->|Read/Write| DB[(SQLite Database)]
Backend -->|Tool Calls| MCPServer[MCP Server python]
MCPServer -->|Access DB| DB
Backend -->|Orchestrate Agent| GoogleADK[Google ADK Coaching Agent]
GoogleADK -->|Use Tools| MCPServer
Ensure Node.js (v18+) and Python (3.10+) are installed.
- Navigate to the backend directory:
cd backend - Initialize virtual environment:
python -m venv venv
- Activate virtual environment:
- Windows PowerShell:
.\venv\Scripts\Activate.ps1 - macOS/Linux:
source venv/bin/activate
- Windows PowerShell:
- Install dependencies:
pip install -r requirements.txt
- Configure
.envfile:- Open the
.envfile in thebackendfolder. - (Optional) Set your
GEMINI_API_KEYto enable Gemini AI reports. If left blank, the backend automatically triggers local rule-based coaching reports.
- Open the
- Start the FastAPI server:
uvicorn app.main:app --host 127.0.0.1 --port 8000 --reload
- Open a new terminal and navigate to the frontend directory:
cd frontend - Install package requirements:
npm install
- Start the Vite React development server:
npm run dev
- Open your browser and navigate to
http://localhost:5173.
To deploy the entire stack in containers (FastAPI on port 8000, React client on port 80):
- From the root project directory:
docker-compose up --build
- Open your browser and navigate to
http://localhost.
- Knee Angle (
Hip -> Knee -> Ankle): Descends to< 100°for a valid rep. - Lumbar Lean Angle (
Shoulder -> Hiprelative to vertical): Warns if lean exceeds40°(rounded back). - Knee Valgus Ratio (
Distance(Knees) / Distance(Hips)): Warns if ratio falls below0.85(knees collapsing).
- Elbow Angle (
Shoulder -> Elbow -> Wrist): Lowering to< 90°and extending to> 160°for a valid rep. - Core Alignment Angle (
Shoulder -> Hip -> Ankle): Warns of hip sagging (< 155°) or pike hips (> 200°).
- Hang Extension (
Shoulder -> Elbow -> Wrist): Starts from fully extended arms (> 155°). - Chin Clearance: Chin Y-coordinate must clear wrist Y-coordinate.
- Torso Sway: Hip X displacement fluctuation warns if kipping/swinging is detected.
Deployed Link = https://ai-form-coach-orpin.vercel.app/
The AI Form Coach Agent is engineered to protect user privacy:
- Zero Footage Stored: Webcam video frames are read by MediaPipe in-browser and immediately discarded. No video data leaves your local machine.
- Local Databases: Workout history is saved in a local SQLite database (
fitness_coach.db). - Local AI Fallbacks: Runs 100% locally if no API key is set, protecting your metrics from external API requests.