FloodWatch is a full-stack, production-ready flood detection and early-warning web application engineered specifically for Calabar and surrounding riverine communities in Cross River State, Nigeria.
# FloodWatch (fdps-) — Flood Detection and Early-Warning System
FloodWatch is a full-stack, production-ready flood detection and early-warning web application engineered specifically for Calabar and surrounding riverine communities in Cross River State, Nigeria.
---
## Technical Stack & Architecture
- **Backend Runtime**: Node.js & Express.js
- **Templating Engine**: EJS with role-based layout partials (`header`, `footer`, `navbar`, `sidebar`, `risk-badge`)
- **Database**: MySQL 8 with parameterized queries (`mysql2/promise`), strict SQL injection safety
- **Authentication**: `express-session` & `bcryptjs`
- **Core Engine Module**: `engine/fdpsEngine.js` — houses deterministic weighted flood-risk scoring, threshold classification, email alert dispatch, and prediction-accuracy metric evaluation (Accuracy, Precision, Recall, F1, Confusion Matrix)
- **Separated API Routes**: Page routes (`routes/pages/`) strictly separated from JSON API endpoints (`routes/api/`)
- **Frontend Maps & Charts**: Leaflet.js (CDN) with OpenStreetMap tiles & Chart.js (CDN)
- **CSS Design System**: Custom flat design system (`public/css/fdps-style.css`), all classes prefixed with `fdps-*`. Strict constraint: **NO gradients anywhere** — solid color tokens only.
- **Pure Node.js Policy**: NO Python code or Python-based ML libraries (scikit-learn, etc.). The prediction model is implemented as an explainable, deterministic weighted rule-based scoring system in native JavaScript.
---
## 4-Tier Risk Color Palette (Solid Tokens)
The system enforces a uniform 4-tier color code across all views (Dashboard, Leaflet Map, Alerts, History):
- **Low**: Green (`#16a34a` / `#dcfce7` fill)
- **Moderate**: Yellow (`#854d0e` / `#fef9c3` fill)
- **High**: Orange (`#9a3412` / `#ffedd5` fill)
- **Severe**: Red (`#991b1b` / `#fee2e2` fill)
---
## Core Mathematical Scoring Formula (`engine/fdpsEngine.js`)
The composite flood-risk score \( S \in [0, 100] \) for any given location is computed using normalized …