An intelligent healthcare analytics platform that combines burnout prediction, workload balancing, and real-time employee monitoring to optimize workforce well-being and operational efficiency.
WorkWell AI is a comprehensive workforce management system designed for healthcare facilities (hospitals, clinics) that:
- Predicts burnout risk using AI models trained on synthetic hospital data
- Automatically redistributes workload to prevent doctor/employee overload
- Monitors employee well-being in real-time using facial emotion recognition
- Provides actionable insights through interactive dashboards and visualizations
- Trains lightweight AI models using 50+ synthetic doctor profiles
- Calculates burnout scores based on:
- Weekly hours worked
- Patient load
- Emotional state (emotion scores)
- Categorizes risk levels: Low, Medium, High
- Formula:
burnoutScore = (weeklyHours * 0.4) + (patientLoad * 0.4) + (emotionScore * 100 * 0.2)
- Analyzes real-time patient traffic and doctor availability
- Identifies overloaded doctors (burnoutScore > 70 or patientsToday > 40)
- Redistributes patients to less loaded doctors
- Prioritizes doctors with lower burnout scores
- Provides workload recommendations via API
- Runs every 60 seconds automatically
- Redistributes workload based on burnout risk
- Updates database with optimized patient distribution
- Logs before/after states for transparency
- Manual trigger available via
/api/ai/optimize
- Multi-face detection using face-api.js
- Emotion recognition (happy, sad, angry, neutral, etc.)
- Burnout score calculation from facial expressions
- Live dashboard updates every 15 seconds
- Face recognition and employee tracking
- Employee Overview: Card-based layout showing burnout scores, hours, and risk levels
- Workload Overview: Bar charts comparing current vs recommended patient loads
- Burnout Charts: Visual distribution of risk levels
- Real-time Metrics: Live updates on employee status
- React 19.1.1 - UI framework
- Vite - Build tool and dev server
- Tailwind CSS 4.1.17 - Styling
- Recharts 3.3.0 - Data visualization
- Chart.js 4.5.1 - Chart components
- face-api.js 0.22.2 - Facial recognition and emotion detection
- Node.js - Runtime environment
- Express 5.1.0 - Web framework
- MongoDB - Database (with in-memory fallback)
- Mongoose 8.19.3 - ODM for MongoDB
- ES6 Modules - Modern JavaScript syntax
- Node.js 18+ installed
- MongoDB installed and running (optional - system works with in-memory fallback)
git clone <repository-url>
cd workwell-aicd backend
npm installcd ../frontend
npm installCreate backend/.env:
PORT=5000
MONGODB_URI=mongodb://localhost:27017/workwell-ai
NODE_ENV=development# Windows
mongod --dbpath C:\data\db
# Linux/Mac
sudo systemctl start mongodcd backend
npm run devExpected output:
π Server running on port 5000
π€ Initializing AI System...
π Training burnout prediction model...
β
AI System initialized successfully!
π€ Starting AI Scheduler (runs every 60 seconds)...
cd frontend
npm run devExpected output:
VITE ready in XXX ms
β Local: http://localhost:5174/
- Frontend Dashboard: http://localhost:5174
- Backend API: http://localhost:5000
- MongoDB: mongodb://localhost:27017/workwell-ai
GET /api/employees- Fetch all employeesPOST /api/employees/update- Create or update employee with emotion data
POST /api/ai/predictBurnout- Predict burnout risk for doctor(s)GET /api/ai/balanceWorkload- Get workload balance recommendationsPOST /api/ai/optimize- Manually trigger workload optimizationGET /api/ai/telemetry- Get AI telemetry dataPOST /api/ai/telemetry- Send AI telemetry data
GET /api/time/today- Get today's time tracking data
Located in backend/ai/modelTrainer.js:
- Reads training data from
backend/data/doctorTrainingData.json - Uses weighted formula to calculate burnout scores (0-100 scale)
- Stores predictions in MongoDB
doctorAnalyticscollection - Falls back to in-memory storage if MongoDB unavailable
Located in backend/ai/workloadBalancer.js:
- Generates mock patient traffic data
- Combines with burnout scores to identify overloaded doctors
- Calculates optimal patient distribution
- Returns recommendations for workload redistribution
Located in backend/aiScheduler.js:
- Automatically runs every 60 seconds
- Fetches all doctors and their current workloads
- Identifies overworked (currentPatients > recommendedPatients) and underworked doctors
- Redistributes patients prioritizing lower burnout scores
- Updates database with new distribution
- Logs detailed before/after states
workwell-ai/
βββ backend/
β βββ ai/
β β βββ modelTrainer.js # AI burnout prediction model
β β βββ workloadBalancer.js # Workload balancing logic
β βββ aiScheduler.js # Automatic workload scheduler
β βββ config/
β β βββ db.js # MongoDB connection
β βββ controllers/
β β βββ aiController.js # AI endpoints controller
β β βββ employeeController.js # Employee CRUD
β β βββ timeController.js # Time tracking
β βββ data/
β β βββ doctorTrainingData.json # 50+ synthetic doctor profiles
β β βββ generateDoctorData.js # Data generator script
β β βββ mockData.json # Mock employee data
β βββ models/
β β βββ Employee.js # Employee MongoDB schema
β βββ routes/
β β βββ ai.js # AI routes
β β βββ employees.js # Employee routes
β β βββ time.js # Time routes
β βββ server.js # Express server
β
βββ frontend/
β βββ src/
β β βββ components/
β β β βββ Dashboard.jsx # Main dashboard
β β β βββ EmployeeOverview.jsx # Employee cards
β β β βββ WorkloadOverview.jsx # Workload charts
β β β βββ BurnoutChart.jsx # Burnout distribution
β β β βββ ...
β β βββ pages/
β β β βββ MonitorCam.jsx # Webcam monitoring
β β βββ lib/
β β β βββ api.js # API utilities
β β βββ ...
β βββ ...
β
βββ README.md
- Location:
frontend/src/components/EmployeeOverview.jsx - Features:
- Responsive card grid layout (1/2/3 columns)
- Displays: Name, Weekly Hours, Today Hours, Burnout Score, Risk Status
- Auto-refreshes every 15 seconds
- Color-coded risk badges (Red/Blue/Green)
- Location:
frontend/src/components/WorkloadOverview.jsx - Features:
- Bar chart comparing current vs recommended patient loads
- Highlights overloaded doctors in red
- Summary statistics cards
- Auto-refreshes every 30 seconds
- Location:
frontend/src/components/Dashboard.jsx - Features:
- Metric cards (Total Employees, High Risk Count, etc.)
- Burnout distribution chart
- Workload overview integration
- Employee table
The system gracefully handles MongoDB connection:
- If MongoDB is available: Uses persistent storage
- If MongoDB is unavailable: Falls back to in-memory storage
- Connection string:
mongodb://localhost:27017/workwell-ai
- Interval: 60 seconds (configurable in
server.js) - Manual Trigger:
POST /api/ai/optimize
- Employee Overview: 15 seconds
- Workload Overview: 30 seconds
- AI Scheduler: 60 seconds
{
name: String (required),
email: String (unique, required),
role: String (default: 'Employee'),
burnoutScore: Number (0-100),
status: String (Low/Normal/Medium/High),
weeklyHours: Number,
todayHours: Number,
currentPatients: Number,
recommendedPatients: Number,
faceDescriptor: [Number], // 128-dim face embedding
lastEmotion: String,
emotionHistory: [{
emotion: String,
score: Number,
timestamp: Date
}],
lastUpdated: Date
}{
doctorId: Number (unique, required),
name: String,
department: String,
burnoutScore: Number (0-100),
category: String (Low/Medium/High),
weeklyHours: Number,
patientLoad: Number,
emotionScore: Number,
currentPatients: Number,
recommendedPatients: Number,
shiftDuration: Number,
lastUpdated: Date
}curl -X POST http://localhost:5000/api/ai/predictBurnout \
-H "Content-Type: application/json" \
-d '{
"doctor": {
"doctorId": 1,
"weeklyHours": 60,
"patientLoad": 50,
"emotionScore": 0.3
}
}'curl http://localhost:5000/api/ai/balanceWorkloadcurl -X POST http://localhost:5000/api/ai/optimize- Problem: "MongoDB Connection Error"
- Solution: System automatically falls back to in-memory storage. Check MongoDB is running:
mongod --version
- Problem: "Training data not found"
- Solution: Run
node backend/data/generateDoctorData.jsto generate synthetic data
- Problem: CORS errors or connection refused
- Solution: Ensure backend is running on port 5000 and frontend on 5174. Check
backend/server.jsCORS configuration.
- Fork the repository
- Create a 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 ISC License.
- face-api.js - Facial recognition and emotion detection
- Recharts - Beautiful chart visualizations
- Tailwind CSS - Utility-first CSS framework
- MongoDB - NoSQL database
For issues, questions, or contributions, please open an issue on the repository.
Built with β€οΈ for better workforce well-being