Inspiration
Inspiration
In real clinical emergencies and rural or air-gapped hospital workflows, doctors and patients cannot rely on an uninterrupted internet connection—nor can hospitals freely send sensitive Protected Health Information (PHI) to external servers when offline or connectivity-constrained. At the same time, generic chatbots lack patient EHR context (allergies, active medications) and authoritative medical grounding.
We built CuraGrid (MedNexus AI) to bridge that gap: a multi-platform, privacy-preserving healthcare ecosystem powered by Hybrid AI—combining on-device inference (MediaPipe GenAI / LiteRT, Chrome Built-in Gemini Nano, local Ollama, and embedded medical RAG) with Cloud Gemini via Firebase AI Logic when online.
What It Does
CuraGrid connects patients, doctors, and hospital command centers across Android, Web, and a Node.js + Firebase backend:
📱 Android Patient & Doctor App (Kotlin + Jetpack Compose)
- AI Video Call Consultation & Ambient Listener (
CameraX+ Speech-to-Text + Streaming TTS): Patients can run live video consultations with a real-time AI Doctor persona (supporting English, Hindi, and Hinglish) backed by SSE streaming (gemini-3.1-flash-lite), EHR awareness, and automatic post-call clinical summaries. - EHR-Aware Emergency & Clinical AI Chat: Multi-turn clinical and triage chatbots that automatically inject patient EHR context (e.g., Penicillin/Sulfa allergies, active Ramipril/Atorvastatin prescriptions) so contraindicated drugs are flagged automatically.
- Multimodal Vision Analysis: Attach prescriptions, lab reports, or wound photos for Gemini Vision interpretation.
- True Offline Mode (Zero Connectivity / Zero PHI Egress): Uses Google MediaPipe GenAI (
tasks-genai) with an on-device.taskmodel (/data/local/tmp/llm/gemma.task) paired with an embedded local OpenStax Medical RAG asset (openstax_emergency_rag.json) and an offline CPR metronome. - Emergency SOS + Nearest Hospital Routing: Finds the nearest seeded hospital from the database using patient GPS coordinates and displays live interactive OpenStreetMap (
osmdroid) routing without external tile-blocker failures.
- AI Video Call Consultation & Ambient Listener (
🩺 Doctor Clinical Workstation (
web_app/— React + TypeScript + Firebase)- Integrated with Firebase AI Logic (
firebase/ai) supportingInferenceMode.PREFER_ON_DEVICE,ONLY_ON_DEVICE, andPREFER_IN_CLOUD. - Secured with Firebase App Check (
ReCaptchaV3Provider), dynamically controlled with Firebase Remote Config, and synced with Cloud Firestore. - Includes encounter management, push-to-talk / voice dictation clinical notes, medical record inspection, and live textbook RAG synthesis.
- Integrated with Firebase AI Logic (
🏥 Hospital Command Center (
website/— React + Leaflet)- Live Ambulance Radar (OpenStreetMap + Leaflet), Ward/Bed Allocation, Doctor Schedules, Prescriptions, Telehealth, and Textbook Knowledge Browser.
🧠 Hybrid AI Core & RAG Backend (
ai-core/+backend/)- Dual-runtime router (
ai-core/src/hybridAiRouter.js) routing between on-device engines and Cloud Gemini (@google/genai), backed by a curated clinical knowledge index (knowledge_index.json) filtered to remove noisy quiz/review-question chunks.
- Dual-runtime router (
How We Built It
- Hybrid AI & Cloud: Firebase AI Logic (
firebase/aion Web,com.google.firebase:firebase-aion Android), Google GenAI SDK (@google/genaiwithgemini-3.1-flash-liteSSE streaming & multimodal vision), Chromewindow.ai/ Ollama local bridge, and Google MediaPipetasks-genai:0.10.24for on-device.taskinference on Android. - Firebase Stack: Cloud Firestore (live sync + local JSON fallback adapter), Firebase App Check (Play Integrity & ReCaptchaV3 + debug token evaluation), and Firebase Remote Config.
- Mobile: Kotlin, Jetpack Compose (Material 3), CameraX, Retrofit + OkHttp SSE, Coil, and
osmdroidOpenStreetMap. - Web & Backend: React 19, TypeScript, Vite, Tailwind CSS, Leaflet, Express.js, and Node.js.
Challenges We Ran Into
- Eliminating Canned Fallback Traps & Noisy RAG: Early prototypes intercepted medical keywords with static templates and retrieved textbook "Review Questions" pages into prompts. We removed all hardcoded keyword traps, added RAG chunk quality filtering (
isNoisyRagEntry), and wired full multi-turn history + Firestore EHR context into every AI route. - Voice Call Latency & Multilingual Speech: Waiting for full LLM responses made voice consults feel sluggish, and hardcoded
en-INspeech recognition hurt Hindi/Hinglish demos. We implemented SSE token streaming with first-sentence TTS playback and added live language switching (Auto,English,हिन्दी,Hinglish), plus speech text sanitization so markdown/URLs are never spoken aloud. - True On-Device LLM Execution: Pushing and loading a quantized 521 MB LiteRT
.taskmodel on physical Android hardware alongside local OpenStax vector lookup so the app remains genuinely useful in airplane mode. - Resolving Map 403 Blocker Errors: Replaced blocked map tile sources with clean OpenStreetMap (
osmdroidon Android,Leafleton Web) and database-backed nearest-hospital matching for safe SOS demonstrations.
What We Learned
- Hybrid AI works best when context (EHR + clean RAG) and routing policy (Remote Config + latency/connectivity awareness) travel seamlessly across both on-device and cloud runtimes.
- Sub-sentence SSE streaming transforms how responsive an AI voice consultation feels on mobile.
What's Next for CuraGrid
- Fine-tuned MedGemma on-device checkpoints for specialized clinical triage.
- Real-time WebRTC peer-to-peer doctor-patient video rooms with live ambient SOAP note extraction synced straight to HL7 FHIR / ABDM health records. ## What it does
How we built it
Challenges we ran into
Accomplishments that we're proud of
What we learned
What's next for Curagrid
Built With
- android
- camerax
- cloud-firestore
- express.js
- firebase
- firebase-ai-logic
- firebase-app-check
- firebase-remote-config
- gemini
- gemma
- jetpack-compose
- kotlin
- leaflet.js
- mediapipe
- node.js
- openstreetmap
- rag
- react
- tailwindcss
- typescript
- vite