PostureCoach uses your webcam and on-device machine learning to detect 7 posture issues in real-time β no server, no data leaves your browser. Designed as a calm, supportive digital coach, it features a warm, human-centered interface, gamified health tracking, gentle break reminders, and a fully customizable settings panel.
Getting Started Β· Features Β· Architecture Β· Adding Detectors Β· Keyboard Shortcuts
PostureCoach classifies 7 distinct posture issues across a 3-tier severity system:
| Issue | Severity | Detection Method |
|---|---|---|
| β Good Posture | π’ Good | Neck angle within -95Β° to -65Β° range |
| β Slouching | π΄ Bad | Head dropped too far (angle < -95Β°) |
| π΄ Bad | Head jutting forward (angle > -65Β°) | |
| π‘ Warning | Left/right ear Y-position asymmetry | |
| π‘ Warning | Shoulder-hip midpoint torso angle deviation | |
| β¬οΈ Uneven Shoulders | π‘ Warning | Left/right shoulder height difference |
| π£ Chin Tucked | π‘ Warning | Nose too close to shoulder midpoint |
| π€· Shoulders Raised | π‘ Warning | Ear-to-shoulder distance decreased (stress shrug) |
| π Too Close to Screen | π‘ Warning | Self-calibrating shoulder-width proximity estimate |
- Per-frame recording of posture data, scores, and detected issues
- Session summary modal with accuracy breakdown, timeline heatmap, and top issues
- CSV export β download raw session data for external analysis
- Session history β last 30 sessions persisted to localStorage
- Configurable countdown timer (default: 30 minutes)
- Fullscreen overlay with randomized stretch routines (neck rolls, shoulder shrugs, seated twist, wrist circles, standing stretch, 20-20-20 eye rule)
- Snooze option (5 minutes)
- 8 achievements to unlock: First Steps, Iron Spine, Streak King, Dedicated, Habit Formed, Perfection, Marathon, Clean Sheet
- Animated achievement toast with glowing border on unlock
- Progress persisted across sessions via localStorage
- Detection sensitivity β adjust neck angle range, head tilt threshold, lean detection angle
- Voice alerts β toggle on/off, control speed, pitch, and cooldown between alerts
- Break timer β enable/disable, set interval (10β60 minutes)
- Display β toggle skeleton lines and neck guide overlay
- All settings auto-saved to localStorage
- Gamified health tips with XP progression and level tracking
- 6 science-backed posture benefit cards with unlock mechanics
- Interactive posture quiz with instant feedback
- Embedded video resources and daily habit checklist
- Warm, human-centered design with soft shadows, organic easing, and an ambient slow-drift gradient background
- Calming Mode β low-contrast, dimmed UI toggle for deep focus sessions
- π§ββοΈ Supportive, non-judgmental status indicators and gentle breathing animations instead of clinical "alarms"
- Toast notifications, immersive break overlays, and responsive design
- Google Fonts (DM Sans, DM Mono) for a friendly, approachable feel
- Node.js 18+ and npm 9+
- A device with a webcam
# Clone the repository
git clone https://github.com/your-username/posture-ai.git
cd posture-ai
# Install dependencies
npm install
# Start the development server
npm run devOpen http://localhost:5173 in your browser. Grant camera permission when prompted.
npm run build
npm run previewPostureCoach follows a modular, single-responsibility architecture. Each concern is isolated into its own file or directory.
src/
β
βββ posture/ # Posture detection engine
β βββ types.js Classification config (labels, severity, voice)
β βββ analyzer.js Orchestrator β runs all detectors
β βββ drawing.js Canvas rendering (skeleton, dots, guides)
β βββ detectors/ One file per posture check
β βββ index.js Barrel export
β βββ neckAngle.js Slouching & Forward Head
β βββ headTilt.js Head Tilted
β βββ shoulderLevel.js Uneven Shoulders
β βββ leanDetector.js Leaning Sideways
β βββ chinTuck.js Chin Tucked
β βββ shoulderShrug.js Shoulders Raised (stress)
β βββ screenDistance.js Too Close to Screen
β
βββ analytics/ # Session tracking & persistence
β βββ sessionTracker.js Per-frame posture recording
β βββ storage.js localStorage read/write
β
βββ features/ # Feature modules
β βββ breakReminder/ Break timer overlay
β β βββ BreakOverlay.jsx
β β βββ BreakOverlay.css
β βββ gamification/ Achievement system
β β βββ achievements.js
β β βββ AchievementToast.jsx
β β βββ AchievementToast.css
β βββ sessionSummary/ End-of-session report
β β βββ SessionSummary.jsx
β β βββ SessionSummary.css
β βββ settings/ App configuration
β βββ SettingsContext.jsx
β βββ SettingsPanel.jsx
β βββ SettingsPanel.css
β
βββ hooks/ # Reusable React hooks
β βββ useToast.js Toast notification system
β βββ useBreakTimer.js Configurable break countdown
β βββ useKeyboardShortcuts.js Global keyboard shortcuts
β
βββ utils/ # Pure utility functions
β βββ geometry.js getAngle, getDistance, getMidpoint
β βββ insights.js AI insight message generator
β βββ exportReport.js CSV export utility
β
βββ component/ # UI components
β βββ PostureCamera.jsx Main camera + detection component
β βββ PostureCamera.css
β βββ Navbar.jsx
β βββ Navbar.css
β βββ ScrollToTop.tsx
β
βββ pages/ # Route pages
βββ Dashboard.jsx Main posture analysis view
βββ HealthTips.jsx Gamified health module
βββ HealthTips.css
The plugin-style architecture makes extending detection trivial:
1. Define the posture type in src/posture/types.js:
NECK_CRANE: {
label: "Neck Crane",
emoji: "π¦",
level: "warning",
voice: "Your neck is craning forward",
},2. Create the detector in src/posture/detectors/neckCrane.js:
import { POSTURE_TYPES } from "../types";
export function detectNeckCrane(kp) {
// Your detection logic using keypoints
// Return { issue: POSTURE_TYPES.NECK_CRANE } or { issue: null }
}3. Export it from src/posture/detectors/index.js:
export { detectNeckCrane } from "./neckCrane";4. Register it in src/posture/analyzer.js:
const crane = detectNeckCrane(kp);
// Add crane.issue to the issues arrayThat's it β the UI, voice alerts, scoring, and analytics automatically pick up the new detector.
| Key | Action |
|---|---|
Space |
Pause / resume detection |
F |
Toggle fullscreen camera |
M |
Toggle mute |
Esc |
Close settings panel or exit fullscreen |
| Layer | Technology |
|---|---|
| Framework | React 19 |
| Bundler | Vite 8 |
| AI Model | TensorFlow.js + MoveNet (SinglePose Lightning) |
| Routing | React Router 7 |
| Styling | Vanilla CSS with CSS custom properties |
| Fonts | Google Fonts (DM Sans, DM Mono) |
| Persistence | localStorage (settings, sessions, achievements) |
| Voice | Web Speech API (SpeechSynthesisUtterance) |
PostureCoach runs 100% on-device. Your webcam feed is processed locally by TensorFlow.js inside your browser. No video, keypoints, or posture data is ever sent to any external server. Session data is stored only in your browser's localStorage.
This project is licensed under the MIT License β see the LICENSE file for details.
Built using TensorFlow.js + MoveNet
PostureCoach β Sit tall. Live well.