# rishit-ui/resqtrack architecture

> Architecture diagram of the GitHub repository rishit-ui/resqtrack, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rishit-ui/resqtrack
- Repository: https://github.com/rishit-ui/resqtrack

## Overview

ResQTrack detects and confirms road incidents from camera video, then alerts the response backend to coordinate responders, scene navigation, nearby facilities, and case tracking. The detector also builds vehicle profiles and renders an operator HUD. The README documents dashboard/responder experiences and the end-to-end response stages. Some modules are represented from the source index or README rather than inspected source; their internal links are omitted where the available evidence does not establish ownership.

Main entry points: [`backend/app.py`](https://github.com/rishit-ui/resqtrack/blob/main/backend/app.py) (Response API), [`main_before_database_debug.py`](https://github.com/rishit-ui/resqtrack/blob/main/main_before_database_debug.py) (Video detector), [`backend/services/routing_service.py`](https://github.com/rishit-ui/resqtrack/blob/main/backend/services/routing_service.py) (Road routing), [`backend/services/hospital_service.py`](https://github.com/rishit-ui/resqtrack/blob/main/backend/services/hospital_service.py) (Facility search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_detect["Detection and evidence"]
  node_detector["Video detector"]
  node_incident["Incident reasoning<br/>[incident_engine.py]"]
  node_profiles["Vehicle profiles<br/>[vehicle_profile.py]"]
  node_kinematics["Motion features<br/>[kinematics.py]"]
  node_hud["Detector HUD<br/>[overlay.py]"]
end

subgraph group_response["Incident response"]
  node_alert["Alert sender<br/>[alert_client.py]"]
  node_api["Response API<br/>[app.py]"]
  node_dispatch["Responder dispatch<br/>[dispatch.py]"]
end

subgraph group_routing["Routing and facilities"]
  node_geo["Geospatial services<br/>[geo.py]"]
  node_route["Road routing<br/>[routing_service.py]"]
  node_traffic["Traffic scoring<br/>[traffic.py]"]
  node_hospitals["Facility search"]
end

subgraph group_state["Realtime and records"]
  node_db[("Incident database<br/>[database.py]")]
  node_realtime["Live updates<br/>[realtime.py]"]
end

subgraph group_models["Temporal analysis"]
  node_temporal["Temporal detector"]
  node_features["Feature engine"]
  node_ml["Model inference"]
  node_legacy_logic["Accident logic<br/>[accident_logic.py]"]
end

node_camera(("Traffic camera"))
node_dashboard["Control room"]
node_responder["Responder app"]

node_camera -->|"provides video"| node_detector
node_detector -->|"evaluates frames"| node_incident
node_detector -->|"updates profiles"| node_profiles
node_profiles -->|"uses motion"| node_kinematics
node_detector -->|"renders overlay"| node_hud
node_incident -->|"supplies evidence"| node_hud
node_detector -->|"queues alert"| node_alert
node_alert -->|"posts incident"| node_api
node_api -->|"selects responders"| node_dispatch
node_dispatch -->|"uses location"| node_geo
node_api -->|"requests routes"| node_route
node_route -->|"uses coordinates"| node_geo
node_route -->|"scores alternatives"| node_traffic
node_api -->|"searches facilities"| node_hospitals
node_hospitals -->|"uses coordinates"| node_geo
node_hospitals -->|"ranks by road time"| node_route
node_api -->|"reads and writes"| node_db
node_realtime -->|"reads records"| node_db
node_api -.->|"broadcasts updates"| node_realtime
node_dashboard -->|"views incidents"| node_api
node_responder -->|"accepts dispatch"| node_api
node_features -.->|"supplies features"| node_temporal
node_temporal -.->|"uses model"| node_ml

click node_detector "https://github.com/rishit-ui/resqtrack/blob/main/main_before_database_debug.py"
click node_incident "https://github.com/rishit-ui/resqtrack/blob/main/vision/incident_engine.py"
click node_profiles "https://github.com/rishit-ui/resqtrack/blob/main/vision/vehicle_profile.py"
click node_kinematics "https://github.com/rishit-ui/resqtrack/blob/main/vision/kinematics.py"
click node_hud "https://github.com/rishit-ui/resqtrack/blob/main/vision/overlay.py"
click node_alert "https://github.com/rishit-ui/resqtrack/blob/main/vision/alert_client.py"
click node_api "https://github.com/rishit-ui/resqtrack/blob/main/backend/app.py"
click node_dispatch "https://github.com/rishit-ui/resqtrack/blob/main/backend/services/dispatch.py"
click node_geo "https://github.com/rishit-ui/resqtrack/blob/main/backend/services/geo.py"
click node_route "https://github.com/rishit-ui/resqtrack/blob/main/backend/services/routing_service.py"
click node_traffic "https://github.com/rishit-ui/resqtrack/blob/main/backend/services/traffic.py"
click node_hospitals "https://github.com/rishit-ui/resqtrack/blob/main/backend/services/hospital_service.py"
click node_db "https://github.com/rishit-ui/resqtrack/blob/main/backend/database.py"
click node_realtime "https://github.com/rishit-ui/resqtrack/blob/main/backend/realtime.py"
click node_temporal "https://github.com/rishit-ui/resqtrack/blob/main/temporal_detector.py"
click node_features "https://github.com/rishit-ui/resqtrack/blob/main/temporal_features_engine.py"
click node_ml "https://github.com/rishit-ui/resqtrack/blob/main/temporal_ml_inference.py"
click node_legacy_logic "https://github.com/rishit-ui/resqtrack/blob/main/accident_logic.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_detector,node_incident,node_profiles,node_kinematics,node_hud toneBlue
class node_alert,node_api,node_dispatch toneAmber
class node_geo,node_route,node_traffic,node_hospitals toneMint
class node_db,node_realtime toneRose
class node_temporal,node_features,node_ml,node_legacy_logic,node_camera,node_dashboard,node_responder toneIndigo
```

## Components

### Detection and evidence

- [Video detector](https://github.com/rishit-ui/resqtrack/blob/main/main_before_database_debug.py): `main_before_database_debug.py`
- [Incident reasoning](https://github.com/rishit-ui/resqtrack/blob/main/vision/incident_engine.py): `vision/incident_engine.py`
- [Vehicle profiles](https://github.com/rishit-ui/resqtrack/blob/main/vision/vehicle_profile.py): `vision/vehicle_profile.py`
- [Motion features](https://github.com/rishit-ui/resqtrack/blob/main/vision/kinematics.py): `vision/kinematics.py`
- [Detector HUD](https://github.com/rishit-ui/resqtrack/blob/main/vision/overlay.py): `vision/overlay.py`

### Incident response

- [Alert sender](https://github.com/rishit-ui/resqtrack/blob/main/vision/alert_client.py): `vision/alert_client.py`
- [Response API](https://github.com/rishit-ui/resqtrack/blob/main/backend/app.py): `backend/app.py`
- [Responder dispatch](https://github.com/rishit-ui/resqtrack/blob/main/backend/services/dispatch.py): `backend/services/dispatch.py`

### Routing and facilities

- [Geospatial services](https://github.com/rishit-ui/resqtrack/blob/main/backend/services/geo.py): `backend/services/geo.py`
- [Road routing](https://github.com/rishit-ui/resqtrack/blob/main/backend/services/routing_service.py): `backend/services/routing_service.py`
- [Traffic scoring](https://github.com/rishit-ui/resqtrack/blob/main/backend/services/traffic.py): `backend/services/traffic.py`
- [Facility search](https://github.com/rishit-ui/resqtrack/blob/main/backend/services/hospital_service.py): `backend/services/hospital_service.py`

### Realtime and records

- [Incident database](https://github.com/rishit-ui/resqtrack/blob/main/backend/database.py): `backend/database.py`
- [Live updates](https://github.com/rishit-ui/resqtrack/blob/main/backend/realtime.py): `backend/realtime.py`

### Temporal analysis

- [Temporal detector](https://github.com/rishit-ui/resqtrack/blob/main/temporal_detector.py): `temporal_detector.py`
- [Feature engine](https://github.com/rishit-ui/resqtrack/blob/main/temporal_features_engine.py): `temporal_features_engine.py`
- [Model inference](https://github.com/rishit-ui/resqtrack/blob/main/temporal_ml_inference.py): `temporal_ml_inference.py`
- [Accident logic](https://github.com/rishit-ui/resqtrack/blob/main/accident_logic.py): `accident_logic.py`

### Other components

- **Traffic camera**
- **Control room**
- **Responder app**

## Connections

- Traffic camera → Video detector: provides video
- Video detector → Incident reasoning: evaluates frames (evidence: `main_before_database_debug.py`)
- Video detector → Vehicle profiles: updates profiles (evidence: `main_before_database_debug.py`)
- Vehicle profiles → Motion features: uses motion (evidence: `vision/vehicle_profile.py`)
- Video detector → Detector HUD: renders overlay (evidence: `main_before_database_debug.py`)
- Incident reasoning → Detector HUD: supplies evidence (evidence: `vision/overlay.py`)
- Video detector → Alert sender: queues alert (evidence: `main_before_database_debug.py`)
- Alert sender → Response API: posts incident (evidence: `vision/alert_client.py`)
- Response API → Responder dispatch: selects responders (evidence: `backend/app.py`)
- Responder dispatch → Geospatial services: uses location (evidence: `backend/services/dispatch.py`)
- Response API → Road routing: requests routes (evidence: `backend/app.py`)
- Road routing → Geospatial services: uses coordinates (evidence: `backend/services/routing_service.py`)
- Road routing → Traffic scoring: scores alternatives (evidence: `backend/services/routing_service.py`)
- Response API → Facility search: searches facilities (evidence: `backend/app.py`)
- Facility search → Geospatial services: uses coordinates (evidence: `backend/services/hospital_service.py`)
- Facility search → Road routing: ranks by road time (evidence: `backend/services/hospital_service.py`)
- Response API → Incident database: reads and writes (evidence: `backend/app.py`)
- Live updates → Incident database: reads records (evidence: `backend/realtime.py`)
- Response API → Live updates: broadcasts updates (evidence: `backend/app.py`)
- Control room → Response API: views incidents
- Responder app → Response API: accepts dispatch
- Feature engine → Temporal detector: supplies features
- Temporal detector → Model inference: uses model
