Agentic Incident Response & Real-Time Coordination System
ResQ-AI Backend is a high-performance Node.js server powering the ResQ-AI platform.
It enables real-time emergency incident reporting, AI-assisted severity triage, duplicate consolidation, and live command-center updates using WebSockets.
The system is designed for smart cities, emergency services, and disaster-response coordination, ensuring fast, credible, and scalable incident handling.
- Secure JWT-based authentication
- Two user roles:
- Citizen โ Mobile app users who report incidents
- Admin โ Command Center operators who validate and manage incidents
- Lightweight heuristic NLP engine
- Automatically assigns severity during incident creation:
- High โ Fire, Blood, Explosion, Accident
- Medium โ Smoke, Traffic, Crowd
- Low โ Pothole, Noise, Garbage
- Detects duplicate incident reports using geospatial proximity
- Uses atomic MongoDB transactions
- Merges duplicates into a single verified incident
- Converts duplicate reports into verification votes (+1 credibility)
- Citizens can:
- Upvote (Verify) โ +1
- Downvote (Reject) โ -1
- Automatic rejection when vote score โค -5
- Net score determines whether an incident is valid or rejected
- Socket.io integration
- Live push updates to Admin Dashboard:
- New incidents
- Incident merges
- Status updates
- Vote changes
- MongoDB 2dsphere indexing
- Enables:
- Radius-based searches
- Location clustering
- Duplicate detection using proximity
| Layer | Technology |
|---|---|
| Runtime | Node.js |
| Framework | Express.js |
| Database | MongoDB |
| ODM | Mongoose |
| Real-Time | Socket.io |
| Security | JWT, BCrypt, CORS |
| Architecture | MVC with Service Layer |
- Node.js v18+
- MongoDB (Local installation or Atlas URI)
git clone <repository_url>
cd Dev-Hack-Backend
npm installCreate a .env file in the root directory:
PORT=5000
MONGO_URI=mongodb://localhost:27017/resq_ai_db
JWT_SECRET=your_super_secret_key_change_this
NODE_ENV=developmentThe public API only allows Citizen registration.
To create the first Admin, run:
node createAdmin.js# Development mode (with nodemon)
npm run dev
# Production mode
npm start| Method | Endpoint | Description | Access |
|---|---|---|---|
| POST | /signup | Register a new Citizen | Public |
| POST | /login | Login (Returns JWT + Role) | Public |
| Method | Endpoint | Description | Access |
|---|---|---|---|
| POST | / | Report a new incident (Auto severity) | Citizen |
| GET | / | Get local incident feed (Newest first) | Citizen |
| POST | /:id/upvote | Verify an incident (+1) | Citizen |
| POST | /:id/downvote | Reject an incident (-1) | Citizen |
| Method | Endpoint | Description | Access |
|---|---|---|---|
| GET | /feed | Priority feed (Severity โ Votes) | Admin |
| PATCH | /:id | Update status or add notes | Admin |
| POST | /merge | Merge duplicate incidents | Admin |
| GET | /seed | Generate demo test data | Admin |
| Event Name | Payload | Trigger |
|---|---|---|
| new-incident | { incidentObject } | Citizen submits a report |
| incident-updated | { incidentObject } | Status, notes, or votes updated |
| incident-merged | { primaryId, duplicateId } | Admin merges incidents |
Dev-Hack-Backend/
โโโ controllers/
โโโ middleware/
โโโ models/
โโโ routes/
โโโ lib/
โโโ server.js
โโโ createAdmin.js
- Create Incident A โ Fire at Lab (10.0, 10.0)
- Create Incident B โ Smoke at Lab (10.0001, 10.0001)
- Login as Admin
- Merge using POST /api/admin/merge
{
"primaryId": "ID_OF_A",
"duplicateId": "ID_OF_B"
}ResQ-AI Backend provides:
- Low-latency emergency coordination
- High incident credibility through consensus
- Scalable real-time architecture
- Production-grade geospatial intelligence
| Unverified Incident | Verified Incident |
|---|---|
![]() |
![]() |




