# paras2611/smartparkingsystem architecture

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

- Interactive diagram: https://gitdiagram.com/paras2611/smartparkingsystem
- Repository: https://github.com/paras2611/smartparkingsystem

## Overview

Smart Parking is an end-to-end local-network surveillance and ticketing application. An ESP32-CAM captures and uploads images; the FastAPI upload handler stores the frame, invokes vehicle inference, rejects non-vehicle images or creates a priced ticket with a QR code, then persists successful tickets and broadcasts live events. The React dashboard offers live monitoring, ticket/history views, API upload testing, and settings. The main upload pipeline and several UI/API relationships are evidenced in excerpts and the README; Settings and some dashboard capabilities are represented from the SOURCE INDEX and README, so uncertain internal links are omitted.

Main entry points: [`parking_dashboard/src/App.jsx`](https://github.com/paras2611/smartparkingsystem/blob/main/parking_dashboard/src/App.jsx) (Dashboard Router), [`parking_backend/main.py`](https://github.com/paras2611/smartparkingsystem/blob/main/parking_backend/main.py) (Upload API), [`parking_dashboard/src/pages/Dashboard.jsx`](https://github.com/paras2611/smartparkingsystem/blob/main/parking_dashboard/src/pages/Dashboard.jsx) (Live Dashboard), [`ESP_CAM_32/src/main.cpp`](https://github.com/paras2611/smartparkingsystem/blob/main/ESP_CAM_32/src/main.cpp) (ESP32-CAM Firmware)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Camera Edge"]
  node_trigger(("Motion or Button"))
  node_camera["ESP32-CAM Firmware<br/>[main.cpp]"]
end

subgraph group_backend["Backend Processing"]
  node_upload["Upload API<br/>[main.py]"]
  node_inference["Vehicle Detection<br/>[yolo_service.py]"]
  node_ticketing["Ticket Processing<br/>[main.py]"]
  node_qr["QR Generation<br/>[qr_service.py]"]
  node_ws["WebSocket Events<br/>[main.py]"]
  node_api["Ticket and Stats API<br/>[main.py]"]
end

subgraph group_state["Ticket State"]
  node_schema["Ticket Model<br/>[models.py]"]
  node_database[("SQLite Database<br/>[database.py]")]
  node_assets["Images and QR Assets<br/>[main.py]"]
end

subgraph group_ui["Dashboard UI"]
  node_app["Dashboard Router<br/>[App.jsx]"]
  node_live["Live Dashboard<br/>[Dashboard.jsx]"]
  node_history["Detection History"]
  node_tickets["Ticket Display<br/>[Tickets.jsx]"]
  node_testing["API Testing<br/>[ApiTesting.jsx]"]
  node_settings["Settings<br/>[Settings.jsx]"]
end

node_browser(("Dashboard User"))

node_trigger -->|"triggers capture"| node_camera
node_camera -->|"posts image"| node_upload
node_upload -->|"invokes detection"| node_inference
node_upload -->|"writes image"| node_assets
node_upload -->|"processes result"| node_ticketing
node_ticketing -->|"generates QR"| node_qr
node_ticketing -->|"creates ticket"| node_schema
node_ticketing -->|"persists ticket"| node_database
node_ticketing -->|"broadcasts events"| node_ws
node_qr -->|"writes QR image"| node_assets
node_schema -->|"uses base"| node_database
node_browser -.->|"opens dashboard"| node_app
node_app -->|"routes to"| node_live
node_app -->|"routes to"| node_history
node_app -->|"routes to"| node_tickets
node_app -->|"routes to"| node_testing
node_app -->|"routes to"| node_settings
node_live -->|"posts snapshots"| node_upload
node_live -->|"receives events"| node_ws
node_testing -->|"posts image"| node_upload
node_history -->|"fetches tickets"| node_api
node_tickets -->|"fetches tickets"| node_api

click node_camera "https://github.com/paras2611/smartparkingsystem/blob/main/ESP_CAM_32/src/main.cpp"
click node_upload "https://github.com/paras2611/smartparkingsystem/blob/main/parking_backend/main.py"
click node_inference "https://github.com/paras2611/smartparkingsystem/blob/main/parking_backend/yolo_service.py"
click node_ticketing "https://github.com/paras2611/smartparkingsystem/blob/main/parking_backend/main.py"
click node_qr "https://github.com/paras2611/smartparkingsystem/blob/main/parking_backend/qr_service.py"
click node_ws "https://github.com/paras2611/smartparkingsystem/blob/main/parking_backend/main.py"
click node_api "https://github.com/paras2611/smartparkingsystem/blob/main/parking_backend/main.py"
click node_schema "https://github.com/paras2611/smartparkingsystem/blob/main/parking_backend/models.py"
click node_database "https://github.com/paras2611/smartparkingsystem/blob/main/parking_backend/database.py"
click node_assets "https://github.com/paras2611/smartparkingsystem/blob/main/parking_backend/main.py"
click node_app "https://github.com/paras2611/smartparkingsystem/blob/main/parking_dashboard/src/App.jsx"
click node_live "https://github.com/paras2611/smartparkingsystem/blob/main/parking_dashboard/src/pages/Dashboard.jsx"
click node_history "https://github.com/paras2611/smartparkingsystem/blob/main/parking_dashboard/src/pages/DetectionHistory.jsx"
click node_tickets "https://github.com/paras2611/smartparkingsystem/blob/main/parking_dashboard/src/pages/Tickets.jsx"
click node_testing "https://github.com/paras2611/smartparkingsystem/blob/main/parking_dashboard/src/pages/ApiTesting.jsx"
click node_settings "https://github.com/paras2611/smartparkingsystem/blob/main/parking_dashboard/src/pages/Settings.jsx"

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_trigger,node_camera,node_browser toneBlue
class node_upload,node_inference,node_ticketing,node_qr,node_ws,node_api toneAmber
class node_schema,node_database,node_assets toneMint
class node_app,node_live,node_history,node_tickets,node_testing,node_settings toneRose
```

## Components

### Camera Edge

- **Motion or Button**
- [ESP32-CAM Firmware](https://github.com/paras2611/smartparkingsystem/blob/main/ESP_CAM_32/src/main.cpp): `ESP_CAM_32/src/main.cpp`

### Backend Processing

- [Upload API](https://github.com/paras2611/smartparkingsystem/blob/main/parking_backend/main.py): `parking_backend/main.py`
- [Vehicle Detection](https://github.com/paras2611/smartparkingsystem/blob/main/parking_backend/yolo_service.py): `parking_backend/yolo_service.py`
- [Ticket Processing](https://github.com/paras2611/smartparkingsystem/blob/main/parking_backend/main.py): `parking_backend/main.py`
- [QR Generation](https://github.com/paras2611/smartparkingsystem/blob/main/parking_backend/qr_service.py): `parking_backend/qr_service.py`
- [WebSocket Events](https://github.com/paras2611/smartparkingsystem/blob/main/parking_backend/main.py): `parking_backend/main.py`
- [Ticket and Stats API](https://github.com/paras2611/smartparkingsystem/blob/main/parking_backend/main.py): `parking_backend/main.py`

### Ticket State

- [Ticket Model](https://github.com/paras2611/smartparkingsystem/blob/main/parking_backend/models.py): `parking_backend/models.py`
- [SQLite Database](https://github.com/paras2611/smartparkingsystem/blob/main/parking_backend/database.py): `parking_backend/database.py`
- [Images and QR Assets](https://github.com/paras2611/smartparkingsystem/blob/main/parking_backend/main.py): `parking_backend/main.py`

### Dashboard UI

- [Dashboard Router](https://github.com/paras2611/smartparkingsystem/blob/main/parking_dashboard/src/App.jsx): `parking_dashboard/src/App.jsx`
- [Live Dashboard](https://github.com/paras2611/smartparkingsystem/blob/main/parking_dashboard/src/pages/Dashboard.jsx): `parking_dashboard/src/pages/Dashboard.jsx`
- [Detection History](https://github.com/paras2611/smartparkingsystem/blob/main/parking_dashboard/src/pages/DetectionHistory.jsx): `parking_dashboard/src/pages/DetectionHistory.jsx`
- [Ticket Display](https://github.com/paras2611/smartparkingsystem/blob/main/parking_dashboard/src/pages/Tickets.jsx): `parking_dashboard/src/pages/Tickets.jsx`
- [API Testing](https://github.com/paras2611/smartparkingsystem/blob/main/parking_dashboard/src/pages/ApiTesting.jsx): `parking_dashboard/src/pages/ApiTesting.jsx`
- [Settings](https://github.com/paras2611/smartparkingsystem/blob/main/parking_dashboard/src/pages/Settings.jsx): `parking_dashboard/src/pages/Settings.jsx`

### Other components

- **Dashboard User**

## Connections

- Motion or Button → ESP32-CAM Firmware: triggers capture (evidence: `README.md`)
- ESP32-CAM Firmware → Upload API: posts image (evidence: `README.md`)
- Upload API → Vehicle Detection: invokes detection (evidence: `parking_backend/main.py`)
- Upload API → Images and QR Assets: writes image (evidence: `parking_backend/main.py`)
- Upload API → Ticket Processing: processes result (evidence: `parking_backend/main.py`)
- Ticket Processing → QR Generation: generates QR (evidence: `parking_backend/main.py`)
- Ticket Processing → Ticket Model: creates ticket (evidence: `parking_backend/main.py`)
- Ticket Processing → SQLite Database: persists ticket (evidence: `parking_backend/main.py`)
- Ticket Processing → WebSocket Events: broadcasts events (evidence: `parking_backend/main.py`)
- QR Generation → Images and QR Assets: writes QR image (evidence: `parking_backend/qr_service.py`)
- Ticket Model → SQLite Database: uses base (evidence: `parking_backend/models.py`)
- Dashboard User → Dashboard Router: opens dashboard
- Dashboard Router → Live Dashboard: routes to (evidence: `parking_dashboard/src/App.jsx`)
- Dashboard Router → Detection History: routes to (evidence: `parking_dashboard/src/App.jsx`)
- Dashboard Router → Ticket Display: routes to (evidence: `parking_dashboard/src/App.jsx`)
- Dashboard Router → API Testing: routes to (evidence: `parking_dashboard/src/App.jsx`)
- Dashboard Router → Settings: routes to (evidence: `parking_dashboard/src/App.jsx`)
- Live Dashboard → Upload API: posts snapshots (evidence: `parking_dashboard/src/pages/Dashboard.jsx`)
- Live Dashboard → WebSocket Events: receives events (evidence: `parking_dashboard/src/pages/Dashboard.jsx`)
- API Testing → Upload API: posts image (evidence: `parking_dashboard/src/pages/ApiTesting.jsx`)
- Detection History → Ticket and Stats API: fetches tickets (evidence: `parking_dashboard/src/pages/DetectionHistory.jsx`)
- Ticket Display → Ticket and Stats API: fetches tickets (evidence: `parking_dashboard/src/pages/Tickets.jsx`)
