# CHAIR FORCE ONE

An omnibus sensing → reasoning → acting platform built for **SCI Hackathon 2026**. The anchor use case is a wheelchair user, reframed as *an operator in an extreme environment*: pressure injuries are their radiation exposure, lost cellular signal is their degraded comms, cushion telemetry is their mission telemetry. Solve that problem with the same architecture you'd use for space or defense, and every module reinforces every other.

The result is one unified pipeline that predicts and prevents health crises across pressure, posture, cardiac, and environmental domains — because compounding, invisible risks escalate silently, and most systems today are reactive, not predictive.

---

## Live Demo — Two-Stage ECG Classifier

The fastest way to see the platform do something real. It's a **self-contained browser demo** — no server, no hardware, no install. It loads TensorFlow.js from a CDN and pulls its models directly from Google's Teachable Machine, so you just open the file.

**Just open it:**

```bash
# from the repo root
open dashboard/two_stage_ecg_demo.html        # macOS
xdg-open dashboard/two_stage_ecg_demo.html     # Linux
start dashboard/two_stage_ecg_demo.html        # Windows
```

**Or serve the whole dashboard folder** (recommended — avoids browser file:// restrictions):

```bash
cd dashboard
python -m http.server 8000
# then visit http://localhost:8000/two_stage_ecg_demo.html
```

**Prefer a front door?** Open [`index.html`](index.html) at the repo root — a launcher that surfaces every dashboard and shows which ones run in-browser versus which need hardware attached.

**What it does:** upload or capture an ECG image and watch a two-stage pipeline run:

1. **Stage 1 — Image Detection** (PTB-XL): "What are we even looking at?"
2. **Stage 2 — Cardiac Classification** (Mendeley): the actual diagnosis.
3. **Subjective-Logic fusion**: each stage emits an SL opinion; the two are fused, aged with a temporal-decay model (Chronofy), and framed for CBOR-LD transport.

> Needs an internet connection (CDN scripts + hosted models). A webcam or a saved ECG image works as input.

There's also a single-stage variant at `dashboard/ecg_classifier_demo.html` if you want the simpler pipeline.

---

## Repository Layout

The platform maps all 24 hackathon problems onto six reasoning modules, plus a hardware sensing layer (`sensus/`).

| Module | Path | Focus | Sponsor |
|--------|------|-------|---------|
| **BODY** | `body/` | Pressure-injury risk, relief quality, activity phenotypes, posture alerts (Problems 1–4) | Kalogon |
| **HEART** | `heart/` | Synthetic ECG, algo-vs-ML benchmarking, transformer model, lead extraction (21–24) | Who We Play For |
| **ENVIRONMENT** | `environment/` | Health-risk prediction, radiation/hazard protection (13–14) | BoxMica |
| **SPACE** | `space/` | Launch detection, object behavior, delay-tolerant ops, lunar awareness (15–18) | BoxMica |
| **AUTONOMY** | `autonomy/` | Autonomous delivery loop, analytics, safe-AI broker (5–7) | BeeNex |
| **OPERATIONS** | `ops/` | Conversation-to-state, workflow analysis, text-to-SQL, record linkage (8–12, 19–20) | MyelAI · Steppingblocks |
| **SENSUS** | `sensus/` | Contactless hardware layer — 60GHz mmWave, ESP32 CSI mesh, hazard node, Pi 5 edge | — |
| **CORE** | `chairforce_core/` | Cardiac monitor + Subjective-Logic integration shared across modules | — |

Design docs live at the root: **[`ARCHITECTURE.md`](ARCHITECTURE.md)** (full concept, data flow, hardware BOM) and **[`DATABRICKS_STRATEGY.md`](DATABRICKS_STRATEGY.md)** (Lakehouse plan).

---

## Dashboards at a Glance

| Dashboard | Path | Runtime | Needs |
|-----------|------|---------|-------|
| **Two-Stage ECG Classifier** ⭐ | `dashboard/two_stage_ecg_demo.html` | Browser | Internet only |
| ECG Image Classifier | `dashboard/ecg_classifier_demo.html` | Browser | Internet only |
| Contactless Health Monitor | `sensus/pi/services/dashboard.py` | Flask | MQTT broker + sensors |
| 60GHz mmWave | `sensus/mmwave_dashboard.py` | Web | Seeed MR60BHA2 via ESPHome |
| Hazard Detection | `sensus/hazard_dashboard.py` | Web | ESP32-C3 over serial |

The two browser dashboards run anywhere. The three `sensus/` dashboards are the live-hardware side of the platform — see [`sensus/README.md`](sensus/README.md) for wiring and setup.

---

## Unified Data Flow

```
SENSORS                EDGE (Pi 5 / Laptop+4090)        CLOUD (Databricks)
─────────              ─────────────────────────         ──────────────────
Kalogon Mat ──┐         ┌─────────────────────────┐      ┌──────────────┐
ESP32 CSI ────┤  MQTT   │  CHAIR FORCE ONE Engine  │Delta │ Unity Catalog│
AD8232 ECG ───┤ ──────→ │  body/ heart/ env/       │ ───→ │  cushion_tel │
IMU/GPS ──────┤   BLE   │  space/ autonomy/ ops/   │      │  ecg_records │
Env sensors ──┘         │  Delay-tolerant queue    │      │  env_readings│
                        │  Gemini interpretation   │      └──────┬───────┘
                        │  ElevenLabs voice alerts │             │
                        └───────────┬──────────────┘      Text-to-SQL · Linkage
                              Dashboard :5000
```

---

## Quick Start

```bash
git clone https://github.com/b-urge/chairforce-one.git
cd chairforce-one

# 1. See it work — no setup:
python -m http.server 8000 --directory dashboard
#    → http://localhost:8000/two_stage_ecg_demo.html

# 2. Explore a reasoning module:
python body/pressure_risk.py

# 3. Bring up the hardware layer:
#    follow sensus/README.md
```

Reasoning modules are Python; the `sensus/` layer targets ESP32 / Raspberry Pi 5. Approximate hardware BOM is ~$204 (full table in `ARCHITECTURE.md`).

---

## License

See [`sensus/LICENSE`](sensus/LICENSE) for the hardware layer. MIT license.
