HMS-AI is an AI-powered health analytics platform that collects, visualizes, and analyzes data from Bluetooth wearable devices in real time. It combines a modern dark-themed web interface with machine learning insights to give users a personalized picture of their health.
| Feature | Status | Notes |
|---|---|---|
| User Authentication | β | Login/Signup with SHA256 hashing, Flask session management, profile chip in header |
| Real-time Dashboard | β | Heart Rate, Steps, Sleep, Calories via Chart.js β only populated from real device data |
| Web Bluetooth Integration | β | Browser-native BLE via the Web Bluetooth API β no server required |
| AI Health Score | β | 0β100 score aggregated from vitals with confidence levels and personalized insights |
| ML Recommendations | β | Scikit-learn RandomForest classifier in api/predict.py generates context-aware advice |
| Vital Signs Monitoring | β | Live heart rate from GATT notifications; BP / SpOβ / temp shown only with real sensor data |
| Sleep Analysis | β | 7-day sleep chart (hours + efficiency) rendered via Chart.js |
| Data Export | β | Full CSV export of health metrics via /api/wearable/data/export |
| Responsive UI | β | Glassmorphism dark theme, mobile-first layout, split-panel auth pages |
| Hybrid Deployment | β | Vercel (frontend CDN) + Render (Flask/Gunicorn backend) |
HMS-AI uses two complementary Bluetooth integrations:
The main way users connect wearables. Runs entirely in the browser β no server Bluetooth adapter needed.
User's Browser (Chrome/Edge)
βββ navigator.bluetooth.requestDevice()
βββ Native OS device picker shown to user
βββ User selects their wearable
βββ Read: battery level, manufacturer name
βββ Subscribe: heart rate notifications (live, every ~1 s)
βββ Updates dashboard metrics in real time
βββ POST /api/wearable/ble-reading β persisted to DB
Requirements:
- HTTPS (or
localhost) β Web Bluetooth is blocked on plain HTTP - Chrome 56+ / Edge 79+ / Opera 43+ β Firefox and Safari are not supported
- A user gesture (button click) to trigger the device picker
Supported devices (anything advertising standard GATT services):
Polar Β· Garmin Β· Fitbit Β· Samsung Galaxy Watch Β· Mi Band Β· Amazfit Β· WHOOP Β· Oura Ring
β¦plus any device advertising Heart Rate (0x180D), Blood Pressure (0x1810), Fitness Machine (0x1826), or Glucose (0x1808) services.
Located in ble/ble.py. Useful when the Flask server is running locally on the same machine as the wearable device (e.g. a Raspberry Pi, a development laptop).
β οΈ Thebleakbackend is not called by the web dashboard on cloud deployments (Render/Vercel) because the server has no physical Bluetooth adapter that can reach the user's device.
The UI was redesigned in March 2026 with a new medical-tech aesthetic.
| Token | Value |
|---|---|
| Background | #060c18 / #0a0f1c (deep charcoal) |
| Accent Primary | #0d9488 (medical teal) |
| Accent Secondary | #10b981 (emerald green) |
| Font | Inter (variable weight) |
| Cards | Glassmorphism β backdrop-filter: blur(20px) + subtle teal border glow |
| Buttons | Pill-shaped, gradient fill, shimmer-on-hover |
Page layouts:
- Landing page β Split-panel hero (copy left, live health card mock right), stats bar, feature cards, timeline steps, device logos
- Login / Sign Up β Split-panel (decorative left with stats + form right)
- Dashboard β 3-column responsive card grid with glassmorphism cards
- HTML5 / CSS3 / Vanilla JS (ES6+)
- Web Bluetooth API β browser-native BLE device connection
- Chart.js β sleep trend charts
- Font Awesome 6 β icons
- Google Fonts β Inter
- Flask (Python 3.12+)
- Pandas / NumPy β data processing
- Scikit-learn β RandomForest health risk prediction
- SQLite (dev) / ephemeral cloud DB (prod)
- Flask-CORS β cross-origin headers for Vercel β Render
- Vercel β frontend (global CDN, rewrite rules)
- Render β backend (Gunicorn WSGI)
- Docker β containerized production build
- Git β CI/CD via push-triggered deployments
hms.ai/
βββ api/
β βββ auth.py # Login, Register, Profile (/api/auth/*)
β βββ dashboard.py # Data aggregation (/api/dashboard/<user_id>)
β βββ predict.py # ML inference (/api/predict/*)
β βββ wearable.py # Data export, BLE reading ingestion
β βββ ai_advice.py # Gemini AI health advice (/api/ai/*)
βββ ble/
β βββ ble.py # Python BLE scanner (bleak) β local/Pi use
βββ database/
β βββ models.py # User & HealthData SQLite models
βββ model_training/
β βββ preprocess.py # Dataset preparation
β βββ train.py # Train RandomForest health risk model
βββ services/
β βββ background_manager.py # Background data collection services
βββ static/
β βββ css/
β β βββ main.css # Design tokens, navbar, buttons, footer
β β βββ home.css # Landing page styles (hero, features, steps)
β β βββ auth.css # Login/signup split-panel styles
β β βββ dashboard.css # Dashboard card grid and metric styles
β βββ js/
β βββ main.js # Auth forms, mobile nav, loading spinner
β βββ dashboard.js # Dashboard data loading, Web Bluetooth, charts
βββ templates/
β βββ index.html # Landing page
β βββ login.html # Login page
β βββ signup.html # Sign up page
β βββ dashboard.html # Main dashboard
βββ app.py # Flask entry point, route definitions
βββ Dockerfile # Production container
βββ requirements.txt # Python dependencies
βββ vercel.json # Vercel routing/rewrite rules
- Python 3.12+
- pip
- A Chromium-based browser (Chrome / Edge) for Bluetooth features
# 1. Clone
git clone https://github.com/Danchi-1/hms.ai.git
cd hms.ai
# 2. Create virtual environment
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Configure environment
cp .env.example .env
# Edit .env β set SECRET_KEY and GEMINI_API_KEY
# 5. (Optional) Train the ML model
python model_training/preprocess.py
python model_training/train.py
# 6. Run
python app.pyVisit http://localhost:5000 β Bluetooth features work on localhost without HTTPS.
| Platform | Config |
|---|---|
| Render (backend) | Build: pip install -r requirements.txt Β· Start: gunicorn app:app |
| Vercel (frontend) | Framework: Other Β· Ensure vercel.json rewrites are present |
| Docker | docker build -t hms-ai . && docker run -p 5000:5000 hms-ai |
β οΈ On cloud deployments, the app must be served over HTTPS for Web Bluetooth to work. Render and Vercel both provide HTTPS by default.
| Component | Details |
|---|---|
| Model | RandomForestClassifier (Scikit-learn) |
| Inputs | Steps, sleep duration, sleep efficiency, heart rate |
| Output | Risk level (Low / Medium / High) + confidence score |
| Inference | Runs on dashboard load via /api/predict/ |
| AI Advice | Gemini API (/api/ai/health-advice) generates natural-language recommendations |
| Training | python model_training/train.py β saves model.pkl |
No data is ever simulated or fabricated. All metric cards (-- by default) update only from two real sources:
- Backend API β historical data from
/api/dashboard/<user_id>(Fitbit sync data stored in DB) - Web Bluetooth β live readings from a physically connected BLE device (heart rate notifications via GATT)
Vitals such as blood pressure, SpOβ, and temperature remain at -- until a compatible sensor provides them. Trend indicators are only shown with real historical comparison data.
- Passwords: SHA256 with salt via
hashlib - Sessions: Flask
sessionencrypted withSECRET_KEY - Input validation: Regex sanitization on username/email fields
- CORS: Strict origin whitelist (Vercel + Render + localhost only)
- Bluetooth: Browser enforces HTTPS-only access and explicit user permission per device
| Feature | Chrome | Edge | Firefox | Safari |
|---|---|---|---|---|
| General UI | β | β | β | β |
| Web Bluetooth | β | β | β | β |
| Chart.js | β | β | β | β |
For full functionality (Bluetooth device connection), use Chrome or Edge.
MIT License β see LICENSE for details.