# rifqiabbiyu6822/cctv architecture

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

- Interactive diagram: https://gitdiagram.com/rifqiabbiyu6822/cctv
- Repository: https://github.com/rifqiabbiyu6822/cctv

## Overview

This is a desktop vehicle-counting application: users select a video or ASF/WMV source, detect and track cars across a counting line, and review directional counts. They can enter session metadata and save records to Google Sheets, then load records for summaries, charts, and PDF reporting. A separate script trains the YOLO car model. The sampled excerpts support these main responsibilities and several calls; some UI wiring and report-generation details are unsampled, so uncertain links are omitted.

Main entry points: [`app.py`](https://github.com/rifqiabbiyu6822/cctv/blob/master/app.py) (Desktop application), [`detector.py`](https://github.com/rifqiabbiyu6822/cctv/blob/master/detector.py) (Car detection and counting), [`google_sheets_helper.py`](https://github.com/rifqiabbiyu6822/cctv/blob/master/google_sheets_helper.py) (Sheets access), [`reports_widget.py`](https://github.com/rifqiabbiyu6822/cctv/blob/master/reports_widget.py) (Reports interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture and counting"]
  node_app["Desktop application<br/>[app.py]"]
  node_regular["Video processing<br/>[app.py]"]
  node_asf["ASF processor"]
  node_counter["Car detection and counting<br/>[detector.py]"]
end

subgraph group_records["Records and reporting"]
  node_dialog["Session data entry"]
  node_sheets_helper["Sheets access"]
  node_sheets[("Google Sheets")]
  node_reports["Reports interface<br/>[reports_widget.py]"]
  node_report_loader["Report data loader<br/>[reports_widget.py]"]
  node_pdf["PDF generation<br/>[pdf_service.py]"]
  node_pdf_output["PDF report"]
end

subgraph group_model["Detection model"]
  node_config["Detection settings"]
  node_trainer["YOLO training<br/>[train_model.py]"]
  node_dataset["Dataset configuration<br/>[data.yaml]"]
  node_yolo["YOLO model runtime"]
end

node_user(("Operator"))
node_video(("Video source"))

node_user -->|"operates"| node_app
node_video -->|"provides video"| node_app
node_app -->|"starts processing"| node_regular
node_app -->|"starts ASF processing"| node_asf
node_regular -->|"processes frames"| node_counter
node_asf -->|"processes frames"| node_counter
node_counter -->|"reads settings"| node_config
node_counter -->|"detects and tracks"| node_yolo
node_app -->|"opens entry dialog"| node_dialog
node_dialog -->|"saves record"| node_sheets_helper
node_app -->|"saves counts"| node_sheets_helper
node_reports -->|"loads report data"| node_report_loader
node_report_loader -->|"requests records"| node_sheets_helper
node_sheets_helper -->|"reads and writes"| node_sheets
node_reports -->|"requests PDF"| node_pdf
node_pdf -->|"creates"| node_pdf_output
node_dataset -->|"configures training"| node_trainer
node_trainer -->|"trains model"| node_yolo

click node_app "https://github.com/rifqiabbiyu6822/cctv/blob/master/app.py"
click node_regular "https://github.com/rifqiabbiyu6822/cctv/blob/master/app.py"
click node_asf "https://github.com/rifqiabbiyu6822/cctv/blob/master/yolo_asf_processor.py"
click node_counter "https://github.com/rifqiabbiyu6822/cctv/blob/master/detector.py"
click node_config "https://github.com/rifqiabbiyu6822/cctv/blob/master/detection_config.py"
click node_dialog "https://github.com/rifqiabbiyu6822/cctv/blob/master/data_input_dialog.py"
click node_sheets_helper "https://github.com/rifqiabbiyu6822/cctv/blob/master/google_sheets_helper.py"
click node_reports "https://github.com/rifqiabbiyu6822/cctv/blob/master/reports_widget.py"
click node_report_loader "https://github.com/rifqiabbiyu6822/cctv/blob/master/reports_widget.py"
click node_pdf "https://github.com/rifqiabbiyu6822/cctv/blob/master/pdf_service.py"
click node_trainer "https://github.com/rifqiabbiyu6822/cctv/blob/master/train_model.py"
click node_dataset "https://github.com/rifqiabbiyu6822/cctv/blob/master/data.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_app,node_regular,node_asf,node_counter toneBlue
class node_dialog,node_sheets_helper,node_sheets,node_reports,node_report_loader,node_pdf,node_pdf_output toneAmber
class node_config,node_trainer,node_dataset,node_yolo toneMint
class node_user,node_video toneIndigo
```

## Components

### Capture and counting

- [Desktop application](https://github.com/rifqiabbiyu6822/cctv/blob/master/app.py): `app.py`
- [Video processing](https://github.com/rifqiabbiyu6822/cctv/blob/master/app.py): `app.py`
- [ASF processor](https://github.com/rifqiabbiyu6822/cctv/blob/master/yolo_asf_processor.py): `yolo_asf_processor.py`
- [Car detection and counting](https://github.com/rifqiabbiyu6822/cctv/blob/master/detector.py): `detector.py`

### Records and reporting

- [Session data entry](https://github.com/rifqiabbiyu6822/cctv/blob/master/data_input_dialog.py): `data_input_dialog.py`
- [Sheets access](https://github.com/rifqiabbiyu6822/cctv/blob/master/google_sheets_helper.py): `google_sheets_helper.py`
- **Google Sheets**
- [Reports interface](https://github.com/rifqiabbiyu6822/cctv/blob/master/reports_widget.py): `reports_widget.py`
- [Report data loader](https://github.com/rifqiabbiyu6822/cctv/blob/master/reports_widget.py): `reports_widget.py`
- [PDF generation](https://github.com/rifqiabbiyu6822/cctv/blob/master/pdf_service.py): `pdf_service.py`
- **PDF report**

### Detection model

- [Detection settings](https://github.com/rifqiabbiyu6822/cctv/blob/master/detection_config.py): `detection_config.py`
- [YOLO training](https://github.com/rifqiabbiyu6822/cctv/blob/master/train_model.py): `train_model.py`
- [Dataset configuration](https://github.com/rifqiabbiyu6822/cctv/blob/master/data.yaml): `data.yaml`
- **YOLO model runtime**

### Other components

- **Operator**
- **Video source**

## Connections

- Operator → Desktop application: operates
- Video source → Desktop application: provides video
- Desktop application → Video processing: starts processing
- Desktop application → ASF processor: starts ASF processing
- Video processing → Car detection and counting: processes frames
- ASF processor → Car detection and counting: processes frames
- Car detection and counting → Detection settings: reads settings
- Car detection and counting → YOLO model runtime: detects and tracks
- Desktop application → Session data entry: opens entry dialog
- Session data entry → Sheets access: saves record
- Desktop application → Sheets access: saves counts
- Reports interface → Report data loader: loads report data
- Report data loader → Sheets access: requests records
- Sheets access → Google Sheets: reads and writes
- Reports interface → PDF generation: requests PDF
- PDF generation → PDF report: creates
- Dataset configuration → YOLO training: configures training
- YOLO training → YOLO model runtime: trains model
