A real-time flood prediction and monitoring system that provides early warnings and risk assessments for urban areas worldwide. The system integrates data from river gauges, weather forecasts, and historical flood events to predict and visualize flood risks.
- Live River Gauge Data: Monitors 25+ river gauges across high-risk flood zones worldwide
- Weather Integration: Fetches real-time weather forecasts from NOAA/NWS
- WebSocket Updates: Real-time data streaming to connected clients
- Interactive Map: Visualize gauges, flood zones, and risk areas on an interactive map
- Risk Assessment: Multi-factor risk calculation based on:
- River gauge heights and flow rates
- Rainfall forecasts
- Soil saturation levels
- Proximity to water bodies
- Spatial Analysis: Geographic risk zone generation using interpolation
- Confidence Scoring: Prediction confidence based on data freshness and availability
- Flood Event Database: Track and analyze past flood events
- Impact Assessment: Record casualties, evacuations, and economic damage
- Statistical Analysis: Trends, recurrence intervals, and return periods
- Verification System: Verified vs. unverified flood event tracking
- Data Ingestion: Automatic gauge and weather data updates every 5-15 minutes
- Flood Predictions: Automated risk calculations every 10 minutes
- Data Cleanup: Scheduled cleanup of old measurements
- Framework: FastAPI with async/await support
- Database: PostgreSQL with PostGIS for geospatial data
- Task Scheduler: APScheduler for background jobs
- External APIs:
- USGS Water Services API
- NOAA/NWS Weather API
- Key Services:
- Data ingestion (USGS, Weather)
- Flood prediction and risk calculation
- Historical flood management
- WebSocket real-time updates
- Framework: React 18 with TypeScript
- Routing: React Router v6
- Styling: Tailwind CSS
- Maps: Leaflet for interactive mapping
- State Management: React hooks
- Real-time: WebSocket client for live updates
- Containerization: Docker & Docker Compose
- Web Server: Nginx (frontend reverse proxy)
- Database: PostgreSQL 15 with PostGIS extension
- Deployment: Railway-ready with production configurations
The system monitors flood-prone areas across:
- Asia: Bangladesh, India, Pakistan, Sri Lanka, Thailand, Vietnam
- Africa: Egypt, Malawi, Mozambique, Nigeria
- South America: Argentina, Brazil, Colombia
- Europe: Germany, Italy, United Kingdom
- North America: United States (Texas, Louisiana, Florida)
- Australia/Oceania: Australia
- USGS Water Services: Real-time river gauge data
- NOAA/NWS: Weather forecasts and precipitation data
- Manual Gauges: Custom monitoring points for international locations
- Historical Records: User-contributed and verified flood event data
See GETTING_STARTED.md for detailed setup instructions.
# Clone the repository
git clone <repository-url>
cd flood-detector
# Configure environment
cp .env.example .env
# Edit .env with your database credentials
# Start the application
docker compose up --build
# Seed initial gauge data
docker compose exec backend python3 scripts/seed_gauges.pyAccess the application at http://localhost:3000
flood-detector/
βββ backend/ # FastAPI backend
β βββ app/
β β βββ models/ # SQLAlchemy models
β β βββ routes/ # API endpoints
β β βββ services/ # Business logic
β β βββ spatial/ # Geospatial processing
β β βββ tasks/ # Background tasks
β β βββ utils/ # Utilities
β βββ scripts/ # Database seeding scripts
β βββ requirements.txt # Python dependencies
βββ frontend/ # React frontend
β βββ src/
β β βββ components/ # React components
β β βββ pages/ # Page components
β β βββ services/ # API & WebSocket clients
β β βββ types/ # TypeScript types
β βββ package.json # Node dependencies
βββ docker-compose.yaml # Docker orchestration
βββ .env # Environment configuration
DATABASE_URL: PostgreSQL connection stringLOG_LEVEL: Logging level (INFO, DEBUG, etc.)CORS_ORIGINS: Allowed CORS origins
VITE_API_BASE_URL: Backend API URLVITE_WS_URL: WebSocket server URL
See .env.example for complete configuration options.
GET /api/gauges/- List all active gaugesGET /api/gauges/{id}- Get specific gauge detailsGET /api/gauges/{id}/measurements- Get gauge measurementsPOST /api/gauges/refresh/{site_id}- Refresh gauge data
GET /api/predictions/- List flood predictionsGET /api/predictions/latest- Get latest predictionPOST /api/predictions/calculate- Calculate risk for locationGET /api/predictions/zones- Get risk zonesGET /api/predictions/heatmap- Get risk heatmap
GET /api/historical/- List historical floodsGET /api/historical/{id}- Get flood detailsGET /api/historical/statistics- Get flood statisticsGET /api/historical/location/nearby- Find nearby floodsPOST /api/historical/- Create flood record
WS /ws/flood-updates- Real-time flood updates
# Backend tests
cd backend
pytest
# Frontend tests
cd frontend
npm test# Create migration
alembic revision --autogenerate -m "description"
# Apply migrations
alembic upgrade headEdit backend/scripts/seed_gauges.py and add to MANUAL_GAUGES list:
{
"usgs_site_id": "MANUAL_XX_01",
"name": "River Name at City, Country",
"latitude": 0.0,
"longitude": 0.0
}Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- USGS: United States Geological Survey for river gauge data
- NOAA/NWS: National Weather Service for weather forecasts
- OpenStreetMap: Map data and tiles
- PostGIS: Geospatial database extension
For issues, questions, or contributions:
- Open an issue on GitHub
- Contact: [[email protected]]
- Machine learning-based flood prediction models
- Mobile application (iOS/Android)
- SMS/Email alert notifications
- Integration with additional weather APIs
- Community reporting features
- Multi-language support
- Advanced visualization (3D flood modeling)
Built with β€οΈ for safer communities worldwide