Recover at home. Never alone.
Haven is a home rehab coach for shoulder recovery after breast cancer surgery. A laptop camera and a wearable armband guide each exercise, keep the patient inside the limits their physical therapist set, and give the PT a clear picture of recovery between visits.
| Live site | havenn.health |
| For judges | havenn.health/judges: a scripted session and the PT console, no camera needed |
| Devpost | devpost.com/software/haven-xuzh06 |
| Demo video | YouTube |
Haven is a hackathon prototype, not a medical device. It does not diagnose or treat anything, and the range limits in the demo are placeholders: real limits come from the patient's surgeon or physical therapist.
After breast cancer surgery, most shoulder rehab happens alone at home, and between visits the physical therapist can't see how high the arm got, whether it hurt, or whether a limit was crossed. Guidance matters: in a 2024 randomized trial, 85.7% of patients on an early, tailored exercise program regained full shoulder strength within six months, compared with 18% on usual care (Min et al., JAMA Surgery).
- Movement reminders. The PT sets a reminder interval, and the armband chirps when the arm hasn't been raised above 60° for that long.
- Guided reps with voice coaching. Pose tracking on the laptop camera counts every rep, measures its peak angle, and catches shrugging, leaning and a bent elbow. A warm recorded voice talks the patient through each set, asks for a pain rating after it, and checks for swelling or cording at the end.
- Care team limits enforced on the band. The PT's range limit is sent to the armband whenever it connects. The band beeps faster as the arm nears the limit and alarms above it, during sessions and between them.
- Clinician dashboard. PTs add patients, set the recovery phase, exercises, sets, reps, limits and goals, and follow range of motion, pain, form, daily arm use, the latest armband trace and every flag.
- Verified AI reports. Gemini writes a plain summary for the patient and a one-page report for the PT, and the server checks every number in that text against the data.
Six exercises are built in: side raise, scaption raise, forward raise, wall walk, shoulder rolls and elbow winging.
flowchart LR
cam["Laptop camera"] -->|"video stays on device"| web
band["Armband<br/>XIAO ESP32-S3 + BNO085"] <-->|"BLE, 20 Hz angle stream<br/>limit + reminder settings"| web
web["Browser app<br/>React + MediaPipe Pose<br/>session engine, voice coach"] -->|"angles, reps, pain, symptoms"| api
web -->|"sign in"| auth0["Auth0"]
api["Express API<br/>one Vercel function"] -->|"SQL"| tiger[("Tiger Cloud<br/>TimescaleDB")]
api -->|"verify token"| auth0
api -->|"computed stats + flags"| gemini["Gemini"]
The browser does all the vision work. The API only ever sees numbers: angles, rep counts, pain ratings and symptom answers.
| Layer | Tools |
|---|---|
| Wearable | Seeed XIAO ESP32-S3, BNO085 IMU, buzzer, LiPo battery, Bluetooth Low Energy (Nordic UART service) |
| Frontend | React 19, TypeScript, Vite, MediaPipe Tasks Vision (Pose Landmarker), Web Bluetooth, Web Audio, Web Speech, GSAP, Vitest |
| Backend | Node.js 22, Express 5, node-postgres, Google Gen AI SDK (Gemini), Vitest |
| Database | Tiger Cloud (TimescaleDB on Postgres): hypertables, columnstore, continuous aggregates |
| Auth | Auth0 (@auth0/auth0-react in the browser, express-oauth2-jwt-bearer on the API) |
| Hosting | Vercel (static app plus one Node function), custom domain havenn.health |
The coaching voice is a pack of clips recorded ahead of time with Gemini text to speech (npm run voice-pack), so sessions play natural speech instantly and offline.
Haven's data is time series at heart: every rep, every armband sample and every minute of daily arm use has a timestamp. The schema is plain Postgres (001_schema.sql), and 002_timescale.sql layers Tiger Data on top.
| Table | What it holds | Chunk interval | Storage |
|---|---|---|---|
band_samples |
The armband's raw 20 Hz stream during sessions (elevation, angular rate) | 1 day | Columnstore after 1 day, segmented by patient_id, ordered by t desc |
daily_use |
Per-minute summaries from the band's daily use mode (peak elevation, raises above 90°, active minutes) | 7 days | Columnstore after 7 days, segmented by patient_id, ordered by bucket_start desc, bucket_minutes |
reps |
Every rep: peak angle, duration, source (camera or band), limit and form flags, the band's peak for the same rep | 7 days | Row store |
The raw band stream is the bulk of the data, 20 rows a second per patient, so it moves to the columnstore after a day. Segmenting by patient keeps each patient's history contiguous, which is exactly how the dashboard reads it.
Two daily rollups, both bucketed by the patient's local day with time_bucket(..., 'America/New_York'):
rom_dailyfromreps: best and mean peak angle, rep count, reps over the limit, reps with compensation, and the average camera vs band gap, per patient, exercise, arm and day.daily_use_dailyfromdaily_use: active minutes, raises above 90° and peak elevation per patient and day.
Both run in real-time mode (materialized_only = false), so a session shows up on the dashboard the moment it is saved, and a policy refreshes the last 90 days every 15 minutes.
repscopiespatient_id,exercise_id,sideandkindfrom its parent rows so the continuous aggregate can roll up without joins.- Each set stores a snapshot of the limit in force, so changing a prescription never rewrites history.
- Sessions are written in one transaction, with reps and band samples batch inserted through
unnest(one round trip per set, one for the whole band trace). 001_schema.sqldefinesrom_dailyanddaily_use_dailyas plain views with the same columns, so the app also runs on ordinary Postgres;db:setupskips the Timescale migration where the extension isn't available.
- Deterministic rules raise every flag.
flags.tsflags range loss, rising or high pain, reported swelling or cording, low daily arm use, limit breaks in sessions and at home, more compensation and missed sessions. The same code runs in the server and the app, straight from the rollups. - Gemini only writes wording. It receives the computed stats and flags as JSON, never video. Its instructions forbid new numbers, diagnoses, and adding, dropping or regrading a flag. Requests are sent with
store: false. - Every number is checked.
numberGuard.tspulls every number out of Gemini's text and looks for it in the data it was given. If any are missing, the server sends the draft back once with those numbers named; anything still unsupported is saved with the report and shown to the PT. - Limits come from the plan, not the request. When a session is saved, the server takes the phase, each set's limit and every over-limit mark from the PT's plan, so an edited request can't hide a limit break.
- Video never leaves the computer. MediaPipe Pose runs in the browser, with the model and runtime served from the app itself. Patients can hide the camera image and see only an outline of their arm. Voice answers to the pain question are optional, since browser speech recognition may use a cloud service.
- Roles come from verified emails. Clinicians are the addresses in
CLINICIAN_EMAILS. A patient signs in to the record their PT created for their email, and anyone else sees the demo patient read only. Only an email Auth0 has verified counts.
- Board: Seeed XIAO ESP32-S3
- Sensor: BNO085 IMU sampled at 100 Hz, measuring the upper arm's angle against gravity
- Link: Bluetooth Low Energy to the browser at 20 Hz
- Alerts: a buzzer that beeps faster from 10° below the PT's limit, alarms above it, and chirps as a movement reminder
- Power: 600 mAh LiPo
In a session the camera leads and the band fills in when the camera loses sight of the arm. Its reading is mapped into the camera's frame through the rest pose captured at calibration, and each rep stores both peaks so the dashboard can show how closely they agree.
The band speaks plain text over the Nordic UART service.
- Band to app: one line per sample at 20 Hz:
ms, elevation°, rate °/s, gyro x, gyro y, gyro z, zeroed, limit°, over - App to band:
zzero the arm at rest,c<deg>set the limit (c0turns it off),r<min>set the movement reminder (r0turns it off),m1/m0mute and unmute,btest beep
The band saves the limit and reminder, warns only once zeroed, and forgets the zero at power off. The app also supports a binary GATT protocol with a per minute daily use log for future firmware, and picks whichever service the band offers. Until the band keeps that log, the demo's daily_use rows come from the seed data. The full contract is in web/src/lib/band/protocol.ts.
You need Node.js 22.12 or later and a Postgres database. A Tiger Cloud service gives you the full Timescale setup; plain Postgres also works without it.
1. API server
cd server
cp .env.example .env # then set DATABASE_URL
npm install
npm run db:setup -- --seed # apply migrations and load the demo patient
npm run dev # API on http://localhost:8787/api2. Web app (second terminal)
cd web
cp .env.example .env.local # optional
npm install # also downloads the MediaPipe pose model into public/
npm run dev # http://localhost:5173, proxies /api to the serverOpen the app in Chrome or Edge (Web Bluetooth). No armband? Press Simulate band on the setup screen.
server/.env
| Variable | Description |
|---|---|
DATABASE_URL |
Postgres connection string, such as a Tiger Cloud service URL. Required. |
AUTH0_DOMAIN |
Auth0 tenant domain. With AUTH0_AUDIENCE, turns on sign in checks. |
AUTH0_AUDIENCE |
Identifier of the API you created in Auth0. |
CLINICIAN_EMAILS |
Comma separated emails that sign in as clinicians. |
GEMINI_API_KEY |
Google AI Studio key, for reports and npm run voice-pack. |
GEMINI_MODEL |
Gemini model for reports. Defaults to gemini-3.8-flash. |
DEMO_PATIENT_ID |
The seeded demo patient, shown on /judges and to sign ins without a record. |
PORT |
API port. Defaults to 8787. |
web/.env.local
| Variable | Description |
|---|---|
VITE_AUTH0_DOMAIN |
Auth0 tenant domain. |
VITE_AUTH0_CLIENT_ID |
Client ID of your Auth0 Single Page Application. |
VITE_AUTH0_AUDIENCE |
Must match AUTH0_AUDIENCE on the server. |
VITE_PATIENT_ID |
The seeded demo patient. |
- No Auth0 keys: dev mode, for your own machine only. There's no sign in, every request acts as the demo clinician, and the top bar switches between the Patient and Clinician sides. The server won't start this way if
web/distexists, and a Vercel deploy answers503. - Auth0 on the web app but not the server: the app shows a notice instead of loading, so nobody silently gets the clinician view.
- No Gemini key: everything works except generating reports. The voice pack is already in
web/public/voice, so coaching still speaks. - No database or server: the web app runs offline with a placeholder patient. Sessions work but aren't saved.
| Folder | Command | What it does |
|---|---|---|
server |
npm run db:setup |
Apply new migrations; add -- --seed to load the demo patient |
server |
npm run export-demo |
Save the demo patient's dashboard into the web app as an offline fallback |
server |
npm run voice-pack |
Record the coaching lines with Gemini text to speech |
| both | npm test / npm run typecheck |
Vitest / TypeScript |
node db/scripts/generate-seed.mjs regenerates db/seed.sql so the demo data ends yesterday.
Haven deploys to Vercel as one project, configured by vercel.json. server/scripts/vercel-build.mjs serves web/dist as static files and bundles the Express API with esbuild into a single Node 22 function; /api/* goes to the function, /judges to the judges page, and everything else to the single-page app. This works whether the project's Root Directory is the repo root or server/.
Set the server variables and the VITE_ variables in the Vercel project settings (Vite reads the VITE_ ones at build time).
- Smarter alerts that adapt to each patient's own trend instead of fixed thresholds.
- Lymphedema monitoring that goes beyond the patient reporting arm heaviness.
- Discreet haptics so the band can warn with a vibration instead of a sound.
