Real-Time Emergency Coordination Engine

Every second
is a distributed
systems problem

Vanguard-EMS transforms ambulance routing in chaotic Indian urban traffic into a high-concurrency coordination engine — combining AI vision, shared state, and dynamic signal control.

▶ View Live Demo ⭐ Star on GitHub
3x
Faster Response Time
Concurrent Ambulances
~50ms
Signal Propagation
0
Hard Rule Violations Allowed
// live_demo.py

Watch the system coordinate in real time

The simulator feeds live GPS positions to the backend, which calculates green-wave corridors and clears intersections ahead of the ambulance.

http://localhost:8000 — Vanguard Dashboard
LIVE
AMB-014
EN ROUTE
📍 Hamidia Rd → MP Nagar
🏥 Target: AIIMS Bhopal
4:22 ETA (MIN)
Hamidia × DB Mall GREEN
MP Nagar × Zone II GREEN
Arera Colony Sq. QUEUING
Bittan Market NORMAL
Hamidia × DB Mall MP Nagar × Zone II Arera Colony Hamidia Rd + 🏥 AIIMS Bhopal
// system_log
09:14:22 AMB-014 position ingested
09:14:22 ArmorIQ: route validated
09:14:23 Green-wave: Hamidia × DB Mall
09:14:23 Green-wave: MP Nagar × Zone II
09:14:24 Gemini: roadblock detected [C-17]
09:14:24 Rerouting via Arera bypass...
// features.list

Everything needed to clear the path

Each component was designed to solve a specific failure mode of conventional ambulance coordination in dense urban environments.

📡
Real-Time GPS Ingestion
Captures live ambulance trajectories as they happen, feeding continuous position updates into the coordination engine with sub-second latency.
// simulator/ambulance_driver.py
👁️
AI Roadblock Detection
Environment snapshots are processed by Google Gemini to identify physical obstacles, congestion, and road anomalies that GPS alone cannot detect.
// Google Gemini Vision API
🔄
Distributed Shared State
A SpacetimeDB-inspired synchronization layer ensures every node has a consistent real-time world view, eliminating coordination conflicts between services.
// backend/state_manager.py
🛡️
ArmorIQ Rule Validation
Every proposed route is validated against hard safety constraints. No path can be activated if it violates a hard rule — safety is non-negotiable.
// backend/armoriq.py
🚦
Dynamic Green-Wave Signals
Traffic signals along the ambulance corridor are pre-cleared in sequence, creating a smooth green corridor that minimizes stops and delay.
// backend/signal_controller.py
📊
Metrics & Observability
All routing decisions, response times, and system events are logged to MongoDB Atlas, enabling post-incident analysis and continuous improvement.
// MongoDB Atlas
// system_architecture

Three layers that patch reality

The architecture maps directly to how emergency response actually fails — and fixes each failure mode.

LAYER 01 /
Ingest
The Reality
Captures raw inputs from the physical world: GPS streams from ambulance units and environment snapshots from cameras. Gemini Vision turns images into structured obstacle data.
FastAPI WebSocket Gemini Vision GPS Simulator
LAYER 02 /
Process
The Coordination
Maintains globally consistent state across all nodes. Every proposed action is validated by ArmorIQ before execution — ensuring the system never enters an unsafe state.
SpacetimeDB-inspired State ArmorIQ Engine Path Planner
LAYER 03 /
Output
The Patch
Actuation layer that sends green-wave commands to signal controllers in sequence and logs all decisions to MongoDB for accountability and analytics.
Signal Controller API MongoDB Atlas Live Dashboard
// tech_stack.yml

Built on battle-tested components

Every technology choice was made to maximize throughput and minimize latency on constrained infrastructure.

Layer Technology Purpose Type
Backend Python 3.10 + FastAPI Coordination engine, WebSocket server, REST API CORE
Frontend HTML / CSS / JavaScript Real-time monitoring dashboard CORE
AI / Vision Google Gemini API Roadblock detection from environment images AI
Database MongoDB Atlas Performance metrics, routing decisions, event logs DATABASE
Infra Docker + Docker Compose Containerized service orchestration INFRA
Simulation Python Ambulance Driver Generates realistic GPS trajectories for testing CORE
// getting_started

Up and running in 4 steps

Docker handles all the dependencies. You only need a Gemini API key.

01
Clone the repo
git clone https://github.com/\nAadi7171/Vanguard-ems.git cd Vanguard-ems
02
Set environment variables
# Create .env in project root GEMINI_API_KEY=your_key_here MONGO_URI=mongodb://mongo:27017/
03
Start all services
docker-compose up --build # Or on Windows: run.bat
04
Open the dashboard
http://localhost:8000 # Backend → :8000 # MongoDB → :27017 # Simulator → runs headlessly
View on GitHub ↗ ⬇ Download ZIP