How team-qua-n-tum/ner-shield works
Purpose and Entry Points
NER-SHIELD is a logistics-accessibility platform for India’s North Eastern Region. It combines road, incident, weather, vehicle, and predicted disruption risk into route recommendations, alerts, and a GIS operations dashboard. Backend HTTP startup is backend/app/main.py; API v1 composition is backend/app/api/v1/api.py. The browser client starts at frontend/src/main.jsx and renders the application from frontend/src/App.jsx.
API and Application Boundary
FastAPI endpoint modules expose domain-oriented read/write operations for dashboards, roads, routes, risks, incidents, vehicles, districts, and alerts. Request/response contracts are isolated in schema modules, while application services coordinate domain logic rather than placing it in handlers.
Paths: backend/app/api/v1/endpoints/routes.py, backend/app/api/v1/endpoints/risk.py, backend/app/schemas/route.py, backend/app/services/routing_service.py.
Data Store and Operational Domain
The backend store is the persistence boundary for logistics state and likely connects API/services to configured database infrastructure. The intended production geospatial database is PostgreSQL/PostGIS; repository data folders provide road, incident, district, vehicle, weather, and synthetic-data inputs. Runtime configuration is centralized separately.
Paths: backend/app/db/store.py, backend/app/core/config.py, data/roads, data/incidents.
Risk and Disruption Intelligence
Risk analysis models road-disruption likelihood and provides explanations for results. A separate disruption training pipeline generates synthetic training data and trains model artifacts; application-level AI service bridges predictive capability to API/domain workflows. This is the boundary between offline ML preparation and online decision support.
Paths: backend/ai/risk/risk_engine.py, backend/ai/risk/model.py, backend/ai/risk/explainer.py, backend/ai/disruption/train.py, backend/app/services/ai_service.py.
Routing, Cost, and ETA Pipeline
Routing constructs a graph, derives cost from factors such as blockage/risk, finds and optimizes candidate paths, then estimates ETA. It supports the core flow: road and disruption state → risk-aware route selection → ETA → logistics recommendations/alerts. Routing is encapsulated independently of FastAPI, enabling service and test use.
Paths: backend/routing/graph.py, backend/routing/cost.py, backend/routing/engine.py, backend/routing/optimizer.py, backend/routing/eta.py.
Frontend Dashboard and Mapping
The Vite React frontend presents operations data through dashboard panels and layered maps: roads, districts, incidents, risks, routes, and vehicles. API client modules form its backend boundary, although bundled JSON/mock data indicates the UI can operate against local demonstration data. Leaflet/OpenStreetMap are intended map infrastructure; an OSRM utility indicates external routing integration potential.
Paths: frontend/src/components/dashboard/OperationsMap.jsx, frontend/src/components/map/NERMap.jsx, frontend/src/components/map/RiskLayer.jsx, frontend/src/lib/api/client.js, frontend/src/utils/osrm.js.
Deployment and External Dependencies
Docker artifacts support containerized backend and compose-based local deployment. Material external systems are PostgreSQL/PostGIS for geospatial persistence, OpenStreetMap/Leaflet for map visualization, and potentially OSRM for route geometry or routing. Environment-specific values are supplied outside source through .env.
Paths: backend/Dockerfile, backend/docker-compose.yml, docker-compose.yml, .env.example.
Main entry points: routes.py Route & risk endpoints · risk_engine.py Risk engine · routing_service.py Routing service · api.py API v1 router
Components 22
Backend API
- FastAPI startup
backend/app/main.py - API v1 router
backend/app/api/v1/api.py - Route & risk endpoints · Representative domain endpoints also cover dashboards, incidents, vehicles, districts, and alerts.
backend/app/api/v1/endpoints/routes.py - Route contracts
backend/app/schemas/route.py - Routing service · Coordinates route decisions outside HTTP handlers.
backend/app/services/routing_service.py - AI service · Bridges online prediction into domain workflows.
backend/app/services/ai_service.py - Logistics state store
backend/app/db/store.py - Runtime configuration
backend/app/core/config.py
Routing & Intelligence
- Risk engine
backend/ai/risk/risk_engine.py - Risk model
backend/ai/risk/model.py - Risk explanations
backend/ai/risk/explainer.py - Disruption training · Generates synthetic training data and model artifacts.
backend/ai/disruption/train.py - Road graph
backend/routing/graph.py - Risk-aware cost
backend/routing/cost.py - Route engine
backend/routing/engine.py - Route optimizer
backend/routing/optimizer.py - ETA estimator
backend/routing/eta.py
Operations Client
- React application
frontend/src/main.jsx - Operations map · Displays layered roads, districts, incidents, risks, routes, and vehicles.
frontend/src/components/dashboard/OperationsMap.jsx - API client
frontend/src/lib/api/client.js
Infrastructure
- PostgreSQL/PostGIS
- OpenStreetMap / Leaflet
Connections 22
- FastAPI startup → API v1 router: mounts
- API v1 router → Route & risk endpoints: routes requests
- Route & risk endpoints → Route contracts: uses contracts
- Route & risk endpoints → Routing service: requests routes
- Route & risk endpoints → AI service: requests risk
- Routing service → Logistics state store: reads road state
- Routing service → Route engine: selects routes
- AI service → Risk engine: evaluates risk
- Risk engine → Risk model: uses
- Risk engine → Risk explanations: explains
- Disruption training → Risk model: trains artifacts
- Road graph → Risk-aware cost: supplies network
- Risk-aware cost → Route engine: weights paths
- Risk engine → Risk-aware cost: provides disruption risk
- Route engine → Route optimizer: produces candidates
- Route optimizer → ETA estimator: selected route
- React application → Operations map: renders
- React application → API client: uses
- API client → API v1 router: HTTP requests
- Operations map → OpenStreetMap / Leaflet: renders with
- Logistics state store → PostgreSQL/PostGIS: persists to
- Runtime configuration → Logistics state store: configures