Skip to content

Latest commit

Β 

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RescueAI β€” Tactical AI Emergency Response & Operations Command

Vercel Python 3.10+ FastAPI React 18 Three.js Docker

An AI-driven emergency decision-support platform that transforms fragmented, contradictory disaster reports into an explainable, resource-aware, and human-authorized response plan in seconds.

πŸš€ Live Production Deployment: https://rescue-ai-mocha.vercel.app
πŸ“– Product Requirements Document: PRD.md | Download RescueAI_PRD.docx

Safety Principle: RescueAI never autonomously dispatches real emergency personnel. Every AI recommendation flows through:
Emergency Report β†’ Multi-Agent Analysis β†’ Explainable Recommendation β†’ Human Commander Review β†’ Authorized Simulated Dispatch.


🌟 Key Highlights

  • 🌐 Interactive 3D Tactical Globe: Built with Three.js and React Three Fiber. Features an auto-rotating wireframe sphere, glowing geopolitical boundary of Pakistan, strategic city hubs, 100+ orbiting telemetry particles, and real-time orbital hover HUD telemetry cards.
  • πŸ‡΅πŸ‡° Nationwide Coverage (27+ Cities): Pre-seeded nationwide dataset across Pakistan (Karachi, Lahore, Islamabad, Quetta, Peshawar, Multan, Faisalabad, Gwadar, Gilgit, Skardu, etc.) with 70+ incidents, 89+ trauma centers, and 250+ rescue fleets.
  • ⚑ 6 Specialized Autonomous Agents:
    1. Intake Agent: Classifies free-text/voice/social media reports into structured schema.
    2. Analysis Agent: Evaluates triage severity, confidence, and conflicting info detection.
    3. Resource Agent: Multi-factor matching balancing travel distance, crew readiness, and fleet capability.
    4. Hospital Agent: Live trauma, ICU, and burn center bed capacity scoring.
    5. Secondary Risk Agent: Anticipates cascading risks (gas leaks, structural collapse, aftershocks).
    6. Planning Agent: Synthesizes a prioritized, step-by-step action plan with RAG citations.
  • 🎯 Tactical Incident Registry & Filters: Multi-criteria filtering by Status (REPORTED, TRIAGED, DISPATCHED, RESOLVED), Severity (CRITICAL, HIGH, MEDIUM, LOW), and Type, paired with a dynamic results counter.
  • πŸ“ City Quick-Pick & GPS Auto-Fill: Streamlined emergency intake modal with a 29-city dropdown that automatically populates precise GPS coordinates for accurate geospatial mapping.
  • πŸ›‘οΈ DEFCON Readiness & Live Telemetry: Dynamic command-center layout with DEFCON status, live PKT timestamp, and animated telemetry indicators.
  • πŸ“± Mobile & Field Command Mode: Fully responsive tactical UX with an animated slide-out hamburger drawer menu (<= 960px), compact telemetry HUD, and touch-optimized viewports for field commanders on smartphones and tablets.

1. System Architecture

rescueai/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ agents/                   # The 6 specialized agents + orchestrator + RAG
β”‚   β”‚   β”œβ”€β”€ intake_agent.py       # Agent 1: raw text -> structured incident
β”‚   β”‚   β”œβ”€β”€ analysis_agent.py     # Agent 2: severity/urgency scoring + explainability
β”‚   β”‚   β”œβ”€β”€ resource_agent.py     # Agent 3: multi-factor resource matching
β”‚   β”‚   β”œβ”€β”€ hospital_agent.py     # Agent 4: hospital bed capacity scoring
β”‚   β”‚   β”œβ”€β”€ risk_agent.py         # Agent 5: secondary-risk & hazard anticipation
β”‚   β”‚   β”œβ”€β”€ planning_agent.py     # Agent 6: synthesizes comprehensive response plan
β”‚   β”‚   β”œβ”€β”€ knowledge_base.py     # Lightweight TF-IDF RAG retriever
β”‚   β”‚   └── orchestrator.py       # Pipeline execution & conflict resolution
β”‚   β”œβ”€β”€ routers/                  # FastAPI routers
β”‚   β”‚   β”œβ”€β”€ incidents.py          # Incident intake, analysis, approval, resolve
β”‚   β”‚   β”œβ”€β”€ misc.py               # Resources, hospitals, dashboard stats, audit, alerts
β”‚   β”‚   └── demo.py               # One-click crisis scenario loader
β”‚   β”œβ”€β”€ knowledge_base/           # RAG source documents (markdown guidelines)
β”‚   β”œβ”€β”€ tests/                    # Unit & integration test suite (13 passing tests)
β”‚   β”œβ”€β”€ models.py                 # SQLAlchemy ORM (9 tables)
β”‚   β”œβ”€β”€ schemas.py                # Pydantic request/response validation schemas
β”‚   β”œβ”€β”€ database.py               # SQLite / PostgreSQL engine config
β”‚   β”œβ”€β”€ seed_pakistan.py          # Nationwide data seeder (27+ cities, 70+ incidents)
β”‚   └── main.py                   # FastAPI application & static bundle server
β”œβ”€β”€ frontend/
β”‚   └── src/
β”‚       β”œβ”€β”€ components/
β”‚       β”‚   β”œβ”€β”€ MapView.jsx       # 3D Tactical Globe (Three.js/R3F) & 2D Tactical Grid
β”‚       β”‚   β”œβ”€β”€ ParticleBackground.jsx # Ambient canvas particle dust
β”‚       β”‚   β”œβ”€β”€ PageTransition.jsx# Smooth Framer Motion page navigation
β”‚       β”‚   β”œβ”€β”€ ResponsePlanPanel.jsx # AI recommendation & explainability inspector
β”‚       β”‚   β”œβ”€β”€ SeverityBadge.jsx # Color-coded tactical severity indicators
β”‚       β”‚   └── StatCard.jsx      # Telemetry metric cards with animated counters
β”‚       β”œβ”€β”€ pages/                # Command Center, Incidents, Map, Fleets, Hospitals, Analytics
β”‚       β”œβ”€β”€ api/client.js         # Axios API client wrapper
β”‚       └── styles.css            # Dark tactical EOC design system
β”œβ”€β”€ Dockerfile                    # Multi-stage production container
└── docker-compose.yml

Multi-Agent Pipeline Flow

[Raw Emergency Reports] ────────► [Agent 1: Intake]
                                          β”‚
                                          β–Ό
                               [Structured Incident]
                                          β”‚
             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β–Ό                            β–Ό                            β–Ό
   [Agent 2: Analysis]           [Agent 5: Risk]             [Conflict Detection]
   (Severity & Confidence)     (Secondary Hazards)         (Conflicting Eyewitnesses)
             β”‚                            β”‚                            β”‚
             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                          β–Ό
             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β–Ό                                                         β–Ό
   [Agent 3: Resources]                                      [Agent 4: Hospitals]
   (Fleets / SAR / Fire)                                     (Trauma & ICU Beds)
             β”‚                                                         β”‚
             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                          β–Ό
                             [Agent 6: Response Planning]
                             (RAG Knowledge Base Citations)
                                          β”‚
                                          β–Ό
                         [AI Recommendation & Action Steps]
                                          β”‚
                           ═══════════════════════════════
                           πŸ”΄ HUMAN COMMANDER APPROVAL GATE
                           ═══════════════════════════════
                                          β”‚
                                          β–Ό
                        [Simulated Dispatch + Audit Ledger]

2. Quick Start

Option A β€” Run Unified App (Recommended)

Run both the FastAPI backend and built React frontend together on port 7860:

# 1. Clone the repository
git clone https://github.com/lizzz-dev/RescueAI.git
cd RescueAI

# 2. Setup Python environment
python -m venv venv
# On Windows:
.\venv\Scripts\activate
# On Linux/macOS:
source venv/bin/activate

# 3. Install dependencies
pip install -r backend/requirements.txt

# 4. Seed nationwide Pakistan dataset (70+ incidents, 89 hospitals, 250 fleets across 27 cities)
python backend/seed_pakistan.py

# 5. Build frontend
cd frontend
npm install
npm run build
cd ..

# 6. Launch server
python -m uvicorn backend.main:app --host 127.0.0.1 --port 7860

Open your browser to: http://127.0.0.1:7860

  • Web Application: http://127.0.0.1:7860
  • Interactive Swagger API Docs: http://127.0.0.1:7860/docs

Option B β€” Docker

docker compose up --build
  • App: http://localhost:7860
  • Swagger API Docs: http://localhost:7860/docs

Option C β€” Development Mode (Hot Reload)

Backend Terminal:

python -m uvicorn backend.main:app --host 127.0.0.1 --port 7860 --reload

Frontend Terminal:

cd frontend
npm run dev
# Running at http://localhost:5173 (proxies API requests to port 7860)

3. Production Cloud Deployment: Vercel

RescueAI is fully configured for continuous, zero-cost deployment on Vercel:

  • Frontend Client: High-performance React 18 SPA built with Vite (frontend/dist & public/).
  • Serverless API Backend: Native Python 3.11 FastAPI runtime handled via api/index.py, executing all 6 autonomous agents, SQLAlchemy ORM, and RAG knowledge retrieval.
  • Inter-Agency Pre-Seeded Dataset: Automatically seeds 70+ incidents, 89+ trauma hospitals, and 250+ rescue fleet units across 27+ districts on initial load.
  • Production URL: https://rescue-ai-mocha.vercel.app

Automated CI/CD

Every commit pushed to GitHub (main) automatically triggers Vercel to build the React application and deploy the serverless Python endpoints with zero manual intervention.


4. API Reference

Method Endpoint Purpose
POST /api/incidents Submit emergency text report β†’ Agent 1 structures it
POST /api/incidents/{id}/reports Submit secondary eyewitness report (triggers conflict detection)
GET /api/incidents List all incidents (supports filtering by status & severity)
GET /api/incidents/{id} Retrieve incident detail and linked eyewitness reports
POST /api/incidents/{id}/analyze Execute Agents 2–6 to synthesize response plan
GET /api/incidents/{id}/response-plan Fetch latest AI response recommendation
POST /api/incidents/{id}/approve Human Commander Approval β†’ flips fleet status to DISPATCHED
POST /api/incidents/{id}/reject Reject AI proposal with commander reason
POST /api/incidents/{id}/resolve Mark incident fully resolved
GET /api/resources Rescue fleets inventory (Ambulances, SAR, Fire, Utility)
GET /api/hospitals Hospital registry with ER & ICU bed counts
GET /api/dashboard/stats High-level operations telemetry numbers
GET /api/dashboard/analytics Incident distribution, severity breakdown, and fleet utilization
GET /api/audit-logs Immutable audit ledger tracking all AI and commander actions
GET /api/notifications Real-time dispatch alerts stream
POST /api/demo/load-scenario Loads live crisis scenario with conflicting eyewitness reports

5. Automated Test Suite

RescueAI includes a comprehensive test suite exercising agent logic, scoring formulas, edge cases, and end-to-end pipeline execution:

# Run backend tests
cd backend
python -m unittest tests.test_agents -v

13 Passing Tests Cover:

  • Incident type keyword extraction and edge cases
  • Severity and urgency mathematical scoring
  • Conflicting report discrepancy detection (casualty count variances)
  • Workload-aware fleet matching (not just closest, but available and capable)
  • Trauma hospital capacity weighting and ICU availability
  • Gap reporting when zero resources are nearby
  • RAG TF-IDF knowledge base document retrieval
  • Full multi-agent end-to-end integration

6. What's Real vs. Simulated

Component Status Details
AI Agents Real & Deterministic 6 rule-based, explainable scoring agents; no hallucination or hidden logic
Geospatial Mapping Real Coordinates 3D globe coordinates mapped to real Pakistani cities & boundaries
Fleet Dispatch Simulated Fleet status updates in SQLite database; no real-world sirens triggered
Hospital Comms Simulated Logged to notifications table for operational demonstration
RAG Knowledge Base Real Retrieval TF-IDF vector retrieval over curated disaster response markdown manuals

7. License & Credits

Built for emergency response decision-support and hackathon demonstrations.
Created by Team RescueAI // Tactical EOC Systems.

About

Autonomous Multi-Agent Tactical Emergency Operations & Disaster Response Command Center with 3D Geospatial Visualization and Human-In-The-Loop Clearance.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages