# balajipenugonda/cafe-watch architecture

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

- Interactive diagram: https://gitdiagram.com/balajipenugonda/cafe-watch
- Repository: https://github.com/balajipenugonda/cafe-watch

## Overview

Café Watch is a local restaurant-floor monitoring dashboard. Staff connect a webcam, video, or CCTV stream; the app finds and verifies table regions, classifies table conditions, and presents live status and a cleaning queue. Staff can edit regions, record cleaning and ready actions, and export activity. The graph includes the documented AI and streaming stages, but decisions.py and occupancy.py were not sampled; their internal calls are therefore not expanded. Relationships rely on the shown excerpts and README.

Main entry points: [`public/app.js`](https://github.com/balajipenugonda/cafe-watch/blob/main/public/app.js) (Floor dashboard), [`server.py`](https://github.com/balajipenugonda/cafe-watch/blob/main/server.py) (Local API), [`streams.py`](https://github.com/balajipenugonda/cafe-watch/blob/main/streams.py) (Stream sessions), [`public/state.js`](https://github.com/balajipenugonda/cafe-watch/blob/main/public/state.js) (Table status state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Floor dashboard"]
  node_dashboard_ui["Floor dashboard<br/>[app.js]"]
  node_region_detection["Layout confirmation<br/>[detection.js]"]
  node_status_state["Table status state<br/>[state.js]"]
  node_staff_operations["Staff workflow<br/>[operations.js]"]
  node_alert_audio["Alert sounds<br/>[sounds.js]"]
  node_activity_export["Activity and CSV<br/>[app.js]"]
  node_cleaning_queue["Cleaning queue<br/>[app.js]"]
  node_region_editor["Region editing<br/>[app.js]"]
end

subgraph group_server["Local service"]
  node_api["Local API<br/>[server.py]"]
end

subgraph group_inference["AI inference"]
  node_table_decisions["Status decisions<br/>[decisions.py]"]
  node_occupancy["Guest occupancy<br/>[occupancy.py]"]
  node_object_evidence["Object evidence<br/>[objects.py]"]
  node_table_detector["Table detection<br/>[server.py]"]
  node_model_analysis["Table analysis<br/>[server.py]"]
end

subgraph group_streaming["CCTV streaming"]
  node_stream_sessions["Stream sessions<br/>[streams.py]"]
  node_ffmpeg_decoder["FFmpeg decoding<br/>[streams.py]"]
end

node_staff(("Restaurant staff"))
node_source(("Camera or video"))
node_camera_host["CCTV host"]

node_staff -->|"uses"| node_dashboard_ui
node_source -->|"connects"| node_dashboard_ui
node_dashboard_ui -->|"sends frames"| node_api
node_dashboard_ui -->|"requests streams"| node_stream_sessions
node_api -->|"routes detection"| node_table_detector
node_api -->|"routes analysis"| node_model_analysis
node_api -->|"creates sessions"| node_stream_sessions
node_table_detector -->|"verifies regions"| node_model_analysis
node_model_analysis -->|"classifies states"| node_table_decisions
node_model_analysis -->|"checks guests"| node_occupancy
node_model_analysis -->|"classifies objects"| node_object_evidence
node_api -->|"starts decoder"| node_ffmpeg_decoder
node_camera_host -->|"provides stream"| node_ffmpeg_decoder
node_ffmpeg_decoder -->|"feeds JPEGs"| node_stream_sessions
node_stream_sessions -->|"serves previews"| node_dashboard_ui
node_dashboard_ui -->|"confirms layout"| node_region_detection
node_dashboard_ui -->|"records observations"| node_status_state
node_dashboard_ui -->|"applies staff actions"| node_staff_operations
node_dashboard_ui -->|"plays alerts"| node_alert_audio
node_staff -->|"edits regions"| node_region_editor
node_staff -->|"reviews queue"| node_cleaning_queue
node_staff -->|"exports log"| node_activity_export
node_status_state -->|"orders dirty tables"| node_cleaning_queue
node_staff_operations -->|"resets observations"| node_status_state

click node_dashboard_ui "https://github.com/balajipenugonda/cafe-watch/blob/main/public/app.js"
click node_region_detection "https://github.com/balajipenugonda/cafe-watch/blob/main/public/detection.js"
click node_status_state "https://github.com/balajipenugonda/cafe-watch/blob/main/public/state.js"
click node_staff_operations "https://github.com/balajipenugonda/cafe-watch/blob/main/public/operations.js"
click node_alert_audio "https://github.com/balajipenugonda/cafe-watch/blob/main/public/sounds.js"
click node_api "https://github.com/balajipenugonda/cafe-watch/blob/main/server.py"
click node_table_decisions "https://github.com/balajipenugonda/cafe-watch/blob/main/decisions.py"
click node_occupancy "https://github.com/balajipenugonda/cafe-watch/blob/main/occupancy.py"
click node_object_evidence "https://github.com/balajipenugonda/cafe-watch/blob/main/objects.py"
click node_table_detector "https://github.com/balajipenugonda/cafe-watch/blob/main/server.py"
click node_model_analysis "https://github.com/balajipenugonda/cafe-watch/blob/main/server.py"
click node_stream_sessions "https://github.com/balajipenugonda/cafe-watch/blob/main/streams.py"
click node_ffmpeg_decoder "https://github.com/balajipenugonda/cafe-watch/blob/main/streams.py"
click node_activity_export "https://github.com/balajipenugonda/cafe-watch/blob/main/public/app.js"
click node_cleaning_queue "https://github.com/balajipenugonda/cafe-watch/blob/main/public/app.js"
click node_region_editor "https://github.com/balajipenugonda/cafe-watch/blob/main/public/app.js"

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_dashboard_ui,node_region_detection,node_status_state,node_staff_operations,node_alert_audio,node_activity_export,node_cleaning_queue,node_region_editor toneBlue
class node_api toneAmber
class node_table_decisions,node_occupancy,node_object_evidence,node_table_detector,node_model_analysis toneMint
class node_stream_sessions,node_ffmpeg_decoder toneRose
class node_staff,node_source,node_camera_host toneIndigo
```

## Components

### Floor dashboard

- [Floor dashboard](https://github.com/balajipenugonda/cafe-watch/blob/main/public/app.js): `public/app.js`
- [Layout confirmation](https://github.com/balajipenugonda/cafe-watch/blob/main/public/detection.js): `public/detection.js`
- [Table status state](https://github.com/balajipenugonda/cafe-watch/blob/main/public/state.js): `public/state.js`
- [Staff workflow](https://github.com/balajipenugonda/cafe-watch/blob/main/public/operations.js): `public/operations.js`
- [Alert sounds](https://github.com/balajipenugonda/cafe-watch/blob/main/public/sounds.js): `public/sounds.js`
- [Activity and CSV](https://github.com/balajipenugonda/cafe-watch/blob/main/public/app.js): `public/app.js`
- [Cleaning queue](https://github.com/balajipenugonda/cafe-watch/blob/main/public/app.js): `public/app.js`
- [Region editing](https://github.com/balajipenugonda/cafe-watch/blob/main/public/app.js): `public/app.js`

### Local service

- [Local API](https://github.com/balajipenugonda/cafe-watch/blob/main/server.py): `server.py`

### AI inference

- [Status decisions](https://github.com/balajipenugonda/cafe-watch/blob/main/decisions.py): `decisions.py`
- [Guest occupancy](https://github.com/balajipenugonda/cafe-watch/blob/main/occupancy.py): `occupancy.py`
- [Object evidence](https://github.com/balajipenugonda/cafe-watch/blob/main/objects.py): `objects.py`
- [Table detection](https://github.com/balajipenugonda/cafe-watch/blob/main/server.py): `server.py`
- [Table analysis](https://github.com/balajipenugonda/cafe-watch/blob/main/server.py): `server.py`

### CCTV streaming

- [Stream sessions](https://github.com/balajipenugonda/cafe-watch/blob/main/streams.py): `streams.py`
- [FFmpeg decoding](https://github.com/balajipenugonda/cafe-watch/blob/main/streams.py): `streams.py`

### Other components

- **Restaurant staff**
- **Camera or video**
- **CCTV host**

## Connections

- Restaurant staff → Floor dashboard: uses (evidence: `README.md`)
- Camera or video → Floor dashboard: connects (evidence: `README.md`)
- Floor dashboard → Local API: sends frames (evidence: `README.md`)
- Floor dashboard → Stream sessions: requests streams (evidence: `public/app.js`)
- Local API → Table detection: routes detection (evidence: `server.py`)
- Local API → Table analysis: routes analysis (evidence: `server.py`)
- Local API → Stream sessions: creates sessions (evidence: `server.py`)
- Table detection → Table analysis: verifies regions (evidence: `README.md`)
- Table analysis → Status decisions: classifies states (evidence: `README.md`)
- Table analysis → Guest occupancy: checks guests (evidence: `README.md`)
- Table analysis → Object evidence: classifies objects (evidence: `README.md`)
- Local API → FFmpeg decoding: starts decoder (evidence: `streams.py`)
- CCTV host → FFmpeg decoding: provides stream (evidence: `README.md`)
- FFmpeg decoding → Stream sessions: feeds JPEGs (evidence: `streams.py`)
- Stream sessions → Floor dashboard: serves previews (evidence: `README.md`)
- Floor dashboard → Layout confirmation: confirms layout (evidence: `public/app.js`)
- Floor dashboard → Table status state: records observations (evidence: `public/app.js`)
- Floor dashboard → Staff workflow: applies staff actions (evidence: `public/app.js`)
- Floor dashboard → Alert sounds: plays alerts (evidence: `public/app.js`)
- Restaurant staff → Region editing: edits regions (evidence: `README.md`)
- Restaurant staff → Cleaning queue: reviews queue (evidence: `README.md`)
- Restaurant staff → Activity and CSV: exports log (evidence: `README.md`)
- Table status state → Cleaning queue: orders dirty tables (evidence: `README.md`)
- Staff workflow → Table status state: resets observations (evidence: `public/operations.js`)
