Margi
Complete Project & UI Design Brief
Signal drops. The critical minute doesn't.
Table of contents
- Executive summary & product vision
- Deep analogies (present to judges)
- Hackathon alignment & deliverables
- System architecture
- Design system — Night-Highway HUD
- Screen inventory (current + planned)
- User flows & navigation map
- START triage FSM (medical)
- Golden Hour Packet & QR relay
- Journey, CrashEngine, Trip Info
- AI chatbot layer
- Data, SQLite POI, location fixes
- Refinement plan (full — R1–R9)
- P0 file map & known bugs
- What we rejected
- Tech stack & repo map
- Demo script & acceptance tests
- Glossary & related documents
1. Executive summary
Margi is an offline-first emergency co-pilot for Indian highways. When mobile signal fails after a crash, victims and bystanders still get START medical triage, trauma-tier hospital routing (not “nearest pin”), a human-readable Golden Hour Packet (GHP) for 108, and a QR bystander relay until any phone regains network.
| Item | Detail |
|---|---|
| Primary app | novadrive-mobile/ — Expo SDK 54, Android via Expo Go / APK |
| Web mirror | novadrive/ — Next.js prototype |
| Deadline | May 31, 2026, 11:59 PM IST (Unstop) |
| P0 status | Built & working — airplane-mode demo path |
| Next | Refinement plan (UI polish) — pending “go” from product owner |
2. Deep analogies
3. Hackathon (RoadSoS)
| Criterion | Margi response |
|---|---|
| Offline | FSM + SQLite POI + GHP + QR on device |
| AI chatbot | Text UI + offline keyword parser; optional LLM online |
| Location services | GPS + trauma-tier routing + Trip Info corridor (planned) |
| Valid contacts | Verified phones in DB; “unverified” if missing — never fake hospital as 108 |
Submit: GitHub, emergency_seed.db, 7 slides, Word doc, working APK demo.
4. System architecture
5. Design system — Night-Highway HUD
Tone: Calm, authoritative, night-driving HUD. Not panic red fullscreen loops.
| Token | Hex | Use |
|---|---|---|
| Background | #0B1220 | App bg |
| Surface | #151D2E | Cards |
| Surface 2 | #1C2636 | Inputs |
| Border | #2A3A52 | Dividers |
| Text | #E8EDF4 | Primary text |
| Muted | #8B9BB0 | Secondary / grey lines on splash |
| Amber | #FBBF24 | Primary CTA, logo accent |
| Cyan | #22D3EE | Online, GPS, coords |
| Safe green | #6EE7B7 | GREEN triage |
| Urgent | #FB7185 | RED triage, SOS (sparingly) |
Typography (refinement)
- Display / logo: Barlow Condensed or DM Sans Bold
- Body: DM Sans
- GHP / dispatch: JetBrains Mono
- Accessibility slider: 100%–145% font scale (planned R3)
Components
| Component | Variants / rules |
|---|---|
| NovaButton | primary (amber), secondary, ghost, danger — min height 48dp |
| SeverityChip | RED/YELLOW/GREEN/BLACK — always text + color |
| ProgressRail | Locate → Triage → Route → Packet → Relay |
| HoldSOSButton | Hold 1.5s — not tap |
| DispatchCard | Monospace GHP block |
| FacilityCard | Distance km, tier, verified badge |
| CrashCandidateModal | Calm 15s — no auto action at 0 |
| NovaLogo (planned R1) | SVG highway + pulse mark |
6. Screen inventory
6.1 Onboarding (current + planned)
CURRENT: Text “Margi”, tagline, grey body copy, Get started.
PLANNED: Logo animation 0.8s → wordmark → tagline → grey subline “Offline triage · trauma routing · QR relay” → Get started button fade-in.
CURRENT: “Email optional”, Continue as Guest, Continue.
PLANNED: Email (required for Login), “Continue with email”, “Continue as Guest (demo)”, footer legal line.
Blood type, allergies, conditions, emergency contact — stored local/Guest.
CURRENT: Toggles for large text, high contrast, reduce motion, TTS stub.
PLANNED: Slider for text size with live preview line.
6.2 Home & journey
CURRENT: “Happy journey, Guest”, Start journey, Emergency, Scan QR, Replay onboarding.
PLANNED: Hero dashboard — greeting, hero card “Ready for the highway?”, large Start journey, secondary actions row.
Transition screen 1.2–1.8s: “Starting journey…”, animated route line, then auto-enter HUD.
Large speed km/h, status ACTIVE, Hold for SOS (1.5s), Simulate crash, End journey.
Point A (GPS) / Point B → Plan trip → scroll cards: trauma centers, accident zones, dead zones, precautions, contacts. Chat: “Ask about this route”.
6.3 Emergency flow
CURRENT BUG: Shows “Chennai–Trichy corridor (demo)” and facilities 800km away if user not in Chennai.
FIX: Real reverse geocode; POI bbox 100km; honest message if no local POIs.
START questions + chat “Describe emergency” → offline keywords prefill FSM.
Trauma-tier sorted facilities — tap to select → Packet.
GHP monospace text + QR code (lz-string + SHA-256).
Cache for bystander, SMS 108 when online, link to Scan QR.
Camera scan → verify hash → SecureStore → SMS 108.
7. Navigation map
8. START triage FSM
States: AMBULATORY → BREATHING_CHECK → AIRWAY_REPOSITION → RESPIRATORY_RATE → PERFUSION_CHECK → MENTAL_STATUS → TAGGED
| Condition | Result |
|---|---|
| Can walk | GREEN |
| Airway fails | BLACK |
| Airway OK after reposition | → RR check (NOT instant RED) |
| RR > 30 | RED |
| Bad perfusion | RED |
| No commands | RED |
| All pass, non-ambulatory | YELLOW |
9. Golden Hour Packet
MARGI GHP Triage: RED Location: NH48 km 87 (13.08270, 80.27070) Facility: Apollo Highway Trauma (~12km, ~18min) Phone: 044-27428888 Hash: nd-a3f2c891
QR: ND1: + lz-string compressed JSON { id, triage, lat, lng, integrity }.
10. Journey & CrashEngine
| Rule | Value |
|---|---|
| Active when | Journey status = ACTIVE only |
| Speed before | > 25 km/h |
| Accel peak | > threshold in 8s window |
| Speed after | < 5 km/h |
| On trigger | 15s calm dialog — user confirms — NO auto 108 |
| Judges | Simulate crash button |
11. Trip Info cards (R6)
| Card type | Content |
|---|---|
| Route summary | Distance, est. time A→B |
| Trauma centers en route | Top 3 from SQLite along corridor |
| Accident-prone zones | corridor_hazards table |
| Low-network zones | dead_zones table |
| Precautions | Night, rain, NH rules |
| Contacts | 108 + verified hospital |
12. AI chatbot
- Emergency flow: offline keywords → FSM slots
- Trip flow (R6): keywords → show relevant cards
- Online optional: LLM fills slots only — never overrides triage
Keywords: can't walk, not breathing, unconscious, breathing fast, weak pulse, etc.
13. Refinement plan — FULL SPEC (R1–R9)
go or continue. Builds on P0 shipped in novadrive-mobile/ (Expo SDK 54).13.0 Executive summary
P0 proved the medical spine (START FSM, GHP, QR relay, airplane mode). Refinement covers: brand splash, auth/accessibility UX, Happy Journey home, journey transition, Trip Info (A→B) for judges, real GPS + sensible routing distances, CrashEngine tuning, cohesive UI pass.
Out of this pass: always-on scream/voice crash (battery, privacy, false positives); production Supabase auth (stub only); NGO marketplace, OS crash APIs (P2).
13.1 Your feedback → mapped work
| # | Your ask | Root cause today | Phase |
|---|---|---|---|
| 1 | Splash: logo popup, tagline, Get Started | Text-only splash, no motion/brand mark | R1 |
| 2 | Real email + Login; accessibility slider | “Email optional” + toggle not slider | R2, R3 |
| 3 | Happy Journey home; Start → transition → HUD | Plain home + abrupt navigation | R4, R5 |
| 4 | Trip info A→B + chatbot retrieval | P1 deferred; not built | R6 |
| 5 | Real location; facilities not 800 km away | Hardcoded NH48 landmark; POI seeded Chennai only | R7 |
| 6 | UI inspiration / reference images | Minimal components beyond tokens | R9 |
| 7 | Scream on loud sound; crash on phone throw | Scream not implemented; CrashEngine too strict | R8 |
| 8 | Replay full onboarding from splash | Added “Replay onboarding” on home | Keep |
13.2 Design direction (locked)
- Aesthetic: Night-Highway HUD — calm, not panic. Navy, amber actions, cyan for online/live.
- Motion: One hero moment per flow (splash reveal, journey handoff). Respect
reduceMotion. - Typography: Barlow Condensed or DM Sans (display); DM Sans (body); JetBrains Mono (GHP).
- Logo (in-app SVG): Highway lane + pulse node in shield/hex; wordmark Nova (white) + Drive (amber); 2s scale + fade on splash.
13.3 Phase R1 — Splash screen
Sequence (~2.5s before button enabled):
- 0–0.8s: Logo mark scales in (spring), subtle amber glow ring
- 0.8–1.4s: Wordmark “Margi” fades up
- 1.4–2.0s: Tagline: “Signal drops. The critical minute doesn’t.”
- 2.0s+: Grey subline: “Offline triage · trauma routing · QR relay for 108”
- Get started button fades in (primary amber)
| File | Change |
|---|---|
app/splash.tsx | Reanimated sequence; use NovaLogo |
src/components/NovaLogo.tsx | New — SVG mark + wordmark |
Acceptance: First launch feels like a product; reduceMotion skips animations; Get started → /auth.
13.4 Phase R2 — Sign-in
- Email field required (valid format)
- Primary: Continue with email (stores in profile; Supabase later)
- Secondary: Continue as Guest (demo) for judges
- Footer: “No password stored on device.”
13.5 Phase R3 — Accessibility slider
- Replace boolean “Larger text” with slider 100% → 145%
- Live preview: “Can the injured person walk?”
- Persist
a11y.fontScale;ScreenShellapplies globally - High contrast toggle unchanged
13.6 Phase R4 — Home (“Happy Journey”) hero
- Top: Nova mark + time-of-day greeting (Good evening, Guest)
- Hero card: “Ready for the highway?” + golden hour / offline subcopy
- Large Start journey CTA
- Secondary: Emergency · Scan QR
- Tertiary: Replay onboarding (existing)
- Optional chip: last journey / POI count in region
Note: Start journey does not start GPS yet — only after R5 transition.
13.7 Phase R5 — Journey transition → HUD
Home [Start journey]
→ /journey/depart (new, 1.2–1.8s)
“Starting journey…” + route line anim + progress bar
→ /journey (HUD, auto-start GPS + CrashEngine)
| File | Change |
|---|---|
app/journey/depart.tsx | New — Reanimated transition |
app/home.tsx | Navigate to depart, not journey directly |
app/journey.tsx | On mount: startJourney() if not ACTIVE |
13.8 Phase R6 — Trip Info (A → B)
New screen /trip/plan from Home before Start journey.
| Field | Behavior |
|---|---|
| Point A | Default = current GPS; editable |
| Point B | Text / preset corridors (Chennai → Trichy) |
| Plan trip | Builds corridor briefing cards |
Briefing cards (scroll): Route summary · Trauma centers en route (top 3) · Accident-prone zones (corridor_hazards) · Low-network zones (dead_zones) · Precautions · Emergency contacts (108 + verified hospital).
Chatbot: “Ask about this route” — offline keywords → cards; online LLM only selects cards, text from DB.
corridor_hazards (id, name, lat, lng, severity, nh_code, note); dead_zones (id, name, lat, lng, radius_km, note);
13.9 Phase R7 — Real location (fix 800 km bug) — BUILD FIRST
locate.tsx forces landmark: 'Chennai–Trichy corridor (demo)' and NH48 km 87. POI DB centers Chennai (~13.08, 80.27) — users elsewhere see facilities hundreds of km away.| Fix | Detail |
|---|---|
| A. Reverse geocode | expo-location geocode OR offline NH lookup |
| B. Remove demo strings | City/district from geocode; NH km only if matched |
| C. Bbox filter | Only POIs within 100 km; honest message if none |
| D. Regional POI seed | ingestCorridors.py for user’s state or Overpass on first online launch |
| E. Cap display | Warn if facility > 150 km: “Outside offline pack — verify by phone” |
13.10 Phase R8 — CrashEngine & scream (honest scope)
| Approach | Verdict |
|---|---|
| Always-on mic + scream ML | Rejected — battery, privacy, false positives |
| Push-to-talk “I need help” | P1 optional |
| Accel + speed crash | Keep — honest for hackathon |
Why phone throw fails: Requires speed before >25 km/h AND accel peak >~2.8g AND speed after <5 km/h. Sofa drop: speed ≈ 0 → by design no crash. Use Simulate crash for judges.
Tuning: Driving mode keeps gates; Dev overlay shows accel peak; High sensitivity lowers accel to ~2.0g (lab only).
13.11 Phase R9 — UI polish
- Share reference images in
docs/design/refs/ - Extract spacing, radius, icon style, CTA hierarchy
- Apply via NovaButton, ScreenShell, FacilityCard, ProgressRail, DispatchCard
- Test 5.5" and 6.7" Android; safe areas; 48dp touch targets
13.12 Recommended build order
| Order | Phase | Est. | Why |
|---|---|---|---|
| 1 | R7 Real GPS + POI bbox | 2d | Wrong distances kill trust |
| 2 | R1 Splash + logo | 1d | Brand entrance |
| 3 | R2 Auth | 0.5d | |
| 4 | R3 A11y slider | 0.5d | |
| 5 | R4 Home hero | 1d | |
| 6 | R5 Journey transition | 1d | |
| 7 | R6 Trip Info A→B | 2d | Judges wow |
| 8 | R8 CrashEngine tune | 1d | |
| 9 | R9 UI pass | 2d | Last |
Say go for full refinement or go slim to skip R6 (R1–R5, R7, R8 only, ~4–5 days).
13.13 Files touched (estimate)
| Area | New | Modified |
|---|---|---|
| Splash / brand | NovaLogo.tsx | splash.tsx |
| Auth / a11y | — | auth.tsx, accessibility.tsx, ScreenShell.tsx |
| Home / journey | journey/depart.tsx, trip/plan.tsx | home.tsx, journey.tsx |
| Location / POI | geocode.ts | locate.tsx, facilitiesDb.ts, ingestCorridors.py |
| Trip / chat | tripBriefing.ts, parseTripQuery.ts | AppContext.tsx |
| Crash | — | crashEngine.ts, dev overlay |
13.14 Before you say go — decisions needed
- Reference images in repo or linked (3+ screenshots)
- Logo: in-app SVG (fast) vs external PNG (Anti-Gravity)
- Your region for POI seed priority (state/highway)
- Trip Info: full R6 vs slim static NH48 corridor only
- Scream: confirm reject for May vs P1.5 push-to-talk on SOS only
13.15 Refinement sprint acceptance
- Full onboarding replay: splash animation → auth → medical → a11y slider → home hero
- Start journey → transition → HUD
- Trip plan A→B shows corridor cards (if R6 in scope)
- Real GPS; nearest facility distance believable
- Airplane mode test still passes
npm testFSM tests still pass
14. P0 shipped — file map (novadrive-mobile)
| Path | Purpose |
|---|---|
app/splash.tsx | Onboarding entry |
app/auth.tsx | Guest / email stub |
app/medical.tsx | Blood type, allergies, emergency contact |
app/accessibility.tsx | A11y toggles (slider planned R3) |
app/home.tsx | Happy journey hub + replay onboarding |
app/journey.tsx | GPS HUD, Hold SOS, Simulate crash |
app/emergency/locate.tsx | GPS capture (demo landmark bug) |
app/emergency/triage.tsx | START FSM + chat |
app/emergency/route.tsx | Trauma-tier facility list |
app/emergency/packet.tsx | GHP + QR |
app/emergency/relay.tsx | Bystander cache + SMS 108 |
app/scan.tsx | QR scan bystander flow |
src/lib/startTriageFSM.ts | Medical decision machine |
src/lib/ghp.ts | GHP build, lz-string QR, SHA-256 (expo-crypto) |
src/lib/facilitiesDb.ts | SQLite ~50 POIs Chennai corridor |
src/lib/crashEngine.ts | Accel + speed fusion |
src/lib/parseEmergencyText.ts | Offline keyword → FSM slots |
src/context/AppContext.tsx | Journey, crash dialog, triage, GHP state |
src/theme/colors.ts | Night-Highway HUD tokens |
15. Known bugs & limitations (today)
| Issue | Impact | Fix phase |
|---|---|---|
| Locate shows Chennai–Trichy demo landmark | Judges see fake location | R7 |
| POI DB Chennai-only | 800+ km distances elsewhere | R7 |
| Phone throw won’t trigger crash | Needs driving speed context | R8 / use Simulate |
| Scream detection | Not implemented (by design) | Rejected / P1.5 optional |
| Onboarding skips splash after first run | AsyncStorage nd_onboarded | Replay onboarding button |
16. What we rejected
17. Tech & repo
novadrive-mobile/ Expo SDK 54, Expo Router (PRIMARY) novadrive/ Next.js mirror docs/ Plans + this PDF source scripts/ ingestCorridors.py → POI DB
18. Demo & tests
90s script: Problem → Journey → Simulate crash (calm) → SOS → Triage RED → GHP + QR → Airplane mode → Second phone scan → SMS.
Replay onboarding: Home → “Replay onboarding (from splash)”.
Run: npm run start:tunnel in novadrive-mobile (hotspot); Expo Go SDK 54.
19. Glossary
| Term | Meaning |
|---|---|
| START | Simple Triage And Rapid Treatment |
| GHP | Golden Hour Packet for 108 |
| FSM | Medical decision state machine |
| Trauma tier | 1=best trauma center … 3=clinic |
| Relay | Bystander QR handoff |
| RoadSoS | Hackathon track |
| Rah-Veer | MoRTH ₹25k Good Samaritan (P1) |
20. Related documents
- This page — complete UI brief (HTML)
- Margi Complete PDF
- Master team brief (index)
docs/MARGI_REFINEMENT_PLAN.md— full refinement specdocs/MARGI_FINAL_IMPLEMENTATION_PLAN.md— P0 implementation