DEV Community

Harshini trinayani
Harshini trinayani

Posted on

Beyond Turn-by-Turn: Building an AI-Powered Emergency Green Corridor with Google Gemini

Project Links: []https://github.com/HarshiniTrinayani/ArogyaRoute

Event: Meet the Builders — Gen AI APAC

Tech Stack: React 18, Google Gemini 1.5 Flash, Leaflet GIS, Web Audio API, Tailwind CSS

When an ambulance turns on its siren, we often imagine a clear road ahead. The reality of urban traffic is very different.

An ambulance does not travel through a city in isolation. Its journey depends on a chain of independent actors: the driver finding a path through gridlock, traffic police trying to clear blocked intersections, traffic signals cycling on fixed timers, and hospital emergency teams waiting for a patient whose condition may be rapidly changing.

During a medical emergency, every minute lost to a red light or an unexpected bottleneck costs time that a patient simply does not have. Yet today, these systems rarely communicate in real time.

I built AarogyaRoute to explore a different approach: what happens if we stop treating an emergency vehicle as an isolated car using a navigation app, and instead treat its journey as a synchronized Emergency Green Corridor connecting the ambulance, the city’s traffic network, and the destination hospital?

Here is the story of how I built the AarogyaRoute prototype using React, Leaflet, and Google Gemini 1.5 Flash.

1. The Problem: Why the "Golden Hour" Breaks Down

In major metropolitan cities like Hyderabad, Bengaluru, Delhi, and Chennai, "Green Corridors" do exist—but they are almost entirely manual, labor-intensive, and ad-hoc:

  • How it happens today: A hospital calls the Traffic Police Control Room hours in advance (typically for live organ transplants). Police leadership coordinates over VHF walkie-talkies and WhatsApp groups.
  • The ground reality: Up to 30 traffic officers must be physically dispatched to stand at consecutive intersections, manually holding signals green and placing barricades to halt cross-traffic.
  • The fatal limitation: This manual coordination requires 30 to 60 minutes of advance notice.
    For everyday, unplanned critical emergencies—such as an acute STEMI heart attack, a stroke, or a severe highway accident—setting up a manual corridor is impossible. The ambulance is left to navigate ordinary peak-hour gridlock alone.
    AarogyaRoute was designed to bridge this gap: replacing manual advance coordination with an automated, software-defined green corridor that activates in seconds.
    In fast-growing metropolitan areas across India and the Asia-Pacific region, that critical window is frequently compromised by five practical bottlenecks:

  • 1.Static Signal Timing: Municipal traffic lights run on pre-programmed timing cycles or automated loops that do not know an ambulance is 400 meters away.

  • 2.Severe Junction Congestion: Dense intersections become physical blockades where cars cannot easily pull aside even when they hear a siren.

  • 3.** Unpredictable Obstacles**: Sudden breakdowns, minor collisions, or road construction create instant gridlock with zero advance warning for approaching emergency medical services (EMS).

  • 4.Fragmented Communication: Traffic police officers on the ground are rarely notified in advance about an incoming emergency vehicle’s exact lane, route, or arrival second.

  • 5.Delayed Hospital Preparation: Emergency departments (EDs) often only receive full clinical context when the gurney wheels through the front door, leaving trauma surgeons and catheterization labs scrambling to prepare.

  • 6.The core issue is not simply finding the shortest line on a map. The issue is coordination

2. The Idea: From Navigation App to Coordinated Green Corridor
Traditional navigation apps provide turn-by-turn directions to a single driver. They are blind to the emergency ecosystem around that vehicle.

AarogyaRoute changes this model by establishing a continuous, bidirectional communication chain across four key stakeholders:

🚑 The Ambulance Crew (EMS): Receives an uncluttered cockpit heads-up display (HUD), continuous route clearance confirmation, and real-time patient telemetry monitoring.

🚦 Traffic Police & Signal Operations: Receives automated, geofenced signal preemption alerts and lane clearance orders ahead of the vehicle.

🤖 The AI Coordination Layer (Powered by Google Gemini): Continuously ingests streaming spatial parameters, evaluates route trade-offs, generates stakeholder-specific situation reports (SITREPs), and powers an interactive natural-language dispatch copilot.

🏥 The Destination Hospital Emergency Department: Receives live patient vitals, dynamic arrival countdowns, and automated clinical prep checklists to stage trauma teams before the vehicle arrives.

3. What I Built
AarogyaRoute is a client-side web application designed to act as a Digital Twin and Operational Command Hub for emergency transit.

The application provides dedicated dashboards for each persona alongside a unified Command Hub:

Multi-Persona Command Hub Header & Overview
A single-pane overview allowing dispatchers to monitor the moving ambulance, dynamic traffic signal states, incoming patient telemetry, and police dispatch feeds simultaneously.

Caption: Master control header showing active corridor metrics, speed (54 km/h), patient HR (122 bpm), time saved (~12.5 min), and multi-stakeholder status indicators.

Interactive Radar Map & GenAI Copilot
Built with Leaflet GIS and customized with a CartoDB dark theme, the map visualizes animated ambulance movements, dual-layer glowing route polylines, smart junction nodes, and pulsing 400-meter geofence clearance rings alongside the Gemini-powered Copilot.

Caption: Real-time GIS radar tracking paired with the interactive GenAI Copilot chat interface for instant queries.

Patient Telemetry & ER Readiness Panel
Monitors cardiac condition and links triage status directly with hospital preparation checklists.

Caption: 60 FPS HTML5 Canvas Lead-II ECG waveform monitor paired with encrypted police radio feeds and ER trauma prep checklists.

4. Where Google Gemini Fits
When building an AI-powered system, architectural boundaries are vital: What should be handled by traditional deterministic code, and what should be handled by an LLM?

Autonomous Multi-Stakeholder Situation Reports (SITREPs)
Every few seconds, the application packages the ambulance's telemetry into a structured prompt for Gemini 1.5 Flash.
Gemini returns structured directives tailored for each operational role:

Conversational Emergency Copilot
Stakeholders query the system through AICopilotChat.jsx. When an officer asks "Where is the ambulance and when will it reach my post?", Gemini calculates context dynamically:

  1. System Architecture & Data Flow AarogyaRoute runs as a reactive single-page application built with React 18, Vite, and Tailwind CSS.

  • State Store (EmergencyContext.jsx): Maintains active scenarios, patient vitals, signal states, and radio logs.
  • Spatial Engine (routingEngine.js): Interpolates coordinates along waypoints and computes Haversine distances to signals.
  • Signal State Machine: Geofencing logic executes state transitions
  • AI Synthesis Layer (geminiService.js): Calls @google/generative-ai to dispatch structured SITREPs.

6. Real-World Scenario: Hyderabad Tech Corridor
Patient: 58-year-old male with Acute Myocardial Infarction (STEMI Code Red).

Vitals: HR 122 bpm, BP 86/54 mmHg, SpO2 89%, ST-segment elevation.

Route: JNTU Metro to AIG Hospitals, Gachibowli (8.1 km across 6 major junctions).

Mission Timeline
Activation: Paramedic confirms Code Red priority; system selects Flyover Bypass.

Automated Green Wave: Signals shift to PREEMPTING at 800m and ACTIVE_GREEN at 300m with procedural clearance chimes sounding across radio logs.

Incident Detection & Reroute: A collision blocks lanes near Cyber Towers. Paramedic logs the hazard; Gemini shifts corridor to the flyover bypass, saving an estimated 4.2 minutes.

Clinical Alert: SpO2 drops to 83%. Gemini issues an urgent directive to AIG Hospitals to prime high-flow oxygen and catheterization teams.

Handover: Ambulance completes run in 8.5 minutes (vs standard peak transit of ~21 minutes).

  1. Technical Details Great-Circle Distance via Haversine Formula To compute distance without external API latency:

*HTML5 Canvas Cardiac Waveform *
RenderingPatientVitalsCard.jsx uses an animated 2D canvas context to render a Lead-II ECG trace modeling the P-Q-R-S-T cardiac cycle with a fading phosphor trail (rgba(10, 15, 29, 0.2)).

Procedural Web Audio
SynthesisaudioService.js uses native AudioContext web oscillators for radio squelch chirps (880 Hz–1760 Hz sine wave) and green-wave clearance chimes (C5-E5-G5 major triad).

8. Technical Reality: What Is Real vs. Simulated

  1. Current Limitations & Future Roadmap Current Limitations Browser State: Simulation state resides in browser memory.

Client-side API Key: Gemini calls originate client-side during the prototype phase.

Single Device Session: All roles run within a single client context.

10. Conclusion
In critical emergencies, technology should quietly connect the dots in the background. The hardest challenge in emergency response is not raw speed—it is coordination.

By combining deterministic spatial mathematics with the reasoning power of Google Gemini 1.5 Flash, AarogyaRoute demonstrates how disparate urban systems can be unified into a single, proactive coordination corridor to protect the Golden Hour.

Top comments (0)