Skip to content

aasimansari1/disaster-alert-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

🚨 Disaster Alert System

Real-time disaster alerts on an interactive map — with live Socket.IO updates, severity levels, safe zones, and evacuation instructions.

React Node.js Socket.IO MongoDB Leaflet License: MIT


When disaster strikes, seconds matter. This system broadcasts geo-tagged alerts to all connected users in real time — showing affected radius, safe zones, evacuation routes, and step-by-step safety instructions on an interactive map.


✨ Features

🗺️ Interactive Map

  • React Leaflet map with geo-tagged alerts
  • Visual affected radius per disaster
  • Safe zone markers (shelters, hospitals, evacuation points)
  • Click any alert for full details

⚡ Real-Time Updates

  • Socket.IO pushes new alerts instantly to all connected users
  • No page refresh needed
  • Live connection status indicator

🌪️ Disaster Types

  • Earthquake, Flood, Cyclone, Fire
  • Heavy Rainfall, Landslide, Tsunami, Drought
  • 4 severity levels: Low / Medium / High / Critical

🛡️ Safety Tools

  • Step-by-step safety instructions per alert
  • Safe zone locations with type (shelter / hospital / evacuation)
  • Alert status tracking: Active / Monitoring / Resolved

📸 Screenshots

Live Map View Alert Details
Map Detail

⚡ Quick Start

git clone https://github.com/aasimansari1/disaster-alert-system.git
cd disaster-alert-system

# Backend
cd server
cp .env.example .env     # add MONGO_URI and JWT_SECRET
npm install
npm start                # → http://localhost:5000

# Frontend (new terminal)
cd ../client
npm install
npm start                # → http://localhost:3000

🔧 Environment Variables

# server/.env
MONGO_URI=mongodb://localhost:27017/disaster-alerts
JWT_SECRET=your-secret-key
PORT=5000
NODE_ENV=development

# Optional — email notifications on critical alerts
MAIL_HOST=smtp.gmail.com
MAIL_USER=your@gmail.com
MAIL_PASS=your-app-password

🏗️ Architecture

  Browser A                Browser B                Browser C
     │                        │                        │
     └──────────────┬──────────────────────────────────┘
                    │  Socket.IO (real-time)
                    ▼
          ┌─────────────────┐
          │   Node.js /     │
          │   Express       │
          │   Socket.IO     │
          └────────┬────────┘
                   │
                   ▼
          ┌─────────────────┐
          │    MongoDB      │
          │  (alerts, users,│
          │   safe zones)   │
          └─────────────────┘

  New alert posted → Socket.IO broadcasts to ALL connected clients instantly

📡 API Endpoints

Method Endpoint Description
POST /api/auth/register Register user
POST /api/auth/login Login, returns JWT
GET /api/alerts Get all active alerts
POST /api/alerts Create new alert (auth required)
GET /api/alerts/:id Get alert details
PATCH /api/alerts/:id Update alert status
GET /api/alerts/nearby Alerts within radius of coords

🗂️ Project Structure

disaster-alert-system/
├── client/                     # React frontend
│   └── src/
│       ├── components/
│       │   ├── Map/            # React Leaflet map + markers
│       │   ├── Alerts/         # Alert list, detail, filters
│       │   ├── Charts/         # Chart.js disaster analytics
│       │   └── Layout/         # Navbar, sidebar
│       ├── context/            # Auth, Socket context
│       ├── hooks/              # useAlerts, useSocket, useLocation
│       ├── pages/              # Dashboard, Map, Alerts, Login
│       └── services/           # Axios API client
└── server/
    ├── config/                 # MongoDB connection
    ├── controllers/            # Alert, auth, user logic
    ├── middleware/             # JWT auth, rate limiting, helmet
    ├── models/                 # Alert (geo + severity), User
    ├── routes/                 # alerts, auth, users
    ├── socket/                 # Socket.IO event handlers
    └── index.js                # Entry point

🛠️ Tech Stack

Layer Technology
Frontend React 18, React Leaflet, Chart.js, Framer Motion
Real-Time Socket.IO (client + server)
Backend Node.js, Express.js
Database MongoDB, Mongoose (GeoJSON 2dsphere index)
Auth JWT, bcryptjs
Security Helmet, express-rate-limit, express-validator
Notifications Nodemailer (email alerts)

🗺️ Roadmap

  • Push notifications (PWA / Firebase)
  • SMS alerts via Twilio
  • Government API integration for verified alerts
  • Offline mode (service worker)
  • Multi-language support

🤝 Contributing

git checkout -b feature/your-feature
git commit -m 'Add your feature'
git push origin feature/your-feature

📄 License

MIT © Mohd Aasim Ansari


Built to keep people safe. If this is useful to you, please ⭐ star the repo!

About

Real-time disaster alert system with interactive maps, Socket.IO, and severity-based notifications

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors