A real-time flood monitoring dashboard built with the MERN stack for tracking water levels across Sri Lanka's major rivers.
- Real-time Monitoring: Live water level data from 10 IoT stations across Sri Lanka
- Interactive Map: Visual representation with color-coded markers on Sri Lanka map
- Advanced Alert System: Three-tier alerts (Normal, Warning, Danger) based on thresholds
- Historical Data Visualization: 24-hour water level trends with Recharts
- Weather Integration: Current weather conditions and forecasts
- Risk Assessment Dashboard: Overall risk level with actionable recommendations
- Recent Activity Log: Real-time event tracking and system notifications
- Statistics Overview: System-wide metrics and analytics
- Detailed Station Views: In-depth analysis for each monitoring station
- Trend Indicators: Rising, falling, or stable water level trends
- Battery Monitoring: Track IoT device battery levels
- Responsive Design: Works seamlessly on desktop and mobile devices
Frontend:
- React (Vite)
- Tailwind CSS
- React-Leaflet (Maps)
- Recharts (Data Visualization)
- Axios
Backend:
- Node.js
- Express.js
- MongoDB (Mongoose)
flood-alert-system/
├── backend/
│ ├── models/
│ │ ├── Station.js
│ │ └── Reading.js
│ ├── routes/
│ │ ├── stationRoutes.js
│ │ └── readingRoutes.js
│ ├── server.js
│ ├── seed.js
│ ├── .env
│ └── package.json
├── frontend/
│ ├── src/
│ │ ├── components/
│ │ │ ├── MapView.jsx
│ │ │ ├── StatusCard.jsx
│ │ │ └── HistoryChart.jsx
│ │ ├── pages/
│ │ │ ├── Dashboard.jsx
│ │ │ └── StationDetail.jsx
│ │ ├── App.jsx
│ │ ├── main.jsx
│ │ └── index.css
│ ├── index.html
│ ├── vite.config.js
│ ├── tailwind.config.js
│ └── package.json
└── README.md
- Node.js (v16 or higher)
- MongoDB Atlas account (free tier works fine)
- npm or yarn
-
Navigate to project directory
cd "d:\Embedded Project\flood-alert-system" -
Run the setup script
.\setup.ps1
This will:
- Install backend dependencies
- Seed the database with 10 stations and realistic data
- Start the backend server on port 5000
-
In a NEW terminal, start the frontend
cd "d:\Embedded Project\flood-alert-system" .\start-frontend.ps1
Frontend will run on http://localhost:5173
-
Clone the repository
cd "d:\Embedded Project\flood-alert-system"
-
Set up the Backend
cd backend npm install -
Configure Environment Variables
Update
backend/.envif needed:PORT=5000 MONGODB_URI=mongodb://localhost:27017/flood-alert-system -
Seed the Database
npm run seed
-
Start the Backend Server
npm run dev
Server will run on
http://localhost:5000 -
Set up the Frontend (in a new terminal)
cd frontend npm install -
Start the Frontend
npm run dev
Frontend will run on
http://localhost:5173
GET /api/stations- Get all stations with latest statusGET /api/stations/:id- Get specific station detailsPOST /api/stations- Create a new station
GET /api/readings/:stationId- Get readings for a station (last 50)POST /api/readings- Submit a new reading
Example POST request to submit reading:
{
"stationId": "kelani-01",
"waterLevel": 5.2,
"batteryLevel": 95
}The system includes 10 pre-configured monitoring stations across Sri Lanka:
- Kelani River - Kaduwela Bridge
- Kelani River - Hanwella
- Kalu Ganga - Ratnapura
- Kalu Ganga - Kalutara
- Mahaweli River - Kandy
- Mahaweli River - Peradeniya
- Nilwala Ganga - Matara
- Gin Ganga - Galle
- Attanagalu Oya - Gampaha
- Deduru Oya - Kurunegala
Note: These are demonstration stations with simulated data. In production, one physical IoT device will be deployed and connected to the system.
- 🟢 Normal: Water level below warning threshold
- 🟠 Warning: Water level between warning and danger thresholds
- 🔴 Danger: Water level above danger threshold
You can add new monitoring stations via the API or directly in MongoDB:
{
stationId: "station-id",
name: "Station Name",
location: {
lat: 7.8731,
lng: 80.7718
},
thresholds: {
warning: 5.0,
danger: 7.0
}
}- Dashboard View: See all stations on the map with color-coded status
- Click on Markers: View quick station information
- View Details: Click "View Details" to see historical data and charts
- Active Alerts: Check the sidebar for stations with warnings or dangers
- Admin Panel: Click "⚙️ Admin Panel" button to:
- ➕ Add new stations for your IoT devices
- ✏️ Edit station thresholds
- 🎮 Test with device simulator (no hardware needed!)
- 📊 Manage all stations in one place
- Deploy to services like Heroku, Railway, or DigitalOcean
- Use MongoDB Atlas for cloud database
- Build:
npm run build - Deploy to Vercel, Netlify, or any static hosting service
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
Built with ❤️ for flood monitoring in Sri Lanka
- OpenStreetMap for map tiles
- React-Leaflet for map integration
- Recharts for data visualization