Skip to content

prabhatbhatiaa/Pravah

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

29 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Data Driven Real-Time Delhi Flood Risk Monitoring & Management System

image

Live Demo: https://pravah-proj.vercel.app/

A comprehensive, data-driven dashboard designed to help city administrators monitor, predict, and manage urban flood risks in real-time. It integrates rainfall data, drainage capacity, and citizen complaints to generate dynamic risk scores for 250 municipal wards in Delhi.

✨ Features

  • Real-Time Risk Engine β€” Dynamic algorithm calculating risk scores (0-100) based on rainfall (mm), drainage capacity (%), and active complaints.
  • Interactive City Map β€” Visualizes 250 wards with color-coded risk markers (Red/Yellow/Green) and pulse animations for high-risk zones.
  • Dual-Role Interface β€”
  1. Citizen Portal: Submit geo-tagged waterlogging complaints bala
  2. Admin Dashboard: Monitor KPIs, view ward-level analytics, and update infrastructure status.
  • Professional Visualization β€” Clean, government-grade UI with data-dense tables and actionable insights.
  • Dual Themes β€” Both light mode and dark mode implemented to suit all users.
  • Simulated IoT Data β€” Realistic, synchronized datasets for Rainfall and Drainage across all Delhi zones.

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  IoT Sensors β”‚      β”‚   Citizen    β”‚      β”‚    Admin     β”‚
β”‚ (Rain/Drain) β”‚      β”‚  Reporting   β”‚      β”‚   Actions    β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                     β”‚                     β”‚
       β–Ό                     β–Ό                     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Data Aggregation Layer                 β”‚
β”‚              (CSV / In-Memory State Store)               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Risk Engine (Python)                  β”‚
β”‚   Formula: (Drainage * 0.5) + (Rain * 0.3) + (Logs * 0.2)β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   REST API   │◀───▢│   Frontend   β”‚β—€ ──▢│ Leaflet Maps β”‚
β”‚  (FastAPI)   β”‚      β”‚  (HTML/JS)   β”‚      β”‚ (Visuals)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Project Structure

Pravah/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ data/
β”‚   β”‚   β”œβ”€β”€ wards.csv           # 250 Ward Geo-coordinates & Zones
β”‚   β”‚   β”œβ”€β”€ rainfall.csv        # Live Rainfall Data (mm)
β”‚   β”‚   β”œβ”€β”€ drainage.csv        # Infrastructure Capacity (%)
β”‚   β”‚   └── complaints.csv      # Citizen Report Log
β”‚   β”‚
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ main.py             # FastAPI Entry Point & CORS
β”‚   β”‚   β”œβ”€β”€ config.py           # Settings & Constants
β”‚   β”‚   β”œβ”€β”€ models.py           # Pydantic Schemas
β”‚   β”‚   └── services/
β”‚   β”‚       β”œβ”€β”€ api.py          # API Route Handlers
β”‚   β”‚       β”œβ”€β”€ data_loader.py  # CSV Parsing & Merging Logic
β”‚   β”‚       β”œβ”€β”€ risk_engine.py  # Risk Calculation Algorithm
β”‚   β”‚       └── admin_ops.py    # Admin Action Logic
β”‚   β”‚
β”‚   └── requirements.txt        # Python Dependencies
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ css/
β”‚   β”‚   β”œβ”€β”€ styles.css          # Main Theme & Responsive Rules
β”‚   β”‚   β”œβ”€β”€ admin.css           # Dashboard Specific Styles
β”‚   β”‚
β”‚   β”œβ”€β”€ js/
β”‚   β”‚   β”œβ”€β”€ common.js           # API Config & Utilities
β”‚   β”‚   β”œβ”€β”€ admin.js            # Dashboard Logic & Maps
β”‚   β”‚   β”œβ”€β”€ dashboard.js        # Citizen Map & Reporting
β”‚   β”‚   β”œβ”€β”€ complaints.js       # Form Handling
β”‚   β”‚   └── login.js            # Auth Logic
β”‚   β”‚
β”‚   β”œβ”€β”€ index.html              # Landing Page
β”‚   β”œβ”€β”€ admin.html              # Main Admin Control Room
β”‚   β”œβ”€β”€ dashboard.html          # Citizen Reporting Page
β”‚   └── login.html              # Admin Login Gate
β”‚   └── about.html              # About The Project
β”‚
└── README.md

πŸš€ Quick Start

Prerequisites

  • Python 3.9+
  • Web Browser(Desktop Mode for now)
  • Git

1. Clone & Setup

# Clone the repository
git clone https://github.com/prabhatbhatiaa/pravah.git
cd pravah

# Backend Setup
cd backend
python -m venv venv
.\venv\Scripts\activate  # Windows
# source venv/bin/activate # Mac/Linux

# Install dependencies
pip install -r requirements.txt

2. Runs the Backend

# Start Uvicorn Server
uvicorn src.main:app --reload

3. Run the Frontend

1. Open the frontend folder.
2. Open index.html via Live Server (VS Code Extension) or simply double-click it.
3. Important: Ensure frontend/js/common.js points to http://localhost:8000 for local development.

πŸ” System Access

  1. Landing Page β€” : Public access to project overview.
  2. About Us Page β€” : Public accessto the details of the project.
  3. Citizen Dashboard β€” Public access to view map & report issues.
  4. Admin Portal β€” : Restricted access via Session Storage.

πŸ“‹ API Endpoints

Public

  • GET /api/wards β€” Returns full GeoJSON of all 250 wards with calculated risk.
  • GET /api/risk-summary β€” Returns aggregate stats (High Risk count, Total Wards).
  • POST /api/complaint β€” Submit a new citizen complaint.

Admin

  • GET /api/admin/overview β€” Returns detailed tabular data sorted by risk.
  • POST /api/admin/update-drainage β€” Update drainage capacity for a specific ward.

🧠 Risk Calculation Logic

The Risk Engine (risk_engine.py) calculates a score (0-100) for every ward in real-time

  1. Drainage Factor (50%): Inverse of capacity. Lower drainage = Higher risk.
  2. Rainfall Factor (30%): Normalized against a critical threshold (150mm).
  3. Complaint Factor (20%): Active complaints boost the risk score significantly.
Final Score = (Drainage_Risk * 0.5) + (Rainfall_Risk * 0.3) + (Complaint_Risk * 0.2)

πŸ› οΈ Technology Stack

Backend:

  • FastAPI β€” High-performance Python framework.
  • Pandas β€” Data manipulation and CSV handling.
  • Uvicorn β€” ASGI Server.

Frontend:

  • HTML5 / CSS3 β€” Responsive layout with CSS Variables.
  • Vanilla JavaScript β€” Logic without heavy frameworks.
  • Leaflet.js β€” Interactive Maps & Marker rendering.

Deployment:

  • Render β€” Python Backend Hosting.
  • Vercel β€” Static Frontend Hosting.

πŸ“¦ Dependencies

fastapi
uvicorn
pandas
pydantic
python-multipart
Create backend/requirements.txt with the above and run:
pip install -r backend/requirements.txt

πŸ”’ Security Considerations

  • Session Storage Auth β€” Basic client-side session management for the hackathon prototype.
  • CORS Configuration β€” Backend restricted to specific origins in production.

πŸ› Troubleshooting

Map not loading:

  • Check if the Backend URL in frontend/js/common.js matches your running server.
  • Ensure no trailing slash in the API base URL (e.g., https://api.com not https://api.com/).

Admin page redirects to login:

  • Ensure you actually logged in via login.html to set the session key.
  • Check browser console for sessionStorage errors.

High latency on first load:

  • The backend is hosted on a free Render instance which spins down after inactivity. The first request might take 50 seconds to wake it up.

🎯 Roadmap

  • Integration with live IMD Weather API.
  • IoT Sensor integration for real-time water level monitoring.
  • SMS Alerts to citizens in High-Risk zones.
  • Predictive AI model for 24hr flood forecasting.
  • Mobile-responsive UI improvements

πŸ‘€ Author

Prabhat Bhatia & Suhani Yadav


Note: This project was built for a govt level hackathon. The data for "Rainfall" and "Drainage" is simulated based on real-world Delhi ward boundaries and flood hotspots.

About

Data driven civic intelligence platform that enables proactive monsoon preparedness by integrating multiple urban data sources into a single, actionable system.

Resources

Stars

Watchers

Forks

Contributors