Skip to content

About

AI Powered Workplace Wellbeing Website

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

33 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

WorkWell AI - AI-Powered Workforce Well-being Dashboard

WorkWell AI React Node.js MongoDB

An intelligent healthcare analytics platform that combines burnout prediction, workload balancing, and real-time employee monitoring to optimize workforce well-being and operational efficiency.

🎯 Overview

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
image image image

✨ Key Features

πŸ€– AI-Powered Burnout Prediction

  • 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)

βš–οΈ Smart Workload Balancing

  • 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

πŸ”„ Automatic Workload Scheduler

  • 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

πŸ‘₯ Real-Time Employee Monitoring

  • 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

πŸ“Š Interactive Dashboards

  • 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

πŸ› οΈ Tech Stack

Frontend

  • 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

Backend

  • 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

πŸ“¦ Installation

Prerequisites

  • Node.js 18+ installed
  • MongoDB installed and running (optional - system works with in-memory fallback)

Step 1: Clone the Repository

git clone <repository-url>
cd workwell-ai

Step 2: Install Backend Dependencies

cd backend
npm install

Step 3: Install Frontend Dependencies

cd ../frontend
npm install

Step 4: Configure Environment Variables

Create backend/.env:

PORT=5000
MONGODB_URI=mongodb://localhost:27017/workwell-ai
NODE_ENV=development

Step 5: Start MongoDB (Optional)

# Windows
mongod --dbpath C:\data\db

# Linux/Mac
sudo systemctl start mongod

πŸš€ Running the Application

Start Backend Server

cd backend
npm run dev

Expected output:

πŸš€ Server running on port 5000
πŸ€– Initializing AI System...
πŸ“Š Training burnout prediction model...
βœ… AI System initialized successfully!
πŸ€– Starting AI Scheduler (runs every 60 seconds)...

Start Frontend Development Server

cd frontend
npm run dev

Expected output:

VITE ready in XXX ms
➜ Local: http://localhost:5174/

Access the Application

πŸ“‘ API Endpoints

Employee Management

  • GET /api/employees - Fetch all employees
  • POST /api/employees/update - Create or update employee with emotion data

AI & Analytics

  • POST /api/ai/predictBurnout - Predict burnout risk for doctor(s)
  • GET /api/ai/balanceWorkload - Get workload balance recommendations
  • POST /api/ai/optimize - Manually trigger workload optimization
  • GET /api/ai/telemetry - Get AI telemetry data
  • POST /api/ai/telemetry - Send AI telemetry data

Time Tracking

  • GET /api/time/today - Get today's time tracking data

🧠 AI Features Explained

1. Burnout Prediction Model

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 doctorAnalytics collection
  • Falls back to in-memory storage if MongoDB unavailable

2. Workload Balancer

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

3. AI Scheduler

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

πŸ“ Project Structure

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

🎨 Frontend Components

EmployeeOverview

  • 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)

WorkloadOverview

  • 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

Dashboard

  • Location: frontend/src/components/Dashboard.jsx
  • Features:
    • Metric cards (Total Employees, High Risk Count, etc.)
    • Burnout distribution chart
    • Workload overview integration
    • Employee table

πŸ”§ Configuration

MongoDB Connection

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

AI Scheduler Settings

  • Interval: 60 seconds (configurable in server.js)
  • Manual Trigger: POST /api/ai/optimize

Data Refresh Rates

  • Employee Overview: 15 seconds
  • Workload Overview: 30 seconds
  • AI Scheduler: 60 seconds

πŸ“Š Data Models

Employee Schema

{
  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
}

DoctorAnalytics Schema

{
  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
}

πŸ§ͺ Testing

Test Burnout Prediction

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
    }
  }'

Test Workload Balance

curl http://localhost:5000/api/ai/balanceWorkload

Trigger Manual Optimization

curl -X POST http://localhost:5000/api/ai/optimize

🚨 Troubleshooting

MongoDB Connection Issues

  • Problem: "MongoDB Connection Error"
  • Solution: System automatically falls back to in-memory storage. Check MongoDB is running: mongod --version

AI Model Not Training

  • Problem: "Training data not found"
  • Solution: Run node backend/data/generateDoctorData.js to generate synthetic data

Frontend Not Loading

  • Problem: CORS errors or connection refused
  • Solution: Ensure backend is running on port 5000 and frontend on 5174. Check backend/server.js CORS configuration.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the ISC License.

πŸ™ Acknowledgments

  • face-api.js - Facial recognition and emotion detection
  • Recharts - Beautiful chart visualizations
  • Tailwind CSS - Utility-first CSS framework
  • MongoDB - NoSQL database

πŸ“§ Support

For issues, questions, or contributions, please open an issue on the repository.


Built with ❀️ for better workforce well-being

About

AI Powered Workplace Wellbeing Website

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages