A production-grade web application for real-time ambulance tracking, intelligent routing, traffic signal preemption, and emergency vehicle coordination. Built for smart city infrastructure.
- Python 3.10+ installed
# 1. Install dependencies
pip install fastapi uvicorn websockets python-jose[cryptography] python-multipart aiofiles
# 2. Start the server
python backend/app.py
# 3. Open in browser
# → http://localhost:3000| Role | Username | Password |
|---|---|---|
| Admin | admin |
admin123 |
| Driver | driver1 |
driver123 |
- Live ambulance tracking on dark-themed map (CARTO + OpenStreetMap)
- 5 simulated ambulances moving along realistic Chennai routes
- 8 real hospitals with capacity and specialty data
- 20 traffic signals with preemption visualization
- 80+ nearby vehicles that yield to ambulances
- Dynamic traffic congestion display
- JWT authentication with role-based access (admin/driver)
- WebSocket real-time updates (1 update/second)
- Intelligent routing with traffic-aware pathfinding
- Nearest hospital detection with bed availability
- Green corridor creation — traffic signals preempted within 500m
- Vehicle alert system — nearby vehicles alerted within 300m
- Emergency dispatch — manually dispatch new ambulances
- Ambulance GPS movement along waypoints
- Dynamic traffic congestion (changes every 3 seconds)
- Traffic signal cycling (red/yellow/green)
- Nearby vehicle movement with yielding behavior
- Adjustable simulation speed (0.5x to 3x)
┌─────────────────────────────────────────────────────┐
│ Web Dashboard │
│ Leaflet Map | Real-Time Tracking | Analytics │
└──────────────────────┬──────────────────────────────┘
│ WebSocket + REST
┌──────────────────────▼──────────────────────────────┐
│ FastAPI Backend │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌─────────┐ │
│ │ Routing │ │ Traffic │ │ Notify │ │ Signal │ │
│ │ Service │ │ Analysis │ │ Service │ │ Control │ │
│ └──────────┘ └──────────┘ └──────────┘ └─────────┘ │
│ Simulation Engine │
├──────────────────────────────────────────────────────┤
│ In-Memory Store (PostgreSQL + Redis ready) │
└──────────────────────────────────────────────────────┘
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/login |
JWT authentication |
| GET | /api/ambulances |
List all ambulances |
| GET | /api/hospitals |
List all hospitals |
| GET | /api/hospitals/nearest?lat=&lng= |
Find nearest hospital |
| GET | /api/traffic/segments |
Traffic congestion data |
| GET | /api/traffic/signals |
Traffic signal states |
| GET | /api/alerts |
Emergency alerts |
| GET | /api/stats |
System statistics |
| POST | /api/simulation/speed |
Change sim speed |
| POST | /api/simulation/dispatch |
Dispatch new ambulance |
| WS | /ws |
WebSocket real-time feed |
docker-compose up --buildThis starts: PostgreSQL, Redis, Backend, Nginx (port 80)
| Component | Technology |
|---|---|
| Backend | Python + FastAPI |
| Real-Time | WebSockets |
| Frontend | Vanilla HTML/CSS/JS |
| Maps | Leaflet + OpenStreetMap/CARTO |
| Auth | JWT |
| Production DB | PostgreSQL |
| Cache | Redis |
| Deployment | Docker + Nginx |
LIFELANE/
├── backend/
│ ├── app.py # Main application (FastAPI + simulation)
│ ├── requirements.txt # Python dependencies
│ ├── config/index.js # Config reference
│ ├── middleware/ # Auth, error handling, rate limiting
│ └── utils/ # Geo utilities, logger
├── frontend/
│ ├── index.html # Dashboard with real-time map
│ └── login.html # Authentication page
├── database/
│ ├── migrations/001_initial.sql # PostgreSQL schema
│ └── seeds/seed.sql # Initial data
├── nginx/nginx.conf # Reverse proxy config
├── docker-compose.yml # Full stack deployment
├── Dockerfile.backend # Backend container
├── .env # Environment variables
└── README.md # This file
MIT