# preet/raintk architecture

> Architecture diagram of the GitHub repository preet/raintk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/preet/raintk
- Repository: https://github.com/preet/raintk

## Overview

##### Main Components

a) Core Systems Layer:
- Animation System (RainTkAnimationSystem)
- Input System (RainTkInputSystem)
- Transform System (RainTkTransformSystem)

b) Widget Layer:
- Base Widget Components
- Specialized Widgets (Text, Rectangle, Image, etc.)
- Layout Components (Grid, Row, Column)
- Input Components (MouseArea, InputArea)

c) Resource Management:
- Image Atlas System
- Shader Management
- Font Resource Handling

**┌─────────────────────────────────────────────┐**
- Application Layer              │
- ┤
- Widget Layer                  │
- ┤
- Core Systems                   │
- ┤
- External Dependencies            │
- ┘

##### Key Elements to Highlight

a) Core Systems Interactions:
- How InputSystem propagates events through the widget hierarchy
- AnimationSystem's connection to property updates
- Demonstrate TransformSystem's effect on widget positioning

b) Widget Hierarchy:
- Inheritance from RainTkWidget base class
- Demonstrate composition patterns (e.g., how ScrollArea contains ScrollBar)
- Layout management relationships

c) Property Binding System:
- Reactive update mechanism
- Property dependency chains

##### Specific Implementation Details

Key architectural features:
- Scene Management (RainTkScene)
- Drawing Pipeline (MainDrawStage)
- Input Handling Chain
- Property Update System

##### Connection Points

Clear interfaces between:
- Widget-to-System interactions
- Input propagation paths
- Resource loading and management
- Property binding mechanisms

##### External Dependencies

Ks framework components:
- ks::core
- ks::shared
- ks::platform
- ks::gui
- ks::ecs
- ks::gl
- ks::text

- Component relationships
- System boundaries

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Dependencies Layer
    subgraph Dependencies
        KS_CORE["ks::core"]:::external
        KS_SHARED["ks::shared"]:::external
        KS_PLATFORM["ks::platform"]:::external
        KS_GUI["ks::gui"]:::external
        KS_ECS["ks::ecs"]:::external
        KS_GL["ks::gl"]:::external
        KS_DRAW["ks::draw"]:::external
        KS_TEXT["ks::text"]:::external
    end

    %% Core Systems Layer
    subgraph CoreSystems
        DrawSystem["Draw System"]:::core
        AnimSystem["Animation System"]:::core
        InputSystem["Input System"]:::core
        TransformSystem["Transform System"]:::core
        PropSystem["Property System"]:::core
        Scene["Scene Manager"]:::core
        MainDrawStage["Main Draw Stage"]:::core
    end

    %% Resource Management Layer
    subgraph Resources
        ImageAtlas["Image Atlas"]:::resource
        AtlasImage["Atlas Image"]:::resource
        ShaderMgmt["Shader Management"]:::resource
    end

    %% Widget Base Layer
    subgraph WidgetBase
        BaseWidget["Base Widget"]:::widget
        DrawableWidget["Drawable Widget"]:::widget
    end

    %% Specialized Widgets Layer
    subgraph Widgets
        TextWidget["Text Widget"]:::widget
        RectWidget["Rectangle Widget"]:::widget
        ImageWidget["Image Widget"]:::widget
        TextInputWidget["Text Input Widget"]:::widget
    end

    %% Layout Components Layer
    subgraph Layout
        GridLayout["Grid Layout"]:::layout
        RowLayout["Row Layout"]:::layout
        ColLayout["Column Layout"]:::layout
    end

    %% Input Components Layer
    subgraph Input
        MouseArea["Mouse Area"]:::input
        InputArea["Input Area"]:::input
        InputListener["Input Listener"]:::input
    end

    %% Container Components Layer
    subgraph Containers
        ScrollArea["Scroll Area"]:::container
        ScrollBar["Scroll Bar"]:::container
        ListView["List View"]:::container
    end

    %% Relationships
    DrawSystem --> BaseWidget
    AnimSystem --> PropSystem
    InputSystem --> InputListener
    TransformSystem --> BaseWidget
    BaseWidget --> DrawableWidget
    DrawableWidget --> Widgets
    PropSystem --> BaseWidget
    Scene --> MainDrawStage
    ImageAtlas --> AtlasImage
    ImageAtlas --> DrawSystem

    %% Component Mappings
    click DrawSystem "https://github.com/preet/raintk/blob/master/raintk/RainTkDrawSystem.hpp"
    click AnimSystem "https://github.com/preet/raintk/blob/master/raintk/RainTkAnimationSystem.hpp"
    click InputSystem "https://github.com/preet/raintk/blob/master/raintk/RainTkInputSystem.hpp"
    click TransformSystem "https://github.com/preet/raintk/blob/master/raintk/RainTkTransformSystem.hpp"
    click BaseWidget "https://github.com/preet/raintk/blob/master/raintk/RainTkWidget.hpp"
    click DrawableWidget "https://github.com/preet/raintk/blob/master/raintk/RainTkDrawableWidget.hpp"
    click TextWidget "https://github.com/preet/raintk/blob/master/raintk/RainTkText.hpp"
    click RectWidget "https://github.com/preet/raintk/blob/master/raintk/RainTkRectangle.hpp"
    click ImageWidget "https://github.com/preet/raintk/blob/master/raintk/RainTkImage.hpp"
    click TextInputWidget "https://github.com/preet/raintk/blob/master/raintk/RainTkTextInput.hpp"
    click GridLayout "https://github.com/preet/raintk/blob/master/raintk/RainTkGrid.hpp"
    click RowLayout "https://github.com/preet/raintk/blob/master/raintk/RainTkRow.hpp"
    click ColLayout "https://github.com/preet/raintk/blob/master/raintk/RainTkColumn.hpp"
    click MouseArea "https://github.com/preet/raintk/blob/master/raintk/RainTkMouseArea.hpp"
    click InputArea "https://github.com/preet/raintk/blob/master/raintk/RainTkInputArea.hpp"
    click InputListener "https://github.com/preet/raintk/blob/master/raintk/RainTkInputListener.hpp"
    click ImageAtlas "https://github.com/preet/raintk/blob/master/raintk/RainTkImageAtlas.hpp"
    click AtlasImage "https://github.com/preet/raintk/blob/master/raintk/RainTkAtlasImage.hpp"
    click ShaderMgmt "https://github.com/preet/raintk/tree/master/raintk/shaders/"
    click Scene "https://github.com/preet/raintk/blob/master/raintk/RainTkScene.hpp"
    click MainDrawStage "https://github.com/preet/raintk/blob/master/raintk/RainTkMainDrawStage.hpp"
    click PropSystem "https://github.com/preet/raintk/blob/master/raintk/RainTkProperty.hpp"
    click ScrollArea "https://github.com/preet/raintk/blob/master/raintk/RainTkScrollArea.hpp"
    click ScrollBar "https://github.com/preet/raintk/blob/master/raintk/RainTkScrollBar.hpp"
    click ListView "https://github.com/preet/raintk/blob/master/raintk/RainTkListView.hpp"

    %% Styles
    classDef external fill:#gray,stroke:#333,stroke-width:2px
    classDef core fill:#blue,stroke:#333,stroke-width:2px
    classDef resource fill:#yellow,stroke:#333,stroke-width:2px
    classDef widget fill:#green,stroke:#333,stroke-width:2px
    classDef layout fill:#lightgreen,stroke:#333,stroke-width:2px
    classDef input fill:#purple,stroke:#333,stroke-width:2px
    classDef container fill:#orange,stroke:#333,stroke-width:2px
```
