How ujjwalkumar6200/aerixon-backend works
Aerixon is an emergency-dispatch backend. Its main workflow accepts and validates an emergency, then dispatches manual or priority-based allocation; allocation atomically claims an available ambulance and updates emergency state. Separate API branches handle authentication, retries, audit records, and metrics. The graph preserves the documented capabilities, while several controller-to-service and route-to-controller links rely on SOURCE INDEX references rather than full excerpts; unsampled implementation details are not inferred.
Main entry points: app.js Express app · allocation.service.js Atomic allocation · server.js Server startup · allocation.routes.js Allocation routes
Components 34
API surface
- Express app
src/app.js - Emergency routes
src/routes/emergency.routes.js - Allocation routes
src/routes/allocation.routes.js - Priority routes
src/routes/priority.routes.js - Auto-allocation routes
src/routes/autoAllocation.routes.js - Retry routes
src/routes/retry.routes.js - Auth routes
src/routes/auth.routes.js - Audit routes
src/routes/audit.routes.js - Metrics routes
src/routes/metrics.routes.js
Emergency dispatch
- Emergency intake
src/controllers/emergency.controller.js - Request validation
src/validators/emergency.validator.js - Emergency records
src/models/emergency.model.js - Manual allocation
src/controllers/allocation.controller.js - Atomic allocation
src/services/allocation.service.js - Automatic allocation
src/controllers/autoAllocation.controller.js - Priority dispatch
src/services/autoAllocation.service.js - Priority ranking
src/services/priority.service.js - State transitions
src/utils/stateMachine.js - Retry endpoint
src/controllers/retry.controller.js - Retry policy
src/services/retry.service.js - Retry rules
src/utils/retryPolicy.js
Identity and operations
- JWT authorization
src/middlewares/auth.middleware.js - Login endpoint
src/controllers/auth.controller.js - Credential service
src/services/auth.service.js - User records
src/models/user.model.js - Audit endpoint
src/controllers/audit.controller.js - Audit logging
src/services/audit.service.js - Metrics endpoint
src/controllers/metrics.controller.js - Metrics aggregation
src/services/metrics.service.js
Runtime and storage
- Server startup
server.js - Database connection
src/config/db.js - MongoDB
- Ambulance records
src/models/ambulance.model.js
Other components
- API client
Connections 43
- API client → Express app: sends requests
src/app.js - Express app → Emergency routes: mounts routes
src/app.js - Express app → Allocation routes: mounts routes
src/app.js - Express app → Priority routes: mounts routes
src/app.js - Express app → Auto-allocation routes: mounts routes
src/app.js - Express app → Retry routes: mounts routes
src/app.js - Express app → Auth routes: mounts routes
src/app.js - Express app → Audit routes: mounts routes
src/app.js - Express app → Metrics routes: mounts routes
src/app.js - Emergency routes → Emergency intake: routes to
src/controllers/emergency.controller.js - Allocation routes → JWT authorization: checks access
src/routes/allocation.routes.js - Allocation routes → Manual allocation: routes to
src/routes/allocation.routes.js - Priority routes → Priority ranking: routes to
- Auto-allocation routes → Automatic allocation: routes to
src/routes/autoAllocation.routes.js - Retry routes → Retry endpoint: routes to
src/routes/retry.routes.js - Auth routes → Login endpoint: routes to
src/routes/auth.routes.js - Audit routes → JWT authorization: checks access
src/routes/audit.routes.js - Audit routes → Audit endpoint: routes to
src/routes/audit.routes.js - Metrics routes → JWT authorization: checks access
src/routes/metrics.routes.js - Metrics routes → Metrics endpoint: routes to
src/routes/metrics.routes.js - Emergency intake → Request validation: validates input
src/controllers/emergency.controller.js - Emergency intake → Emergency records: stores request
src/controllers/emergency.controller.js - Manual allocation → Atomic allocation: requests allocation
src/controllers/allocation.controller.js - Manual allocation → Audit logging: records outcome
src/controllers/allocation.controller.js - Automatic allocation → Priority dispatch: requests dispatch
src/controllers/autoAllocation.controller.js - Priority dispatch → Priority ranking: ranks emergencies
src/services/autoAllocation.service.js - Priority dispatch → Atomic allocation: allocates ambulance
src/services/autoAllocation.service.js - Atomic allocation → State transitions: checks transitions
src/services/allocation.service.js - Retry endpoint → Retry policy: requests retry
- Retry policy → Atomic allocation: retries allocation
src/services/retry.service.js - Retry policy → Retry rules: applies rules
src/services/retry.service.js - Login endpoint → Credential service: authenticates user
src/controllers/auth.controller.js - Credential service → User records: reads credentials
- Audit endpoint → Audit logging: reads audit data
- Metrics endpoint → Metrics aggregation: requests metrics
src/controllers/metrics.controller.js - Server startup → Database connection: connects database
server.js - Server startup → Emergency records: creates indexes
server.js - Server startup → Ambulance records: creates indexes
server.js - Database connection → MongoDB: connects to
src/config/db.js - Atomic allocation → MongoDB: reads and writes
src/services/allocation.service.js - Emergency records → MongoDB: stores records
src/models/emergency.model.js - Credential service → MongoDB: reads users
src/services/auth.service.js - Metrics aggregation → MongoDB: aggregates data