# datphannexor/parkingspacedetection architecture

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

- Interactive diagram: https://gitdiagram.com/datphannexor/parkingspacedetection
- Repository: https://github.com/datphannexor/parkingspacedetection

## Overview

ParkingSpaceDetection combines parking-space vision, parking-session billing, operational APIs, and desktop/web/mobile clients. The principal workflow is camera or video input → slot-state detection → event-driven session and fee processing → persistent history and reporting → client views. The repository also contains a separate legacy regions/probability-map runtime. Some client implementations and integrations are represented only by the README; edges for those are documented relationships, not inspected call sites.

Main entry points: [`src/parkingspace/main.py`](https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/main.py) (Legacy Runtime Entry), [`backend_microservices/services/ai_detection_service/main.py`](https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/services/ai_detection_service/main.py) (Detection API), [`backend_microservices/services/parking_billing_service/main.py`](https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/services/parking_billing_service/main.py) (Session and Billing), [`src/parkingspace/services.py`](https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/services.py) (Detection Services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vision["Vision and Detection"]
  node_ai_api["Detection API<br/>[main.py]"]
  node_legacy_ai["Legacy AI Adapter<br/>[adapter.py]"]
  node_vision_model["YOLO / OpenCV Detection"]
  node_slot_mapper["Slot ID Mapping<br/>[mapper.py]"]
end

subgraph group_operations["Parking Operations"]
  node_billing_api["Session and Billing<br/>[main.py]"]
  node_billing_adapter["Legacy Billing Adapter<br/>[adapter.py]"]
  node_auth_api["Authentication and RBAC<br/>[main.py]"]
  node_reporting_api["Reports and WebSocket<br/>[main.py]"]
  node_desktop_sync["Desktop Sync<br/>[main.py]"]
end

subgraph group_platform["Shared Platform"]
  node_mysql[("MySQL")]
  node_redis[("Redis")]
  node_rabbitmq["RabbitMQ"]
  node_event_contracts["Event Contracts and Publisher<br/>[schemas.py]"]
  node_db_access["Database and Cache Access<br/>[connection.py]"]
end

subgraph group_clients["Operator Clients"]
  node_desktop["Desktop Application<br/>[app_gui.py]"]
  node_dashboard["Streamlit Dashboard"]
  node_mobile["Flutter Mobile App"]
end

subgraph group_legacy["Legacy Runtime"]
  node_legacy_main["Legacy Runtime Entry<br/>[main.py]"]
  node_legacy_services["Detection Services<br/>[services.py]"]
  node_legacy_pipeline["Region Pipeline<br/>[pipeline.py]"]
  node_legacy_regions["Region Definitions<br/>[regions.py]"]
  node_legacy_config["Runtime Configuration<br/>[config.py]"]
  node_capabilities["Capability Detection<br/>[capabilities.py]"]
  node_performance["Performance Monitoring<br/>[performance.py]"]
  node_legacy_logger["Logging<br/>[logger.py]"]
  node_legacy_exceptions["Runtime Exceptions<br/>[exceptions.py]"]
end

node_operator(("Operator"))
node_camera(("Image / Video / Camera"))

node_operator -->|"uploads media"| node_ai_api
node_camera -->|"provides frames"| node_ai_api
node_ai_api -->|"delegates detection"| node_legacy_ai
node_legacy_ai -->|"runs detection"| node_vision_model
node_ai_api -->|"maps slot IDs"| node_slot_mapper
node_ai_api -->|"publishes results"| node_event_contracts
node_event_contracts -->|"sends events"| node_rabbitmq
node_billing_api -->|"reads and writes"| node_mysql
node_billing_api -->|"reads slot state"| node_redis
node_billing_api -->|"consumes events"| node_event_contracts
node_billing_api -->|"uses billing adapter"| node_billing_adapter
node_auth_api -->|"reads and writes"| node_mysql
node_auth_api -->|"issues JWT"| node_operator
node_reporting_api -->|"queries history"| node_mysql
node_reporting_api -.->|"serves slot state"| node_redis
node_desktop_sync -.->|"syncs records"| node_mysql
node_desktop_sync -->|"uses events"| node_event_contracts
node_db_access -.->|"connects to"| node_mysql
node_db_access -.->|"connects to"| node_redis
node_operator -->|"operates"| node_desktop
node_operator -->|"views reports"| node_dashboard
node_operator -->|"monitors remotely"| node_mobile
node_desktop -.->|"uses backend"| node_auth_api
node_dashboard -.->|"views reporting"| node_reporting_api
node_mobile -->|"uses REST and WebSocket"| node_reporting_api
node_legacy_main -->|"loads configuration"| node_legacy_config
node_legacy_main -->|"detects capabilities"| node_capabilities
node_legacy_main -->|"starts processing"| node_legacy_services
node_legacy_services -->|"processes frames"| node_legacy_pipeline
node_legacy_services -->|"loads regions"| node_legacy_regions
node_legacy_services -->|"monitors performance"| node_performance
node_legacy_main -->|"sets up logging"| node_legacy_logger
node_legacy_main -->|"handles failures"| node_legacy_exceptions
node_legacy_pipeline -.->|"classifies regions"| node_legacy_regions

click node_ai_api "https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/services/ai_detection_service/main.py"
click node_legacy_ai "https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/adapters/legacy_ai_adapter/adapter.py"
click node_vision_model "https://github.com/datphannexor/parkingspacedetection/blob/main/ParkingVisionV8/run_droidcam_v8s_boardlock.py"
click node_slot_mapper "https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/adapters/slot_id_mapper/mapper.py"
click node_billing_api "https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/services/parking_billing_service/main.py"
click node_billing_adapter "https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/adapters/legacy_billing_adapter/adapter.py"
click node_auth_api "https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/services/auth_service/main.py"
click node_reporting_api "https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/services/reporting_service/main.py"
click node_desktop_sync "https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/services/desktop_sync_service/main.py"
click node_event_contracts "https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/shared/events/schemas.py"
click node_db_access "https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/shared/database/connection.py"
click node_desktop "https://github.com/datphannexor/parkingspacedetection/blob/main/ParkingSpaceDesktopApp/app_gui.py"
click node_dashboard "https://github.com/datphannexor/parkingspacedetection/blob/main/ParkingSpaceDesktopApp/streamlit_dashboard.py"
click node_mobile "https://github.com/datphannexor/parkingspacedetection/tree/main/flutter_mobile_app"
click node_legacy_main "https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/main.py"
click node_legacy_services "https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/services.py"
click node_legacy_pipeline "https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/pipeline.py"
click node_legacy_regions "https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/regions.py"
click node_legacy_config "https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/config.py"
click node_capabilities "https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/capabilities.py"
click node_performance "https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/performance.py"
click node_legacy_logger "https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/logger.py"
click node_legacy_exceptions "https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/exceptions.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_ai_api,node_legacy_ai,node_vision_model,node_slot_mapper toneBlue
class node_billing_api,node_billing_adapter,node_auth_api,node_reporting_api,node_desktop_sync toneAmber
class node_mysql,node_redis,node_rabbitmq,node_event_contracts,node_db_access toneMint
class node_desktop,node_dashboard,node_mobile toneRose
class node_legacy_main,node_legacy_services,node_legacy_pipeline,node_legacy_regions,node_legacy_config,node_capabilities,node_performance,node_legacy_logger,node_legacy_exceptions,node_operator,node_camera toneIndigo
```

## Components

### Vision and Detection

- [Detection API](https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/services/ai_detection_service/main.py): `backend_microservices/services/ai_detection_service/main.py`
- [Legacy AI Adapter](https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/adapters/legacy_ai_adapter/adapter.py): `backend_microservices/adapters/legacy_ai_adapter/adapter.py`
- [YOLO / OpenCV Detection](https://github.com/datphannexor/parkingspacedetection/blob/main/ParkingVisionV8/run_droidcam_v8s_boardlock.py): `ParkingVisionV8/run_droidcam_v8s_boardlock.py`
- [Slot ID Mapping](https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/adapters/slot_id_mapper/mapper.py): `backend_microservices/adapters/slot_id_mapper/mapper.py`

### Parking Operations

- [Session and Billing](https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/services/parking_billing_service/main.py): `backend_microservices/services/parking_billing_service/main.py`
- [Legacy Billing Adapter](https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/adapters/legacy_billing_adapter/adapter.py): `backend_microservices/adapters/legacy_billing_adapter/adapter.py`
- [Authentication and RBAC](https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/services/auth_service/main.py): `backend_microservices/services/auth_service/main.py`
- [Reports and WebSocket](https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/services/reporting_service/main.py): `backend_microservices/services/reporting_service/main.py`
- [Desktop Sync](https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/services/desktop_sync_service/main.py): `backend_microservices/services/desktop_sync_service/main.py`

### Shared Platform

- **MySQL**
- **Redis**
- **RabbitMQ**
- [Event Contracts and Publisher](https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/shared/events/schemas.py): `backend_microservices/shared/events/schemas.py`
- [Database and Cache Access](https://github.com/datphannexor/parkingspacedetection/blob/main/backend_microservices/shared/database/connection.py): `backend_microservices/shared/database/connection.py`

### Operator Clients

- [Desktop Application](https://github.com/datphannexor/parkingspacedetection/blob/main/ParkingSpaceDesktopApp/app_gui.py): `ParkingSpaceDesktopApp/app_gui.py`
- [Streamlit Dashboard](https://github.com/datphannexor/parkingspacedetection/blob/main/ParkingSpaceDesktopApp/streamlit_dashboard.py): `ParkingSpaceDesktopApp/streamlit_dashboard.py`
- [Flutter Mobile App](https://github.com/datphannexor/parkingspacedetection/tree/main/flutter_mobile_app): `flutter_mobile_app`

### Legacy Runtime

- [Legacy Runtime Entry](https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/main.py): `src/parkingspace/main.py`
- [Detection Services](https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/services.py): `src/parkingspace/services.py`
- [Region Pipeline](https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/pipeline.py): `src/parkingspace/pipeline.py`
- [Region Definitions](https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/regions.py): `src/parkingspace/regions.py`
- [Runtime Configuration](https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/config.py): `src/parkingspace/config.py`
- [Capability Detection](https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/capabilities.py): `src/parkingspace/capabilities.py`
- [Performance Monitoring](https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/performance.py): `src/parkingspace/performance.py`
- [Logging](https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/logger.py): `src/parkingspace/logger.py`
- [Runtime Exceptions](https://github.com/datphannexor/parkingspacedetection/blob/main/src/parkingspace/exceptions.py): `src/parkingspace/exceptions.py`

### Other components

- **Operator**
- **Image / Video / Camera**

## Connections

- Operator → Detection API: uploads media (evidence: `README.md`)
- Image / Video / Camera → Detection API: provides frames (evidence: `README.md`)
- Detection API → Legacy AI Adapter: delegates detection (evidence: `backend_microservices/services/ai_detection_service/main.py`)
- Legacy AI Adapter → YOLO / OpenCV Detection: runs detection (evidence: `backend_microservices/adapters/legacy_ai_adapter/adapter.py`)
- Detection API → Slot ID Mapping: maps slot IDs (evidence: `backend_microservices/services/ai_detection_service/main.py`)
- Detection API → Event Contracts and Publisher: publishes results (evidence: `backend_microservices/services/ai_detection_service/main.py`)
- Event Contracts and Publisher → RabbitMQ: sends events (evidence: `README.md`)
- Session and Billing → MySQL: reads and writes (evidence: `backend_microservices/services/parking_billing_service/main.py`)
- Session and Billing → Redis: reads slot state (evidence: `backend_microservices/services/parking_billing_service/main.py`)
- Session and Billing → Event Contracts and Publisher: consumes events (evidence: `backend_microservices/services/parking_billing_service/main.py`)
- Session and Billing → Legacy Billing Adapter: uses billing adapter (evidence: `backend_microservices/services/parking_billing_service/main.py`)
- Authentication and RBAC → MySQL: reads and writes (evidence: `backend_microservices/services/auth_service/main.py`)
- Authentication and RBAC → Operator: issues JWT (evidence: `README.md`)
- Reports and WebSocket → MySQL: queries history (evidence: `backend_microservices/services/reporting_service/main.py`)
- Reports and WebSocket → Redis: serves slot state (evidence: `README.md`)
- Desktop Sync → MySQL: syncs records (evidence: `README.md`)
- Desktop Sync → Event Contracts and Publisher: uses events (evidence: `backend_microservices/services/desktop_sync_service/main.py`)
- Database and Cache Access → MySQL: connects to (evidence: `README.md`)
- Database and Cache Access → Redis: connects to (evidence: `README.md`)
- Operator → Desktop Application: operates (evidence: `README.md`)
- Operator → Streamlit Dashboard: views reports (evidence: `README.md`)
- Operator → Flutter Mobile App: monitors remotely (evidence: `README.md`)
- Desktop Application → Authentication and RBAC: uses backend (evidence: `README.md`)
- Streamlit Dashboard → Reports and WebSocket: views reporting (evidence: `README.md`)
- Flutter Mobile App → Reports and WebSocket: uses REST and WebSocket (evidence: `README.md`)
- Legacy Runtime Entry → Runtime Configuration: loads configuration (evidence: `src/parkingspace/main.py`)
- Legacy Runtime Entry → Capability Detection: detects capabilities (evidence: `src/parkingspace/main.py`)
- Legacy Runtime Entry → Detection Services: starts processing (evidence: `src/parkingspace/main.py`)
- Detection Services → Region Pipeline: processes frames (evidence: `src/parkingspace/services.py`)
- Detection Services → Region Definitions: loads regions (evidence: `src/parkingspace/services.py`)
- Detection Services → Performance Monitoring: monitors performance (evidence: `src/parkingspace/services.py`)
- Legacy Runtime Entry → Logging: sets up logging (evidence: `src/parkingspace/main.py`)
- Legacy Runtime Entry → Runtime Exceptions: handles failures (evidence: `src/parkingspace/main.py`)
- Region Pipeline → Region Definitions: classifies regions (evidence: `src/parkingspace/pipeline.py`)
