A real-time posture monitoring application with gamification elements. Uses AI-powered pose detection to help you maintain good posture while working, with a virtual pet companion that grows as you improve your habits!
In today's digital age, many people spend hours sitting in front of computers for work and entertainment. This often leads to poor posture, neck pain, and long-term health issues.
Posturemon solves this problem by:
- ๐ฏ Monitoring your posture in real-time using your webcam
- ๐ฎ Gamifying good posture habits with quests and achievements
- ๐พ Providing a virtual pet companion that evolves based on your performance
- ๐ Tracking your posture statistics over time
- โฐ Reminding you to maintain proper posture and take breaks
- Real-time Posture Detection: Uses MediaPipe and OpenCV for accurate pose estimation
- Personalized Calibration: Set your ideal posture for customized monitoring
- Gamification System:
- Daily and weekly quests
- Achievement system with unlockable rewards
- Virtual pet that grows with your progress
- Experience points and leveling
- Statistics Dashboard: Track your posture performance over time
- Session Management: Start/stop monitoring sessions with detailed logs
- SQLite Database: Persistent storage of user data and posture logs
- Framework: Next.js 16.0.0 (React 19.2.0)
- Language: TypeScript
- Styling: Tailwind CSS 4.0
- UI Components: Radix UI (tabs, progress, slots)
- State Management: Zustand
- API Client: Custom REST client for Flask backend
- Framework: Flask 3.1.2
- Language: Python 3
- Computer Vision:
- OpenCV 4.12.0.88
- MediaPipe 0.10.14 (pose detection)
- Database: SQLite with custom ORM
- Data Processing: NumPy, SciPy
- Concurrency: Threading for camera management
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Next.js Frontend (Port 3000) โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
โ โ Landing Page โ โ Main App โ โ UI Store โ โ
โ โ โ โ (Tabs: Home, โ โ (Zustand) โ โ
โ โ โ โ Quest, Pet) โ โ โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
โ โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโ โ
โ โ backend-api.ts โ โ
โ โ (API Client) โ โ
โ โโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HTTP REST API
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Flask Backend (Port 5050) โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
โ โ main.py โ โ posture.py โ โ database.py โ โ
โ โ (API Routes) โ โ (Pose Logic) โ โ(SQLite ORM) โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
โ โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโ โ
โ โ Camera Thread โ โ
โ โ (MediaPipe + โ โ
โ โ OpenCV) โ โ
โ โโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโ โ
โ โ posture_logs.db โ โ
โ โ (SQLite) โ โ
โ โโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฒ
โ Webcam Access
(Hardware)
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/camera/start |
Start webcam monitoring |
| POST | /api/camera/stop |
Stop webcam |
| POST | /api/camera/calibrate |
Calibrate ideal posture |
| GET | /api/posture/current |
Get real-time posture status |
| GET | /api/stats/today |
Get today's statistics |
| GET | /api/stats/week |
Get 7-day statistics |
| POST | /api/user/set |
Set username |
| GET | /api/user/get |
Get user information |
| GET | /api/health |
Health check |
| GET | /api/status |
Get camera & calibration status |
- Python 3.8+
- Node.js 18+ and npm/pnpm
- Webcam access
-
Navigate to backend directory:
cd backend -
Create and activate a virtual environment:
# Create the environment python3 -m venv .venv # Activate on macOS/Linux source .venv/bin/activate # Activate on Windows # .venv\Scripts\activate
-
Install Python dependencies:
pip install -r requirements.txt
-
Run the Flask backend:
python main.py
Backend will run on
http://localhost:5050Optional demo mode (shows OpenCV window):
python main.py --demo
-
Navigate to frontend directory:
cd posturemon -
Install dependencies:
npm install # or pnpm install -
Run the development server:
npm run dev # or pnpm devFrontend will run on
http://localhost:3000 -
Build for production:
npm run build npm start
Create a .env.local file in /posturemon (optional):
NEXT_PUBLIC_API_URL=http://localhost:5050- Start both backend and frontend (in separate terminals)
- Open browser to
http://localhost:3000 - Click "Start Monitoring" on the home screen
- Calibrate your posture: Click calibrate when sitting in your ideal posture
- Start working! The app will monitor your posture and alert you when slouching
- Complete quests to earn XP and level up your virtual pet
- View statistics to track your progress over time
Posturemon/
โโโ backend/ # Flask API server
โ โโโ main.py # API routes and Flask app
โ โโโ posture.py # PostureChecker class (MediaPipe logic)
โ โโโ database.py # SQLite database wrapper
โ โโโ requirements.txt # Python dependencies
โ โโโ .venv/ # Python virtual environment
โ
โโโ posturemon/ # Next.js frontend
โ โโโ app/ # Next.js app router
โ โ โโโ page.tsx # Landing page
โ โ โโโ app/page.tsx # Main application
โ โโโ components/ # React components
โ โ โโโ screens/ # Tab screen components
โ โ โโโ ui/ # Radix UI components
โ โ โโโ pet/ # Virtual pet components
โ โโโ services/ # Business logic
โ โ โโโ backend-api.ts # API client
โ โ โโโ quest-system.ts # Quest management
โ โ โโโ achievement-system.ts
โ โโโ store/ # Zustand state management
โ โโโ package.json
โ โโโ next.config.ts
โ
โโโ README.md
Users Table:
id(INTEGER PRIMARY KEY)name(TEXT)created_at(TIMESTAMP)
Posture Logs Table:
id(INTEGER PRIMARY KEY)user_id(INTEGER)timestamp(TIMESTAMP)posture_quality(TEXT): "good" or "bad"session_id(TEXT)
- Pose Detection: MediaPipe detects 33 body landmarks from webcam feed
- Calibration: Users calibrate their ideal posture, storing reference angles
- Real-time Monitoring: Backend compares current angles to calibrated angles
- Threshold Detection: Alerts when slouch duration exceeds threshold
- Data Logging: Stores posture events in SQLite database
- Gamification: Frontend processes logs into quests, achievements, and pet progression
Contributions are welcome! Feel free to open issues or submit pull requests.
MIT License - feel free to use this project for personal or commercial purposes.
Made with โค๏ธ to help you maintain better posture!