# abhishekkaisar/parkguard-stm32-smart-parking architecture

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

- Interactive diagram: https://gitdiagram.com/abhishekkaisar/parkguard-stm32-smart-parking
- Repository: https://github.com/abhishekkaisar/parkguard-stm32-smart-parking

## Overview

ParkGuard is STM32 firmware for parking access control with fail-open flood/fire response. The main loop samples vehicle, keypad, and hazard inputs, applies access and hazard state rules, drives the barrier and indicators, and refreshes the OLED. The README documents several behaviors not visible in the partial main.c excerpt; those branches are retained, with documented relationships cited to the README. Sensor polling and most control details share one implementation file, so their internal call sequence is not expanded beyond supported evidence.

Main entry points: [`firmware/Core/Src/main.c`](https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/main.c) (Main loop), [`firmware/Core/Src/ssd1306.c`](https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/ssd1306.c) (OLED status), [`firmware/Core/Src/fonts.c`](https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/fonts.c) (Display fonts), [`firmware/Drivers/STM32F1xx_HAL_Driver/Src`](https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/tree/main/firmware/Drivers/STM32F1xx_HAL_Driver/Src) (STM32 HAL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Access control"]
  node_main["Main loop<br/>[main.c]"]
  node_ultrasonic["Vehicle sensing<br/>[main.c]"]
  node_gate["Gate control<br/>[main.c]"]
  node_occupancy["Occupancy rules<br/>[main.c]"]
  node_rearm["Lane re-arm<br/>[main.c]"]
end

subgraph group_safety["Hazard response"]
  node_hazards["Hazard assessment<br/>[main.c]"]
  node_indicators["LED indicators<br/>[main.c]"]
end

subgraph group_ui["User interface"]
  node_keypad["Keypad and PIN<br/>[main.c]"]
  node_display["OLED status<br/>[ssd1306.c]"]
  node_fonts["Display fonts<br/>[fonts.c]"]
end

subgraph group_platform["Firmware platform"]
  node_hal["STM32 HAL"]
end

node_driver(("Vehicle / supervisor"))
node_peripherals{{"Garage hardware"}}

node_driver -->|"requests access"| node_main
node_peripherals -->|"provides distance"| node_ultrasonic
node_peripherals -->|"provides hazard readings"| node_hazards
node_peripherals -->|"provides key presses"| node_keypad
node_main -.->|"samples lane"| node_ultrasonic
node_main -->|"checks capacity"| node_occupancy
node_main -->|"commands barrier"| node_gate
node_main -->|"enforces clear interval"| node_rearm
node_main -->|"scans keys"| node_keypad
node_main -->|"evaluates readings"| node_hazards
node_hazards -->|"holds open"| node_gate
node_hazards -->|"signals alarm"| node_indicators
node_main -->|"renders status"| node_display
node_display -->|"uses glyphs"| node_fonts
node_main -->|"uses peripheral APIs"| node_hal
node_gate -->|"drives servo"| node_peripherals
node_indicators -->|"drives LEDs"| node_peripherals

click node_main "https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/main.c"
click node_ultrasonic "https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/main.c"
click node_gate "https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/main.c"
click node_occupancy "https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/main.c"
click node_rearm "https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/main.c"
click node_keypad "https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/main.c"
click node_hazards "https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/main.c"
click node_indicators "https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/main.c"
click node_display "https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/ssd1306.c"
click node_fonts "https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/fonts.c"
click node_hal "https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/tree/main/firmware/Drivers/STM32F1xx_HAL_Driver/Src"

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_main,node_ultrasonic,node_gate,node_occupancy,node_rearm toneBlue
class node_hazards,node_indicators toneAmber
class node_keypad,node_display,node_fonts toneMint
class node_hal toneRose
class node_driver,node_peripherals toneIndigo
```

## Components

### Access control

- [Main loop](https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/main.c): `firmware/Core/Src/main.c`
- [Vehicle sensing](https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/main.c): `firmware/Core/Src/main.c`
- [Gate control](https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/main.c): `firmware/Core/Src/main.c`
- [Occupancy rules](https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/main.c): `firmware/Core/Src/main.c`
- [Lane re-arm](https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/main.c): `firmware/Core/Src/main.c`

### Hazard response

- [Hazard assessment](https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/main.c): `firmware/Core/Src/main.c`
- [LED indicators](https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/main.c): `firmware/Core/Src/main.c`

### User interface

- [Keypad and PIN](https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/main.c): `firmware/Core/Src/main.c`
- [OLED status](https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/ssd1306.c): `firmware/Core/Src/ssd1306.c`
- [Display fonts](https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/blob/main/firmware/Core/Src/fonts.c): `firmware/Core/Src/fonts.c`

### Firmware platform

- [STM32 HAL](https://github.com/abhishekkaisar/parkguard-stm32-smart-parking/tree/main/firmware/Drivers/STM32F1xx_HAL_Driver/Src): `firmware/Drivers/STM32F1xx_HAL_Driver/Src`

### Other components

- **Vehicle / supervisor**
- **Garage hardware**

## Connections

- Vehicle / supervisor → Main loop: requests access
- Garage hardware → Vehicle sensing: provides distance
- Garage hardware → Hazard assessment: provides hazard readings
- Garage hardware → Keypad and PIN: provides key presses
- Main loop → Vehicle sensing: samples lane (evidence: `firmware/Core/Src/main.c`)
- Main loop → Occupancy rules: checks capacity (evidence: `firmware/Core/Src/main.c`)
- Main loop → Gate control: commands barrier (evidence: `firmware/Core/Src/main.c`)
- Main loop → Lane re-arm: enforces clear interval (evidence: `firmware/Core/Src/main.c`)
- Main loop → Keypad and PIN: scans keys (evidence: `firmware/Core/Src/main.c`)
- Main loop → Hazard assessment: evaluates readings (evidence: `firmware/Core/Src/main.c`)
- Hazard assessment → Gate control: holds open (evidence: `firmware/Core/Src/main.c`)
- Hazard assessment → LED indicators: signals alarm (evidence: `firmware/Core/Src/main.c`)
- Main loop → OLED status: renders status (evidence: `firmware/Core/Src/main.c`)
- OLED status → Display fonts: uses glyphs
- Main loop → STM32 HAL: uses peripheral APIs
- Gate control → Garage hardware: drives servo
- LED indicators → Garage hardware: drives LEDs
