# abhinav-narra/cafe-ai architecture

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

- Interactive diagram: https://gitdiagram.com/abhinav-narra/cafe-ai
- Repository: https://github.com/abhinav-narra/cafe-ai

## Overview

This is a local Tea Stall CCTV monitoring application. Its main workflow captures webcam, CCTV-stream, or video frames; detects and tracks people and items; creates visit sessions and debounced serving events; persists analytics in SQLite while publishing annotated frames and recordings; and presents live monitoring and date-filtered analytics in Streamlit. The graph also preserves worker enrollment, runtime configuration, telemetry, and review capabilities. Some subsystem links rely on README statements or SOURCE INDEX references; unsampled implementation details are not inferred.

Main entry points: [`main.py`](https://github.com/abhinav-narra/cafe-ai/blob/main/main.py) (Frame orchestration), [`dashboard/app.py`](https://github.com/abhinav-narra/cafe-ai/blob/main/dashboard/app.py) (Streamlit entry), [`dashboard/views.py`](https://github.com/abhinav-narra/cafe-ai/blob/main/dashboard/views.py) (Analytics views), [`dashboard/components.py`](https://github.com/abhinav-narra/cafe-ai/blob/main/dashboard/components.py) (Live UI components)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture and vision"]
  node_main["Frame orchestration<br/>[main.py]"]
  node_detection["YOLO detection<br/>[detector.py]"]
  node_frame_pipeline["Frame pipeline<br/>[pipeline.py]"]
end

subgraph group_analytics["Tracking and analytics"]
  node_person_tracker["Visit tracking<br/>[person_tracker.py]"]
  node_event_processor["Service events<br/>[event_processor.py]"]
  node_cup_counter["Cup counting<br/>[cup_counter.py]"]
  node_plate_counter["Plate counting<br/>[plate_counter.py]"]
  node_service_counter["Service totals<br/>[service_counter.py]"]
  node_worker_recognition["Worker recognition"]
end

subgraph group_persistence["Local persistence"]
  node_database[("SQLite analytics<br/>[database.py]")]
  node_db_models["Data models<br/>[models.py]"]
  node_video_recorder["Video recording<br/>[video_recorder.py]"]
end

subgraph group_dashboard["Dashboard"]
  node_dashboard_app["Streamlit entry<br/>[app.py]"]
  node_dashboard_views["Analytics views<br/>[views.py]"]
  node_dashboard_components["Live UI components<br/>[components.py]"]
  node_dashboard_styles["Dashboard styling<br/>[styles.py]"]
end

subgraph group_runtime["Runtime support"]
  node_settings["Runtime settings<br/>[settings.py]"]
  node_telemetry["Runtime telemetry<br/>[telemetry.py]"]
  node_visualization["Frame overlays<br/>[visualization.py]"]
  node_roi["ROI geometry<br/>[roi.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
end

node_operator(("Camera operator"))
node_camera_source(("Camera or video"))
node_dashboard_user(("Dashboard user"))

node_operator -->|"starts analysis"| node_main
node_camera_source -->|"provides frames"| node_main
node_main -->|"coordinates buffering"| node_frame_pipeline
node_main -->|"runs inference"| node_detection
node_main -->|"updates visits"| node_person_tracker
node_main -->|"processes events"| node_event_processor
node_main -->|"matches workers"| node_worker_recognition
node_main -->|"updates totals"| node_service_counter
node_main -->|"persists analytics"| node_database
node_main -->|"records frames"| node_video_recorder
node_main -->|"annotates frames"| node_visualization
node_main -->|"publishes status"| node_telemetry
node_main -->|"uses regions"| node_roi
node_event_processor -->|"counts cups"| node_cup_counter
node_event_processor -->|"counts plates"| node_plate_counter
node_person_tracker -->|"checks regions"| node_roi
node_visualization -->|"draws regions"| node_roi
node_dashboard_user -->|"opens dashboard"| node_dashboard_app
node_dashboard_app -->|"routes pages"| node_dashboard_views
node_dashboard_app -->|"builds interface"| node_dashboard_components
node_dashboard_app -->|"injects styles"| node_dashboard_styles
node_dashboard_app -->|"applies settings"| node_settings
node_dashboard_app -->|"creates repository"| node_database
node_dashboard_app -->|"creates recognizer"| node_worker_recognition
node_dashboard_views -->|"reads analytics"| node_database
node_dashboard_views -->|"registers workers"| node_worker_recognition
node_dashboard_views -->|"lists recordings"| node_video_recorder
node_dashboard_components -->|"reads status"| node_telemetry
node_dashboard_components -->|"renders regions"| node_roi
node_dashboard_views -->|"renders panels"| node_dashboard_components
node_settings -->|"updates values"| node_config
node_database -.->|"uses schema"| node_db_models

click node_main "https://github.com/abhinav-narra/cafe-ai/blob/main/main.py"
click node_detection "https://github.com/abhinav-narra/cafe-ai/blob/main/detection/detector.py"
click node_frame_pipeline "https://github.com/abhinav-narra/cafe-ai/blob/main/utils/pipeline.py"
click node_person_tracker "https://github.com/abhinav-narra/cafe-ai/blob/main/tracking/person_tracker.py"
click node_event_processor "https://github.com/abhinav-narra/cafe-ai/blob/main/analytics/event_processor.py"
click node_cup_counter "https://github.com/abhinav-narra/cafe-ai/blob/main/analytics/cup_counter.py"
click node_plate_counter "https://github.com/abhinav-narra/cafe-ai/blob/main/analytics/plate_counter.py"
click node_service_counter "https://github.com/abhinav-narra/cafe-ai/blob/main/analytics/service_counter.py"
click node_worker_recognition "https://github.com/abhinav-narra/cafe-ai/blob/main/analytics/worker_recognition.py"
click node_database "https://github.com/abhinav-narra/cafe-ai/blob/main/database/database.py"
click node_db_models "https://github.com/abhinav-narra/cafe-ai/blob/main/database/models.py"
click node_video_recorder "https://github.com/abhinav-narra/cafe-ai/blob/main/utils/video_recorder.py"
click node_dashboard_app "https://github.com/abhinav-narra/cafe-ai/blob/main/dashboard/app.py"
click node_dashboard_views "https://github.com/abhinav-narra/cafe-ai/blob/main/dashboard/views.py"
click node_dashboard_components "https://github.com/abhinav-narra/cafe-ai/blob/main/dashboard/components.py"
click node_dashboard_styles "https://github.com/abhinav-narra/cafe-ai/blob/main/dashboard/styles.py"
click node_settings "https://github.com/abhinav-narra/cafe-ai/blob/main/utils/settings.py"
click node_telemetry "https://github.com/abhinav-narra/cafe-ai/blob/main/utils/telemetry.py"
click node_visualization "https://github.com/abhinav-narra/cafe-ai/blob/main/utils/visualization.py"
click node_roi "https://github.com/abhinav-narra/cafe-ai/blob/main/utils/roi.py"
click node_config "https://github.com/abhinav-narra/cafe-ai/blob/main/config.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_main,node_detection,node_frame_pipeline,node_dashboard_user toneBlue
class node_person_tracker,node_event_processor,node_cup_counter,node_plate_counter,node_service_counter,node_worker_recognition toneAmber
class node_database,node_db_models,node_video_recorder toneMint
class node_dashboard_app,node_dashboard_views,node_dashboard_components,node_dashboard_styles toneRose
class node_settings,node_telemetry,node_visualization,node_roi,node_config,node_operator,node_camera_source toneIndigo
```

## Components

### Capture and vision

- [Frame orchestration](https://github.com/abhinav-narra/cafe-ai/blob/main/main.py): `main.py`
- [YOLO detection](https://github.com/abhinav-narra/cafe-ai/blob/main/detection/detector.py): `detection/detector.py`
- [Frame pipeline](https://github.com/abhinav-narra/cafe-ai/blob/main/utils/pipeline.py): `utils/pipeline.py`

### Tracking and analytics

- [Visit tracking](https://github.com/abhinav-narra/cafe-ai/blob/main/tracking/person_tracker.py): `tracking/person_tracker.py`
- [Service events](https://github.com/abhinav-narra/cafe-ai/blob/main/analytics/event_processor.py): `analytics/event_processor.py`
- [Cup counting](https://github.com/abhinav-narra/cafe-ai/blob/main/analytics/cup_counter.py): `analytics/cup_counter.py`
- [Plate counting](https://github.com/abhinav-narra/cafe-ai/blob/main/analytics/plate_counter.py): `analytics/plate_counter.py`
- [Service totals](https://github.com/abhinav-narra/cafe-ai/blob/main/analytics/service_counter.py): `analytics/service_counter.py`
- [Worker recognition](https://github.com/abhinav-narra/cafe-ai/blob/main/analytics/worker_recognition.py): `analytics/worker_recognition.py`

### Local persistence

- [SQLite analytics](https://github.com/abhinav-narra/cafe-ai/blob/main/database/database.py): `database/database.py`
- [Data models](https://github.com/abhinav-narra/cafe-ai/blob/main/database/models.py): `database/models.py`
- [Video recording](https://github.com/abhinav-narra/cafe-ai/blob/main/utils/video_recorder.py): `utils/video_recorder.py`

### Dashboard

- [Streamlit entry](https://github.com/abhinav-narra/cafe-ai/blob/main/dashboard/app.py): `dashboard/app.py`
- [Analytics views](https://github.com/abhinav-narra/cafe-ai/blob/main/dashboard/views.py): `dashboard/views.py`
- [Live UI components](https://github.com/abhinav-narra/cafe-ai/blob/main/dashboard/components.py): `dashboard/components.py`
- [Dashboard styling](https://github.com/abhinav-narra/cafe-ai/blob/main/dashboard/styles.py): `dashboard/styles.py`

### Runtime support

- [Runtime settings](https://github.com/abhinav-narra/cafe-ai/blob/main/utils/settings.py): `utils/settings.py`
- [Runtime telemetry](https://github.com/abhinav-narra/cafe-ai/blob/main/utils/telemetry.py): `utils/telemetry.py`
- [Frame overlays](https://github.com/abhinav-narra/cafe-ai/blob/main/utils/visualization.py): `utils/visualization.py`
- [ROI geometry](https://github.com/abhinav-narra/cafe-ai/blob/main/utils/roi.py): `utils/roi.py`
- [Runtime configuration](https://github.com/abhinav-narra/cafe-ai/blob/main/config.py): `config.py`

### Other components

- **Camera operator**
- **Camera or video**
- **Dashboard user**

## Connections

- Camera operator → Frame orchestration: starts analysis (evidence: `README.md`)
- Camera or video → Frame orchestration: provides frames (evidence: `README.md`)
- Frame orchestration → Frame pipeline: coordinates buffering (evidence: `main.py`)
- Frame orchestration → YOLO detection: runs inference (evidence: `main.py`)
- Frame orchestration → Visit tracking: updates visits (evidence: `main.py`)
- Frame orchestration → Service events: processes events (evidence: `main.py`)
- Frame orchestration → Worker recognition: matches workers (evidence: `main.py`)
- Frame orchestration → Service totals: updates totals (evidence: `main.py`)
- Frame orchestration → SQLite analytics: persists analytics (evidence: `README.md`)
- Frame orchestration → Video recording: records frames (evidence: `main.py`)
- Frame orchestration → Frame overlays: annotates frames (evidence: `main.py`)
- Frame orchestration → Runtime telemetry: publishes status (evidence: `main.py`)
- Frame orchestration → ROI geometry: uses regions (evidence: `main.py`)
- Service events → Cup counting: counts cups (evidence: `analytics/event_processor.py`)
- Service events → Plate counting: counts plates (evidence: `analytics/event_processor.py`)
- Visit tracking → ROI geometry: checks regions (evidence: `tracking/person_tracker.py`)
- Frame overlays → ROI geometry: draws regions (evidence: `utils/visualization.py`)
- Dashboard user → Streamlit entry: opens dashboard (evidence: `README.md`)
- Streamlit entry → Analytics views: routes pages (evidence: `dashboard/app.py`)
- Streamlit entry → Live UI components: builds interface (evidence: `dashboard/app.py`)
- Streamlit entry → Dashboard styling: injects styles (evidence: `dashboard/app.py`)
- Streamlit entry → Runtime settings: applies settings (evidence: `dashboard/app.py`)
- Streamlit entry → SQLite analytics: creates repository (evidence: `dashboard/app.py`)
- Streamlit entry → Worker recognition: creates recognizer (evidence: `dashboard/app.py`)
- Analytics views → SQLite analytics: reads analytics (evidence: `dashboard/views.py`)
- Analytics views → Worker recognition: registers workers (evidence: `dashboard/views.py`)
- Analytics views → Video recording: lists recordings (evidence: `dashboard/views.py`)
- Live UI components → Runtime telemetry: reads status (evidence: `dashboard/components.py`)
- Live UI components → ROI geometry: renders regions (evidence: `dashboard/components.py`)
- Analytics views → Live UI components: renders panels (evidence: `dashboard/views.py`)
- Runtime settings → Runtime configuration: updates values (evidence: `utils/settings.py`)
- SQLite analytics → Data models: uses schema
