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 .task model (/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.
  • 🩺 Doctor Clinical Workstation (web_app/ — React + TypeScript + Firebase)

    • Integrated with Firebase AI Logic (firebase/ai) supporting InferenceMode.PREFER_ON_DEVICE, ONLY_ON_DEVICE, and PREFER_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.
  • 🏥 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.

How We Built It

  • Hybrid AI & Cloud: Firebase AI Logic (firebase/ai on Web, com.google.firebase:firebase-ai on Android), Google GenAI SDK (@google/genai with gemini-3.1-flash-lite SSE streaming & multimodal vision), Chrome window.ai / Ollama local bridge, and Google MediaPipe tasks-genai:0.10.24 for on-device .task inference 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 osmdroid OpenStreetMap.
  • Web & Backend: React 19, TypeScript, Vite, Tailwind CSS, Leaflet, Express.js, and Node.js.

Challenges We Ran Into

  1. 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.
  2. Voice Call Latency & Multilingual Speech: Waiting for full LLM responses made voice consults feel sluggish, and hardcoded en-IN speech 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.
  3. True On-Device LLM Execution: Pushing and loading a quantized 521 MB LiteRT .task model on physical Android hardware alongside local OpenStax vector lookup so the app remains genuinely useful in airplane mode.
  4. Resolving Map 403 Blocker Errors: Replaced blocked map tile sources with clean OpenStreetMap (osmdroid on Android, Leaflet on 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

Share this project:

Updates

Submission history