Inspiration

When someone collapses, the person nearest is usually untrained and frightened. They freeze, they often don't know the local emergency number, and they can't read a paragraph of instructions while their hands shake. The first minutes matter most, and that is exactly when help is hardest to get right. We wanted something a stranger could open with one hand and follow without thinking: short words, big buttons, a picture of the action, and the correct number to call.

What it does

First Aid Copilot is a phone web app (installable PWA) that guides a bystander one short step at a time.

  • Right language, right number. It asks for your language (41 built in) and country (244 supported) once, then always shows the local emergency number.
  • 11 animated guides: CPR, choking, bleeding, burns, stroke (BE FAST), seizure, severe allergy, chest pain, broken bone, nosebleed and heat illness. One line per step, read aloud, with a looping animation.
  • A Call button that fits the situation. Life-threatening guides get a large pulsing Call button. Minor ones (nosebleed, small burn) get a calm "Serious? Call" bar that says when to escalate.
  • CPR coach. A 3 · 2 · 1 · Start countdown, then a 110/min beat with sound, light and vibration, a push counter and a 2-minute swap-rescuer timer. An optional camera mode uses on-device pose tracking to estimate push rate and check that the arms stay straight. It does not measure depth, and the app says so.
  • "Tell me what happened." Speak (the browser's own dictation) or type. An offline keyword router answers instantly; when online an AI double-checks. The AI only picks a guide.
  • My location: coordinates to copy or share, plus a short script of what to tell the operator.
  • Works offline once installed as a PWA.

Safety by design: the AI only routes. Every medical step comes from fixed, reviewable guides based on mainstream lay-rescuer guidance (AHA, ERC, Red Cross). No language model ever writes a medical instruction.

How we built it

The app is plain JavaScript and SVG with no framework, plus a service worker for offline use. It is hosted on Cloudflare Pages, with Pages Functions for the AI endpoints and Workers KV for optional anonymous feedback.

AI routing. Groq gpt-oss-120b returns an allowlisted JSON result, {guide, alts, callNow}, which can only be one of our guide IDs. Text from the user is treated as untrusted input. The offline router runs first, and a merge step combines it with the AI answer, so a flaky network never leaves the user without help.

CPR beat. A naive setInterval drifts, so the scheduler computes each beat from the start time: $$t_n = t_0 + n\,T,\qquad T = \frac{60}{110}\ \text{s} \approx 545\ \text{ms}$$ If the page is suspended, it skips ahead to the next due beat instead of replaying missed ones.

Camera coach. MediaPipe Pose Landmarker runs in the browser. We fuse the vertical motion of the nose, shoulders, elbows and wrists into one signal, detect pushes with an adaptive threshold, and fit the rate over the last 10 pushes:

$$r = \frac{60}{\overline{\Delta t}}\ \text{pushes/min},\qquad \text{target } 100 \le r \le 120$$

The straight-arms check uses the elbow angle between the upper-arm and forearm vectors $\vec u,\vec v$:

$$\theta = \arccos!\left(\frac{\vec u\cdot\vec v}{\lVert\vec u\rVert\,\lVert\vec v\rVert}\right)$$

The tracker is a pure, unit-tested module. It falls back from GPU to CPU if needed, and the camera never leaves the phone.

Languages. English and Thai are hand-written. The other 39 are pre-translated JSON files shipped with the app, so they work offline and instantly. Arabic, Hebrew, Persian and Urdu are laid out right-to-left.

Process. We built it with Claude Code, split into parallel agents with a separate code-review pass. 252 automated tests cover the tracker, the router, the languages and the translation endpoint. The demo video is a deterministic motion-graphics page rendered frame by frame with headless Chrome and ffmpeg.

Challenges we ran into

  • A reasoning model as a router. gpt-oss-120b spends hidden reasoning tokens, so small token limits returned empty answers. We had to raise the budget and set low reasoning effort.
  • Voice input. Our first design recorded audio and sent it to Whisper. Phone built-in dictation was often better and instant, so Whisper became a fallback only. Browser quirks mattered: Safari can't autostart, and double-starting dictation breaks it.
  • Camera tracking without a real rig. We built and tested the tracker on simulated data, and our headless environment has no WebGL. We added a GPU-to-CPU fallback and a plain "camera unavailable" path to Sound + light.
  • Timing. The beat drifted and replayed after the page was suspended, which led to the drift-free scheduler above.
  • Machine-translated safety text. A code review caught real errors. For example, "Nothing in their mouth" (seizure) became a statement in 14 languages, and "Lay them flat, legs up" turned into "lie down yourself" in about 15. We fixed these, locked the fixes in an overrides file so regeneration can't undo them, and kept every translated language labeled "Auto-translated".
  • Right-to-left layout for four languages, including mirrored arrows while keeping digits and timers left-to-right.

Accomplishments that we're proud of

  • A genuinely calm interface: severity-aware calling, a countdown that gives the rescuer a moment, and every screen readable in a few seconds.
  • 41 languages and 244 countries with a first-run flow that never assumes the user's language.
  • An AI design where the model can't hurt anyone: it can only pick from a fixed list.
  • Honesty built into the product: it says when it does not measure depth, that translations are machine-made, and that it is not a medical device.
  • A polished demo video with a synthesized sound track, made entirely from code.
  • 252 passing tests.

What we learned

  • In a safety app, the most important AI decision is what the AI is not allowed to do.
  • Offline-first matters more than any single model, because emergencies happen where signal is bad.
  • Machine translation is fast and fluent but can silently invert a medical instruction. Review by a native speaker with first-aid training is not optional.
  • Small details like timing drift, audio unlocks and right-to-left digit order decide whether an app feels trustworthy under stress.

What's next for First Aid Copilot

  • Clinical and native-speaker review of every guide and every translation before any public release, starting with the lowest-confidence languages.
  • Real-device validation of the camera coach (push rate against a reference) and of per-language voice and dictation.
  • Verify the emergency-number table: 75 entries are flagged unverified.
  • Concept, not built yet: if authorities want it, opt-in sharing of location and what happened with national emergency services through a secure API, or through the phone's own emergency layer on iOS and Android. This would need agreements with those services or platforms. It would stay opt-in and never automatic, with the dispatcher in charge.
  • Pilot with one national emergency service, and add more languages and a stronger offline matcher.

Built With

  • claude
  • claude-code
  • cloudflare-kv
  • cloudflare-pages
  • cloudflare-workers
  • css3
  • ffmpeg
  • geolocation-api
  • gpt-oss-120b
  • groq
  • headless-chrome
  • html5
  • i18n
  • javascript
  • mediapipe
  • node.js
  • pwa
  • rtl
  • service-worker
  • svg
  • web-audio-api
  • web-speech-api
  • webgl
  • whisper
  • wrangler
Share this project:

Updates

Submission history