A modern web application that uses AI-powered pose detection to analyze and provide feedback on posture during squats and desk sitting. Built with React, Node.js, and MediaPipe.
- Real-time Posture Analysis: Upload videos or use webcam for live posture detection
- Dual Mode Detection: Specialized analysis for squats and desk sitting postures
- Rule-based Feedback: Intelligent posture assessment with specific warnings
- Visual Overlays: Pose landmarks and angle measurements displayed on video and images
- Modern UI: Clean, responsive interface with real-time feedback panels
- File Management: Secure upload and processing of videos
- React 18 - Modern UI library with hooks
- TypeScript - Type-safe JavaScript
- Tailwind CSS - Utility-first CSS framework
- Lucide React - Beautiful icons
- Vite - Fast build tool
- Node.js - JavaScript runtime
- Express - Web framework
- Multer - File upload handling
- CORS - Cross-origin resource sharing
- MediaPipe - Pose detection and landmark extraction
- OpenCV - Computer vision and image processing
- Python - AI processing scripts
- Node.js (v16 or higher)
- Python (v3.8 or higher)
- npm or yarn
git clone https://github.com/anand-devx/posture-guard.git
cd posture-guardcd frontend
npm installcd.. # not needed if already using from root directory
cd backend
npm installcd python # Or cd backend/python if using from root directory
pip install -r requirements.txtRename the file named .env.sample to .env in the backend directory and add the following:
PORT=3001 # β
Port your local server will run on
CLOUD_NAME=your_cloudinary_cloud_name # β
Cloudinary cloud name
API_KEY=your_cloudinary_api_key # β
Cloudinary API key
API_SECRET=your_cloudinary_api_secret # β
Cloudinary API secret
CORS_ORIGIN=* # β
Allowed CORS origin(s); * means allow all (use carefully in production)Always add .env to .gitignore to avoid committing secrets:
// .gitignore
.env
In fronend/src/App.tsx change the server_url at line 174 to localhost for testing using local backend, and to live_server for using live server. You can also adjust values of localhost and live_server
// frontend/src/App.tsx : line 172
const localhost = 'http://localhost:3001/api/analyze'; // You can change the port from 3001 to anything here
// frontend/src/App.tsx : line 173
const live_server = 'https://posture-guard.onrender.com/api/analyze'; // You can change the live server here
// frontend/src/App.tsx : line 174
const server_url = live_server; // for using live server
const server_url = localhost; // for using localhost# From frontend and backend directory separately run
npm run devThis will start both the frontend (port 5173) and backend (port 3001) servers.
- Choose between "Squat Analysis" or "Sitting Analysis"
- File Upload: Drag and drop video files (MP4, AVI, MOV, JPG, PNG formats supported)
- Webcam: Click "Start Webcam" for real-time capture
- Click "Analyze Posture" to process your video/image
- View real-time feedback in the side panel
- Check posture quality indicators
- View angle measurements
- Get the proccessed image/video with detection results and angles
- Knee Position: Flags if knee extends beyond toe
- Back Angle: Warns if back angle < 30Β° or > 60Β° with respect to thigh
- Depth Check: Ensures proper squat depth
- Neck Posture: Detects forward head posture (> 20Β°)
- Back Alignment: Checks for neutral spine position wrt thigh
- Overall Posture: Comprehensive sitting assessment
Analyze posture in uploaded video
- Body: FormData with file and postureType
- Response: Analysis results with feedback
Health check endpoint
- Response: Server Name
- Upload Zone: Drag-and-drop file upload
- Webcam Panel: Live video capture
- Control Buttons: Analysis and upload controls
- Real-time Status: Good/poor posture indicators
- Angle Measurements: Precise angle calculations
- Warnings: Specific posture improvement suggestions
- Modify posture rules in
backend/python/posture_analyzer.py - Adjust UI colors in
tailwind.config.js - Update analysis parameters in server configuration
posture-guard-ai/
βββ backend/ # Backend server and API
β βββ package.json # Node.js backend dependencies
β βββ requirements.txt # Python dependencies for posture analysis
β βββ server.js # Express server entry point
β βββ .env.sample
β βββ src/ # Backend source code
β β βββ config/
β β β βββ cloudinary.js # Cloudinary config
β β βββ controllers/
β β β βββ analysisController.js
β β βββ middleware/
β β β βββ errorHandler.js
β β β βββ upload.js
β β βββ python/
β β β βββ posture_analyzer.py # Python script for posture analysis
β β βββ routes/
β β β βββ analysisRoutes.js
β β βββ temp/ # Temporary and processed files
β β β βββ *.jpg
β β β βββ *.jpeg
β β β βββ processed-*.jpg
β β βββ utils/
β β βββ cloudinaryUpload.js
β β βββ runPythonScript.js
βββ frontend/ # Frontend React app
β βββ package.json # Frontend dependencies
β βββ index.html # Main HTML file
β βββ eslint.config.js
β βββ postcss.config.js
β βββ tailwind.config.js
β βββ tsconfig.app.json
β βββ tsconfig.json
β βββ tsconfig.node.json
β βββ vite.config.ts
β βββ src/
β βββ App.tsx # Main React component
β βββ index.css # Global styles
β βββ main.tsx # React entry point
β βββ vite-env.d.ts
β βββ assets/
β βββ logo.svg
β βββ logo2.svg
β βββ logo3.svg
β βββ logo4.svg
β βββ logo5.svg
β βββ meditation-yoga-posture-svgrepo-com.svg
βββ .gitignore # Git ignore file
βββ README.md # Project documentation
npm run build
# Deploy dist/ folder# Ensure Python and Node.js dependencies are installed
npm install && pip install -r requirements.txt- Frontend: Netlify, Vercel, or GitHub Pages
- Backend: Render, Railway, or Heroku
- Database: MongoDB Atlas or PostgreSQL
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, email anandyadav11206@gmail.com
Made with β€οΈ by the Anand