# thanushamh/leanonus architecture

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

- Interactive diagram: https://gitdiagram.com/thanushamh/leanonus
- Repository: https://github.com/thanushamh/leanonus

## Overview

Worker Re-ID processes surveillance video through person detection, short-term tracking, quality filtering, appearance embedding, and persistent identity matching, then produces annotated video, event logs, and snapshots. The web dashboard is a documented alternate interface for demo and custom-video runs. Some runtime files, including the web server and OSNet extractor, were not excerpted, so their internal connections are limited to documented relationships.

Main entry points: [`src/worker_reid/pipeline.py`](https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/pipeline.py) (Video Pipeline), [`web_server.py`](https://github.com/thanushamh/leanonus/blob/main/web_server.py) (Dashboard Server), [`src/worker_reid/identity_manager.py`](https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/identity_manager.py) (Identity Manager), [`src/worker_reid/cli.py`](https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/cli.py) (Command Line)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Run Interfaces"]
  node_cli["Command Line<br/>[cli.py]"]
  node_dashboard["Web Dashboard<br/>[app.js]"]
  node_webserver["Dashboard Server<br/>[web_server.py]"]
end

subgraph group_vision["Frame Analysis"]
  node_pipeline["Video Pipeline<br/>[pipeline.py]"]
  node_config["Config Loader<br/>[config.py]"]
  node_detector["Person Detector<br/>[detector_cloud.py]"]
  node_tracker["ByteTrack Wrapper<br/>[tracker.py]"]
  node_quality["Detection Filter<br/>[quality.py]"]
end

subgraph group_identity["Identity Resolution"]
  node_extractor["OSNet Extractor<br/>[reid_extractor.py]"]
  node_manager["Identity Manager"]
  node_gallery[("Exemplar Gallery<br/>[gallery.py]")]
end

subgraph group_outputs["Results and Dashboard"]
  node_visualizer["Video Overlay<br/>[visualizer.py]"]
  node_annotated["Annotated Video"]
  node_events["Event Audit Log"]
  node_snapshots["Event Snapshots"]
end

node_operator(("Operator"))
node_video(("Input Video"))
node_yolo{{"YOLO Cloud API"}}

node_operator -->|"runs"| node_cli
node_operator -->|"uses"| node_dashboard
node_video -->|"frames"| node_pipeline
node_cli -->|"invokes"| node_pipeline
node_dashboard -->|"requests runs"| node_webserver
node_webserver -->|"starts processing"| node_pipeline
node_pipeline -->|"loads settings"| node_config
node_pipeline -->|"detects people"| node_detector
node_detector -->|"requests detections"| node_yolo
node_pipeline -->|"tracks detections"| node_tracker
node_pipeline -->|"filters tracks"| node_quality
node_pipeline -->|"updates identities"| node_manager
node_manager -->|"extracts embeddings"| node_extractor
node_manager -->|"matches profiles"| node_gallery
node_pipeline -->|"reads profiles"| node_gallery
node_pipeline -->|"draws overlay"| node_visualizer
node_pipeline -->|"writes video"| node_annotated
node_pipeline -->|"writes events"| node_events
node_pipeline -->|"saves snapshots"| node_snapshots
node_webserver -.->|"serves results"| node_annotated
node_webserver -.->|"serves results"| node_events
node_webserver -.->|"serves results"| node_snapshots

click node_cli "https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/cli.py"
click node_dashboard "https://github.com/thanushamh/leanonus/blob/main/web/app.js"
click node_webserver "https://github.com/thanushamh/leanonus/blob/main/web_server.py"
click node_pipeline "https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/pipeline.py"
click node_config "https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/config.py"
click node_detector "https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/detector_cloud.py"
click node_tracker "https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/tracker.py"
click node_quality "https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/quality.py"
click node_extractor "https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/reid_extractor.py"
click node_manager "https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/identity_manager.py"
click node_gallery "https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/gallery.py"
click node_visualizer "https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/visualizer.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_cli,node_dashboard,node_webserver toneBlue
class node_pipeline,node_config,node_detector,node_tracker,node_quality toneAmber
class node_extractor,node_manager,node_gallery,node_yolo toneMint
class node_visualizer,node_annotated,node_events,node_snapshots toneRose
class node_operator,node_video toneIndigo
```

## Components

### Run Interfaces

- [Command Line](https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/cli.py): `src/worker_reid/cli.py`
- [Web Dashboard](https://github.com/thanushamh/leanonus/blob/main/web/app.js): `web/app.js`
- [Dashboard Server](https://github.com/thanushamh/leanonus/blob/main/web_server.py): `web_server.py`

### Frame Analysis

- [Video Pipeline](https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/pipeline.py): `src/worker_reid/pipeline.py`
- [Config Loader](https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/config.py): `src/worker_reid/config.py`
- [Person Detector](https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/detector_cloud.py): `src/worker_reid/detector_cloud.py`
- [ByteTrack Wrapper](https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/tracker.py): `src/worker_reid/tracker.py`
- [Detection Filter](https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/quality.py): `src/worker_reid/quality.py`

### Identity Resolution

- [OSNet Extractor](https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/reid_extractor.py): `src/worker_reid/reid_extractor.py`
- [Identity Manager](https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/identity_manager.py): `src/worker_reid/identity_manager.py`
- [Exemplar Gallery](https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/gallery.py): `src/worker_reid/gallery.py`

### Results and Dashboard

- [Video Overlay](https://github.com/thanushamh/leanonus/blob/main/src/worker_reid/visualizer.py): `src/worker_reid/visualizer.py`
- **Annotated Video**
- **Event Audit Log**
- **Event Snapshots**

### Other components

- **Operator**
- **Input Video**
- **YOLO Cloud API**

## Connections

- Operator → Command Line: runs (evidence: `README.md`)
- Operator → Web Dashboard: uses (evidence: `README.md`)
- Input Video → Video Pipeline: frames (evidence: `src/worker_reid/pipeline.py`)
- Command Line → Video Pipeline: invokes (evidence: `src/worker_reid/cli.py`)
- Web Dashboard → Dashboard Server: requests runs (evidence: `README.md`)
- Dashboard Server → Video Pipeline: starts processing (evidence: `README.md`)
- Video Pipeline → Config Loader: loads settings (evidence: `src/worker_reid/pipeline.py`)
- Video Pipeline → Person Detector: detects people (evidence: `src/worker_reid/pipeline.py`)
- Person Detector → YOLO Cloud API: requests detections (evidence: `src/worker_reid/detector_cloud.py`)
- Video Pipeline → ByteTrack Wrapper: tracks detections (evidence: `src/worker_reid/pipeline.py`)
- Video Pipeline → Detection Filter: filters tracks (evidence: `src/worker_reid/pipeline.py`)
- Video Pipeline → Identity Manager: updates identities (evidence: `src/worker_reid/pipeline.py`)
- Identity Manager → OSNet Extractor: extracts embeddings (evidence: `src/worker_reid/identity_manager.py`)
- Identity Manager → Exemplar Gallery: matches profiles (evidence: `src/worker_reid/identity_manager.py`)
- Video Pipeline → Exemplar Gallery: reads profiles (evidence: `src/worker_reid/pipeline.py`)
- Video Pipeline → Video Overlay: draws overlay (evidence: `src/worker_reid/pipeline.py`)
- Video Pipeline → Annotated Video: writes video (evidence: `README.md`)
- Video Pipeline → Event Audit Log: writes events (evidence: `src/worker_reid/pipeline.py`)
- Video Pipeline → Event Snapshots: saves snapshots (evidence: `src/worker_reid/pipeline.py`)
- Dashboard Server → Annotated Video: serves results
- Dashboard Server → Event Audit Log: serves results
- Dashboard Server → Event Snapshots: serves results
