Real-time flood monitoring and early warning system for Sri Lanka that sends SMS alerts to subscribers when flood conditions are detected.
- Real-time Monitoring: Rainfall monitoring for all 25 districts of Sri Lanka
- Weather Integration: Open-Meteo weather API and GDACS flood alerts
- SMS Alerts: Twilio-powered notifications for flood warnings
- Interactive Dashboard: Color-coded alert levels on an interactive map
- Multi-language Support: English, Sinhala, and Tamil interfaces
- Responsive Design: Works seamlessly on desktop and mobile devices
- Backend: Python 3.11+ with FastAPI
- Frontend: Next.js 14 with Tailwind CSS
- Database: PostgreSQL
- SMS Provider: Twilio
- Maps: Leaflet.js with OpenStreetMap
- Deployment: Docker, DigitalOcean, Vercel
- Docker and Docker Compose
- Node.js 20+ (for frontend development)
- Python 3.11+ (for backend development)
# Clone and start all services
cd floodwatch-lk
docker-compose up -d
# Access:
# - Frontend: http://localhost:3000
# - Backend API: http://localhost:8000
# - API Docs: http://localhost:8000/docscd backend
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
# Create .env file
cp .env.example .env
# Edit .env with your database and Twilio credentials
# Run
uvicorn app.main:app --reloadcd frontend
npm install
# Create .env.local
echo "NEXT_PUBLIC_API_URL=http://localhost:8000" > .env.local
# Run
npm run dev| Level | Rainfall (24h) | Description |
|---|---|---|
| Green | < 50mm | Normal conditions |
| Yellow | 50-100mm | Watch - Monitor conditions |
| Orange | 100-150mm | Warning - Prepare for flooding |
| Red | > 150mm | Emergency - Take immediate action |
| Endpoint | Method | Description |
|---|---|---|
/api/health |
GET | Health check |
/api/districts |
GET | List all districts |
/api/weather/all |
GET | Weather for all districts |
/api/weather/{district} |
GET | Detailed weather for district |
/api/alerts |
GET | Active alerts |
/api/alerts/history |
GET | Historical alerts |
/api/subscribe |
POST | Subscribe to SMS alerts |
/api/unsubscribe |
POST | Unsubscribe from alerts |
See deploy/digitalocean/ for deployment scripts and instructions.
- Connect your GitHub repository to Vercel
- Set environment variable:
NEXT_PUBLIC_API_URL=https://your-api-domain.com - Deploy
DATABASE_URL=postgresql://user:pass@host:5432/floodwatch
TWILIO_ACCOUNT_SID=your_sid
TWILIO_AUTH_TOKEN=your_token
TWILIO_PHONE_NUMBER=+1234567890
FRONTEND_URL=https://your-frontend-domain.com
NEXT_PUBLIC_API_URL=https://your-api-domain.com
We welcome contributions from the community! Please see CONTRIBUTING.md for guidelines on how to contribute to this project.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Issues: Report bugs and request features via GitHub Issues
- Discussions: Join our community discussions for questions and ideas
- Code of Conduct: Please review our Code of Conduct
floodwatch-windy/
├── backend/ # FastAPI backend service
│ ├── app/
│ ├── tests/
│ ├── requirements.txt
│ └── .env.example
├── frontend/ # Next.js frontend application
│ ├── src/
│ ├── public/
│ ├── package.json
│ └── .env.example
├── database/ # Database migrations and setup
├── deploy/ # Deployment configurations
│ └── digitalocean/
├── docker-compose.yml # Docker Compose configuration
├── LICENSE # MIT License
├── CONTRIBUTING.md # Contribution guidelines
└── README.md # This file
- Async request handling with FastAPI
- Database connection pooling
- Caching strategies for weather data
- Optimized frontend bundle with Next.js
- Scalable SMS queue system
- Environment variables for sensitive data (never commit
.env) - SQL injection prevention with parameterized queries
- CORS configuration for frontend integration
- Input validation on all API endpoints
- Secure password hashing for user data
- Mobile app (React Native)
- Historical flood data analysis
- Machine learning flood prediction
- Email notifications
- Email digest reports
- Integration with government agencies
Port already in use:
# Change ports in docker-compose.yml or use:
docker-compose down # Stop all servicesDatabase connection errors:
- Ensure PostgreSQL is running
- Check
DATABASE_URLin.env - Verify network connectivity
API not responding:
- Check backend logs:
docker-compose logs backend - Verify API is accessible:
curl http://localhost:8000/api/health
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
- Open-Meteo for weather data
- GDACS for flood information
- Twilio for SMS services
- OpenStreetMap for map data
- The open-source community
Made with ❤️ for Sri Lanka's safety