Skip to content

thaaaru/floodwatch-windy

FloodWatch LK - Sri Lanka Flood Monitoring & Alert System

License: Apache 2.0 GitHub Stars

Real-time flood monitoring and early warning system for Sri Lanka that sends SMS alerts to subscribers when flood conditions are detected.

Features

  • 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

Tech Stack

  • 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

Quick Start (Local Development)

Prerequisites

  • Docker and Docker Compose
  • Node.js 20+ (for frontend development)
  • Python 3.11+ (for backend development)

Using Docker Compose

# 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/docs

Manual Setup

Backend

cd 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 --reload

Frontend

cd frontend
npm install

# Create .env.local
echo "NEXT_PUBLIC_API_URL=http://localhost:8000" > .env.local

# Run
npm run dev

Alert Thresholds

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

API Endpoints

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

Deployment

DigitalOcean (Backend)

See deploy/digitalocean/ for deployment scripts and instructions.

Vercel (Frontend)

  1. Connect your GitHub repository to Vercel
  2. Set environment variable: NEXT_PUBLIC_API_URL=https://your-api-domain.com
  3. Deploy

Environment Variables

Backend

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

Frontend

NEXT_PUBLIC_API_URL=https://your-api-domain.com

Contributing

We welcome contributions from the community! Please see CONTRIBUTING.md for guidelines on how to contribute to this project.

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Community & Support

  • 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

Project Structure

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

Performance & Scalability

  • Async request handling with FastAPI
  • Database connection pooling
  • Caching strategies for weather data
  • Optimized frontend bundle with Next.js
  • Scalable SMS queue system

Security Considerations

  • 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

Future Roadmap

  • Mobile app (React Native)
  • Historical flood data analysis
  • Machine learning flood prediction
  • Email notifications
  • Email digest reports
  • Integration with government agencies

Troubleshooting

Common Issues

Port already in use:

# Change ports in docker-compose.yml or use:
docker-compose down  # Stop all services

Database connection errors:

  • Ensure PostgreSQL is running
  • Check DATABASE_URL in .env
  • Verify network connectivity

API not responding:

  • Check backend logs: docker-compose logs backend
  • Verify API is accessible: curl http://localhost:8000/api/health

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Acknowledgments

  • 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

About

FloodWatch LK - Windy integration

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors