How smartyash11/ai-fitness-analyzer works
Project type and purpose
• This is a full-stack fitness analytics application.
• Frontend: Next.js + React + Tailwind UI running on Vercel
• Backend/Processing: Python modules for computer vision (MediaPipe, OpenCV, NumPy) exposed either as serverless functions or a microservice.
File structure
• Top level:
• Dockerfile, setup.sh, requirements.txt → deployment and environment setup for Python service
• process_frame.py, thresholds.py, utils.py → core CV/ML logic
• 🏠️_Demo.py → Streamlit-based demo version (local)
• Sample output videos → examples of processed output
• Missing front-end folder in repo implies the Next.js code lives in another repo or will be added under /frontend.
Key insights from README
• Real-time pose detection, form analysis, rep counting, feedback visuals
• Frontend captures camera frames, backend performs pose estimation & scoring
• Original demo runs locally via Streamlit; production uses Next.js + serverless Python
Main components
a. Client (Browser / Mobile)
b. Frontend (Next.js)
c. API Layer / Serverless Functions
d. CV Processing Service (Python):
– process_frame.py
– thresholds.py
– utils.py
– MediaPipe, OpenCV, NumPy libraries
e. Deployment infrastructure:
– Vercel (frontend)
– Container or serverless (backend) via Dockerfile / setup.sh
Relationships and data flows
1. User grants camera access → Browser
2. Frontend streams frames over WebSocket/HTTP POST → API Layer
3. API Layer invokes Python service
4. Python service loads frame → process_frame.py
• Detects landmarks via MediaPipe
• Computes angles & thresholds via thresholds.py
• Applies helpers in utils.py
5. Returns JSON (angles, rep count, feedback flags) and/or annotated image
6. Frontend renders live overlays and updates rep counters
Architectural patterns & design principles
• Separation of concerns: UI vs. processing
• Microservice/serverless for compute-heavy CV
• Stateless functions for scalability
• Dockerized environment for reproducible deployment
Essential details to capture
• API endpoints or WebSocket channels between Next.js and the Python service
• The 3 main Python modules (process_frame, thresholds, utils) as sub-components
• External CV libraries as dependencies
• Demo mode (Streamlit) as an alternate local-run path via 🏠️_Demo.py