# zinjpq/automatic-door architecture

> Architecture diagram of the GitHub repository zinjpq/automatic-door, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zinjpq/automatic-door
- Repository: https://github.com/zinjpq/automatic-door

## Overview

##### Project type and purpose
- This is a full-stack embedded-plus-desktop application (“Automatic Door System”) that uses:
- A Python/Tkinter GUI for monitoring and control
- OpenCV for license-plate recognition
- Multiple microcontroller firmwares (ESP32-CAM, Arduino R3, Raspberry Pi, STM32) to drive door actuators (servos, LCD, infrared sensor, optional RFID)
- Purpose: capture images, detect plates, authorize doors, and physically open/close based on recognition and security rules.

##### File structure
Top level:
- firmware/ – per-platform embedded code
– Arduino/esp32 & r3 folders (.ino and setup headers, libraries)
– RaspberryPi (AuDo.py, MFRC522.py)
– STM32 (CubeMX project, HAL drivers, startup, linker script)
- simulations/ – Proteus schematic and libraries
- src/ – desktop application and plate-detection pipeline
– Components, Assets, Constants, Communication (http_esp32.py, mqtt_raspi.py)
– DetectPlateImage (OpenCV modules: Preprocess, DetectPlates, DetectChars, PossiblePlate/Char)
– Main.py – orchestrator
Configuration & documentation files: README.md, .gitignore, task.md.

##### README for additional insights
- Architecture described verbally: ESP32-CAM streams video → Python program performs plate detection → Tkinter GUI displays logs/status → On recognition, desktop app or MCU code sends UART or MQTT/HTTP commands to microcontrollers → Servos open/close door
- Hardware support for optional RFID, IR sensors
- Contributing steps and individual tasks hint at modular separation: firmware vs. app vs. simulations.

##### Elements
- Clear labels: e.g., “Tkinter GUI”, “DetectPlates.py”, “ESP32-CAM”, “Servo Motor”
- Image flow → detection
- Decision flow → command dispatch
- Control flow → actuation
- Status flow → GUI update
- Blue for desktop modules
- Green for network/communication
- Orange for edge devices/firmware
- Red for actuators/sensors

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Desktop Application Layer
    subgraph "Desktop Application Tier"
        direction TB
        Main["Main Orchestrator\n(src/Main.py)"]:::desktop
        GUI["Tkinter GUI\n(AllBar.py, Widgets.py)"]:::desktop
        subgraph "Plate-Recognition Engine" 
            direction TB
            Pre["Preprocess.py"]:::desktop
            DPlates["DetectPlates.py"]:::desktop
            DChars["DetectChars.py"]:::desktop
            PPlate["PossiblePlate.py"]:::desktop
            PChar["PossibleChar.py"]:::desktop
            MDPlate["MainDetectPlate.py"]:::desktop
            Classif["classifications.txt"]:::desktop
            Flat["flattened_images.txt"]:::desktop
        end
        subgraph "Communication Layer"
            direction TB
            HTTP["http_esp32.py"]:::comm
            MQTT["mqtt_raspi.py"]:::comm
        end
        Const["urls.py"]:::desktop
        DataStore["Local Data Store / Log\n(Detectedplate/, plate.txt)"]:::desktop
    end

    %% Embedded / Edge Tier
    subgraph "Embedded Edge Tier"
        direction TB
        ESP32["ESP32-CAM (HTTP Stream)"]:::edge
        RPi["Raspberry Pi Zero (MQTT Subscriber)"]:::edge
        subgraph "UART Servo Controllers"
            direction TB
            Arduino["Arduino R3\n(UART, Servo, LCD, IR)"]:::edge
            STM32["STM32F103\n(UART, PWM, LCD, EEPROM)"]:::edge
        end
    end

    %% Actuators & Sensors
    subgraph "Actuation & Sensing"
        direction TB
        Servo["Servo Motor"]:::actuator
        LCD["LCD Display"]:::actuator
        IR["Infrared Sensor"]:::actuator
        RFID["RFID Module\n(optional)"]:::actuator
    end

    %% Simulations & Diagrams
    Simulations["Proteus Schematics & Libraries"]:::edge
    Wiring["Wiring & Hardware Diagrams"]:::edge

    %% Flows
    ESP32 -->|"HTTP POST/Stream"| Main
    Main -->|"Invoke Detection"| Pre
    MDPlate -->|"calls"| DPlates
    DPlates --> DChars
    DChars --> PPlate
    PPlate --> PChar
    PChar --> MDPlate
    Main -->|"Read URLs"| Const
    Main -->|"Log plates"| DataStore
    Main -->|"Display status"| GUI
    Main -->|"HTTP Command"| ESP32
    Main -->|"MQTT Publish"| RPi
    ESP32 -->|"UART TX"| Arduino
    RPi -->|"GPIO Control"| Servo
    Arduino -->|"PWM"| Servo
    STM32 -->|"PWM"| Servo
    Arduino -->|"I2C"| LCD
    STM32 -->|"I2C"| LCD
    Arduino -->|"IR Sensor Input"| IR
    RPi -->|"RFID Input"| RFID
    Arduino -->|"EEPROM"| DataStore
    STM32 -->|"EEPROM"| DataStore
    Arduino -->|"ACK (UART)"| Main
    RPi -->|"Status (MQTT)"| GUI
    Simulations -.-> ESP32
    Simulations -.-> Arduino
    Wiring -.-> ESP32
    Wiring -.-> Arduino

    %% Click Events
    click Main "https://github.com/zinjpq/automatic-door/blob/main/src/Main.py"
    click GUI "https://github.com/zinjpq/automatic-door/blob/main/src/Components/AllBar.py"
    click GUI "https://github.com/zinjpq/automatic-door/blob/main/src/Components/Widgets.py"
    click Pre "https://github.com/zinjpq/automatic-door/blob/main/src/DetectPlateImage/Preprocess.py"
    click DPlates "https://github.com/zinjpq/automatic-door/blob/main/src/DetectPlateImage/DetectPlates.py"
    click DChars "https://github.com/zinjpq/automatic-door/blob/main/src/DetectPlateImage/DetectChars.py"
    click PPlate "https://github.com/zinjpq/automatic-door/blob/main/src/DetectPlateImage/PossiblePlate.py"
    click PChar "https://github.com/zinjpq/automatic-door/blob/main/src/DetectPlateImage/PossibleChar.py"
    click MDPlate "https://github.com/zinjpq/automatic-door/blob/main/src/DetectPlateImage/MainDetectPlate.py"
    click Classif "https://github.com/zinjpq/automatic-door/blob/main/src/DetectPlateImage/classifications.txt"
    click Flat "https://github.com/zinjpq/automatic-door/blob/main/src/DetectPlateImage/flattened_images.txt"
    click HTTP "https://github.com/zinjpq/automatic-door/blob/main/src/Communication/http_esp32.py"
    click MQTT "https://github.com/zinjpq/automatic-door/blob/main/src/Communication/mqtt_raspi.py"
    click Const "https://github.com/zinjpq/automatic-door/blob/main/src/Constants/urls.py"
    click DataStore "https://github.com/zinjpq/automatic-door/tree/main/src/Detectedplate/"
    click DataStore "https://github.com/zinjpq/automatic-door/blob/main/src/plate.txt"
    click ESP32 "https://github.com/zinjpq/automatic-door/blob/main/firmware/Arduino/esp32/esp32.ino"
    click ESP32 "https://github.com/zinjpq/automatic-door/blob/main/firmware/Arduino/esp32/setup-esp32-cam.h"
    click RPi "https://github.com/zinjpq/automatic-door/blob/main/firmware/RaspberryPi/AuDo.py"
    click RPi "https://github.com/zinjpq/automatic-door/blob/main/firmware/RaspberryPi/MFRC522.py"
    click Arduino "https://github.com/zinjpq/automatic-door/blob/main/firmware/Arduino/r3/r3.ino"
    click STM32 "https://github.com/zinjpq/automatic-door/blob/main/firmware/Stm32/Core/Inc/main.h"
    click STM32 "https://github.com/zinjpq/automatic-door/blob/main/firmware/Stm32/Core/Src/main.c"
    click STM32 "https://github.com/zinjpq/automatic-door/tree/main/firmware/Stm32/Drivers/"
    click Simulations "https://github.com/zinjpq/automatic-door/blob/main/simulations/Audo.pdsprj"
    click Simulations "https://github.com/zinjpq/automatic-door/tree/main/simulations/Library/"
    click Wiring "https://github.com/zinjpq/automatic-door/tree/main/Images/Wiring Diagram/"

    %% Styles
    classDef desktop fill:#cce5ff,stroke:#004085,color:#004085
    classDef comm fill:#d4edda,stroke:#155724,color:#155724
    classDef edge fill:#fff3cd,stroke:#856404,color:#856404
    classDef actuator fill:#f8d7da,stroke:#721c24,color:#721c24
```
