# wuqin04/parksense architecture

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

- Interactive diagram: https://gitdiagram.com/wuqin04/parksense
- Repository: https://github.com/wuqin04/parksense

## Overview

The source tree implements a parking-management system: camera-based plate processing and fee/occupancy records on a Python host, paired with MicroPython sensors and gate control; browser pages provide a web interface. The README instead describes a desktop file organizer, so it does not reliably document this repository’s behavior. Edges follow shown calls or SOURCE INDEX references; web behavior is not connected where its wiring was not shown.

Main entry points: [`micropython/main.py`](https://github.com/wuqin04/parksense/blob/main/micropython/main.py) (Device Server), [`python/main.py`](https://github.com/wuqin04/parksense/blob/main/python/main.py) (Plate Processing), [`micropython/gate_control.py`](https://github.com/wuqin04/parksense/blob/main/micropython/gate_control.py) (Gate Logic), [`lib/lcd_i2c/lcd_i2c.py`](https://github.com/wuqin04/parksense/blob/main/lib/lcd_i2c/lcd_i2c.py) (I2C LCD Driver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host Parking Service"]
  node_hostapp["Plate Processing<br/>[main.py]"]
  node_car["Car and Fees<br/>[car.py]"]
  node_db["Parking Records<br/>[database.py]"]
  node_recordfiles["JSON Records<br/>[data.json]"]
  node_occupancyfile["Occupancy Records<br/>[occupancy.json]"]
end

subgraph group_device["Embedded Parking Control"]
  node_deviceapp["Device Server<br/>[main.py]"]
  node_gate["Gate Logic<br/>[gate_control.py]"]
  node_sensor["Slot Sensing<br/>[ultrasonic.py]"]
  node_config["Device Configuration<br/>[configs.py]"]
end

subgraph group_drivers["Hardware Drivers"]
  node_servo["Servo Driver<br/>[__init__.py]"]
  node_lcd["I2C LCD Driver<br/>[lcd_i2c.py]"]
  node_lcdconst["LCD Constants<br/>[const.py]"]
  node_lcdtypes["LCD Typing Support<br/>[typing.py]"]
end

subgraph group_web["Web Interface"]
  node_webpages["Parking Pages"]
  node_webbackend["Web Backend<br/>[backend.js]"]
end

node_operator(("Parking Operator"))

node_operator -.->|"submits plates"| node_hostapp
node_hostapp -->|"uses car model"| node_car
node_hostapp -->|"loads and saves"| node_db
node_db -.->|"reads and writes"| node_recordfiles
node_hostapp -->|"updates occupancy"| node_occupancyfile
node_hostapp -->|"sends plate data"| node_deviceapp
node_deviceapp -->|"posts occupancy"| node_hostapp
node_deviceapp -->|"dispatches gate actions"| node_gate
node_deviceapp -->|"creates slot sensors"| node_sensor
node_deviceapp -->|"uses settings"| node_config
node_deviceapp -->|"creates gate controllers"| node_gate
node_gate -->|"moves gate servo"| node_servo
node_gate -->|"updates display"| node_lcd
node_gate -->|"checks capacity"| node_config
node_sensor -->|"uses pin settings"| node_config
node_lcd -->|"uses command constants"| node_lcdconst
node_lcd -->|"uses type support"| node_lcdtypes

click node_hostapp "https://github.com/wuqin04/parksense/blob/main/python/main.py"
click node_car "https://github.com/wuqin04/parksense/blob/main/python/car.py"
click node_db "https://github.com/wuqin04/parksense/blob/main/python/database.py"
click node_recordfiles "https://github.com/wuqin04/parksense/blob/main/data.json"
click node_occupancyfile "https://github.com/wuqin04/parksense/blob/main/occupancy.json"
click node_deviceapp "https://github.com/wuqin04/parksense/blob/main/micropython/main.py"
click node_gate "https://github.com/wuqin04/parksense/blob/main/micropython/gate_control.py"
click node_sensor "https://github.com/wuqin04/parksense/blob/main/micropython/ultrasonic.py"
click node_config "https://github.com/wuqin04/parksense/blob/main/micropython/configs.py"
click node_servo "https://github.com/wuqin04/parksense/blob/main/lib/servo/__init__.py"
click node_lcd "https://github.com/wuqin04/parksense/blob/main/lib/lcd_i2c/lcd_i2c.py"
click node_lcdconst "https://github.com/wuqin04/parksense/blob/main/lib/lcd_i2c/const.py"
click node_lcdtypes "https://github.com/wuqin04/parksense/blob/main/lib/lcd_i2c/typing.py"
click node_webpages "https://github.com/wuqin04/parksense/tree/main/web/pages"
click node_webbackend "https://github.com/wuqin04/parksense/blob/main/web/logic/backend.js"

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_hostapp,node_car,node_db,node_recordfiles,node_occupancyfile toneBlue
class node_deviceapp,node_gate,node_sensor,node_config toneAmber
class node_servo,node_lcd,node_lcdconst,node_lcdtypes toneMint
class node_webpages,node_webbackend toneRose
class node_operator toneIndigo
```

## Components

### Host Parking Service

- [Plate Processing](https://github.com/wuqin04/parksense/blob/main/python/main.py): `python/main.py`
- [Car and Fees](https://github.com/wuqin04/parksense/blob/main/python/car.py): `python/car.py`
- [Parking Records](https://github.com/wuqin04/parksense/blob/main/python/database.py): `python/database.py`
- [JSON Records](https://github.com/wuqin04/parksense/blob/main/data.json): `data.json`
- [Occupancy Records](https://github.com/wuqin04/parksense/blob/main/occupancy.json): `occupancy.json`

### Embedded Parking Control

- [Device Server](https://github.com/wuqin04/parksense/blob/main/micropython/main.py): `micropython/main.py`
- [Gate Logic](https://github.com/wuqin04/parksense/blob/main/micropython/gate_control.py): `micropython/gate_control.py`
- [Slot Sensing](https://github.com/wuqin04/parksense/blob/main/micropython/ultrasonic.py): `micropython/ultrasonic.py`
- [Device Configuration](https://github.com/wuqin04/parksense/blob/main/micropython/configs.py): `micropython/configs.py`

### Hardware Drivers

- [Servo Driver](https://github.com/wuqin04/parksense/blob/main/lib/servo/__init__.py): `lib/servo/__init__.py`
- [I2C LCD Driver](https://github.com/wuqin04/parksense/blob/main/lib/lcd_i2c/lcd_i2c.py): `lib/lcd_i2c/lcd_i2c.py`
- [LCD Constants](https://github.com/wuqin04/parksense/blob/main/lib/lcd_i2c/const.py): `lib/lcd_i2c/const.py`
- [LCD Typing Support](https://github.com/wuqin04/parksense/blob/main/lib/lcd_i2c/typing.py): `lib/lcd_i2c/typing.py`

### Web Interface

- [Parking Pages](https://github.com/wuqin04/parksense/tree/main/web/pages): `web/pages`
- [Web Backend](https://github.com/wuqin04/parksense/blob/main/web/logic/backend.js): `web/logic/backend.js`

### Other components

- **Parking Operator**

## Connections

- Parking Operator → Plate Processing: submits plates
- Plate Processing → Car and Fees: uses car model (evidence: `python/main.py`)
- Plate Processing → Parking Records: loads and saves (evidence: `python/main.py`)
- Parking Records → JSON Records: reads and writes
- Plate Processing → Occupancy Records: updates occupancy (evidence: `python/main.py`)
- Plate Processing → Device Server: sends plate data (evidence: `python/main.py`)
- Device Server → Plate Processing: posts occupancy (evidence: `micropython/main.py`)
- Device Server → Gate Logic: dispatches gate actions (evidence: `micropython/main.py`)
- Device Server → Slot Sensing: creates slot sensors (evidence: `micropython/main.py`)
- Device Server → Device Configuration: uses settings (evidence: `micropython/main.py`)
- Device Server → Gate Logic: creates gate controllers (evidence: `micropython/main.py`)
- Gate Logic → Servo Driver: moves gate servo (evidence: `micropython/gate_control.py`)
- Gate Logic → I2C LCD Driver: updates display (evidence: `micropython/gate_control.py`)
- Gate Logic → Device Configuration: checks capacity (evidence: `micropython/gate_control.py`)
- Slot Sensing → Device Configuration: uses pin settings (evidence: `micropython/ultrasonic.py`)
- I2C LCD Driver → LCD Constants: uses command constants (evidence: `lib/lcd_i2c/lcd_i2c.py`)
- I2C LCD Driver → LCD Typing Support: uses type support (evidence: `lib/lcd_i2c/lcd_i2c.py`)
