Skip to content

AI Fitness Trainer

An in-browser workout coach. Webcam frames become a 33-point pose skeleton, and a biomechanics layer turns joint angles into rep counts, form scores and voice coaching.

pose landmarks tracked
33
on-device, no GPU
~30 FPS
exercises supported
9
  • MediaPipe
  • React
  • Vite
  • FastAPI
  • SQLite

The problem

Rep-counting apps miscount as soon as form gets sloppy, and many need a server or a GPU. I wanted a coach that runs in an ordinary browser tab.

Pipeline

  1. Webcam
  2. MediaPipe Pose
  3. Joint angles
  4. Rep state machine
  5. Form score and voice
  6. Saved locally
Everything runs in the browser; the backend only syncs. The highlighted stage is where the key decision sits.

How it works

MediaPipe Pose runs on-device and tracks 33 landmarks at about 30 frames per second. A kinematics layer smooths joint angles and computes angular velocity, range of motion, tempo and left-right symmetry.

A finite-state machine counts reps, with median smoothing, an 800 ms debounce and spam detection. Each rep gets a form score from 0 to 100, and spoken cues coach in real time.

The browser is the source of truth. Sessions save to localStorage first; the FastAPI and SQLite backend only adds sync, analytics and exports.

The decision

I chose
Local-first storage, with the backend optional.
Instead of
A server-backed app that needs the API to save a workout.
Because
The backend runs on a free tier that sleeps. Making it additive means a cold server costs a sync delay, not a lost workout.

What broke, and the fix

  1. MediaPipe's CDN or the camera can fail to load.

    CDN failover from jsDelivr to unpkg, and a four-stage camera fallback that ends in a manual mode.

  2. A crash in one chart could take down the whole workout.

    Error boundaries at three levels (app, pose, chart) keep a failing widget contained.

What I would do next

  • Record sessions with hand-counted reps, so rep-counting accuracy becomes a measured number rather than a claim.