# manoj8712/cafe_ai_system architecture

> Architecture diagram of the GitHub repository manoj8712/cafe_ai_system, 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/manoj8712/cafe_ai_system
- Repository: https://github.com/manoj8712/cafe_ai_system

## Overview

This is a local hotel/cafe video-analytics application. Its main workflow processes camera or video frames into persistent detections, visit sessions, and attributed cup/plate events; it stores analytics and publishes annotated frames and recordings for a Streamlit dashboard. Other documented capabilities include worker-photo enrollment and matching, date-based totals, and configurable camera regions. Edges follow the README or shown source references; some orchestration details are documented rather than visible in the sampled main.py excerpt.

Main entry points: [`main.py`](https://github.com/manoj8712/cafe_ai_system/blob/main/main.py) (Frame orchestrator), [`dashboard/app.py`](https://github.com/manoj8712/cafe_ai_system/blob/main/dashboard/app.py) (Streamlit dashboard), [`database/database.py`](https://github.com/manoj8712/cafe_ai_system/blob/main/database/database.py) (SQLite analytics), [`analytics/event_processor.py`](https://github.com/manoj8712/cafe_ai_system/blob/main/analytics/event_processor.py) (Item event processor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Video analytics"]
  node_main["Frame orchestrator<br/>[main.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
  node_detector["YOLO detection<br/>[detector.py]"]
  node_roi["ROI geometry<br/>[roi.py]"]
  node_logger["Runtime logging<br/>[logger.py]"]
end

subgraph group_domain["Visits and service events"]
  node_tracker["Visit sessions<br/>[person_tracker.py]"]
  node_recognizer["Worker matching"]
  node_events["Item event processor<br/>[event_processor.py]"]
  node_service_counter["Service totals<br/>[service_counter.py]"]
  node_cup_counter["Cup category<br/>[cup_counter.py]"]
  node_plate_counter["Plate category<br/>[plate_counter.py]"]
end

subgraph group_persistence["Local persistence"]
  node_database[("SQLite analytics<br/>[database.py]")]
end

subgraph group_presentation["Dashboard and evidence"]
  node_dashboard["Streamlit dashboard<br/>[app.py]"]
  node_visualization["Frame overlays<br/>[visualization.py]"]
  node_recorder["Video segments<br/>[video_recorder.py]"]
end

node_operator(("Camera operator"))
node_video_source["Camera or video"]
node_browser_user(("Dashboard user"))

node_operator -->|"starts processing"| node_main
node_video_source -->|"provides frames"| node_main
node_main -->|"requests detections"| node_detector
node_detector -->|"returns tracks"| node_main
node_main -->|"updates sessions"| node_tracker
node_main -->|"matches workers"| node_recognizer
node_main -->|"updates events"| node_events
node_events -->|"records events"| node_database
node_events -->|"updates totals"| node_service_counter
node_main -->|"saves sessions"| node_database
node_main -->|"draws overlays"| node_visualization
node_visualization -->|"draws regions"| node_roi
node_main -->|"writes frames"| node_recorder
node_main -->|"publishes frame"| node_dashboard
node_dashboard -->|"reads totals"| node_database
node_dashboard -->|"registers workers"| node_database
node_dashboard -->|"validates photos"| node_recognizer
node_dashboard -->|"lists recordings"| node_recorder
node_browser_user -->|"views analytics"| node_dashboard
node_config -->|"configures runtime"| node_main
node_main -->|"logs runtime"| node_logger

click node_main "https://github.com/manoj8712/cafe_ai_system/blob/main/main.py"
click node_config "https://github.com/manoj8712/cafe_ai_system/blob/main/config.py"
click node_detector "https://github.com/manoj8712/cafe_ai_system/blob/main/detection/detector.py"
click node_roi "https://github.com/manoj8712/cafe_ai_system/blob/main/utils/roi.py"
click node_tracker "https://github.com/manoj8712/cafe_ai_system/blob/main/tracking/person_tracker.py"
click node_recognizer "https://github.com/manoj8712/cafe_ai_system/blob/main/analytics/worker_recognition.py"
click node_events "https://github.com/manoj8712/cafe_ai_system/blob/main/analytics/event_processor.py"
click node_service_counter "https://github.com/manoj8712/cafe_ai_system/blob/main/analytics/service_counter.py"
click node_cup_counter "https://github.com/manoj8712/cafe_ai_system/blob/main/analytics/cup_counter.py"
click node_plate_counter "https://github.com/manoj8712/cafe_ai_system/blob/main/analytics/plate_counter.py"
click node_database "https://github.com/manoj8712/cafe_ai_system/blob/main/database/database.py"
click node_dashboard "https://github.com/manoj8712/cafe_ai_system/blob/main/dashboard/app.py"
click node_visualization "https://github.com/manoj8712/cafe_ai_system/blob/main/utils/visualization.py"
click node_recorder "https://github.com/manoj8712/cafe_ai_system/blob/main/utils/video_recorder.py"
click node_logger "https://github.com/manoj8712/cafe_ai_system/blob/main/utils/logger.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_config,node_detector,node_roi,node_logger,node_browser_user toneBlue
class node_tracker,node_recognizer,node_events,node_service_counter,node_cup_counter,node_plate_counter toneAmber
class node_database toneMint
class node_dashboard,node_visualization,node_recorder toneRose
class node_operator,node_video_source toneIndigo
```

## Components

### Video analytics

- [Frame orchestrator](https://github.com/manoj8712/cafe_ai_system/blob/main/main.py): `main.py`
- [Runtime configuration](https://github.com/manoj8712/cafe_ai_system/blob/main/config.py): `config.py`
- [YOLO detection](https://github.com/manoj8712/cafe_ai_system/blob/main/detection/detector.py): `detection/detector.py`
- [ROI geometry](https://github.com/manoj8712/cafe_ai_system/blob/main/utils/roi.py): `utils/roi.py`
- [Runtime logging](https://github.com/manoj8712/cafe_ai_system/blob/main/utils/logger.py): `utils/logger.py`

### Visits and service events

- [Visit sessions](https://github.com/manoj8712/cafe_ai_system/blob/main/tracking/person_tracker.py): `tracking/person_tracker.py`
- [Worker matching](https://github.com/manoj8712/cafe_ai_system/blob/main/analytics/worker_recognition.py): `analytics/worker_recognition.py`
- [Item event processor](https://github.com/manoj8712/cafe_ai_system/blob/main/analytics/event_processor.py): `analytics/event_processor.py`
- [Service totals](https://github.com/manoj8712/cafe_ai_system/blob/main/analytics/service_counter.py): `analytics/service_counter.py`
- [Cup category](https://github.com/manoj8712/cafe_ai_system/blob/main/analytics/cup_counter.py): `analytics/cup_counter.py`
- [Plate category](https://github.com/manoj8712/cafe_ai_system/blob/main/analytics/plate_counter.py): `analytics/plate_counter.py`

### Local persistence

- [SQLite analytics](https://github.com/manoj8712/cafe_ai_system/blob/main/database/database.py): `database/database.py`

### Dashboard and evidence

- [Streamlit dashboard](https://github.com/manoj8712/cafe_ai_system/blob/main/dashboard/app.py): `dashboard/app.py`
- [Frame overlays](https://github.com/manoj8712/cafe_ai_system/blob/main/utils/visualization.py): `utils/visualization.py`
- [Video segments](https://github.com/manoj8712/cafe_ai_system/blob/main/utils/video_recorder.py): `utils/video_recorder.py`

### Other components

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

## Connections

- Camera operator → Frame orchestrator: starts processing (evidence: `README.md`)
- Camera or video → Frame orchestrator: provides frames (evidence: `README.md`)
- Frame orchestrator → YOLO detection: requests detections (evidence: `README.md`)
- YOLO detection → Frame orchestrator: returns tracks (evidence: `README.md`)
- Frame orchestrator → Visit sessions: updates sessions (evidence: `README.md`)
- Frame orchestrator → Worker matching: matches workers (evidence: `main.py`)
- Frame orchestrator → Item event processor: updates events (evidence: `main.py`)
- Item event processor → SQLite analytics: records events (evidence: `analytics/event_processor.py`)
- Item event processor → Service totals: updates totals (evidence: `analytics/event_processor.py`)
- Frame orchestrator → SQLite analytics: saves sessions (evidence: `main.py`)
- Frame orchestrator → Frame overlays: draws overlays (evidence: `README.md`)
- Frame overlays → ROI geometry: draws regions (evidence: `utils/visualization.py`)
- Frame orchestrator → Video segments: writes frames (evidence: `main.py`)
- Frame orchestrator → Streamlit dashboard: publishes frame (evidence: `README.md`)
- Streamlit dashboard → SQLite analytics: reads totals (evidence: `dashboard/app.py`)
- Streamlit dashboard → SQLite analytics: registers workers (evidence: `dashboard/app.py`)
- Streamlit dashboard → Worker matching: validates photos (evidence: `dashboard/app.py`)
- Streamlit dashboard → Video segments: lists recordings (evidence: `dashboard/app.py`)
- Dashboard user → Streamlit dashboard: views analytics (evidence: `README.md`)
- Runtime configuration → Frame orchestrator: configures runtime (evidence: `main.py`)
- Frame orchestrator → Runtime logging: logs runtime (evidence: `main.py`)
