Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Kerala Flood Rescue Management System

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.

πŸš€ Features

Core Modules

  1. Victims Management

    • Register and track flood victims
    • Priority-based sorting (1-5 scale)
    • District-wise filtering
    • Status tracking (pending, rescued, evacuated, safe)
  2. Resources Management

    • Track rescue resources (boats, helicopters, food, medicine, etc.)
    • Resource allocation to teams
    • Availability monitoring with low-resource alerts
  3. Teams Management

    • Register rescue teams with specialization
    • Team availability toggle
    • District-wise team distribution
    • Real-time status updates
  4. Smart Dispatch

    • Automatic nearest team selection using BFS algorithm
    • District graph-based routing
    • Route visualization and distance calculation
  5. Routing System

    • 14 Kerala districts represented as graph
    • BFS algorithm for shortest path calculation
    • Route planning between districts
  6. Reports & Analytics

    • Daily summary reports
    • Visual charts (Recharts)
    • Statistics by district, priority, type
    • Completion rates and percentages
  7. Alerts System

    • Low resource warnings
    • High critical victim alerts
    • No available teams notifications
    • District-level alerts
  8. Operation History

    • Last 20 operations log (LIFO stack simulation)
    • Action tracking (CREATE, UPDATE, DELETE, DISPATCH)
    • User activity monitoring

πŸ› οΈ Tech Stack

Backend

  • Node.js with Express.js
  • MongoDB with Mongoose ODM
  • JWT for authentication
  • Bcrypt for password hashing

Frontend

  • React 18 with Vite
  • React Router for navigation
  • Tailwind CSS for styling
  • Recharts for data visualization
  • Axios for API calls
  • Lucide React for icons

πŸ“¦ Installation

Prerequisites

  • Node.js (v16 or higher)
  • MongoDB (local or MongoDB Atlas)
  • npm or yarn

Backend Setup

  1. Navigate to backend directory:
cd backend
  1. Install dependencies:
npm install
  1. Create .env file:
cp .env.example .env
  1. Update .env with 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
  1. Start MongoDB (if running locally):
# On Windows
mongod

# On macOS/Linux
sudo systemctl start mongod
  1. Seed the database (optional):
npm run seed
  1. Start the server:
npm run dev

The backend will run on http://localhost:5000

Frontend Setup

  1. Navigate to frontend directory:
cd frontend
  1. Install dependencies:
npm install
  1. Start the development server:
npm run dev

The frontend will run on http://localhost:3000

πŸ” Default Credentials

After seeding the database, you can login with:

Admin:

  • Email: admin@floodrescue.com
  • Password: admin123

Operator:

  • Email: operator@floodrescue.com
  • Password: operator123

πŸ“ Project Structure

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

🌐 API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login user
  • GET /api/auth/profile - Get user profile

Victims

  • GET /api/victims - Get all victims (query: district, status, sort)
  • GET /api/victims/:id - Get victim by ID
  • POST /api/victims - Create new victim
  • PATCH /api/victims/:id - Update victim
  • DELETE /api/victims/:id - Delete victim

Resources

  • GET /api/resources - Get all resources (query: type, district, status)
  • GET /api/resources/:id - Get resource by ID
  • POST /api/resources - Create new resource
  • PATCH /api/resources/:id - Update resource
  • PATCH /api/resources/:id/allocate - Allocate resource to team

Teams

  • GET /api/teams - Get all teams (query: district, availability, specialization)
  • GET /api/teams/:id - Get team by ID
  • POST /api/teams - Create new team
  • PATCH /api/teams/:id/toggle - Toggle team availability
  • PATCH /api/teams/:id - Update team

Dispatch

  • GET /api/dispatch - Get all dispatches
  • POST /api/dispatch - Smart dispatch (finds nearest team)
  • PATCH /api/dispatch/:id - Update dispatch status

Routes

  • GET /api/routes/districts - Get all districts
  • GET /api/routes/shortest?from=X&to=Y - Get shortest route

Reports

  • GET /api/reports/daily - Get daily report

Alerts

  • GET /api/alerts - Get all alerts

History

  • GET /api/history - Get operation history (last 20)

System

  • POST /api/system/rebuild-priority - Rebuild priority queue (admin only)

🧩 Data Structures Implementation

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

🎨 Features

Dark Mode

  • Toggle between light and dark themes
  • Preference saved in localStorage

Responsive Design

  • Mobile-friendly layout
  • Tailwind CSS for styling

Real-time Updates

  • Auto-refresh for alerts and history
  • Live status updates

🚦 Running the Application

Development Mode

Terminal 1 (Backend):

cd backend
npm run dev

Terminal 2 (Frontend):

cd frontend
npm run dev

Production Build

Backend:

cd backend
npm start

Frontend:

cd frontend
npm run build
npm run preview

πŸ“Š District Graph

The 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.

πŸ”’ Security Features

  • JWT-based authentication
  • Password hashing with bcrypt
  • Role-based access control (admin/operator)
  • Protected API routes
  • Input validation

πŸ› Troubleshooting

MongoDB Connection Issues

  • Ensure MongoDB is running
  • Check connection string in .env
  • Verify MongoDB port (default: 27017)

Port Already in Use

  • Change PORT in backend .env
  • Update frontend proxy in vite.config.js

Authentication Errors

  • Clear localStorage and login again
  • Check JWT_SECRET in backend .env

πŸ“ License

This project is created for educational purposes as part of a flood rescue management system.

πŸ‘₯ Contributing

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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages