# himadri2041/purplle architecture

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

- Interactive diagram: https://gitdiagram.com/himadri2041/purplle
- Repository: https://github.com/himadri2041/purplle

## Overview

Purplle converts CCTV video into visitor and zone events, then ingests those events into a FastAPI analytics service. The main documented path is detection/tracking and staff filtering → event log → ingestion and normalization → store analytics → API results and dashboard. The graph also preserves the documented analytics capabilities and the separate video-processing/ReID implementation. Some pipeline internals and analytics endpoints were not sampled, so their connections are shown only where the README or source index supports them.

Main entry points: [`api/intelligence.py`](https://github.com/himadri2041/purplle/blob/main/api/intelligence.py) (Intelligence store), [`pipeline/detect_track.py`](https://github.com/himadri2041/purplle/blob/main/pipeline/detect_track.py) (Detection and tracking), [`app/main.py`](https://github.com/himadri2041/purplle/blob/main/app/main.py) (FastAPI service), [`pipeline/process_video.py`](https://github.com/himadri2041/purplle/blob/main/pipeline/process_video.py) (Video processor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vision["Video analytics"]
  node_tracking["Detection and tracking<br/>[detect_track.py]"]
  node_identity["Visitor identity<br/>[reid_manager.py]"]
  node_staff["Staff filtering<br/>[uniform.py]"]
  node_video_processor["Video processor<br/>[process_video.py]"]
  node_zone_classifier["Zone classifier<br/>[event_emitter.py]"]
end

subgraph group_eventflow["Event processing"]
  node_event_schema["Event schema<br/>[event_schema.py]"]
  node_event_log[("Event log<br/>[events.jsonl]")]
  node_ingestion["Event ingestion<br/>[ingestion.py]"]
end

subgraph group_intelligence["Store intelligence"]
  node_intelligence_store[("Intelligence store<br/>[intelligence.py]")]
  node_metrics["Metrics<br/>[metrics.py]"]
  node_funnel["Conversion funnel<br/>[funnel.py]"]
  node_heatmap["Zone heatmap<br/>[intelligence.py]"]
  node_anomalies["Anomaly detection<br/>[anomalies.py]"]
  node_health["Feed health<br/>[health.py]"]
  node_analytics_compat["Analytics compatibility<br/>[analytics.py]"]
end

subgraph group_interface["API experience"]
  node_api["FastAPI service<br/>[main.py]"]
  node_dashboard["Web dashboard<br/>[index.html]"]
end

node_camera(("CCTV video"))
node_operator(("Store operator"))

node_camera -->|"provides footage"| node_tracking
node_tracking -->|"filters staff"| node_staff
node_tracking -->|"writes events"| node_event_log
node_tracking -.->|"emits event records"| node_event_schema
node_video_processor -->|"assigns identities"| node_identity
node_video_processor -->|"imports classifier"| node_zone_classifier
node_video_processor -.->|"emits events"| node_event_log
node_event_log -->|"loads file"| node_ingestion
node_api -->|"routes ingest"| node_ingestion
node_ingestion -->|"ingests batch"| node_intelligence_store
node_event_schema -->|"normalizes events"| node_intelligence_store
node_api -->|"requests analytics"| node_intelligence_store
node_metrics -->|"requests metrics"| node_intelligence_store
node_funnel -->|"supports funnel"| node_intelligence_store
node_heatmap -->|"computes heatmap"| node_intelligence_store
node_anomalies -->|"supports anomalies"| node_intelligence_store
node_health -->|"supports health"| node_intelligence_store
node_analytics_compat -->|"uses analytics store"| node_intelligence_store
node_operator -->|"requests results"| node_api
node_operator -->|"views dashboard"| node_dashboard
node_dashboard -.->|"requests data"| node_api

click node_tracking "https://github.com/himadri2041/purplle/blob/main/pipeline/detect_track.py"
click node_identity "https://github.com/himadri2041/purplle/blob/main/reid_manager.py"
click node_staff "https://github.com/himadri2041/purplle/blob/main/pipeline/uniform.py"
click node_video_processor "https://github.com/himadri2041/purplle/blob/main/pipeline/process_video.py"
click node_zone_classifier "https://github.com/himadri2041/purplle/blob/main/pipeline/event_emitter.py"
click node_event_schema "https://github.com/himadri2041/purplle/blob/main/pipeline/event_schema.py"
click node_event_log "https://github.com/himadri2041/purplle/blob/main/api/events.jsonl"
click node_ingestion "https://github.com/himadri2041/purplle/blob/main/app/ingestion.py"
click node_intelligence_store "https://github.com/himadri2041/purplle/blob/main/api/intelligence.py"
click node_metrics "https://github.com/himadri2041/purplle/blob/main/app/metrics.py"
click node_funnel "https://github.com/himadri2041/purplle/blob/main/app/funnel.py"
click node_heatmap "https://github.com/himadri2041/purplle/blob/main/api/intelligence.py"
click node_anomalies "https://github.com/himadri2041/purplle/blob/main/app/anomalies.py"
click node_health "https://github.com/himadri2041/purplle/blob/main/app/health.py"
click node_analytics_compat "https://github.com/himadri2041/purplle/blob/main/api/analytics.py"
click node_api "https://github.com/himadri2041/purplle/blob/main/app/main.py"
click node_dashboard "https://github.com/himadri2041/purplle/blob/main/dashboard/index.html"

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_identity,node_staff,node_video_processor,node_zone_classifier toneBlue
class node_event_schema,node_event_log,node_ingestion toneAmber
class node_intelligence_store,node_metrics,node_funnel,node_heatmap,node_anomalies,node_health,node_analytics_compat toneMint
class node_api,node_dashboard toneRose
class node_camera,node_operator toneIndigo
```

## Components

### Video analytics

- [Detection and tracking](https://github.com/himadri2041/purplle/blob/main/pipeline/detect_track.py): `pipeline/detect_track.py`
- [Visitor identity](https://github.com/himadri2041/purplle/blob/main/reid_manager.py): `reid_manager.py`
- [Staff filtering](https://github.com/himadri2041/purplle/blob/main/pipeline/uniform.py): `pipeline/uniform.py`
- [Video processor](https://github.com/himadri2041/purplle/blob/main/pipeline/process_video.py): `pipeline/process_video.py`
- [Zone classifier](https://github.com/himadri2041/purplle/blob/main/pipeline/event_emitter.py): `pipeline/event_emitter.py`

### Event processing

- [Event schema](https://github.com/himadri2041/purplle/blob/main/pipeline/event_schema.py): `pipeline/event_schema.py`
- [Event log](https://github.com/himadri2041/purplle/blob/main/api/events.jsonl): `api/events.jsonl`
- [Event ingestion](https://github.com/himadri2041/purplle/blob/main/app/ingestion.py): `app/ingestion.py`

### Store intelligence

- [Intelligence store](https://github.com/himadri2041/purplle/blob/main/api/intelligence.py): `api/intelligence.py`
- [Metrics](https://github.com/himadri2041/purplle/blob/main/app/metrics.py): `app/metrics.py`
- [Conversion funnel](https://github.com/himadri2041/purplle/blob/main/app/funnel.py): `app/funnel.py`
- [Zone heatmap](https://github.com/himadri2041/purplle/blob/main/api/intelligence.py): `api/intelligence.py`
- [Anomaly detection](https://github.com/himadri2041/purplle/blob/main/app/anomalies.py): `app/anomalies.py`
- [Feed health](https://github.com/himadri2041/purplle/blob/main/app/health.py): `app/health.py`
- [Analytics compatibility](https://github.com/himadri2041/purplle/blob/main/api/analytics.py): `api/analytics.py`

### API experience

- [FastAPI service](https://github.com/himadri2041/purplle/blob/main/app/main.py): `app/main.py`
- [Web dashboard](https://github.com/himadri2041/purplle/blob/main/dashboard/index.html): `dashboard/index.html`

### Other components

- **CCTV video**
- **Store operator**

## Connections

- CCTV video → Detection and tracking: provides footage (evidence: `README.md`)
- Detection and tracking → Staff filtering: filters staff (evidence: `pipeline/detect_track.py`)
- Detection and tracking → Event log: writes events (evidence: `README.md`)
- Detection and tracking → Event schema: emits event records
- Video processor → Visitor identity: assigns identities (evidence: `pipeline/process_video.py`)
- Video processor → Zone classifier: imports classifier (evidence: `pipeline/process_video.py`)
- Video processor → Event log: emits events
- Event log → Event ingestion: loads file
- FastAPI service → Event ingestion: routes ingest (evidence: `app/main.py`)
- Event ingestion → Intelligence store: ingests batch (evidence: `app/ingestion.py`)
- Event schema → Intelligence store: normalizes events (evidence: `api/intelligence.py`)
- FastAPI service → Intelligence store: requests analytics (evidence: `app/main.py`)
- Metrics → Intelligence store: requests metrics (evidence: `app/metrics.py`)
- Conversion funnel → Intelligence store: supports funnel (evidence: `README.md`)
- Zone heatmap → Intelligence store: computes heatmap (evidence: `README.md`)
- Anomaly detection → Intelligence store: supports anomalies (evidence: `README.md`)
- Feed health → Intelligence store: supports health (evidence: `README.md`)
- Analytics compatibility → Intelligence store: uses analytics store (evidence: `api/analytics.py`)
- Store operator → FastAPI service: requests results (evidence: `README.md`)
- Store operator → Web dashboard: views dashboard (evidence: `README.md`)
- Web dashboard → FastAPI service: requests data
