π¨ Emergency Response & Notification Service
Multi-channel alerts and emergency evacuation guidance for CivicTwin AI
Purposeβ
Emergency Response & Notification Service provides:
- π Emergency Route Finding β Fastest routes for ambulances and fire trucks
- πΊοΈ Evacuation Guidance β Safe evacuation routes for citizens
- π± Multi-channel Alerts β Push, SMS, Email, Web notifications
- π Cascade Broadcasting β City-wide alerts triggered by AI predictions
- π Geolocation-based Targeting β Only notify citizens in affected zones
Technology Stackβ
| Component | Technology |
|---|---|
| Runtime | Node.js + Express |
| Database | MongoDB (notifications, logs) |
| Push Notifications | Firebase FCM |
| SMS | Twilio / Vonage |
| SendGrid / Nodemailer | |
| Message Queue | Apache Kafka |
| Cache | Redis |
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 Type | Severity | Channels | Action |
|---|---|---|---|
| Flooding | CRITICAL | Push + SMS + Web | Evacuate immediately |
| Traffic Accident | HIGH | Push + Web | Avoid area |
| Air Pollution | MEDIUM | Push | Limit outdoor activities |
| Congestion | LOW | Web | Change 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β
| Metric | Target |
|---|---|
| Alert delivery time | < 30 seconds |
| Push notification delivery | > 95% success rate |
| SMS delivery | > 90% success rate |
| API response time | < 200ms |
Related Servicesβ
- AI Prediction Service β Triggers alerts based on predictions
- Digital Twin Service β Provides affected zone data
- Incident Service β Incident management integration
π Licenseβ
This project is distributed under the GNU General Public License v3.0.