Inspiration
It started with my grandma. She has sleep apnea, and on nights I slept beside her I would lie awake listening, worried about whether she was still breathing. That fear is what made me look for treatment, and that's how I found CPAP.
But she didn't like it. The mask was uncomfortable, it pressed on her face, and the whole setup felt like a hassle every night. A machine that works only helps if you can actually sleep with it on.
So we talked to more CPAP users. Their stories kept matching hers: masks that leak, press on the nose bridge, dry the mouth, or feel claustrophobic. Many had quietly stopped using it without telling anyone why. Later we found the same pattern in the research. Lu et al. (2024) showed that standard masks create pressure hotspots and leaks, and that a cushion shaped to the patient's face reduces both.
The timing makes it worse. Medicare keeps paying for a CPAP machine only if the patient meets an adherence rule in the first 90 nights:
$$ \exists \text{ a 30-night window within nights } 1\ldots 90 \;:\; #{\, n : h_n \ge 4 \text{ hours} \,} \;\ge\; 21 $$
When a patient like my grandma gives up in those first weeks, she loses her therapy and her equipment supplier loses the rental. Everyone wants the same outcome, and no one has a good way to see the problem coming.
That's why we're building Snug: sleep apnea treatment you don't feel. It's a PAP experience people can actually sleep with, so families like mine can sleep too.
What it does
Snug is a comfort and adherence ecosystem that works with any CPAP brand. Three parts run today as a live prototype:
- Snug Fit (phone face scan). The front camera finds 478 facial landmarks and measures the nose and face in millimetres. It then scores all four mask styles (nasal pillows, nasal, full face and total face) and picks a size, taking into account the patient's sleeping position, mouth breathing and main concern.
- Snug Night Coach (10-second morning check-in). The patient logs hours, symptoms and comfort. They get one clear next step, a one-tap request for a fit check, and progress toward the Medicare 21-of-30 target. Snug never changes machine settings.
- Snug Care Console (for equipment suppliers). It ranks patients by a transparent dropout-risk score and shows why each one is flagged. Suppliers can act in one click (refit, chin strap, humidifier tips, call). It updates live as patients check in.
Planned next: Snug Clip, a small motion and humidity sensor that clips onto the outside of the mask and tells whether a leak was caused by the mask moving, and Snug Custom, a cushion fitted to the patient's face.
How we built it
- Monorepo in TypeScript. One shared, pure
corepackage (adherence rules, mask matching, coaching rules, risk score) runs on both the server and the browser, with 21 unit tests and GitHub Actions CI. - Frontend. React 19 + Vite. Backend. Express with a WebSocket, so a check-in on the phone appears in the Care Console in about a second. Without a server, the app falls back to a demo mode in the browser.
- Face measurement in the browser. It uses MediaPipe Face Landmarker; no image ever leaves the phone. We use the iris as a built-in ruler, because the human iris is about 11.7 mm across in nearly everyone:
$$ s = \frac{11.7\ \text{mm}}{d_{\text{iris}}\ [\text{px}]}, \qquad \text{measurement (mm)} = s \cdot d_{\text{landmarks}}\ [\text{px}] $$
We take the median of 30 frames for each measurement to steady it against head movement.
- Explainable risk score. It adds up named factors (low recent use, falling trend, repeated leaks or dry mouth, low comfort, running out of time to meet the Medicare target, an open fit-check request). A supplier fix lowers the score:
$$ R = \sum_i w_i f_i, \qquad R \ge 45 \Rightarrow \text{Follow up}, \quad 20 \le R < 45 \Rightarrow \text{Watch} $$
- Hardware design (proposed). We drew a reference schematic and a PCB placement study for Snug Clip. It uses a Bluetooth chip, a 6-axis motion sensor and a humidity sensor, all running directly from a coin cell. The chip saves about 30 KB of summary data per night instead of about 8.6 MB of raw data. Our battery estimate is about 250 nights.
- Research basis. Our custom-cushion plan builds on Lu et al. (2024), Computational design of custom-fit PAP masks. In that study, a cushion shaped to the face in its compressed state leaked less and pressed more evenly than a commercial mask, especially when it was designed across several facial expressions.
Challenges we ran into
- Real millimetres from an ordinary camera. Without a depth sensor we needed a ruler, which is why we use the iris. We also had to pick facial points that map to how each mask style is actually sized: nose width for pillows, nose height for nasal, nose bridge to lower lip for full face, and face height for total face.
- Four mask styles, four ways of sizing. One measurement can't fit every mask, so each style is sized from its own measurement and scored with its own rules.
- Keeping it safe. It was tempting to let an AI "adjust therapy". We chose clear rules that never change the prescription, and that say exactly why something was flagged.
- A demo that works anywhere. Judges might open the static site with no server, so we built a fallback that keeps the patient view and the console in sync inside the browser.
Accomplishments that we're proud of
- A complete loop that works today: a phone check-in → a patient flagged at risk → one-click fix by the supplier → the risk score goes down, live.
- A face scan that runs entirely on the phone, so there is no camera data to protect.
- Every recommendation can be explained, and the documentation includes the methods, a validation plan and references.
What we learned
- The adherence problem is a comfort and coordination problem more than a technology problem. Suppliers have the incentive to fix it but no view into how the night went.
- Combining clinical policy (the Medicare rule), health economics and engineering produced a much sharper product than any one of them alone.
- In health tech, "explainable and safe" beats "clever". A supplier will act on a score only if they can see why it is high.
What's next for Snug
- Check scan accuracy against a ruler and against fitters' size choices (mean error, Bland–Altman, agreement).
- Build a Snug Clip prototype and match its movement data against leak data from the CPAP machine.
- A pilot with an equipment supplier (about 50 patients), with Medicare adherence as the main outcome.
- Multi-expression 3D scans and simulated cushion compression, leading to Snug Custom.
Snug is a hackathon prototype for research and demonstration. It is not a medical device and does not change CPAP settings.
Built With
- bluetooth
- computer-vision
- css3
- express.js
- github-actions
- html5
- imu
- kicad-style-schematic
- mediapipe
- mermaid
- netlify
- node.js
- nrf52
- react
- render
- typescript
- vite
- vitest
- webrtc
- websockets