# 8harath/car-parking-detection architecture

> Architecture diagram of the GitHub repository 8harath/car-parking-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/8harath/car-parking-detection
- Repository: https://github.com/8harath/car-parking-detection

## Overview

This is a parking-lot occupancy application: users load an image or video, mark spaces, run classical image processing or YOLO vehicle detection, then view occupancy and export reports/history. The main CLI flow is explicit; README also describes a separate interactive GUI and its selection, zoom, undo, and statistics capabilities. Source excerpts show the detector-to-model and reporting calls, but not every internal processing or persistence detail, so those relationships are omitted where not evidenced.

Main entry points: [`enhanced_parking_detector.py`](https://github.com/8harath/car-parking-detection/blob/main/enhanced_parking_detector.py) (Space selection), [`run.py`](https://github.com/8harath/car-parking-detection/blob/main/run.py) (CLI workflow), [`car_detector.py`](https://github.com/8harath/car-parking-detection/blob/main/car_detector.py) (Vehicle detection), [`gui.py`](https://github.com/8harath/car-parking-detection/blob/main/gui.py) (Desktop GUI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_cli["CLI workflow<br/>[run.py]"]
  node_gui["Desktop GUI<br/>[gui.py]"]
  node_settings["Detection settings<br/>[config.py]"]
end

subgraph group_interaction["Space setup and viewing"]
  node_space_editor["Space selection"]
  node_gui_canvas["Interactive canvas<br/>[gui.py]"]
  node_video_image["Image/video input"]
end

subgraph group_analysis["Occupancy analysis"]
  node_frame_prep["Frame processing"]
  node_space_occupancy["Space occupancy"]
  node_yolo["Vehicle detection<br/>[car_detector.py]"]
  node_special_space["Special-space detection<br/>[car_detector.py]"]
end

subgraph group_outputs["Reports and state"]
  node_position_store[("Saved space layout<br/>[config.py]")]
  node_directory_setup["Output directories"]
  node_reporting["Visual and text reports<br/>[car_detector.py]"]
  node_csv_history[("Occupancy CSV history")]
  node_analytics_view["Statistics dashboard<br/>[gui.py]"]
end

node_operator(("Parking operator"))
node_yolo_model["YOLOv8 model"]

node_operator -->|"starts"| node_cli
node_operator -->|"opens"| node_gui
node_cli -->|"reads defaults"| node_settings
node_cli -->|"initializes"| node_video_image
node_gui -->|"creates detector"| node_space_editor
node_gui -->|"hosts"| node_gui_canvas
node_gui_canvas -->|"edits spaces"| node_space_editor
node_cli -.->|"runs selection"| node_space_editor
node_video_image -->|"provides frames"| node_frame_prep
node_frame_prep -->|"prepares input"| node_space_occupancy
node_space_occupancy -->|"logs status"| node_csv_history
node_space_editor -->|"saves layout"| node_position_store
node_space_editor -->|"requests detection"| node_yolo
node_yolo_model -->|"loads model"| node_yolo
node_yolo -->|"classifies spaces"| node_special_space
node_yolo -->|"generates reports"| node_reporting
node_space_occupancy -->|"displays statistics"| node_analytics_view
node_space_editor -->|"prepares folders"| node_directory_setup
node_cli -->|"announces outputs"| node_reporting

click node_cli "https://github.com/8harath/car-parking-detection/blob/main/run.py"
click node_gui "https://github.com/8harath/car-parking-detection/blob/main/gui.py"
click node_settings "https://github.com/8harath/car-parking-detection/blob/main/config.py"
click node_space_editor "https://github.com/8harath/car-parking-detection/blob/main/enhanced_parking_detector.py"
click node_gui_canvas "https://github.com/8harath/car-parking-detection/blob/main/gui.py"
click node_video_image "https://github.com/8harath/car-parking-detection/blob/main/enhanced_parking_detector.py"
click node_frame_prep "https://github.com/8harath/car-parking-detection/blob/main/enhanced_parking_detector.py"
click node_space_occupancy "https://github.com/8harath/car-parking-detection/blob/main/enhanced_parking_detector.py"
click node_yolo "https://github.com/8harath/car-parking-detection/blob/main/car_detector.py"
click node_special_space "https://github.com/8harath/car-parking-detection/blob/main/car_detector.py"
click node_position_store "https://github.com/8harath/car-parking-detection/blob/main/config.py"
click node_directory_setup "https://github.com/8harath/car-parking-detection/blob/main/setup_directories.py"
click node_reporting "https://github.com/8harath/car-parking-detection/blob/main/car_detector.py"
click node_csv_history "https://github.com/8harath/car-parking-detection/blob/main/enhanced_parking_detector.py"
click node_analytics_view "https://github.com/8harath/car-parking-detection/blob/main/gui.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_cli,node_gui,node_settings toneBlue
class node_space_editor,node_gui_canvas,node_video_image toneAmber
class node_frame_prep,node_space_occupancy,node_yolo,node_special_space toneMint
class node_position_store,node_directory_setup,node_reporting,node_csv_history,node_analytics_view toneRose
class node_operator,node_yolo_model toneIndigo
```

## Components

### Application entry

- [CLI workflow](https://github.com/8harath/car-parking-detection/blob/main/run.py): `run.py`
- [Desktop GUI](https://github.com/8harath/car-parking-detection/blob/main/gui.py): `gui.py`
- [Detection settings](https://github.com/8harath/car-parking-detection/blob/main/config.py): `config.py`

### Space setup and viewing

- [Space selection](https://github.com/8harath/car-parking-detection/blob/main/enhanced_parking_detector.py): `enhanced_parking_detector.py`
- [Interactive canvas](https://github.com/8harath/car-parking-detection/blob/main/gui.py): `gui.py`
- [Image/video input](https://github.com/8harath/car-parking-detection/blob/main/enhanced_parking_detector.py): `enhanced_parking_detector.py`

### Occupancy analysis

- [Frame processing](https://github.com/8harath/car-parking-detection/blob/main/enhanced_parking_detector.py): `enhanced_parking_detector.py`
- [Space occupancy](https://github.com/8harath/car-parking-detection/blob/main/enhanced_parking_detector.py): `enhanced_parking_detector.py`
- [Vehicle detection](https://github.com/8harath/car-parking-detection/blob/main/car_detector.py): `car_detector.py`
- [Special-space detection](https://github.com/8harath/car-parking-detection/blob/main/car_detector.py): `car_detector.py`

### Reports and state

- [Saved space layout](https://github.com/8harath/car-parking-detection/blob/main/config.py): `config.py`
- [Output directories](https://github.com/8harath/car-parking-detection/blob/main/setup_directories.py): `setup_directories.py`
- [Visual and text reports](https://github.com/8harath/car-parking-detection/blob/main/car_detector.py): `car_detector.py`
- [Occupancy CSV history](https://github.com/8harath/car-parking-detection/blob/main/enhanced_parking_detector.py): `enhanced_parking_detector.py`
- [Statistics dashboard](https://github.com/8harath/car-parking-detection/blob/main/gui.py): `gui.py`

### Other components

- **Parking operator**
- **YOLOv8 model**

## Connections

- Parking operator → CLI workflow: starts (evidence: `README.md`)
- Parking operator → Desktop GUI: opens (evidence: `README.md`)
- CLI workflow → Detection settings: reads defaults (evidence: `run.py`)
- CLI workflow → Image/video input: initializes (evidence: `run.py`)
- Desktop GUI → Space selection: creates detector (evidence: `gui.py`)
- Desktop GUI → Interactive canvas: hosts (evidence: `gui.py`)
- Interactive canvas → Space selection: edits spaces (evidence: `gui.py`)
- CLI workflow → Space selection: runs selection (evidence: `run.py`)
- Image/video input → Frame processing: provides frames (evidence: `enhanced_parking_detector.py`)
- Frame processing → Space occupancy: prepares input (evidence: `enhanced_parking_detector.py`)
- Space occupancy → Occupancy CSV history: logs status (evidence: `enhanced_parking_detector.py`)
- Space selection → Saved space layout: saves layout (evidence: `README.md`)
- Space selection → Vehicle detection: requests detection (evidence: `enhanced_parking_detector.py`)
- YOLOv8 model → Vehicle detection: loads model (evidence: `car_detector.py`)
- Vehicle detection → Special-space detection: classifies spaces (evidence: `car_detector.py`)
- Vehicle detection → Visual and text reports: generates reports (evidence: `enhanced_parking_detector.py`)
- Space occupancy → Statistics dashboard: displays statistics (evidence: `gui.py`)
- Space selection → Output directories: prepares folders (evidence: `enhanced_parking_detector.py`)
- CLI workflow → Visual and text reports: announces outputs (evidence: `run.py`)
