# christianharris-3/pyui architecture

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

- Interactive diagram: https://gitdiagram.com/christianharris-3/pyui
- Repository: https://github.com/christianharris-3/pyui

## Overview

##### Main Components
- Pygame Application Layer:
– Represent the main application or game loop (e.g. “basic start” script and pyuitesting) that sets up pygame, creates a display, and uses PyUI for rendering.
- PyUI Core (UI Class):
– Represent the central UI object (the “pyui.UI()” instance) that is instantiated by the user. This acts as the controller that maintains state, binds all GUI objects, and exposes the event handling (via loadtickdata) and rendering functions (via rendergui).
- GUI Object Factory and Components:
– List out the different GUI elements that can be created by the UI object. Create blocks for “Buttons,” “Checkboxes,” “Labels/Text,” “Textboxes,” “Tables (including scroller tables),” “Sliders/Scrollers,” “Windowed Menus/Windows,” and even “Composite Objects” (like Search Bar and DropDown).
- Style & Configuration System:
- In-built Image System:
- Utility Functions:

##### Depicting Relationships & Data Flow
- “Style & Configuration System” with the “PyUI Core” and “GUI Components” to indicate that styling information is propagated automatically (or via functions like ui.setstyle) to modify the appearance of each component.
- Link the “In-built Image System” with the “GUI Components” (particularly text objects and buttons) to illustrate that image rendering (both vector and manually drawn) is integrated into GUI objects.

##### Architectural Patterns and Design Details
- That the PyUI module employs a factory-like design where the UI object creates various GUI components.
- There is a separation of concerns: the module encapsulates GUI object creation, event handling, rendering, and styling into logically separate parts.
- The design supports extensibility—evidenced by having many configurable variables through its style system and the ability to add custom events or new GUI component types.

##### Technologies, Frameworks, and Libraries
- Explicitly mention pygame as the rendering backend and event manager used for all display and input processing.
- That while GitHub Actions (in .github/workflows) take care of automation and publishing, the core focus is on runtime behavior and visual GUI component management.

##### Essential Elements
- Clear labels and names for each node/component.
- Sub-blocks within the PyUI Core for “GUI Object Creation,” “Event Handling,” and “Style Updates” so that the responsibilities are clearly partitioned.
- Mention versioning components: note that older versions (contained in the “old PyUI versions” folder) exist but are separated from the current maintained core.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Pygame Application Layer
    subgraph "Pygame Application Layer"
        A1("Pygame Application (Basic Start & Testing)"):::application
        A2("Pygame Display"):::application
    end

    %% UI/GUI Layer
    subgraph "UI/GUI Layer"
        UI("UI Core (pyui.UI)"):::ui
        UI -->|"handles"| UI1("Event Handling"):::ui
        UI -->|"creates"| UI2("GUI Object Creation"):::ui
        UI -->|"renders"| UI3("Rendering"):::ui

        subgraph "GUI Object Components"
            B1("Buttons"):::ui
            B2("Checkboxes"):::ui
            B3("Labels/Text"):::ui
            B4("Textboxes"):::ui
            B5("Tables/Scroller Tables"):::ui
            B6("Sliders/Scrollers"):::ui
            B7("Windowed Menus/Windows"):::ui
            B8("Composite Objects (SearchBar, DropDown)"):::ui
        end
    end

    %% Utility Layer
    subgraph "Utility Layer"
        S("Style & Configuration System"):::util
        I("In‐built Image System"):::util
        U("Utility Functions (Color/Collision)"):::util
        O("Old PyUI Versions"):::util
    end

    %% Relationships between Layers
    A1 -->|"instantiates"| UI
    A1 -->|"sendsEvents(loadtickdata)"| UI
    UI -->|"updatesDisplay(rendergui)"| A2

    %% UI Core and GUI Components interactions
    UI -->|"creates"| B1
    UI -->|"creates"| B2
    UI -->|"creates"| B3
    UI -->|"creates"| B4
    UI -->|"creates"| B5
    UI -->|"creates"| B6
    UI -->|"creates"| B7
    UI -->|"creates"| B8

    %% UI Core connections with Utility Layer
    UI -->|"appliesStyle"| S
    UI -->|"integratesImages"| I
    UI -->|"callsUtilities"| U

    %% Additional connection: Utility system used by GUI Components
    S -->|"styles"| B1
    S -->|"styles"| B2
    S -->|"styles"| B3
    S -->|"styles"| B4
    S -->|"styles"| B5
    S -->|"styles"| B6
    S -->|"styles"| B7
    S -->|"styles"| B8

    %% Old versions separated from current core
    O -.->|"legacy"| UI

    %% Click Events
    click A1 "https://github.com/christianharris-3/pyui/blob/master/_basic start_.py"
    click A1 "https://github.com/christianharris-3/pyui/blob/master/pyuitesting.py"
    click UI "https://github.com/christianharris-3/pyui/blob/master/PyUI.py"
    click S "https://github.com/christianharris-3/pyui/blob/master/PyUI.py"
    click U "https://github.com/christianharris-3/pyui/blob/master/PyUI.py"
    click I "https://github.com/christianharris-3/pyui/blob/master/PyUI vector maker.py"

    %% Styles
    classDef application fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef ui fill:#A9DFBF,stroke:#145A32,stroke-width:2px;
    classDef util fill:#F9E79F,stroke:#9A7D0A,stroke-width:2px;
```
