# sridesiyan/monitor-v2 architecture

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

- Interactive diagram: https://gitdiagram.com/sridesiyan/monitor-v2
- Repository: https://github.com/sridesiyan/monitor-v2

## Overview

#### Purpose and active shape
This repository implements restaurant-table video analytics: detecting people/pose, tracking staff and diners, associating activity with configured table regions, and producing occupancy, serving, cleanliness, and session records. It contains a legacy Python implementation under `coe-intern-main/` and a deployment-oriented `restaurant_monitoring/` application built around Axelera Voyager pipelines. The vendored `voyager-sdk-latest/` is runtime infrastructure, not restaurant business logic.

#### Entry points and orchestration
The deployment-facing entry points are `restaurant_monitoring/apps/main.py`, `restaurant_monitoring/inference.py`, and `restaurant_monitoring/deploy.py`. They initialize the runtime, execute a configured inference pipeline, and attach restaurant-specific postprocessing. The legacy/offline entry point is `coe-intern-main/analytics/pipeline.py`; a top-level `analytics/pipeline.py` also exists, suggesting an alternate wrapper or copy.

The primary declarative composition is `restaurant_monitoring/pipelines/restaurant_full_pipeline.yaml`, with separable detection, tracking, pose, serving, occupancy, rendering, database, and export pipeline definitions in `restaurant_monitoring/pipelines/`.

#### Video inference and tracking boundary
Frames enter through the application/runtime layer and are processed by an Axelera/Voyager graph. The restaurant pipeline configuration and model configuration are in:
- `restaurant_monitoring/pipelines/restaurant_detection.yaml`
- `restaurant_monitoring/pipelines/restaurant_tracking.yaml`
- `restaurant_monitoring/models/yolov8s.toml`

Detection/pose/tracker metadata crosses from the SDK-managed graph into Python business logic through `restaurant_monitoring/runtime/inference_runtime.py` and `restaurant_monitoring/decoders/embeddings.py`. The deployment includes a pose weight file, `restaurant_monitoring/yolov8n-pose.pt`. The SDK build artifacts show the full pipeline uses YOLO detection, YOLO pose, OSNet ReID, and OC-SORT tracking.

#### Table spatial model and state machine
Table definitions are a critical domain boundary: configured regions map raw tracked-person positions to restaurant tables. Core implementation paths are:
- `restaurant_monitoring/analytics/table_manager.py`
- `restaurant_monitoring/analytics/roi_config.py`
- `restaurant_monitoring/configs/tables.json`

ROI support includes automatic/dwell-based derivation (`restaurant_monitoring/analytics/auto_roi.py`, `restaurant_monitoring/analytics/dwell_cluster.py`), but configured tables are the stable interface consumed by analytics. Per-table lifecycle transitions are controlled by `restaurant_monitoring/restaurant/table_fsm.py`, separating temporal restaurant state from frame-level model detections.

#### Restaurant event analytics
Business rules consume tracks, pose/embedding signals, table assignments, and FSM state:
- Occupancy: `restaurant_monitoring/restaurant/occupancy_engine.py`
- Serving detection: `restaurant_monitoring/restaurant/serving_detector.py`
- Customer/session continuity: `restaurant_monitoring/restaurant/session_manager.py`
- Cleanliness/plate state: `restaurant_monitoring/restaurant/cleanliness_engine.py`

The equivalent production-packaged implementations are duplicated under `restaurant_monitoring/runtime/business/`, including `runtime/business/fsm/table_fsm.py` and `runtime/business/tracking/serving_detector.py`. This duplication is an important maintenance boundary: changes must identify whether the normal Python path, packaged runtime path, or both are authoritative.

#### Persistence, rendering, and outputs
Event/state results are persisted through the database layer:
- `restaurant_monitoring/database/db.py`
- `restaurant_monitoring/database/models.py`
- `restaurant_monitoring/database/serving_event_logger.py`

SQLite database artifacts are stored under `restaurant_monitoring/outputs/databases/`; reports are emitted under `restaurant_monitoring/outputs/reports/`. Annotated video generation is isolated in `restaurant_monitoring/renderer/renderer.py`, keeping presentation separate from analytics decisions.

#### Runtime and infrastructure dependencies
The deployment targets the Axelera Voyager SDK and accelerator ecosystem, represented by `restaurant_monitoring/runtime/sdk_initializer.py`, `restaurant_monitoring/runtime/cpu_stream.py`, and the vendored `voyager-sdk-latest/voyager-sdk-latest/`. Voyager supplies pipeline execution, model compilation, video/GStreamer integration, inference operators, and native trackers. No network service, web API, or cloud dependency is evident from the supplied tree; persistence and exports are local SQLite/filesystem outputs.

Main entry points: [`restaurant_monitoring/restaurant/occupancy_engine.py`](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/restaurant/occupancy_engine.py) (Restaurant Event Analytics), [`restaurant_monitoring/pipelines/restaurant_full_pipeline.yaml`](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/pipelines/restaurant_full_pipeline.yaml) (Restaurant Full Pipeline), [`restaurant_monitoring/runtime/inference_runtime.py`](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/runtime/inference_runtime.py) (Inference Metadata Decoder), [`restaurant_monitoring/inference.py`](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/inference.py) (Inference Orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_deployment["Deployment Runtime"]
  node_app["Application Entry Points<br/>Python entry points<br/>[main.py]"]
  node_inference["Inference Orchestration<br/>Python runtime<br/>[inference.py]"]
  node_deployment_config["Deployment Setup<br/>deployment script<br/>[deploy.py]"]
  node_sdk_init["SDK Initialization<br/>Voyager adapter<br/>[sdk_initializer.py]"]
  node_voyager{{"Voyager SDK<br/>vendored runtime"}}
  node_full_pipeline["Restaurant Full Pipeline<br/>pipeline configuration"]
  node_detection_pipeline["Detection Pipeline<br/>pipeline configuration"]
  node_tracking_pipeline["Tracking Pipeline<br/>pipeline configuration"]
  node_model_config["YOLO Model Configuration<br/>[yolov8s.toml]"]
  node_metadata_decoder["Inference Metadata Decoder<br/>SDK-to-domain adapter"]
end

subgraph group_domain["Restaurant Analytics"]
  node_table_model["Table Spatial Model<br/>ROI and assignment<br/>[table_manager.py]"]
  node_table_config["Configured Tables<br/>table ROI data<br/>[tables.json]"]
  node_table_fsm["Table Lifecycle FSM<br/>temporal state machine<br/>[table_fsm.py]"]
  node_event_analytics["Restaurant Event Analytics<br/>business rules"]
  node_packaged_business["Packaged Runtime Business Logic<br/>duplicated production logic<br/>[table_fsm.py]"]
end

subgraph group_outputs["Local Outputs"]
  node_database[("Database Layer<br/>SQLite persistence<br/>[db.py]")]
  node_sqlite_outputs[("SQLite Databases<br/>local database files")]
  node_renderer["Annotated Video Renderer<br/>presentation output<br/>[renderer.py]"]
  node_reports["Reports and Exports<br/>local files"]
end

node_legacy_pipeline["Legacy Offline Pipeline<br/>legacy Python pipeline<br/>[pipeline.py]"]

node_app -->|"runs"| node_inference
node_deployment_config -->|"configures"| node_sdk_init
node_inference -->|"initializes"| node_sdk_init
node_sdk_init -->|"loads"| node_voyager
node_inference -->|"executes"| node_full_pipeline
node_full_pipeline -->|"includes"| node_detection_pipeline
node_full_pipeline -->|"includes"| node_tracking_pipeline
node_detection_pipeline -->|"uses"| node_model_config
node_voyager -->|"emits metadata to"| node_metadata_decoder
node_full_pipeline -->|"bridges results through"| node_metadata_decoder
node_metadata_decoder -->|"supplies tracks and pose"| node_table_model
node_table_config -->|"defines regions for"| node_table_model
node_table_model -->|"assigns tracks to"| node_table_fsm
node_metadata_decoder -->|"supplies signals to"| node_event_analytics
node_table_fsm -->|"provides table state"| node_event_analytics
node_event_analytics -->|"persists events via"| node_database
node_database -->|"stores"| node_sqlite_outputs
node_event_analytics -->|"annotates through"| node_renderer
node_event_analytics -->|"exports"| node_reports
node_packaged_business -.->|"parallel implementation"| node_table_fsm
node_legacy_pipeline -.->|"legacy counterpart"| node_event_analytics

click node_app "https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/apps/main.py"
click node_inference "https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/inference.py"
click node_deployment_config "https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/deploy.py"
click node_sdk_init "https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/runtime/sdk_initializer.py"
click node_full_pipeline "https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/pipelines/restaurant_full_pipeline.yaml"
click node_detection_pipeline "https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/pipelines/restaurant_detection.yaml"
click node_tracking_pipeline "https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/pipelines/restaurant_tracking.yaml"
click node_model_config "https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/models/yolov8s.toml"
click node_metadata_decoder "https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/runtime/inference_runtime.py"
click node_table_model "https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/analytics/table_manager.py"
click node_table_config "https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/configs/tables.json"
click node_table_fsm "https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/restaurant/table_fsm.py"
click node_event_analytics "https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/restaurant/occupancy_engine.py"
click node_packaged_business "https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/runtime/business/fsm/table_fsm.py"
click node_legacy_pipeline "https://github.com/sridesiyan/monitor-v2/blob/main/coe-intern-main/analytics/pipeline.py"
click node_database "https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/database/db.py"
click node_renderer "https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/renderer/renderer.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_app,node_inference,node_deployment_config,node_sdk_init,node_voyager,node_full_pipeline,node_detection_pipeline,node_tracking_pipeline,node_model_config,node_metadata_decoder toneBlue
class node_table_model,node_table_config,node_table_fsm,node_event_analytics,node_packaged_business toneAmber
class node_database,node_sqlite_outputs,node_renderer,node_reports toneMint
class node_legacy_pipeline toneNeutral
```

## Components

### Deployment Runtime

Voyager-backed application and pipeline execution.

- [Application Entry Points](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/apps/main.py): Python entry points · Initializes deployment and attaches restaurant postprocessing. · `restaurant_monitoring/apps/main.py`
- [Inference Orchestration](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/inference.py): Python runtime · `restaurant_monitoring/inference.py`
- [Deployment Setup](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/deploy.py): deployment script · `restaurant_monitoring/deploy.py`
- [SDK Initialization](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/runtime/sdk_initializer.py): Voyager adapter · `restaurant_monitoring/runtime/sdk_initializer.py`
- **Voyager SDK**: vendored runtime · Executes accelerator inference, GStreamer, and native tracking.
- [Restaurant Full Pipeline](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/pipelines/restaurant_full_pipeline.yaml): pipeline configuration · Composes detection, tracking, pose, analytics, rendering, persistence, and export stages. · `restaurant_monitoring/pipelines/restaurant_full_pipeline.yaml`
- [Detection Pipeline](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/pipelines/restaurant_detection.yaml): pipeline configuration · `restaurant_monitoring/pipelines/restaurant_detection.yaml`
- [Tracking Pipeline](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/pipelines/restaurant_tracking.yaml): pipeline configuration · `restaurant_monitoring/pipelines/restaurant_tracking.yaml`
- [YOLO Model Configuration](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/models/yolov8s.toml): model configuration · `restaurant_monitoring/models/yolov8s.toml`
- [Inference Metadata Decoder](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/runtime/inference_runtime.py): SDK-to-domain adapter · Converts SDK detection, pose, tracking, and embedding metadata for Python analytics. · `restaurant_monitoring/runtime/inference_runtime.py`

### Restaurant Analytics

Table mapping and temporal business decisions.

- [Table Spatial Model](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/analytics/table_manager.py): ROI and assignment · Maps tracked positions to configured restaurant table regions. · `restaurant_monitoring/analytics/table_manager.py`
- [Configured Tables](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/configs/tables.json): table ROI data · Stable table-region interface consumed by analytics. · `restaurant_monitoring/configs/tables.json`
- [Table Lifecycle FSM](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/restaurant/table_fsm.py): temporal state machine · Separates per-table temporal state from frame-level detections. · `restaurant_monitoring/restaurant/table_fsm.py`
- [Restaurant Event Analytics](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/restaurant/occupancy_engine.py): business rules · Derives occupancy, serving, sessions, and cleanliness events. · `restaurant_monitoring/restaurant/occupancy_engine.py`
- [Packaged Runtime Business Logic](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/runtime/business/fsm/table_fsm.py): duplicated production logic · Parallel runtime implementation that must be kept authoritative with or distinct from normal Python logic. · `restaurant_monitoring/runtime/business/fsm/table_fsm.py`

### Local Outputs

Persistence, reports, and rendered video.

- [Database Layer](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/database/db.py): SQLite persistence · `restaurant_monitoring/database/db.py`
- **SQLite Databases**: local database files
- [Annotated Video Renderer](https://github.com/sridesiyan/monitor-v2/blob/main/restaurant_monitoring/renderer/renderer.py): presentation output · Renders analytics without making business decisions. · `restaurant_monitoring/renderer/renderer.py`
- **Reports and Exports**: local files

### Other components

- [Legacy Offline Pipeline](https://github.com/sridesiyan/monitor-v2/blob/main/coe-intern-main/analytics/pipeline.py): legacy Python pipeline · Separate pre-deployment analytics implementation. · `coe-intern-main/analytics/pipeline.py`

## Connections

- Application Entry Points → Inference Orchestration: runs
- Deployment Setup → SDK Initialization: configures
- Inference Orchestration → SDK Initialization: initializes
- SDK Initialization → Voyager SDK: loads
- Inference Orchestration → Restaurant Full Pipeline: executes
- Restaurant Full Pipeline → Detection Pipeline: includes
- Restaurant Full Pipeline → Tracking Pipeline: includes
- Detection Pipeline → YOLO Model Configuration: uses
- Voyager SDK → Inference Metadata Decoder: emits metadata to
- Restaurant Full Pipeline → Inference Metadata Decoder: bridges results through
- Inference Metadata Decoder → Table Spatial Model: supplies tracks and pose
- Configured Tables → Table Spatial Model: defines regions for
- Table Spatial Model → Table Lifecycle FSM: assigns tracks to
- Inference Metadata Decoder → Restaurant Event Analytics: supplies signals to
- Table Lifecycle FSM → Restaurant Event Analytics: provides table state
- Restaurant Event Analytics → Database Layer: persists events via
- Database Layer → SQLite Databases: stores
- Restaurant Event Analytics → Annotated Video Renderer: annotates through
- Restaurant Event Analytics → Reports and Exports: exports
- Packaged Runtime Business Logic → Table Lifecycle FSM: parallel implementation
- Legacy Offline Pipeline → Restaurant Event Analytics: legacy counterpart
