Skip to content

BryanYeeee/FormCop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FORMCOP

Biomechanical ML coaching that perfects your form, and tracks your workout in real-time.

Built at BACSA Hacks 2026


Next.js · TailwindCSS · Three.js · MediaPipe · Flask · Gemini · MongoDB


What is FormCop?

70% of gym injuries are caused by bad form. People new to working out are 2.5× more likely to get injured and a personal trainer costs hundreds of dollars an hour. We built FormCop, a browser-based ML fitness coach that watches you work out in real time, counts your reps, corrects your posture, and stores your full workout history.


Features

  • 3D animated exercise selector with Mixamo FBX models rendered via Three.js / R3F
  • Real-time pose tracking using a custom-tuned MediaPipe ML model with EMA smoothing
  • Live coaching overlay via instant text instructions while you move
  • Automatic rep counting with per-rep joint angle logging (Pushup, Squat, Bicep Curl)
  • Duration tracking for timed exercises (Plank, Wall Sit, Handstand)
  • AI form analysis powered by Gemini 2.5 Flash Lite — full set feedback after every set
  • Workout session tracker to see every set and rep logged in the current session
  • Full workout history dashboard with all past sessions stored in MongoDB

Supported Exercises

Exercise Type Tracked Metric
Squat Dynamic Reps + joint angles
Bicep Curl Dynamic Reps + elbow angles
Pushup Dynamic Reps + back / elbow angles
Plank Static Hold duration (seconds)
Wall Sit Static Hold duration (seconds)
Handstand Static Hold duration (seconds)

Tech Stack

Layer Technology
Frontend Next.js 16 (App Router), Tailwind CSS, Framer Motion
3D Rendering Three.js via React Three Fiber + Drei, Mixamo FBX models, SkeletonUtils
Pose ML MediaPipe PoseLandmarker (GPU delegate) with custom EMA smoothing filter
Set Feedback Google Gemini 2.5 Flash Lite — receives joint angles, timestamps & rep data
Backend Python Flask (modular blueprints), Flask-CORS
Database MongoDB Atlas (cloud) — stores users, passwords, and workout history as JSON
Auth Username/password via MongoDB + localStorage persistence (AuthContext)
State React Context API — AuthContext, WorkoutContext

Getting Started

Prerequisites

  • Node.js 18+
  • Python 3.10+
  • MongoDB Atlas account (free tier works)
  • Google Gemini API key

1 · Clone the repository

git clone https://github.com/BryanYeeee/FormCop.git
cd formcop

2 · Frontend

cd frontend
npm install
npm run dev

The Next.js dev server starts at http://localhost:3000

3 · Backend

cd backend
python -m venv venv && source venv/bin/activate   # Windows: venv\Scripts\activate
pip install -r requirements.txt

Create a .env file in the backend folder:

GEMINI_API_KEY=your_gemini_api_key_here

Update the MongoDB URI in mongo/mongo.py with your Atlas connection string, then:

python app.py

The Flask API starts at http://localhost:8080

4 · MongoDB setup

In your Atlas cluster create a database named bacsa with a collection named userinfo. Insert at least one user document:

{ "username": "yourname", "password": "yourpassword", "workouts": [] }

Data Flow

  1. User logs in → POST /mongo/ → username stored in AuthContext + localStorage
  2. User selects exercise → ExerciseSelector → router.push('/workout/[id]')
  3. PoseTracker runs MediaPipe on webcam frames, calculates joint angles via processPose
  4. Each rep is stored in repTracking state with peak angles + timestamp
  5. User taps Submit Set → Gemini analysis → FeedbackPanel displayed
  6. User taps Finish → addSet() called on WorkoutContext → router.push('/tracker')
  7. User either repeats steps 2-6 or taps End Workout → endWorkout(username)POST /mongo/new → clears context → router.push('/home')
  8. Dashboard fetches GET /mongo/get?username=... → renders collapsible workout cards

API Reference

Method Endpoint Description
POST /mongo/ Login — body: { username, password }
POST /mongo/new Save workout — body: { username, workout }
GET /mongo/get Fetch workouts — query: ?username=xxx
POST /api/ Analyze form — body: { name, angles, forces }

Our Team

  • Rian Mehta (BCS)
  • Faiyad Ahmed Masnoon (BCS)
  • Bryan Yee (BCS)
  • Martin Lam (KPE)

Built in under 12 hours at BACSA hacks

About

Biomechanical ML coaching that perfects your form, and tracks your workout in real-time. Built for BACSA Hacks 2026.

Resources

Stars

Watchers

Forks

Contributors