Full-stack web application for real-time flood risk prediction using a high-performance XGBoost model trained on All-India datasets.
The system has been upgraded to Model V3, featuring:
- Satellite Integration: Real-time soil moisture from NASA POWER API (GEOS-5/SMAP).
- Advanced ML: High-accuracy XGBoost model replacing the legacy Random Forest.
- 52 Features: Comprehensive feature engineering including rainfall acceleration, SMAP history, and geographic risk indices (TWI, CN).
- Real-time Satellite & Weather Data: Combines Open-Meteo precipitation with NASA's satellite soil wetness data.
- 4-Tier Risk Classification: Low, Moderate, High, and Very High risk levels with professional iconography and alerts.
- Model Metrics Dashboard: Live performance indicators (AUC: 0.962, F1: 0.50) displayed on the user dashboard.
- Modern UI: Professional dark-themed dashboard with dynamic risk scales and interactive map integration.
FloodRiskPredictor/
├── backend/
│ ├── app.py # Flask API server
│ ├── model_loader.py # ML model management (V3 support)
│ ├── weather_fetcher.py # Weather & NASA API integration
│ ├── feature_engineering_v3.py # 52-feature engineering pipeline
│ └── requirements.txt # Python dependencies
├── models/
│ └── new_model/ # Model V3 weights and scalers
├── frontend/
│ ├── src/
│ │ ├── components/ # React components (Dashboard, Alerts, etc.)
│ │ ├── utils/ # API client
│ │ └── App.css # Styles with 4-tier risk themes
└── README.md
- Python 3.8+
- Node.js 16+
- npm or yarn
# Navigate to backend directory
cd backend
# Install Python dependencies
pip install -r requirements.txt
# Run Flask server
python app.pyBackend will run on http://localhost:5000
# Navigate to frontend directory
cd frontend
# Install dependencies
npm install
# Start development server
npm run devFrontend will run on http://localhost:3000
Predict flood risk for a city using Model V3 (52 features).
Request:
{
"city": "Patna"
}Response:
{
"city": "Patna",
"temperature": 28.5,
"confidence": 87.5,
"risk_level": "very_high",
"risk_tier": 4,
"model_version": "v3",
"model_metrics": { "auc": 0.9623, "f1": 0.5032 }
}Get list of available cities.
Check server and model status.
| City | Latitude | Longitude |
|---|---|---|
| Patna | 25.5941°N | 85.1376°E |
| Guwahati | 26.1445°N | 91.7362°E |
| Gorakhpur | 26.7606°N | 83.3732°E |
| Malda | 25.0104°N | 88.1328°E |
| ...And 20+ more major Indian cities |
Backend:
- Flask - API Framework
- XGBoost - Primary Machine Learning Model
- NASA POWER API - Satellite Soil Moisture (GWETROOT)
- Open-Meteo API - Current and Historical Rainfall
Frontend:
- React 18 - UI Library (Vite based)
- Axios - Data fetching
- Modern CSS - 4-tier risk styling and animations
- Algorithm: XGBoost (Extreme Gradient Boosting)
- Feature Count: 52
- Metrics: 0.9623 AUC, 0.496 MCC
- Critical Features: SMAP 7-day Avg, Rainfall Acceleration, Soil Moisture Proxy, Topographic Wetness Index (TWI).
- Select City: Choose from the dropdown to start live analysis.
- View Metrics: Click the "Model Performance" panel to see live model accuracy stats.
- Monitor Alerts: High and Very High risk alerts provide actionable emergency text.
# Install Gunicorn
pip install gunicorn
# Run with Gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 app:app# Build for production
npm run build
# Serve static files with any web server
# dist/ folder contains built filesEnvironment Variables:
Update API endpoint in frontend/src/utils/api.js to production URL.
- Add rate limiting for API endpoints
- Implement API key authentication for production
- Use HTTPS in production
- Add input validation and sanitization
- Multi-city monitoring dashboard
- Historical flood data visualization
- Email/SMS alerts for high risk
- Map-based city selection
- User authentication
- Prediction history tracking
This project is for educational and research purposes.
Contributions welcome! Please open an issue or submit a pull request.
For issues or questions, please open a GitHub issue.
Built for flood risk awareness and prevention