# sarthakjain350/nexus architecture

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

- Interactive diagram: https://gitdiagram.com/sarthakjain350/nexus
- Repository: https://github.com/sarthakjain350/nexus

## Overview

NEXUS turns camera video into vehicle tracks and plate reads, stores observations and journeys, then exposes them through a GIS dashboard with analytics and alerts. The README documents the R1→R2→R3 workflow and major R4/R5 capabilities; excerpts additionally show observation ingestion, query responsibilities, and local video processing. Some frontend and model internals were not sampled, so their documented capabilities are included without speculative internal links.

Main entry points: [`frontend/src/App.jsx`](https://github.com/sarthakjain350/nexus/blob/main/frontend/src/App.jsx) (Dashboard application), [`backend/app/main.py`](https://github.com/sarthakjain350/nexus/blob/main/backend/app/main.py) (Backend API), [`backend/app/services/observation_service.py`](https://github.com/sarthakjain350/nexus/blob/main/backend/app/services/observation_service.py) (Observation ingestion), [`backend/app/repositories`](https://github.com/sarthakjain350/nexus/tree/main/backend/app/repositories) (Data repositories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vision["Detection and ANPR"]
  node_tracking["Vehicle tracking<br/>[r1_tracker.py]"]
  node_anpr["ANPR engine<br/>[app.py]"]
  node_live_ingest["Video ingest runner"]
end

subgraph group_backend["Ingestion and records"]
  node_video_upload["Video uploads<br/>[video_service.py]"]
  node_api["Backend API<br/>[main.py]"]
  node_ingest["Observation ingestion"]
  node_contract["Observation contract<br/>[observation.py]"]
  node_queries["Record queries<br/>[query_service.py]"]
  node_repositories["Data repositories"]
  node_database[("PostgreSQL")]
end

subgraph group_dashboard["Dashboard and analytics"]
  node_dashboard_app["Dashboard application<br/>[App.jsx]"]
  node_gis["GIS dashboard<br/>[TacticalMap.jsx]"]
  node_live_feed["Observation feed<br/>[LiveFeedTable.jsx]"]
  node_journeys["Journey tracking views"]
end

subgraph group_ml["Re-ID and alerts"]
  node_analytics["Traffic analytics"]
  node_alerts["Anomaly alerts"]
  node_reid["Vehicle re-identification<br/>[vehicle_reid.py]"]
end

node_camera_feeds(("CCTV feeds"))

node_camera_feeds -->|"provides video"| node_tracking
node_tracking -->|"passes vehicle crops"| node_anpr
node_anpr -->|"submits observations"| node_api
node_video_upload -->|"runs pipeline"| node_live_ingest
node_live_ingest -->|"posts observations"| node_api
node_api -.->|"routes ingestion"| node_ingest
node_ingest -->|"validates payload"| node_contract
node_ingest -->|"reads and writes"| node_repositories
node_queries -->|"queries records"| node_repositories
node_repositories -->|"persists records"| node_database
node_dashboard_app -->|"requests REST data"| node_api
node_dashboard_app -->|"renders map"| node_gis
node_dashboard_app -->|"renders observations"| node_live_feed
node_dashboard_app -->|"computes analytics"| node_analytics
node_dashboard_app -->|"generates alerts"| node_alerts
node_dashboard_app -->|"shows journeys"| node_journeys
node_api -.->|"supports fusion contract"| node_reid
node_api -->|"serves analytics inputs"| node_analytics

click node_tracking "https://github.com/sarthakjain350/nexus/blob/main/src/tracking/r1_tracker.py"
click node_anpr "https://github.com/sarthakjain350/nexus/blob/main/app.py"
click node_video_upload "https://github.com/sarthakjain350/nexus/blob/main/backend/app/services/video_service.py"
click node_live_ingest "https://github.com/sarthakjain350/nexus/blob/main/scripts/run_video_live_ingest.py"
click node_api "https://github.com/sarthakjain350/nexus/blob/main/backend/app/main.py"
click node_ingest "https://github.com/sarthakjain350/nexus/blob/main/backend/app/services/observation_service.py"
click node_contract "https://github.com/sarthakjain350/nexus/blob/main/backend/app/schemas/observation.py"
click node_queries "https://github.com/sarthakjain350/nexus/blob/main/backend/app/services/query_service.py"
click node_repositories "https://github.com/sarthakjain350/nexus/tree/main/backend/app/repositories"
click node_dashboard_app "https://github.com/sarthakjain350/nexus/blob/main/frontend/src/App.jsx"
click node_gis "https://github.com/sarthakjain350/nexus/blob/main/frontend/src/components/map/TacticalMap.jsx"
click node_live_feed "https://github.com/sarthakjain350/nexus/blob/main/frontend/src/components/observations/LiveFeedTable.jsx"
click node_analytics "https://github.com/sarthakjain350/nexus/blob/main/analytics/traffic_analyzer.py"
click node_alerts "https://github.com/sarthakjain350/nexus/blob/main/analytics/anomaly_detector.py"
click node_reid "https://github.com/sarthakjain350/nexus/blob/main/reid/vehicle_reid.py"
click node_journeys "https://github.com/sarthakjain350/nexus/blob/main/frontend/src/components/tracking/CrossCameraJourney.jsx"

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_tracking,node_anpr,node_live_ingest toneBlue
class node_video_upload,node_api,node_ingest,node_contract,node_queries,node_repositories,node_database toneAmber
class node_dashboard_app,node_gis,node_live_feed,node_journeys toneMint
class node_analytics,node_alerts,node_reid toneRose
class node_camera_feeds toneIndigo
```

## Components

### Detection and ANPR

- [Vehicle tracking](https://github.com/sarthakjain350/nexus/blob/main/src/tracking/r1_tracker.py): `src/tracking/r1_tracker.py`
- [ANPR engine](https://github.com/sarthakjain350/nexus/blob/main/app.py): `app.py`
- [Video ingest runner](https://github.com/sarthakjain350/nexus/blob/main/scripts/run_video_live_ingest.py): `scripts/run_video_live_ingest.py`

### Ingestion and records

- [Video uploads](https://github.com/sarthakjain350/nexus/blob/main/backend/app/services/video_service.py): `backend/app/services/video_service.py`
- [Backend API](https://github.com/sarthakjain350/nexus/blob/main/backend/app/main.py): `backend/app/main.py`
- [Observation ingestion](https://github.com/sarthakjain350/nexus/blob/main/backend/app/services/observation_service.py): `backend/app/services/observation_service.py`
- [Observation contract](https://github.com/sarthakjain350/nexus/blob/main/backend/app/schemas/observation.py): `backend/app/schemas/observation.py`
- [Record queries](https://github.com/sarthakjain350/nexus/blob/main/backend/app/services/query_service.py): `backend/app/services/query_service.py`
- [Data repositories](https://github.com/sarthakjain350/nexus/tree/main/backend/app/repositories): `backend/app/repositories`
- **PostgreSQL**

### Dashboard and analytics

- [Dashboard application](https://github.com/sarthakjain350/nexus/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [GIS dashboard](https://github.com/sarthakjain350/nexus/blob/main/frontend/src/components/map/TacticalMap.jsx): `frontend/src/components/map/TacticalMap.jsx`
- [Observation feed](https://github.com/sarthakjain350/nexus/blob/main/frontend/src/components/observations/LiveFeedTable.jsx): `frontend/src/components/observations/LiveFeedTable.jsx`
- [Journey tracking views](https://github.com/sarthakjain350/nexus/blob/main/frontend/src/components/tracking/CrossCameraJourney.jsx): `frontend/src/components/tracking/CrossCameraJourney.jsx`

### Re-ID and alerts

- [Traffic analytics](https://github.com/sarthakjain350/nexus/blob/main/analytics/traffic_analyzer.py): `analytics/traffic_analyzer.py`
- [Anomaly alerts](https://github.com/sarthakjain350/nexus/blob/main/analytics/anomaly_detector.py): `analytics/anomaly_detector.py`
- [Vehicle re-identification](https://github.com/sarthakjain350/nexus/blob/main/reid/vehicle_reid.py): `reid/vehicle_reid.py`

### Other components

- **CCTV feeds**

## Connections

- CCTV feeds → Vehicle tracking: provides video
- Vehicle tracking → ANPR engine: passes vehicle crops
- ANPR engine → Backend API: submits observations
- Video uploads → Video ingest runner: runs pipeline (evidence: `backend/app/services/video_service.py`)
- Video ingest runner → Backend API: posts observations
- Backend API → Observation ingestion: routes ingestion
- Observation ingestion → Observation contract: validates payload (evidence: `backend/app/services/observation_service.py`)
- Observation ingestion → Data repositories: reads and writes (evidence: `backend/app/services/observation_service.py`)
- Record queries → Data repositories: queries records (evidence: `backend/app/services/query_service.py`)
- Data repositories → PostgreSQL: persists records
- Dashboard application → Backend API: requests REST data
- Dashboard application → GIS dashboard: renders map (evidence: `frontend/src/App.jsx`)
- Dashboard application → Observation feed: renders observations (evidence: `frontend/src/App.jsx`)
- Dashboard application → Traffic analytics: computes analytics (evidence: `frontend/src/App.jsx`)
- Dashboard application → Anomaly alerts: generates alerts (evidence: `frontend/src/App.jsx`)
- Dashboard application → Journey tracking views: shows journeys (evidence: `frontend/src/App.jsx`)
- Backend API → Vehicle re-identification: supports fusion contract
- Backend API → Traffic analytics: serves analytics inputs
