How v1shnuuu/rev works
Purpose and entry points
Revive is a Flutter mobile CPR-coaching app designed to retain a deterministic offline rescue path while optionally using AI for triage and questions. Application startup and global configuration are centered in lib/main.dart, with native host entry points at android/app/src/main/kotlin/com/firstaid/cpr_coach/MainActivity.kt and ios/Runner/AppDelegate.swift.
Emergency journey and screen orchestration
The UI is organized as an emergency workflow: home entry, symptom triage, live CPR coaching, scripted guidance, and optional chat. Key route-level components are lib/screens/home_screen.dart, lib/screens/triage_screen.dart, and lib/screens/live_cpr_screen.dart; supporting guidance and AI interaction live in lib/screens/step_guide_screen.dart and lib/screens/chat_screen.dart. The life-saving path should resolve to static CPR guidance when AI is unavailable or uncertain.
Deterministic CPR core
Motion sensing is isolated from the UI in lib/services/motion_service.dart. It consumes the device accelerometer stream, detects/debounces compression peaks, derives BPM, and classifies rhythm against the target range. Static medical flow and fallback content are data-driven in lib/constants/cpr_steps.dart and lib/constants/emergency_protocols.dart, ensuring rate feedback and CPR instructions do not depend on network or model output.
Feedback, voice, and live presentation
lib/services/audio_service.dart supplies metronome/audio feedback, while lib/services/tts_service.dart and lib/services/stt_service.dart provide on-device spoken instruction and hands-free recognition. The live screen binds these service outputs to CPR-focused visual components such as lib/widgets/components/revive_bpm_gauge.dart, lib/widgets/compression_animation.dart, and lib/widgets/cpr_instruction_animation.dart. Voice recognition can support emergency-keyword actions and conversational input, but should not block the compression loop.
Optional AI boundary
lib/services/ollama_service.dart is the explicit boundary to Gemma via Ollama and an ngrok-accessible host. It supports natural-language triage and Q&A, not sensor interpretation or clinical timing. Connectivity/TLS setup is coupled to startup in lib/main.dart, while operational settings are centralized in lib/constants/app_config.dart. Failures at this boundary must degrade to static protocol guidance rather than stall emergency UI.
Health and platform integration
After a session, lib/services/health_connect_service.dart records incident information through Android Health Connect. This is best-effort: permissions, unsupported devices, or unavailable Health Connect must not interrupt active coaching. Android packaging and manifest capabilities reside under android/app/src/main/AndroidManifest.xml; iOS is present as a Flutter target but Health Connect is Android-specific.
Design and delivery boundaries
A tokenized Flutter design system defines colors, typography, spacing, motion, haptics, and component primitives in lib/theme/app_theme.dart, lib/theme/app_haptics.dart, and lib/widgets/components/revive_card.dart. Runtime targets include Android, iOS, and web (web/index.html), though accelerometer and Health Connect behavior requires physical Android hardware. Dependencies/assets are declared in pubspec.yaml; CI runs through .github/workflows/flutter-ci.yml.
Components 18
Flutter app
- Startup & configuration · Initializes routes, connectivity, and global setup.
lib/main.dart - Design system · Tokens, haptics, and reusable component primitives.
lib/theme/app_theme.dart - Runtime targets · Android, iOS, and web Flutter delivery targets.
web/index.html - Dependencies & CI · Flutter dependencies/assets and continuous integration.
pubspec.yaml
Emergency coaching
- Home entry
lib/screens/home_screen.dart - Symptom triage · Offers deterministic and optional AI-assisted triage.
lib/screens/triage_screen.dart - Live CPR coaching · Runs the active compression feedback loop.
lib/screens/live_cpr_screen.dart - Scripted guidance · Presents offline emergency instructions.
lib/screens/step_guide_screen.dart - Optional AI chat
lib/screens/chat_screen.dart - Static CPR protocols · Offline CPR steps and emergency fallback flows.
lib/constants/emergency_protocols.dart - CPR live visuals · BPM gauge and compression instruction animations.
lib/widgets/components/revive_bpm_gauge.dart
Device services
- Compression sensing · Detects peaks, derives BPM, and classifies rhythm.
lib/services/motion_service.dart - Metronome feedback
lib/services/audio_service.dart - Voice I/O · Spoken instructions and hands-free recognition.
lib/services/tts_service.dart
Optional integrations
- Gemma via Ollama · Optional natural-language triage and Q&A boundary.
lib/services/ollama_service.dart - AI operational settings
lib/constants/app_config.dart - Health Connect recording · Best-effort post-session incident recording.
lib/services/health_connect_service.dart - Android host & capabilities · Native activity and Android manifest permissions.
android/app/src/main/kotlin/com/firstaid/cpr_coach/MainActivity.kt
Connections 23
- Startup & configuration → Home entry: starts
- Startup & configuration → AI operational settings: configures
- Home entry → Symptom triage: begins assessment
- Symptom triage → Live CPR coaching: enters coaching
- Symptom triage → Scripted guidance: uses fallback guidance
- Symptom triage → Optional AI chat: opens questions
- Symptom triage → Gemma via Ollama: optional AI triage
- Optional AI chat → Gemma via Ollama: optional Q&A
- Gemma via Ollama → AI operational settings: uses host settings
- Gemma via Ollama → Static CPR protocols: failure falls back
- Scripted guidance → Static CPR protocols: renders
- Live CPR coaching → Static CPR protocols: uses instructions
- Live CPR coaching → Compression sensing: reads compression rate
- Live CPR coaching → Metronome feedback: drives feedback
- Live CPR coaching → Voice I/O: uses hands-free voice
- Live CPR coaching → CPR live visuals: renders live state
- Live CPR coaching → Health Connect recording: records after session
- Startup & configuration → Design system: applies
- Design system → CPR live visuals: styles
- Compression sensing → Android host & capabilities: requires device sensors
- Health Connect recording → Android host & capabilities: uses Android capability
- Startup & configuration → Runtime targets: builds for
- Dependencies & CI → Startup & configuration: supplies dependencies