A Living City Replica Powered by Live Weather, AI Predictions & Real Geospatial Data
CrisisFlow is a digital twin platform that creates a real-time, 3D virtual replica of Bangalore for crisis management. It integrates live weather data from Open-Meteo, AI-powered flood predictions with STGCN, and actual city geospatial data to coordinate emergency response across government, police, hospitals, fire departments, and citizens during urban disasters.
A 3D Digital Twin City for Crisis Response
When a crisis strikesโlike urban floodingโcoordination between government, police, hospitals, and fire departments is critical. CrisisFlow solves this by creating a living 3D replica of the city that combines:
- Real 3D City Map: Authentic Bangalore with actual building footprints, roads, and water networks from OpenStreetMap
- Live Weather Integration: Real-time rainfall & precipitation data (Open-Meteo API, refreshed every 30 seconds)
- AI-Powered Flood Prediction: STGCN neural network forecasts water spread on the digital twin
- Unified Emergency Dashboard: Multi-role command center for government, police, hospitals, fire, and citizens
- Real-Time Resource Coordination: Track and dispatch resources across the city instantly
- Interactive 3D/2D Views: Immersive visualization of crisis zones and emergency response
Think of it as watching your city in real-time while an AI predicts what happens nextโand coordinating every emergency responder with one integrated platform.
- Live Geospatial Map: Real Bangalore city with actual building footprints, water networks, and terrain from OpenStreetMap
- 3D/2D Visualization: High-performance Deck.gl rendering for immersive city view
- AI Flood Forecasting: STGCN neural network predicts water spread with live weather data
- Live Weather Integration: Real-time rainfall & precipitation from Open-Meteo API (updated every 30 seconds)
- Real-time Simulation: Adjustable flood intensity and depth thresholds on the digital twin
- Hybrid Approach: Combines real geospatial data + AI predictions + live environmental sensors
Each stakeholder sees a tailored view:
- ๐ Government (BBMP): Full system overview, control room access
- ๐ก Police: Traffic management, road blocks, evacuation routes
- ๐ฅ Hospital Network: Capacity planning, ambulance fleet management
- ๐ Fire Department: Resource deployment, incident response
- ๐ค Citizens: Report incidents, access safety information
- Incidents: Track active crises with severity, location, and status
- Alerts: System-wide notifications for critical events
- Resources: Manage ambulances, fire trucks, personnel, and equipment
- Dispatches: Coordinate response teams to incidents
- Citizen Reports: Crowdsource crisis information with location data
- Hospitals: Monitor capacity and capability status
- Road Blocks: Manage traffic control and evacuation routes
- Triage Sessions: Medical resource coordination
- Real Geospatial Base: Authentic Bangalore city with building geometries, roads systems
- 3D/2D Toggle: Switch between immersive 3D view and 2D tactical view
- Live Layer Stacking: Buildings, water networks, flood zones, resource locations all on one map
- Dynamic Flood Overlay: Animated water progression based on AI predictions + real weather
- Interactive Controls: Click to place markers, draw evacuation routes, deploy resources on the digital twin
- Real-time Indicators: Weather status, traffic conditions, incident markers update live
- Find optimal paths for emergency vehicles
- Avoid flooded areas automatically
- Calculate nearest hospitals, fire stations, or resources
- Real-time routing updates as conditions change
backend/
โโโ main.py # FastAPI entry point
โโโ database.py # MongoDB connection (Motor async)
โโโ api.py # STGCN digital twin API
โโโ models/ # Data models (Incident, Alert, Resource, etc.)
โโโ routers/ # REST API endpoints
โโโ train.py # STGCN model training
โโโ seed.py # Sample data initialization
Key Technology Stack:
- FastAPI: High-performance async web framework
- MongoDB: Document database for crisis data
- PyTorch + PyTorch Geometric: Deep learning for flood prediction
- OSMnx + GeoPandas: Geospatial data processing
- Networkx: Graph analytics for routing
frontend/
โโโ src/
โ โโโ App.tsx # Main application component
โ โโโ components/ # UI components (MapView, Dashboards, Panels)
โ โโโ hooks/ # Custom React hooks
โ โ โโโ useDashboard # MongoDB data fetching
โ โ โโโ useFloodSimulation # AI simulation control
โ โ โโโ useRouting # Route calculation
โ โ โโโ useWeather # Weather integration
โ โ โโโ useFloodClustering # Spatial clustering
โ โโโ constants/ # Role configs, view states, UI settings
โ โโโ types/ # TypeScript interfaces
โโโ vite.config.ts # Build configuration
Key Technology Stack:
- React 19: Modern UI framework
- TypeScript: Type-safe frontend development
- Deck.gl: High-performance geospatial visualization
- MapLibre GL: Open-source map rendering
- Vite: Fast development build tool
- Python 3.9+
- Node.js 18+
- MongoDB (local or Atlas)
- GPU (optional, but recommended for STGCN)
-
Clone the repository
cd crisisflow/backend -
Install Python dependencies
pip install -r requirements.txt
-
Configure environment Create a
.envfile:MONGODB_URL=mongodb://localhost:27017 DATABASE_NAME=crisisflow WEATHER_API_URL=https://api.open-meteo.com/v1/forecast?latitude=12.935&longitude=77.645¤t=rain,precipitation&timezone=Asia/Kolkata -
Create a virtual environment (optional but recommended)
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Start the backend
python main.py
Server runs on
http://localhost:8000- API docs:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
- API docs:
-
Navigate to frontend
cd ../frontend -
Install dependencies
npm install
-
Start development server
npm run dev
Opens at
http://localhost:5173 -
Build for production
npm run build
GET /api/dashboard/{role}- Fetch dashboard data for a specific roleGET /api/dashboard/stats/{role}- Role-specific statistics
GET /api/incidents- List all incidentsPOST /api/incidents- Create new incidentGET /api/alerts- Fetch active alertsPOST /api/alerts- Issue new alert
GET /api/resources- List available resourcesGET /api/dispatches- View active dispatch assignmentsPOST /api/dispatches- Create dispatch order
GET /api/zones- Get flood/administrative zonesGET /api/hospitals- Hospital locations and capacityGET /api/road-blocks- Active traffic control points
GET /api/citizen-reports- Crowd-sourced crisis reportsPOST /api/citizen-reports- Submit incident report
GET /api/weather- Get real-time rainfall (Open-Meteo API integration)POST /api/simulate-flood- Run STGCN flood prediction with current weatherGET /api/simulation/{id}- Get simulation results
The Digital Twin is a real-time virtual replica of Bangalore that combines:
- Real geospatial data (actual city geometry)
- Live weather feeds (real rainfall from Open-Meteo API)
- AI predictions (STGCN neural network)
- 3D visualization (immersive city view)
Process:
- Real Geospatial Foundation: Base map loaded with actual buildings, roads, water networks from OpenStreetMap
- Live Weather Input: Real rainfall data from Open-Meteo API (refreshed every 30 seconds)
- Graph Construction: City represented as graph where nodes = zones/buildings, edges = water flow paths
- STGCN Prediction: AI model uses past flood patterns + current weather to forecast water spread
- Temporal Modeling: Sequences of past states + current conditions โ minute-by-minute predictions
- 3D Visualization: Predictions render as animated water levels on the real city map
Data Integration:
- Real-time: Live weather (Open-Meteo API), incident reports, resource locations
- Real Geospatial: Building footprints, drainage systems, terrain elevation (OpenStreetMap)
- Historical: Past flood events and weather records (model training data)
- Result: A living, breathing digital replica that mirrors reality
- View system overview and resource allocation
- Monitor all incidents and dispatches
- Access triage and medical capacity data
- Control simulation parameters and view forecasts
- See assigned zones and active road blocks
- Manage traffic control and evacuation routes
- Respond to incidents with tactical routes
- Coordinate with other services
- Monitor bed capacity and triage queues
- Track ambulance fleet and assignments
- Receive incident alerts for incoming casualties
- Plan resource deployment
- Report crisis observations with location
- Access safety information and evacuation zones
- Receive alerts and emergency notifications
- Find nearest hospital or emergency services
crisisflow/
โโโ backend/ # FastAPI server + AI models
โ โโโ main.py # Application entry point
โ โโโ database.py # MongoDB setup
โ โโโ api.py # STGCN API endpoints
โ โโโ train.py # Model training script
โ โโโ models/ # Pydantic data schemas
โ โ โโโ incident.py
โ โ โโโ alert.py
โ โ โโโ resource.py
โ โ โโโ dispatch.py
โ โ โโโ hospital.py
โ โ โโโ citizen_report.py
โ โ โโโ road_block.py
โ โ โโโ triage_session.py
โ โ โโโ zone.py
โ โโโ routers/ # REST API route handlers
โ โ โโโ incidents.py
โ โ โโโ alerts.py
โ โ โโโ resources.py
โ โ โโโ dispatches.py
โ โ โโโ hospitals.py
โ โ โโโ citizen_reports.py
โ โ โโโ road_blocks.py
โ โ โโโ triage.py
โ โ โโโ zones.py
โ โ โโโ dashboard.py
โ โโโ requirements.txt # Python dependencies
โ โโโ *.json, *.geojson # Geospatial data files
โ
โโโ frontend/ # React TypeScript app
โ โโโ src/
โ โ โโโ App.tsx # Root component
โ โ โโโ components/ # UI components
โ โ โ โโโ MapView.tsx
โ โ โ โโโ ControlPanel.tsx
โ โ โ โโโ GovDashboard.tsx
โ โ โ โโโ RolePanel.tsx
โ โ โ โโโ Timeline.tsx
โ โ โ โโโ Topbar.tsx
โ โ โ โโโ RainEffect.tsx
โ โ โโโ hooks/ # Custom React hooks
โ โ โโโ constants/ # Configuration
โ โ โโโ types/ # TypeScript interfaces
โ โ โโโ assets/ # Images, icons
โ โโโ package.json
โ โโโ vite.config.ts
โ
โโโ Crisis_flow/ # Original prototype (legacy)
Backend:
MONGODB_URL=mongodb://localhost:27017 # MongoDB connection string
DATABASE_NAME=crisisflow # Database name
STGCN_MODEL_PATH=./stgcn_checkpoint.pth # AI model checkpoint
Frontend: Set API base URL in your component configuration or environment:
VITE_API_URL=http://localhost:8000
- incident_id: Unique identifier
- incident_type: flood, traffic, medical, etc.
- zone_id: Geographic zone affected
- location_name: Human-readable location
- severity: critical, high, moderate, low
- status: active, resolved, escalated
- assigned_resources: List of resource IDs
- notes: Additional context
- reported_at, resolved_at: Timestamps
- resource_id: Unique identifier
- resource_type: ambulance, fire_truck, personnel, etc.
- location: Current lat/lon
- status: available, deployed, standby
- capacity: Number of personnel or items
- zone_id: Assigned zone
- alert_id: Unique identifier
- alert_type: system, weather, incident, resource
- severity: critical, high, medium, low
- message: Alert text
- recipient_role: gov, police, hospital, fire, citizen
- created_at: Timestamp
# Backend
cd backend
pytest
# Frontend
cd ../frontend
npm run lintcd backend
python train.py --epochs 100 --batch-size 32cd backend
python clear_data.py
python seed.pyBackend won't start:
- Ensure MongoDB is running:
mongod - Check
.envfile is configured correctly - Verify port 8000 is not in use
Frontend won't connect to backend:
- Ensure backend is running on
http://localhost:8000 - Check CORS settings in
main.py - Verify network connectivity
Flood simulation not working:
- Check STGCN model file exists:
backend/stgcn_checkpoint.pth - Verify geospatial data files are loaded (GeoJSON, OSM files)
- Monitor GPU availability:
nvidia-smi
- Backend: FastAPI with async/await for concurrent request handling
- Frontend: Deck.gl for high-performance 3D rendering; React hooks for efficient re-renders
- Simulation: PyTorch GPU acceleration for neural network inference
- Database: MongoDB indexes on frequently queried fields (zone_id, incident_type, status)
| Layer | Technology | Why? |
|---|---|---|
| Web Framework | FastAPI | Type-safe, async, auto-documentation |
| Database | MongoDB + Motor | Flexible schema, async driver |
| AI/ML | PyTorch Geometric | Graph neural networks for spatial data |
| Frontend | React + TypeScript | Component reusability, type safety |
| 3D Mapping | Deck.gl | 60fps 3D rendering for real geospatial data |
| Weather API | Open-Meteo | Free, real-time rainfall data for Bangalore |
| Build | Vite | 10x faster than Webpack |
| Role | Focus | Key Features |
|---|---|---|
| Government | System overview, coordination | All dashboards, full control |
| Police | Traffic, evacuation, security | Road blocks, routing, zone management |
| Hospital | Medical response, triage | Capacity planning, ambulance fleet |
| Fire | Resource deployment | Equipment tracking, incident response |
| Citizen | Safety, reporting | Report submission, alerts, guidance |
- Implement role-based access control (RBAC) in API routes
- Authenticate users before dashboard access
- Sanitize citizen reports for spam/misinformation
- Use HTTPS in production
- Secure MongoDB with credentials and IP whitelisting
- Real-time SMS/push notifications
- Machine learning for incident severity prediction
- Integration with emergency 911 systems
- Multi-language support
- Mobile app (React Native)
- Historical analytics and reporting
- Predictive resource pre-positioning
- Blockchain for incident audit trails
[Add your license here]
Contributions welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
For questions or issues:
- Open an issue on GitHub
- Check existing documentation in
/docs - Contact the development team
CrisisFlow: Turning Crisis Data into Coordinated Action ๐จ๐ก