# l4hu/car-park-license-plate-recognition-system architecture

> Architecture diagram of the GitHub repository l4hu/car-park-license-plate-recognition-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/l4hu/car-park-license-plate-recognition-system
- Repository: https://github.com/l4hu/car-park-license-plate-recognition-system

## Overview

##### Project type and purpose
- This is a hybrid embedded + web-based application for automated license-plate recognition.
- The “micro_controller” folder contains firmware (C, STM32CubeMX) that runs on an MCU, likely handling sensor/camera interfacing and data acquisition.
- The “micro_processor” folder contains Python modules (detector.py, ocr_reader.py) plus a Flask-style web UI (templates/*.html) to run inference, OCR, manage plates, and serve dashboards.

##### File structure
Top-level
- README.md (empty)
- Src/
– micro_controller/
- .ioc project (STM32CubeMX configuration)
- main.c (firmware entry point)
– micro_processor/
- detector.py (object detection using best.pt model)
- ocr_reader.py (optical character recognition)
- plate_manager_wui.py (Flask app for dashboard, login, plate CRUD)
- templates/ (HTML views for dashboard, add_plate, logs, error pages)
- best.pt (pretrained detection model)
- main.py (app launcher or orchestrator)

##### Components
a. micro_controller
– Hardware block: MCU + camera/sensor interfaces
– Firmware block: STM32CubeMX-generated HAL + main.c state machine
– Communication interface: UART, SPI, or Ethernet to micro_processor
b. micro_processor
– Inference engine: detector.py (loads best.pt)
– OCR engine: ocr_reader.py
– Plate management service/API: endpoints in plate_manager_wui.py
– Web UI: HTML templates + Flask routing
– Data store: (implied) sqlite or file logs for plates & access logs
c. External users
– Web browser clients consuming the dashboard/login/add_plate UIs

##### Relationships and interactions
1. Camera data → MCU firmware (main.c)
2. MCU → micro_processor over serial or network
3. micro_processor detector.py inference → detected plate image
4. detector.py → ocr_reader.py → plate number string
5. plate_manager_wui.py stores results → data store
6. Web browser ↔ Flask app (HTTP requests/responses)
- Control flow:
- User triggers “add plate” from UI → HTTP POST → Flask endpoint → data store

##### Architectural patterns and design principles
- Embedded firmware: event-driven state machine
- Server side: MVC pattern via Flask (models: data store, views: templates, controllers: endpoints)
- Separation of concerns: detection vs. OCR vs. presentation vs. data persistence
- Modularization: each Python script is a single responsibility module

##### Technologies & frameworks
- STM32CubeMX, HAL libraries, C (micro_controller)
- Python 3, Flask, Jinja2 templates (micro_processor)
- PyTorch model (.pt) for detection
- OCR library (e.g., Tesseract) used in ocr_reader.py
- HTML/CSS for WUI

## Diagram (Mermaid)

```mermaid
graph TB
    %% Embedded Device
    subgraph "Embedded Device"
        direction TB
        sensor["Camera Sensor"]:::firmware
        halConfig["STM32CubeMX HAL (.ioc)"]:::firmware
        mcuFirmware["MCU Firmware (main.c)"]:::firmware
        embeddedDoc["Embedded Docs (README.md)"]:::firmware
    end

    %% Processing Server
    subgraph "Processing Server"
        direction TB
        detector["Detector Service (detector.py)"]:::python
        model["Pretrained Model (best.pt)"]:::python
        ocr["OCR Engine (ocr_reader.py)"]:::python
        plateAPI["Plate Management Service/API (plate_manager_wui.py)"]:::python
        orchestrator["Web App Launcher (main.py)"]:::python
        templates["Web UI Templates"]:::templates
        dataStore["Data Store"]:::datasource
        procDoc["Processor Docs (README.md)"]:::python
    end

    %% External Users
    browser["Web Browser"]:::external

    %% Data Flows
    sensor --> mcuFirmware
    mcuFirmware -->|"UART/Serial"| detector
    detector -->|"loads model"| model
    detector -->|"image output"| ocr
    ocr -->|"text output"| plateAPI
    plateAPI -->|"store data"| dataStore
    browser -->|"HTTP Requests/Responses"| plateAPI
    plateAPI -->|"renders views"| templates
    orchestrator -->|"orchestrates services"| plateAPI

    %% Click Events
    click mcuFirmware "https://github.com/l4hu/car-park-license-plate-recognition-system/blob/main/Src/micro_controller/main.c"
    click halConfig "https://github.com/l4hu/car-park-license-plate-recognition-system/blob/main/Src/micro_controller/.ioc"
    click embeddedDoc "https://github.com/l4hu/car-park-license-plate-recognition-system/blob/main/Src/micro_controller/README.md"
    click detector "https://github.com/l4hu/car-park-license-plate-recognition-system/blob/main/Src/micro_processor/detector.py"
    click model "https://github.com/l4hu/car-park-license-plate-recognition-system/blob/main/Src/micro_processor/best.pt"
    click ocr "https://github.com/l4hu/car-park-license-plate-recognition-system/blob/main/Src/micro_processor/ocr_reader.py"
    click plateAPI "https://github.com/l4hu/car-park-license-plate-recognition-system/blob/main/Src/micro_processor/plate_manager_wui.py"
    click orchestrator "https://github.com/l4hu/car-park-license-plate-recognition-system/blob/main/Src/micro_processor/main.py"
    click templates "https://github.com/l4hu/car-park-license-plate-recognition-system/tree/main/Src/micro_processor/templates/"
    click procDoc "https://github.com/l4hu/car-park-license-plate-recognition-system/blob/main/Src/micro_processor/README.md"

    %% Styles
    classDef firmware fill:#cce5ff,stroke:#007bff,color:#000;
    classDef python fill:#d4edda,stroke:#28a745,color:#000;
    classDef datasource fill:#fff3cd,stroke:#ffc107,color:#000;
    classDef db fill:#e2e3e5,stroke:#6c757d,color:#000;
    classDef external fill:#f8d7da,stroke:#dc3545,color:#000;
    classDef templates fill:#e2e3e5,stroke:#6c757d,color:#000;
```
