# vigneshinti/yolov8-cafe-monitoring-system architecture

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

- Interactive diagram: https://gitdiagram.com/vigneshinti/yolov8-cafe-monitoring-system
- Repository: https://github.com/vigneshinti/yolov8-cafe-monitoring-system

## Overview

This is a Flask-based cafe occupancy monitor: a browser dashboard selects a video source, the server delegates frame processing to a detector, and occupancy and annotated video are returned to the dashboard. The detector separates capture, person detection/tracking, annotation, and JPEG encoding, while the dashboard also supports capacity updates, uploads, and occupancy trends. A separate training workflow fine-tunes YOLO on a cafe dataset. Some implementation details are unsampled; edges below rely on the excerpts or explicit README statements.

Main entry points: [`app.py`](https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/app.py) (Flask routes), [`detector.py`](https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/detector.py) (Video capture), [`train.py`](https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/train.py) (YOLO fine-tuning), [`templates/index.html`](https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/templates/index.html) (Dashboard UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Dashboard"]
  node_dashboard["Dashboard UI<br/>[index.html]"]
  node_client["Dashboard logic<br/>[main.js]"]
end

subgraph group_server["Web API"]
  node_flask["Flask routes<br/>[app.py]"]
  node_upload["Uploaded videos<br/>[app.py]"]
end

subgraph group_vision["Vision Pipeline"]
  node_capture["Video capture<br/>[detector.py]"]
  node_inference["Person detection<br/>[detector.py]"]
  node_tracking["Person tracking<br/>[detector.py]"]
  node_occupancy["Occupancy and history<br/>[detector.py]"]
  node_annotation["Frame annotation<br/>[detector.py]"]
  node_encoding["JPEG encoding<br/>[detector.py]"]
end

subgraph group_modeling["Model Training"]
  node_training["YOLO fine-tuning<br/>[train.py]"]
  node_dataset["Cafe dataset config<br/>[cafe.yaml]"]
end

node_user(("Dashboard user"))
node_video_sources(("Webcam / RTSP / video"))
node_yolo["YOLO model runtime"]

node_user -->|"uses"| node_dashboard
node_dashboard -->|"loads"| node_client
node_client -->|"requests API"| node_flask
node_flask -->|"saves uploads"| node_upload
node_flask -->|"switches source"| node_capture
node_flask -->|"reads and updates"| node_occupancy
node_flask -->|"requests frames"| node_encoding
node_video_sources -->|"provides input"| node_capture
node_capture -->|"supplies frames"| node_inference
node_yolo -->|"runs inference"| node_inference
node_inference -.->|"detects people"| node_tracking
node_tracking -.->|"provides count"| node_occupancy
node_occupancy -->|"overlays status"| node_annotation
node_annotation -->|"encodes frames"| node_encoding
node_training -->|"uses config"| node_dataset
node_training -->|"fine-tunes model"| node_yolo

click node_dashboard "https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/templates/index.html"
click node_client "https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/static/js/main.js"
click node_flask "https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/app.py"
click node_upload "https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/app.py"
click node_capture "https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/detector.py"
click node_inference "https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/detector.py"
click node_tracking "https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/detector.py"
click node_occupancy "https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/detector.py"
click node_annotation "https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/detector.py"
click node_encoding "https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/detector.py"
click node_training "https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/train.py"
click node_dataset "https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/data/cafe.yaml"

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,node_client,node_user toneBlue
class node_flask,node_upload toneAmber
class node_capture,node_inference,node_tracking,node_occupancy,node_annotation,node_encoding toneMint
class node_training,node_dataset toneRose
class node_video_sources,node_yolo toneIndigo
```

## Components

### Dashboard

- [Dashboard UI](https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/templates/index.html): `templates/index.html`
- [Dashboard logic](https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/static/js/main.js): `static/js/main.js`

### Web API

- [Flask routes](https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/app.py): `app.py`
- [Uploaded videos](https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/app.py): `app.py`

### Vision Pipeline

- [Video capture](https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/detector.py): `detector.py`
- [Person detection](https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/detector.py): `detector.py`
- [Person tracking](https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/detector.py): `detector.py`
- [Occupancy and history](https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/detector.py): `detector.py`
- [Frame annotation](https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/detector.py): `detector.py`
- [JPEG encoding](https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/detector.py): `detector.py`

### Model Training

- [YOLO fine-tuning](https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/train.py): `train.py`
- [Cafe dataset config](https://github.com/vigneshinti/yolov8-cafe-monitoring-system/blob/main/data/cafe.yaml): `data/cafe.yaml`

### Other components

- **Dashboard user**
- **Webcam / RTSP / video**
- **YOLO model runtime**

## Connections

- Dashboard user → Dashboard UI: uses (evidence: `README.md`)
- Dashboard UI → Dashboard logic: loads
- Dashboard logic → Flask routes: requests API (evidence: `static/js/main.js`)
- Flask routes → Uploaded videos: saves uploads (evidence: `app.py`)
- Flask routes → Video capture: switches source (evidence: `app.py`)
- Flask routes → Occupancy and history: reads and updates (evidence: `app.py`)
- Flask routes → JPEG encoding: requests frames (evidence: `app.py`)
- Webcam / RTSP / video → Video capture: provides input (evidence: `README.md`)
- Video capture → Person detection: supplies frames (evidence: `detector.py`)
- YOLO model runtime → Person detection: runs inference (evidence: `detector.py`)
- Person detection → Person tracking: detects people (evidence: `README.md`)
- Person tracking → Occupancy and history: provides count (evidence: `README.md`)
- Occupancy and history → Frame annotation: overlays status (evidence: `detector.py`)
- Frame annotation → JPEG encoding: encodes frames (evidence: `detector.py`)
- YOLO fine-tuning → Cafe dataset config: uses config (evidence: `train.py`)
- YOLO fine-tuning → YOLO model runtime: fine-tunes model (evidence: `train.py`)
