A real-time boxing analysis platform that uses computer vision to track punches, analyze form, and provide detailed performance metrics through an interactive dashboard.
- Camera-Based Tracking: Uses MediaPipe Pose Detection to track your movements
- Target System: Spawns targets (Jab, Hook, Uppercut) that you can hit
- Demo Mode: Works without backend - saves session data to localStorage
- Score Tracking: Real-time score updates as you hit targets
- Performance Metrics: Score, Average Punch Speed, Reaction Time, Accuracy, Critical Prevention, Total Punches
- Visualizations:
- Punch Accuracy by Type (Bar Chart)
- Reaction Times by Punch Type (Bar Chart)
- Defense Breakdown (Pie Chart)
- Performance Over Session Timeline (Line Chart)
- Session History: Automatically loads your latest session data
- React 19.1.1 with Vite
- Recharts for data visualization
- MediaPipe for pose detection
- Tailwind CSS for styling
- React Router for navigation
- FastAPI for API endpoints
- WebSocket support for real-time game updates
- Supabase integration for data persistence (optional)
- MediaPipe for pose analysis
- Node.js 18+ and npm
- Python 3.11+
- Camera access (for webcam)
- Install dependencies:
npm install- Start development server:
npm run dev- Open browser:
The app will be available at
http://localhost:5173
The app works in demo mode without the backend, but for full functionality:
- Create virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install Python dependencies:
pip install -r requirements.txt- Start FastAPI server:
cd perfectpunch_backend
uvicorn main:app --reloadThe backend will be available at http://localhost:8000
- Start the app and navigate to Landing Page
- Click "Start Analysis" to begin a game session
- Allow camera access when prompted
- Hit targets that appear on screen with your fists
- Watch your score increase and timer count down
- Click "End Game" when finished
After ending a game:
- Automatically navigates to Dashboard
- Shows your session data:
- Score and total punches
- Performance metrics
- Visual charts and graphs
- Timeline of your session
If the backend is not available, the app automatically switches to demo mode:
- Game works with local camera
- Session data saves to browser localStorage
- Dashboard loads from localStorage
- Full functionality without server
perfectpunch-dashboard/
βββ src/
β βββ pages/
β β βββ CameraMirror.jsx # Camera view with game logic
β β βββ DashboardPage.jsx # Analytics dashboard
β β βββ LandingPage.jsx # Landing/home page
β β βββ LoginPage.jsx # User authentication
β β βββ SignupPage.jsx # User registration
β βββ contexts/
β β βββ AuthContext.jsx # Authentication context
β βββ App.jsx # Main app router
βββ perfectpunch_backend/
β βββ main.py # FastAPI application
β βββ api/
β β βββ routers/ # API route handlers
β βββ services/ # Business logic services
β βββ game/ # Game management
βββ public/ # Static assets
- Game Session Starts: Camera initializes, targets spawn
- Hits Detected: MediaPipe tracks pose, detects target hits
- Score Updates: Real-time score and metrics calculated
- Session Ends: Data saved to localStorage (demo) or backend
- Dashboard Loads: Displays session metrics and visualizations
Sessions are saved with the following structure:
{
"session_id": "demo-1234567890",
"timestamp": "2025-11-18T20:04:00.000Z",
"summary": {
"score": 120,
"avg_velocity": 6.5,
"avg_reaction_time": 245,
"accuracy": 85.5,
"critical_prevention": 75.0,
"total_punches": 12
},
"punch_accuracy": {
"jab": 90,
"hook": 85,
"uppercut": 82
},
"reaction_times": {
"jab": 210,
"hook": 250,
"uppercut": 275
},
"defense": {
"blocked": 0,
"dodged": 3,
"hit": 12
},
"timeline": [
{ "t": 5, "velocity": 5.5, "accuracy": 80 },
{ "t": 10, "velocity": 6.0, "accuracy": 85 },
...
]
}Create a .env file for configuration:
VITE_API_BASE_URL=http://127.0.0.1:8000npm run dev- Start development servernpm run build- Build for productionnpm run lint- Run ESLintnpm run preview- Preview production build
- Ensure camera permissions are granted in browser
- Check that no other application is using the camera
- Try refreshing the page
- Check browser console for errors
- Verify session data exists in localStorage
- Play a new game to generate fresh data
- App automatically falls back to demo mode
- Game and dashboard work without backend
- Check
VITE_API_BASE_URLin.envif backend is needed
This is the MVP version on the mvp branch. For development:
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
[Add your license here]