Skip to content

Peersheik/LIFELANE-

 
 

Repository files navigation

LifeLane - Real-time Emergency Vehicle Priority System

A production-grade web application for real-time ambulance tracking, intelligent routing, traffic signal preemption, and emergency vehicle coordination. Built for smart city infrastructure.

Quick Start

Prerequisites

  • Python 3.10+ installed

Run Locally (Fastest)

# 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

Login Credentials

Role Username Password
Admin admin admin123
Driver driver1 driver123

Features

Real-Time Dashboard

  • 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

Core System

  • 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

Simulation Engine

  • 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)

Architecture

┌─────────────────────────────────────────────────────┐
│                  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)          │
└──────────────────────────────────────────────────────┘

API Endpoints

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 Deployment

docker-compose up --build

This starts: PostgreSQL, Redis, Backend, Nginx (port 80)

Tech Stack

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

Project Structure

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

License

MIT

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • HTML 77.5%
  • Python 19.8%
  • JavaScript 2.7%