# quecpython/solution-agriculture-control-panel architecture

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

- Interactive diagram: https://gitdiagram.com/quecpython/solution-agriculture-control-panel
- Repository: https://github.com/quecpython/solution-agriculture-control-panel

## Overview

##### Project type and purpose
- This is an embedded, full-stack (firmware + GUI) application—a “Smart Agriculture Central Control Panel” running in QuecPython on the Quectel U-235 EVB hardware.
- Purpose: read environmental sensors (e.g., AHT20), fetch or display weather forecasts, show real-time and historical data curves, control farm equipment, raise alarms, and allow user configuration via a 5″ MIPI LCD.

##### File structure
- Top-level “code/” directory: all application logic lives here.
- main.py: application entry point and initialization.
- EventMesh.py: internal event bus (pub/sub) for decoupling UI and business logic.
- Agri_ui.py: high–level UI orchestrator, binds screens to events.
- *_screen.py files (welcome, main, monitor, dev1, dev2, alarm, setting1/2, about, weather): individual LVGL screen modules.
- AHT20.py: sensor driver for the AHT20 environmental sensor.
- docs/: architecture illustrations, user guides, and media assets—no code.
- No explicit network modules shown, but weather_screen.py likely uses QuecPython’s HTTP client over the EC600U modem.

##### README for additional insights
- GUI built on LVGL (embedded graphics library). GUI definitions come from NXP’s GUI Guider (auto-generated code).
- Firmware runs in the QuecPython runtime on the EC600U module.
- Sensors and peripherals are onboard the U-235 EVB; display attaches via MIPI.
- EventMesh is the core pattern for inter-module communication.

##### Final checklist
- Central EventMesh component.
- Application modules grouped (Agri_ui, sensor driver, individual screens).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Hardware Layer
    subgraph "Hardware Layer"
        direction TB
        U235["U-235 EVB Board"]:::hardware
        Sensors["Onboard Sensors (AHT20, etc.)"]:::hardware
        LCD["5” MIPI LCD + Touch"]:::hardware
        SIM["SIM & Antenna"]:::hardware
        USB["USB Interface"]:::hardware
    end

    %% Runtime & Frameworks
    subgraph "Runtime & Frameworks"
        direction TB
        QuecPython["QuecPython Interpreter"]:::runtime
        LVGL["LVGL Graphics Library"]:::runtime
        GUI_Guider["GUI Guider Generated Code"]:::runtime
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        Main["Application Bootstrap\n(main.py)"]:::app
        EventBus["Event Bus\n(EventMesh)"]:::app
        UIManager["UI Manager & Business Logic\n(Agri_ui)"]:::app
        SensorDrv["Sensor Driver\n(AHT20.py)"]:::app
        subgraph "UI Screens"
            direction TB
            BaseScreen["Base Screen Module\n(screen.py)"]:::app
            Welcome["Welcome Screen\n(welcome_screen.py)"]:::app
            MainScreen["Main Screen\n(main_screen.py)"]:::app
            Monitor["Monitor Screen\n(monitor_screen.py)"]:::app
            Dev1["Device1 Control Screen\n(dev1_screen.py)"]:::app
            Dev2["Device2 Control Screen\n(dev2_screen.py)"]:::app
            Weather["Weather Forecast Screen\n(weather_screen.py)"]:::app
            Alarm["Alarm Screen\n(alarm_screen.py)"]:::app
            Setting1["Settings Screen1\n(setting1_screen.py)"]:::app
            Setting2["Settings Screen2\n(setting2_screen.py)"]:::app
            About["About Screen\n(about_screen.py)"]:::app
        end
        Assets["Static Assets\n(img/)"]:::app
    end

    %% External Services
    WeatherAPI["Weather API Service"]:::ext

    %% Connections
    Sensors -->|sensor_reading| SensorDrv
    SensorDrv -->|publish event| EventBus
    EventBus -->|subscribe| Monitor
    EventBus -->|subscribe| MainScreen
    EventBus -->|publish weather_data| Weather
    WeatherAPI -->|weather_data| EventBus
    LCD -->|touch_event| LVGL
    LVGL -->|touch_event| EventBus
    EventBus -->|dispatch| UIManager
    UIManager -->|invoke| Welcome
    UIManager -->|invoke| MainScreen
    UIManager -->|invoke| Dev1
    UIManager -->|invoke| Dev2
    UIManager -->|invoke| Weather
    UIManager -->|invoke| Alarm
    UIManager -->|invoke| Setting1
    UIManager -->|invoke| Setting2
    UIManager -->|invoke| About
    UIManager -->|load assets| Assets
    Main -->|bootstrap| EventBus
    Main -->|bootstrap| UIManager
    Main -->|bootstrap| SensorDrv
    Main -->|bootstrap| QuecPython
    Main -->|bootstrap| LVGL

    %% Click Events
    click Main "https://github.com/quecpython/solution-agriculture-control-panel/blob/master/code/main.py"
    click EventBus "https://github.com/quecpython/solution-agriculture-control-panel/blob/master/code/EventMesh.py"
    click UIManager "https://github.com/quecpython/solution-agriculture-control-panel/blob/master/code/Agri_ui.py"
    click SensorDrv "https://github.com/quecpython/solution-agriculture-control-panel/blob/master/code/AHT20.py"
    click Welcome "https://github.com/quecpython/solution-agriculture-control-panel/blob/master/code/welcome_screen.py"
    click MainScreen "https://github.com/quecpython/solution-agriculture-control-panel/blob/master/code/main_screen.py"
    click Monitor "https://github.com/quecpython/solution-agriculture-control-panel/blob/master/code/monitor_screen.py"
    click Dev1 "https://github.com/quecpython/solution-agriculture-control-panel/blob/master/code/dev1_screen.py"
    click Dev2 "https://github.com/quecpython/solution-agriculture-control-panel/blob/master/code/dev2_screen.py"
    click Weather "https://github.com/quecpython/solution-agriculture-control-panel/blob/master/code/weather_screen.py"
    click Alarm "https://github.com/quecpython/solution-agriculture-control-panel/blob/master/code/alarm_screen.py"
    click Setting1 "https://github.com/quecpython/solution-agriculture-control-panel/blob/master/code/setting1_screen.py"
    click Setting2 "https://github.com/quecpython/solution-agriculture-control-panel/blob/master/code/setting2_screen.py"
    click About "https://github.com/quecpython/solution-agriculture-control-panel/blob/master/code/about_screen.py"
    click BaseScreen "https://github.com/quecpython/solution-agriculture-control-panel/blob/master/code/screen.py"
    click Assets "https://github.com/quecpython/solution-agriculture-control-panel/tree/master/code/img/"

    %% Styles
    classDef hardware fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef runtime fill:#a3c4f3,stroke:#333,stroke-width:1px
    classDef app fill:#b7e4c7,stroke:#333,stroke-width:1px
    classDef ext fill:#ffcc80,stroke:#333,stroke-width:1px
```
