A comprehensive MERN stack web application for managing flood rescue operations in Kerala. The system handles victims, resources, teams, routing, and real-time reporting with advanced features like BFS-based routing and priority queue management.
-
Victims Management
- Register and track flood victims
- Priority-based sorting (1-5 scale)
- District-wise filtering
- Status tracking (pending, rescued, evacuated, safe)
-
Resources Management
- Track rescue resources (boats, helicopters, food, medicine, etc.)
- Resource allocation to teams
- Availability monitoring with low-resource alerts
-
Teams Management
- Register rescue teams with specialization
- Team availability toggle
- District-wise team distribution
- Real-time status updates
-
Smart Dispatch
- Automatic nearest team selection using BFS algorithm
- District graph-based routing
- Route visualization and distance calculation
-
Routing System
- 14 Kerala districts represented as graph
- BFS algorithm for shortest path calculation
- Route planning between districts
-
Reports & Analytics
- Daily summary reports
- Visual charts (Recharts)
- Statistics by district, priority, type
- Completion rates and percentages
-
Alerts System
- Low resource warnings
- High critical victim alerts
- No available teams notifications
- District-level alerts
-
Operation History
- Last 20 operations log (LIFO stack simulation)
- Action tracking (CREATE, UPDATE, DELETE, DISPATCH)
- User activity monitoring
- Node.js with Express.js
- MongoDB with Mongoose ODM
- JWT for authentication
- Bcrypt for password hashing
- React 18 with Vite
- React Router for navigation
- Tailwind CSS for styling
- Recharts for data visualization
- Axios for API calls
- Lucide React for icons
- Node.js (v16 or higher)
- MongoDB (local or MongoDB Atlas)
- npm or yarn
- Navigate to backend directory:
cd backend- Install dependencies:
npm install- Create
.envfile:
cp .env.example .env- Update
.envwith your MongoDB URI:
PORT=5000
MONGODB_URI=mongodb://localhost:27017/floodrescue
JWT_SECRET=your_super_secret_jwt_key_change_this_in_production
NODE_ENV=development
- Start MongoDB (if running locally):
# On Windows
mongod
# On macOS/Linux
sudo systemctl start mongod- Seed the database (optional):
npm run seed- Start the server:
npm run devThe backend will run on http://localhost:5000
- Navigate to frontend directory:
cd frontend- Install dependencies:
npm install- Start the development server:
npm run devThe frontend will run on http://localhost:3000
After seeding the database, you can login with:
Admin:
- Email:
admin@floodrescue.com - Password:
admin123
Operator:
- Email:
operator@floodrescue.com - Password:
operator123
floodrescue2/
βββ backend/
β βββ config/
β β βββ db.js # MongoDB connection
β βββ controllers/ # Route controllers
β β βββ alertController.js
β β βββ authController.js
β β βββ dispatchController.js
β β βββ historyController.js
β β βββ reportController.js
β β βββ resourceController.js
β β βββ routeController.js
β β βββ systemController.js
β β βββ teamController.js
β β βββ victimController.js
β βββ middleware/
β β βββ auth.js # JWT authentication
β β βββ logger.js # Operation logging
β βββ models/ # Mongoose models
β β βββ Dispatch.js
β β βββ OperationLog.js
β β βββ Resource.js
β β βββ Team.js
β β βββ User.js
β β βββ Victim.js
β βββ routes/ # API routes
β β βββ alertRoutes.js
β β βββ authRoutes.js
β β βββ dispatchRoutes.js
β β βββ historyRoutes.js
β β βββ reportRoutes.js
β β βββ resourceRoutes.js
β β βββ routeRoutes.js
β β βββ systemRoutes.js
β β βββ teamRoutes.js
β β βββ victimRoutes.js
β βββ scripts/
β β βββ seedData.js # Database seeding
β βββ utils/
β β βββ bfs.js # BFS algorithm
β β βββ graph.js # District graph
β βββ server.js # Express server
β βββ package.json
β
βββ frontend/
βββ src/
β βββ components/
β β βββ Layout.jsx
β β βββ ProtectedRoute.jsx
β βββ context/
β β βββ AuthContext.jsx
β β βββ ThemeContext.jsx
β βββ pages/
β β βββ Alerts.jsx
β β βββ Dispatch.jsx
β β βββ History.jsx
β β βββ Login.jsx
β β βββ Reports.jsx
β β βββ Resources.jsx
β β βββ Teams.jsx
β β βββ Victims.jsx
β βββ services/
β β βββ api.js # API service layer
β βββ App.jsx
β βββ main.jsx
β βββ index.css
βββ package.json
βββ vite.config.js
POST /api/auth/register- Register new userPOST /api/auth/login- Login userGET /api/auth/profile- Get user profile
GET /api/victims- Get all victims (query: district, status, sort)GET /api/victims/:id- Get victim by IDPOST /api/victims- Create new victimPATCH /api/victims/:id- Update victimDELETE /api/victims/:id- Delete victim
GET /api/resources- Get all resources (query: type, district, status)GET /api/resources/:id- Get resource by IDPOST /api/resources- Create new resourcePATCH /api/resources/:id- Update resourcePATCH /api/resources/:id/allocate- Allocate resource to team
GET /api/teams- Get all teams (query: district, availability, specialization)GET /api/teams/:id- Get team by IDPOST /api/teams- Create new teamPATCH /api/teams/:id/toggle- Toggle team availabilityPATCH /api/teams/:id- Update team
GET /api/dispatch- Get all dispatchesPOST /api/dispatch- Smart dispatch (finds nearest team)PATCH /api/dispatch/:id- Update dispatch status
GET /api/routes/districts- Get all districtsGET /api/routes/shortest?from=X&to=Y- Get shortest route
GET /api/reports/daily- Get daily report
GET /api/alerts- Get all alerts
GET /api/history- Get operation history (last 20)
POST /api/system/rebuild-priority- Rebuild priority queue (admin only)
The system uses MongoDB collections to simulate traditional data structures:
- Priority Queue: MongoDB queries with compound index on
priority+registeredAt - Stack: OperationLog collection with LIFO ordering (limit 20)
- Queue: Dispatch collection with FIFO ordering by creation time
- Graph: Hardcoded district adjacency list with BFS traversal
- Toggle between light and dark themes
- Preference saved in localStorage
- Mobile-friendly layout
- Tailwind CSS for styling
- Auto-refresh for alerts and history
- Live status updates
Terminal 1 (Backend):
cd backend
npm run devTerminal 2 (Frontend):
cd frontend
npm run devBackend:
cd backend
npm startFrontend:
cd frontend
npm run build
npm run previewThe system includes a graph representation of 14 Kerala districts:
- Thiruvananthapuram
- Kollam
- Pathanamthitta
- Alappuzha
- Kottayam
- Idukki
- Ernakulam
- Thrissur
- Palakkad
- Malappuram
- Kozhikode
- Wayanad
- Kannur
- Kasaragod
The BFS algorithm calculates shortest paths between districts for optimal team dispatch.
- JWT-based authentication
- Password hashing with bcrypt
- Role-based access control (admin/operator)
- Protected API routes
- Input validation
- Ensure MongoDB is running
- Check connection string in
.env - Verify MongoDB port (default: 27017)
- Change
PORTin backend.env - Update frontend proxy in
vite.config.js
- Clear localStorage and login again
- Check JWT_SECRET in backend
.env
This project is created for educational purposes as part of a flood rescue management system.
This is a complete implementation. Feel free to extend it with additional features like:
- Real-time notifications (WebSocket)
- Mobile app integration
- Advanced analytics
- Multi-language support
- Export functionality (PDF/Excel)
Built with β€οΈ for Kerala Flood Rescue Operations