# grovety/crowpanel_openweather architecture

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

- Interactive diagram: https://gitdiagram.com/grovety/crowpanel_openweather
- Repository: https://github.com/grovety/crowpanel_openweather

## Overview

##### Project type and purpose
- This is an embedded IoT firmware project—a “full-stack” on the ESP32-S3 device—providing a touch-based weather dashboard built with LVGL for the Elecrow Panel Avance 5.0. It includes UI screens, business logic, network communication, and hardware drivers all packaged as an ESP-IDF component.

##### File structure
- Top-level files:
- CMakeLists.txt, sdkconfig.defaults, idf_component.yml: ESP-IDF build and configuration files.
- firmware/: Flash tool binaries & instructions (bootloader, partition, proj.bin).
- sources/: The main application code divided into:
- adapters/: LVGL port & HTTP request abstraction
- entities/: Domain models (Weather, Location, Units, CurrentTime, WIFI, Brightness) and UI screen composites (weather_screen, wifi_screen)
- usecases/: Application use cases (e.g., AccessPointsUpdate)
- main.cpp: Entry point, initialization, event loop

##### README for additional insights
- Two screens: Settings (Wi-Fi config, brightness, city) and Weather Display (current + forecast).
- External services: OpenWeather (weather), ip-api (city detection), pool.ntp.org (time sync).
- Build & flash via VSCode ESP-IDF Extension.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Hardware Layer"
        ESP32["ESP32-S3 MCU"]:::hardware
        Panel["Elecrow Panel Avance 5.0 LCD+Touch"]:::hardware
    end

    subgraph "Infrastructure Layer"
        HTTPAdapter["HTTPRequest Adapter"]:::adapter
        WiFiDriver["Wi-Fi Driver (ESP-IDF)"]:::adapter
        SNTPClient["SNTP Client"]:::adapter
    end

    subgraph "Application Layer"
        AccessPointsUpdate["AccessPointsUpdate UseCase"]:::usecase
        WeatherEntity["Weather Entity"]:::entity
        LocationEntity["Location Entity"]:::entity
        TimeEntity["CurrentTime Entity"]:::entity
        UnitsEntity["Units Entity"]:::entity
        WiFiEntity["WIFI Entity"]:::entity
        BrightnessEntity["Brightness Entity"]:::entity
    end

    subgraph "UI Layer"
        LVGLPort["LVGL Port v8 Adapter"]:::adapter
        WeatherScreen["WeatherScreen"]:::ui
        WifiScreen["WifiScreen"]:::ui
    end

    subgraph "Asset Layer"
        Images["Embedded Images"]:::asset
    end

    subgraph "External Services"
        OpenWeather["OpenWeather API"]:::external
        IPAPI["ip-api.com"]:::external
        NTPService["pool.ntp.org"]:::external
    end

    subgraph "DevOps / Build System"
        RootCMake["CMakeLists.txt"]:::devops
        SDKConfig["sdkconfig.defaults"]:::devops
        SrcCMake["sources/CMakeLists.txt"]:::devops
        Kconfig["sources/Kconfig.projbuild"]:::devops
        ComponentYML["sources/idf_component.yml"]:::devops
        Firmware["Firmware Binaries & FlashTool"]:::devops
    end

    subgraph "Entry Point"
        Main["main.cpp"]:::entry
    end

    %% Connections
    Main -->|"init Wi-Fi"| WiFiDriver
    Main -->|"init HTTP Adapter"| HTTPAdapter
    Main -->|"init SNTP"| SNTPClient
    Main -->|"init LVGL"| LVGLPort

    %% User Interaction
    User["User Touch"]:::external -->|"touch event"| LVGLPort
    LVGLPort -->|"triggers UseCase"| AccessPointsUpdate
    AccessPointsUpdate -->|"calls HTTPAdapter"| HTTPAdapter
    HTTPAdapter -->|"fetch weather"| OpenWeather
    HTTPAdapter -->|"detect city"| IPAPI
    HTTPAdapter -->|"update entity"| WeatherEntity

    %% Timer-driven updates
    Timer["Periodic Timer"]:::external -->|sync time| SNTPClient
    SNTPClient -->|update| TimeEntity
    TimeEntity -->|refresh UI| LVGLPort
    Timer -->|weather update| AccessPointsUpdate

    %% Entities to UI
    WeatherEntity -->|display data| WeatherScreen
    LocationEntity -->|display data| WifiScreen
    UnitsEntity -->|display data| WifiScreen
    BrightnessEntity -->|display data| WifiScreen
    WiFiEntity -->|status| WifiScreen

    %% Display hardware
    LVGLPort -->|render| Panel
    ESP32 -->|drives| Panel
    ESP32 -->|runs| Main

    %% Assets
    Images -->|icons| WeatherScreen
    Images -->|themes| WifiScreen

    %% DevOps flow
    RootCMake --> SrcCMake
    SrcCMake --> ComponentYML
    ComponentYML --> Firmware
    SDKConfig --> Firmware
    Firmware -->|flash tool| ESP32

    %% Click Events
    click Firmware "https://github.com/grovety/crowpanel_openweather/blob/main/firmware/firmare/binaries/bootloader.bin"
    click RootCMake "https://github.com/grovety/crowpanel_openweather/blob/main/CMakeLists.txt"
    click SDKConfig "https://github.com/grovety/crowpanel_openweather/blob/main/sdkconfig.defaults"
    click SrcCMake "https://github.com/grovety/crowpanel_openweather/blob/main/sources/CMakeLists.txt"
    click Kconfig "https://github.com/grovety/crowpanel_openweather/blob/main/sources/Kconfig.projbuild"
    click ComponentYML "https://github.com/grovety/crowpanel_openweather/blob/main/sources/idf_component.yml"
    click Main "https://github.com/grovety/crowpanel_openweather/blob/main/sources/main.cpp"
    click LVGLPort "https://github.com/grovety/crowpanel_openweather/blob/main/sources/adapters/lvgl/lvgl_port_v8.cpp"
    click HTTPAdapter "https://github.com/grovety/crowpanel_openweather/blob/main/sources/adapters/HTTPRequest.h"
    click WeatherScreen "https://github.com/grovety/crowpanel_openweather/blob/main/sources/entities/weather_screen/WeatherScreen.h"
    click WifiScreen "https://github.com/grovety/crowpanel_openweather/blob/main/sources/entities/wifi_screen/WifiScreen.h"
    click AccessPointsUpdate "https://github.com/grovety/crowpanel_openweather/blob/main/sources/usecases/AccessPointsUpdate.h"
    click Images "https://github.com/grovety/crowpanel_openweather/tree/main/sources/images"
    click SNTPClient "https://github.com/grovety/crowpanel_openweather/blob/main/sources/adapters/HTTPRequest.h"

    %% Styles
    classDef hardware fill:#cccccc,stroke:#333,stroke-width:1px
    classDef adapter fill:#b7e4c7,stroke:#2d6a4f,stroke-width:1px
    classDef usecase fill:#ffec99,stroke:#f08a5d,stroke-width:1px
    classDef entity fill:#fff3b0,stroke:#f08a5d,stroke-width:1px
    classDef ui fill:#a0c4ff,stroke:#4361ee,stroke-width:1px
    classDef external fill:#ade8f4,stroke:#1b4965,stroke-width:1px
    classDef asset fill:#d3bdef,stroke:#5a189a,stroke-width:1px
    classDef devops fill:#ffc9de,stroke:#9d0208,stroke-width:1px
    classDef entry fill:#ffafcc,stroke:#d00000,stroke-width:1px
```
