# kaz004/smart-parking-management-system architecture

> Architecture diagram of the GitHub repository kaz004/smart-parking-management-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kaz004/smart-parking-management-system
- Repository: https://github.com/kaz004/smart-parking-management-system

## Overview

##### Project Type and Purpose
- The README explains that the system uses IoT sensors and machine learning to efficiently manage parking spaces, enable real-time monitoring, and integrate number plate scanning. This shows that the project is a full-stack IoT and machine-learning application.
- The system combines hardware data (from IoT sensors and cameras), backend processing (using Python scripts and ML modules), and a web-based frontend (built in the “pm” folder) to display information and manage operations.

##### File Structure
- Backend Components:
- Under “Python files”, you have key scripts like (3)ParkingSpacePicker.py, (4)main PS.py, mongodb.py, and scan.py which hint at the core business logic: picking parking spaces, scanning vehicles, and interacting with a MongoDB database.
- There is also a model.xml file and slot data (images/videos) for parking positions, suggesting that the system handles spatial and visual data.
- A significant part is the “yolov5-master” directory. This contains all the files for the YOLOv5 machine learning framework, reflecting its role in vehicle and license plate detection.
- Frontend Components:
- The “pm” directory holds a web application (with package.json, index.html, and React/JSX files) that likely serves as the user interface to monitor parking reports, history, and scans.
- Support and Deployment:
- Configuration files (e.g., requirements.txt, package.json, Dockerfile, etc.) indicate integration and deployment instructions.
- There are also several utility directories (flask_rest_api, loggers, etc.) which suggest additional layers for API exposure and logging.

##### Main Components
- IoT/Hardware Layer:
- IoT sensors and cameras that capture real-time parking space and number plate data. Represent these as external devices feeding raw data.
- Data Acquisition & Preprocessing:
- A “Scan/Process” module (using scripts like scan.py) that collects video, sensor data, and images from slot data and test images.
- Machine Learning / Detection Module:
- Connections linking raw image/video data (from sensors) to this YOLOv5 module.
- Core Backend Services:
- Modules such as ParkingSpacePicker.py and main PS.py, which handle logic around selecting available spaces, managing entry/exit, and integrating results from the detection modules.
- Also, highlight mongodb.py as the integration point with the data persistence layer.
- Database Layer:
- REST API / Service Layer:
- If the backend exposes APIs (for instance, via the flask_rest_api utilities), include an API gateway or service component that communicates with the frontend.
- Frontend Application:
- “pm” directory application (React-based) as the user interface for administrators and users to view dashboards, history, and reports.
- Integration & Communication:

##### Architectural Patterns and Design Principles
- The system follows a modular layered architecture where each layer (IoT, data ingestion, ML processing, backend logic, and presentation) is separated.
- There is a clear separation of concerns: machine learning is handled independently (via YOLOv5) and then integrated with business logic, and the frontend is completely decoupled from backend processes.
- Using REST APIs (as suggested by the flask_rest_api folder) provides a clear contract between the front and back ends.
- The inclusion of microservice or utility modules (e.g., loggers, docker configurations) indicates attention to scalability, maintainability, and deployment best practices.

##### Final Recommendations for the Principal Software Engineer
- That the interactions (data flows) between components such as sensor data streaming to the detection module, communication from backend to MongoDB, and API requests from the frontend to backend are clearly depicted.
- Being detailed is beneficial: include all the key modules and their interactions to capture the full scope of the parking management process.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "IoT Layer"
        IoT["IoT Sensors & Cameras"]:::hardware
    end

    subgraph "Data Acquisition Layer"
        Scan["Image & Sensor Data Processing"]:::processing
    end

    subgraph "Machine Learning Layer"
        YOLO["Object Detection Engine"]:::ml
    end

    subgraph "Backend Services"
        PS1["ParkingSpacePicker"]:::backend
        PS2["Main PS"]:::backend
        Database["MongoDB"]:::database
        REST["Flask REST API"]:::api
    end

    subgraph "Frontend"
        FE["Frontend UI"]:::frontend
    end

    IoT -->|"sends_data"| Scan
    Scan -->|"for_processing"| YOLO
    YOLO -->|"detection_results"| PS1
    YOLO -->|"detection_results"| PS2
    PS1 -->|"store_data"| Database
    PS2 -->|"store_data"| Database
    PS1 -->|"trigger_api_updates"| REST
    PS2 -->|"trigger_api_updates"| REST
    REST -->|"update_UI"| FE

    click PS1 "https://github.com/kaz004/smart-parking-management-system/blob/main/Python files/(3)ParkingSpacePicker.py"
    click PS2 "https://github.com/kaz004/smart-parking-management-system/blob/main/Python files/(4)main PS.py"
    click Database "https://github.com/kaz004/smart-parking-management-system/blob/main/Python files/mongodb.py"
    click Scan "https://github.com/kaz004/smart-parking-management-system/blob/main/Python files/scan.py"
    click YOLO "https://github.com/kaz004/smart-parking-management-system/tree/main/Python files/yolov5-master"
    click REST "https://github.com/kaz004/smart-parking-management-system/tree/main/Python files/yolov5-master/utils/flask_rest_api"
    click FE "https://github.com/kaz004/smart-parking-management-system/tree/main/pm"

    classDef hardware fill:#f9c,stroke:#333,stroke-width:2px;
    classDef processing fill:#ffe699,stroke:#333,stroke-width:2px;
    classDef ml fill:#cfe2f3,stroke:#333,stroke-width:2px;
    classDef backend fill:#d9ead3,stroke:#333,stroke-width:2px;
    classDef database fill:#ffd966,stroke:#333,stroke-width:2px;
    classDef api fill:#f4cccc,stroke:#333,stroke-width:2px;
    classDef frontend fill:#b4a7d6,stroke:#333,stroke-width:2px;
```
