Real-time AI-powered emergency reporting system for Kenya. Citizens geo-tag incidents, an AI risk engine scores severity, and responders get live WebSocket alerts via a command dashboard. Built with NestJS, Next.js, React-Leaflet, Prisma, and Supabase.
🚨 Dharura AI
Real-time AI-powered emergency intelligence system for Kenya.
"Dharura" means Emergency in Swahili.
---
## 📖 Overview
Dharura AI transforms citizens into **geo-sensors** — enabling anyone to drop a geotagged emergency pin on a live map, describe the incident, and have it instantly classified by an AI risk engine. Severity alerts are then dispatched in real-time to a responder command center via WebSockets.
Built for the unique emergency response landscape of Kenya, Dharura AI bridges the gap between citizens witnessing emergencies and first responders who need actionable, prioritized intelligence.
---
## ✨ Features
- **🗺️ Interactive Live Map** — React-Leaflet powered map centered on Kenya with real-time incident pins
- **🤖 AI Risk Engine** — Scores emergencies based on keyword triggers, incident type, and spatial-temporal clustering (+15 confidence per nearby event within 2km/10 minutes)
- **⚡ Real-time WebSocket Dispatch** — Socket.IO gateway broadcasts new reports instantly to all connected responders
- **🎯 Severity Classification** — Automatically categorizes incidents as `LOW`, `WARNING`, or `CRITICAL`
- **🧑💼 Responder Command Center** — JWT-secured dashboard at `/responder` for acknowledging, routing, and resolving incidents
- **🌙 Light / Dark Mode** — Full theme support via `next-themes` with glassmorphism UI
- **🔐 Auth System** — Hand-rolled JWT + Passport + bcrypt authentication for responders
---
## 🏗️ Architecture
```
Dharura_AI/
├── backend/ # NestJS API + WebSocket Gateway
└── frontend/ # Next.js App Router + React-Leaflet Map
```
### Backend — NestJS (Port 3001)
| Module | Description |
|--------|-------------|
| **Auth** | JWT-based authentication with Passport local strategy and bcrypt password hashing |
| **Reports** | REST API for creating and managing emergency reports, houses the AI Risk Engine |
| **Events Gateway** | Socket.IO gateway that emits `newReport` events to all connected client …