Skip to main content

🚨 Emergency Response & Notification Service

Multi-channel alerts and emergency evacuation guidance for CivicTwin AI


Purpose​

Emergency Response & Notification Service provides:

  1. πŸš‘ Emergency Route Finding β€” Fastest routes for ambulances and fire trucks
  2. πŸ—ΊοΈ Evacuation Guidance β€” Safe evacuation routes for citizens
  3. πŸ“± Multi-channel Alerts β€” Push, SMS, Email, Web notifications
  4. πŸ“Š Cascade Broadcasting β€” City-wide alerts triggered by AI predictions
  5. πŸ“ Geolocation-based Targeting β€” Only notify citizens in affected zones

Technology Stack​

ComponentTechnology
RuntimeNode.js + Express
DatabaseMongoDB (notifications, logs)
Push NotificationsFirebase FCM
SMSTwilio / Vonage
EmailSendGrid / Nodemailer
Message QueueApache Kafka
CacheRedis

Key Features​

πŸš‘ Emergency Route Calculation​

Identifies the fastest, safest route for emergency vehicles by:

  • Avoiding flooded roads
  • Avoiding congested intersections
  • Prioritizing emergency lanes
POST /api/emergency/fastest-route
{
"vehicleType": "ambulance",
"fromLocation": { "lat": 16.04, "lon": 108.21 },
"toLocation": { "lat": 16.08, "lon": 108.20 }
}

Response:
{
"route": [...],
"estimatedTime": 8,
"distance": 2.3,
"avoidedZones": ["zone_flooding_1"],
"alternativeRoutes": [...]
}

πŸ—ΊοΈ Evacuation Guidance​

POST /api/emergency/evacuation-guidance
{
"incidentLocation": { "lat": 16.04, "lon": 108.21 },
"incidentType": "flooding",
"affectedRadius": 500
}

Response:
{
"evacuationRoutes": [...],
"safeZones": [...],
"estimatedEvacuationTime": 45,
"citizensAtRisk": 12500
}

πŸ“± Broadcast Alert​

POST /api/emergency/broadcast-alert
{
"type": "flooding",
"severity": "critical",
"affectedZones": ["zone_1", "zone_2"],
"message": "Flood Warning: Please evacuate immediately",
"channels": ["push", "sms", "web"]
}

Response:
{
"alertId": "alert_xyz",
"recipientsNotified": 8500,
"deliveryStatus": {
"push": "sent",
"sms": "queued",
"web": "published"
}
}

Alert Types & Severity Levels​

Alert TypeSeverityChannelsAction
FloodingCRITICALPush + SMS + WebEvacuate immediately
Traffic AccidentHIGHPush + WebAvoid area
Air PollutionMEDIUMPushLimit outdoor activities
CongestionLOWWebChange route

Message Templates​

Flood Warning​

🚨 FLOOD WARNING - [ZONE NAME]

Water level rising. Please:
βœ… Move to higher ground immediately
βœ… Avoid roads: [ROAD LIST]
βœ… Go to safe zones: [SHELTER LIST]

CivicTwin AI Emergency System

Traffic Accident​

⚠️ TRAFFIC ACCIDENT - [LOCATION]

Serious accident at [ADDRESS].
πŸ”€ Suggested alternate routes: [ALTERNATIVES]
πŸš‘ Emergency vehicles en route - please yield

CivicTwin AI Traffic Management

Delivery & Retry Logic​

Send notification
↓
Try primary channel (Push)
β”œβ”€ Success β†’ Log & done
└─ Fail β†’ Retry (3 times, 30s intervals)
└─ Still failing β†’ Fallback to SMS
└─ Final fallback: Email

Deployment​

Docker​

FROM node:18-alpine
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
EXPOSE 3005
CMD ["npm", "start"]

Environment Variables​

MONGODB_URI=mongodb://mongo:27017/notifications
FIREBASE_PROJECT_ID=civic-twin-firebase
TWILIO_ACCOUNT_SID=...
TWILIO_AUTH_TOKEN=...
SENDGRID_API_KEY=...
KAFKA_BROKER=kafka:9092
PORT=3005

Performance Targets​

MetricTarget
Alert delivery time< 30 seconds
Push notification delivery> 95% success rate
SMS delivery> 90% success rate
API response time< 200ms


πŸ“„ License​

This project is distributed under the GNU General Public License v3.0.