How misbahkhan0009/flood-guard-server works
Project Type and Purpose
• Flood Guard is a full-stack application centered on flood prediction, early warnings, and support for flood victims and rescuers. The main website forecasts floods, shows nearby shelters, and provides navigation details.
• The README explicitly describes how the system will help mitigate flood damages by forecasting floods, monitoring water levels, and coordinating rescue efforts through a web-based interface.
• In addition to Express-based backend services, there is a dedicated ML Model directory that contains several Python scripts and notebooks, indicating an integration of machine learning for flood prediction.
File Structure and Major Components
• Backend (Express.js Server):
• Top-level files like index.js, package.json and package-lock.json indicate the Node.js backend.
• The “routes” directory contains API route definitions for different resources (e.g., victims, shelters, floods, emergency alerts). This shows a RESTful design.
• The “controllers” directory holds the business logic for handling API requests—one for each domain (e.g., water levels, hospitals, hydro level maps).
• The “config” folder (containing db.js and firebase.js) manages database connectivity and authentication setup.
• ML Model Component:
• The “ML Model” directory includes Jupyter notebooks, Python scripts (app1.py, app2.py, predict_api.py), CSV input data, and multiple serialized model files (e.g., .pkl and .sav). This indicates that the ML part is used for flood prediction.
• There could be a microservice or an integrated module which the main backend may call, either synchronously via an API or through batch processing.
• Database:
• The presence of a FloodGuard.sql file indicates that the database schema (described in the README) is set up in MySQL.
• The README also outlines a detailed relational schema with tables for Emergency Alerts, Mobile Towers, Donations, Water Levels, and several other critical components.
• External Services:
• Firebase (in config/firebase.js) is used for authentication.
• Cloudinary is noted in the README for file management.
• Other aspects:
• The ML model may communicate its predictions back to the Express.js API, contributing to decisions like navigation and resource allocation.
Key Architectural Patterns and Relationships
• The system follows an MVC-like separation (routes, controllers, configuration) for the RESTful backend API.
• The ML component appears to be a separate unit which handles flood predictions. There is a clear interaction point where the Node.js server will likely trigger predictions from the Python module.
• The server acts as a mediator, receiving client requests, interacting with the database (via MySQL), processing inputs (using ML predictions), and interfacing with external services (Firebase for auth and Cloudinary for file storage).
• The architecture promotes modularity by splitting responsibilities: one module for forecast/prediction and another for API management & database operations.