# impulseadventure/guislice architecture

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

- Interactive diagram: https://gitdiagram.com/impulseadventure/guislice
- Repository: https://github.com/impulseadventure/guislice

## Overview

Based on our analysis of the file tree and README, this project is the GUIslice library – a lightweight, pure-C GUI framework designed for embedded displays. It supports a wide range of target hardware (Arduino, ESP8266/ESP32, Raspberry Pi, etc.) and multiple graphics/touch drivers (Adafruit-GFX, TFT_eSPI, UTFT, SDL, etc.). It also comes with a drag & drop GUI builder application to help generate layouts, along with numerous example projects demonstrating its usage.

- GUI Builder Application: Represent the standalone, cross-platform desktop tool (found in the “builder” directory and “examples/builder”) that allows users to design GUIs via drag & drop.
- Core Library Module: This is the heart of GUIslice (located mostly in the “src” directory); include files like GUIslice.c, GUIslice.h, and supporting modules (e.g., GUIslice_config.h, GUIslice_th[.c/.h]) that implement core functionalities such as screen drawing, event handling, and resource management.
- Driver/Platform Layer: Identify the various driver implementations that abstract hardware specifics. These include:
- Graphics drivers (e.g., GUIslice_drv_adagfx.*, GUIslice_drv_m5stack.*, GUIslice_drv_tft_espi.*, GUIslice_drv_utft.*, GUIslice_drv_sdl.*)
- This layer is responsible for interfacing with the underlying display hardware or software emulation environments.
- Widgets/Elements Layer: Represent the various GUI elements available (found under “src/elem”), such as XCheckbox, XGauge, XGraph, XKeyPad, and more. They encapsulate the individual controls that can be composed into user interfaces.
- Configuration Repository: The “configs” directory holds numerous hardware-specific header files. This component ensures that the library can be configured for different display technologies, touch controllers, and board-specific settings.
- Examples & Documentation: Although supportive to the main architecture, include blocks representing the “examples” (for Arduino, Linux, M5stack, Wio, etc.) and “docs” directories. These illustrate how to integrate and test the framework in real-world scenarios.

##### Relationships and Data Flow
- That the GUI Builder outputs or generates layout/data (possibly configuration code) that is consumed by the Core Library during application runtime.
- External relationships for supported platforms: the abstraction provided in the “configs” directory feeds configuration data into both the Core Library and the Drivers.

##### Architectural Patterns and Design Principles
- Layered or Modular Architecture: Each tier (builder, core, drivers, widgets, configurations) is largely independent, allowing for reusability and easier management of platform-specific changes.
- Platform Abstraction: Emphasize that the driver layer abstracts away hardware/OS differences (e.g., Arduino vs. Linux using SDL) so that the same API can function across many targets.

##### Incorporate Relevant Technologies and Frameworks
- Mention the supported graphics/touch libraries (e.g., Adafruit-GFX, TFT_eSPI, UTFT, SDL1.2/2.0) either within the driver blocks or as a note.
- That the project is written in pure C (with some C++ in driver implementations for certain platforms such as M5stack) and that it avoids dynamic memory allocation – a design decision important for embedded systems.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Design Time Section
    subgraph "Design Time"
        GB["GUI Builder Application"]:::builder
    end

    %% Runtime Section
    subgraph "Runtime"
        CL["GUIslice Core Library"]:::core
        DR["Driver/Platform Layer"]:::driver
        WD["Widgets/Elements Layer"]:::widget
        CF["Configuration Repository"]:::config
        EX["Examples & Documentation"]:::example
    end

    %% Relationships
    GB -->|"generates_layout"| CL
    CF -->|"provides_config"| CL
    CF -->|"provides_config"| DR
    CL -->|"calls_drivers"| DR
    CL -->|"manages_widgets"| WD
    EX -->|"demonstrates_usage"| CL

    %% Click Events for GUI Builder Application
    click GB "https://github.com/impulseadventure/guislice/tree/master/builder/"
    click GB "https://github.com/impulseadventure/guislice/tree/master/examples/builder/"

    %% Click Events for Core Library Module
    click CL "https://github.com/impulseadventure/guislice/blob/master/src/GUIslice.c"
    click CL "https://github.com/impulseadventure/guislice/blob/master/src/GUIslice.h"
    click CL "https://github.com/impulseadventure/guislice/blob/master/src/GUIslice_config.h"
    click CL "https://github.com/impulseadventure/guislice/blob/master/src/GUIslice_th.cpp"
    click CL "https://github.com/impulseadventure/guislice/blob/master/src/GUIslice_th.h"

    %% Click Events for Driver/Platform Layer
    click DR "https://github.com/impulseadventure/guislice/blob/master/src/GUIslice_drv_adagfx.cpp"
    click DR "https://github.com/impulseadventure/guislice/blob/master/src/GUIslice_drv_adagfx.h"
    click DR "https://github.com/impulseadventure/guislice/blob/master/src/GUIslice_drv_m5stack.cpp"
    click DR "https://github.com/impulseadventure/guislice/blob/master/src/GUIslice_drv_m5stack.h"
    click DR "https://github.com/impulseadventure/guislice/blob/master/src/GUIslice_drv_sdl.c"
    click DR "https://github.com/impulseadventure/guislice/blob/master/src/GUIslice_drv_sdl.h"
    click DR "https://github.com/impulseadventure/guislice/blob/master/src/GUIslice_drv_tft_espi.cpp"
    click DR "https://github.com/impulseadventure/guislice/blob/master/src/GUIslice_drv_tft_espi.h"
    click DR "https://github.com/impulseadventure/guislice/blob/master/src/GUIslice_drv_utft.cpp"
    click DR "https://github.com/impulseadventure/guislice/blob/master/src/GUIslice_drv_utft.h"

    %% Click Event for Widgets/Elements Layer
    click WD "https://github.com/impulseadventure/guislice/tree/master/src/elem/"

    %% Click Event for Configuration Repository
    click CF "https://github.com/impulseadventure/guislice/tree/master/configs/"

    %% Click Events for Examples & Documentation
    click EX "https://github.com/impulseadventure/guislice/tree/master/examples/"
    click EX "https://github.com/impulseadventure/guislice/tree/master/docs/"

    %% Style Definitions
    classDef builder fill:#ADD8E6,stroke:#0000FF,stroke-width:2px;
    classDef core fill:#90EE90,stroke:#008000,stroke-width:2px;
    classDef driver fill:#DDA0DD,stroke:#800080,stroke-width:2px;
    classDef widget fill:#FFD700,stroke:#DAA520,stroke-width:2px;
    classDef config fill:#FFFFE0,stroke:#CCCC00,stroke-width:2px;
    classDef example fill:#F5F5F5,stroke:#808080,stroke-width:2px;
```
