๐๏ธโโ๏ธ GymPose AI - Real-Time Pose Estimation & Joint Analysis
A cutting-edge fitness application that uses AI-powered computer vision to provide real-time pose estimation, form analysis, and personalized coaching feedback for gym exercises.
โจ Features
- Real-Time Pose Detection: Advanced computer vision using OpenCV and MediaPipe
- Form Analysis: Instant feedback on exercise technique with angle calculations
- Rep Counting: Automatic repetition and set tracking
- Progress Analytics: Detailed workout history and performance metrics
- Multi-Exercise Support: Knee bends, squats, deadlifts, lunges, and more
- Beautiful UI/UX: Modern React frontend with smooth animations
- Secure Backend: Java Spring Boot with JWT authentication
- Database: SQLite/PostgreSQL with comprehensive data models
๐๏ธ Architecture
GymPose AI/
โโโ backend/ # Java Spring Boot Backend
โ โโโ src/main/java/
โ โ โโโ com/gympose/
โ โ โโโ controller/ # REST API endpoints
โ โ โโโ service/ # Business logic & pose estimation
โ โ โโโ model/ # Database entities
โ โ โโโ dto/ # Data transfer objects
โ โ โโโ config/ # Security & configuration
โ โโโ pom.xml # Maven dependencies
โโโ frontend/ # React.js Frontend
โ โโโ src/
โ โ โโโ components/ # Reusable UI components
โ โ โโโ pages/ # Application pages
โ โ โโโ contexts/ # React contexts
โ โ โโโ services/ # API integration
โ โโโ package.json # Node.js dependencies
โโโ README.md # This file
๐ Quick Start
Prerequisites
- Java 17+ (for backend)
- Node.js 16+ (for frontend)
- Maven 3.6+ (for Java dependencies)
- Camera-enabled device (for pose detection)
Backend Setup (Java)
- Navigate to backend directory:
- Install dependencies:
- Run the application:
- Access the API:
- Backend: http://localhost:8080/api
- H2 Database Console: http://localhost:8080/h2-console
- API Documentation: http://localhost:8080/swagger-ui.html
Frontend Setup (React)
- Navigate to frontend directory:
- Install dependencies:
- Start development server:
- Access the application:
- Frontend: http://localhost:3000
๐ง Configuration
Backend Configuration
Edit src/main/resources/application.yml:
server:
port: 8080
servlet:
context-path: /api
spring:
datasource:
url: jdbc:h2:mem:gympose_db # Change to PostgreSQL for production
username: sa
password: password
jwt:
secret: your-super-secret-jwt-key-change-in-production
expiration: 86400000
Frontend Configuration
Edit src/services/api.js:
const API_BASE_URL = 'http://localhost:8080/api';
๐ฑ Usage
1. User Registration & Login
- Create an account with email and username
- Secure JWT-based authentication
- User profile management
2. Exercise Selection
- Choose from available exercises:
- Knee Bend: Basic leg strengthening
- Squat: Full body compound movement
- Deadlift: Back and leg strength
- Lunge: Balance and unilateral training
3. Real-Time Pose Detection
- Position your device camera
- Start the exercise session
- Get instant form feedback
- Track repetitions and sets
4. Progress Monitoring
- View workout history
- Analyze performance trends
- Track form improvement over time
๐ง How It Works
Pose Estimation Algorithm
- Frame Capture: Real-time video stream from device camera
- Landmark Detection: OpenCV-based pose landmark identification
- Angle Calculation: Mathematical computation of joint angles
- Form Analysis: AI-powered exercise technique evaluation
- Feedback Generation: Instant coaching tips and corrections
Key Metrics
- Knee Angle: Primary indicator for leg exercises
- Hip Angle: Important for compound movements
- Form Score: Overall technique quality (0-100%)
- Confidence: Detection reliability score
- Balance Score: Posture stability assessment
๐๏ธ Database Schema
Core Entities
- Users: User accounts and profiles
- ExerciseSessions: Workout session records
- PoseData: Real-time pose analysis data
- WorkoutPlans: Personalized exercise programs
Relationships
User (1) โโ (Many) ExerciseSession
ExerciseSession (1) โโ (Many) PoseData
User (1) โโ (Many) WorkoutPlan
๐ Security Features
- JWT Authentication: Secure token-based authentication
- Password Hashing: BCrypt encryption for user passwords
- CORS Configuration: Cross-origin resource sharing setup
- Input Validation: Comprehensive request validation
- SQL Injection Protection: JPA/Hibernate security
๐ API Endpoints
Authentication
POST /api/auth/register - User registration
POST /api/auth/login - User login
GET /api/auth/profile - User profile
Pose Detection
POST /api/pose-detection/start-session - Start exercise session
POST /api/pose-detection/process-frame - Process video frame
POST /api/pose-detection/end-session - End exercise session
GET /api/pose-detection/history - Exercise history
GET /api/pose-detection/statistics - User statistics
Exercise Management
GET /api/pose-detection/exercise-types - Available exercises
GET /api/pose-detection/session/{id}/analysis - Session analysis
๐ฏ Exercise Types
1. Knee Bend
- Target: Quadriceps, Hamstrings, Glutes
- Form: Bend knees to 90ยฐ or less
- Feedback: Depth and knee alignment
2. Squat
- Target: Full body compound movement
- Form: Lower body until thighs parallel to ground
- Feedback: Depth, back position, knee tracking
3. Deadlift
- Target: Lower back, Hamstrings, Glutes
- Form: Hinge at hips, keep back straight
- Feedback: Hip hinge, back position, bar path
4. Lunge
- Target: Unilateral leg strength and balance
- Form: Step forward, lower until both knees at 90ยฐ
- Feedback: Balance, depth, knee alignment
๐ Deployment
Production Backend
- Build JAR file:
mvn clean package -DskipTests
- Run with Java:
java -jar target/gympose-ai-backend-1.0.0.jar
- Environment variables:
export SPRING_PROFILES_ACTIVE=production
export DATABASE_URL=jdbc:postgresql://localhost:5432/gympose
export JWT_SECRET=your-production-secret
Production Frontend
- Build production bundle:
- Serve static files:
npx serve -s build -l 3000
๐งช Testing
Backend Tests
Frontend Tests
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- OpenCV: Computer vision library
- MediaPipe: Pose estimation framework
- Spring Boot: Java application framework
- React: Frontend framework
- Tailwind CSS: Utility-first CSS framework
๐ Support
๐ฎ Future Enhancements
Built with โค๏ธ for the fitness community
Transform your workouts with AI-powered coaching!