# sunnyyssh/consoleui architecture

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

- Interactive diagram: https://gitdiagram.com/sunnyyssh/consoleui
- Repository: https://github.com/sunnyyssh/consoleui

## Overview

##### Main Components

a. Core Layer:
- Application Management System
- Drawing System
- Focus Flow Management
- UIElement Base System
- Exception Handling System

b. UI Elements Layer:
- Basic Elements (TextBlock, Button, Rectangle, etc.)
- Container Elements (Grid, StackPanel, Canvas)
- Interactive Elements (TextBox, OptionChooser)
- Composite Elements (Border, LineComposition)

c. Supporting Systems:
- Binding System
- Event Handling System
- Drawing Pipeline

**[Application Layer]**
- ↑↓
**[Core Services Layer]**
- ↑↓
**[UI Elements Layer]**
- ↑↓
**[Console System]**

##### Component Relationships

a. Core Services Layer should show:
- DrawState → DrawerPal → Console interaction
- FocusFlowManager → KeyListener interaction
- Application → UIElement hierarchy management

b. UI Elements Layer should show:
- Inheritance hierarchy (UIElement as base)
- Composition relationships (Wrapper-based elements)
- Interface implementations (IFocusable, IBindable)

##### Specific Implementation Details

**Application Builder**
- ↓
**Application**
- ↓
**UIElement Hierarchy**
- ↓
**Drawing System → DrawState → Console**
- ↑
**Focus Management System**

##### Important Architectural Patterns to Highlight

- Builder Pattern (ApplicationBuilder, UIElementBuilder)
- Composite Pattern (Wrapper-based elements)
- Observer Pattern (Binding system)
- Chain of Responsibility (Focus flow)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Application Layer"
        AppBuilder[Application Builder]
        App[Application]
    end

    subgraph "Core Services Layer"
        DrawSystem[Drawing System]:::core
        FocusSystem[Focus Flow Management]:::core
        UIBase[UIElement Base System]:::core
        ExceptionSystem[Exception Handling]:::core
        DrawPipeline[Drawing Pipeline]:::core
        EventSystem[Event Handling System]:::core
    end

    subgraph "UI Elements Layer"
        subgraph "Basic Elements"
            TextBlock[TextBlock]:::ui
            Button[Button]:::ui
            Rectangle[Rectangle]:::ui
        end

        subgraph "Container Elements"
            Grid[Grid]:::container
            StackPanel[StackPanel]:::container
            Canvas[Canvas]:::container
        end

        subgraph "Interactive Elements"
            TextBox[TextBox]:::interactive
            OptionChooser[OptionChooser]:::interactive
        end

        subgraph "Composite Elements"
            Border[Border]:::composite
            LineComp[LineComposition]:::composite
        end

        BindingSystem[Binding System]:::support
    end

    subgraph "Console System"
        ConsoleOut[Console Output]
        ConsoleIn[Console Input]
    end

    %% Relationships
    AppBuilder --> App
    App --> UIBase
    UIBase --> DrawSystem
    DrawSystem --> DrawPipeline
    DrawPipeline --> ConsoleOut
    ConsoleIn --> FocusSystem
    FocusSystem --> UIBase
    EventSystem --> UIBase
    BindingSystem --> UIBase

    %% UI Element Relationships
    UIBase --> TextBlock
    UIBase --> Button
    UIBase --> Rectangle
    UIBase --> Grid
    UIBase --> StackPanel
    UIBase --> Canvas
    UIBase --> TextBox
    UIBase --> OptionChooser
    UIBase --> Border
    UIBase --> LineComp

    %% Click Events
    click DrawSystem "https://github.com/sunnyyssh/ConsoleUI/tree/master/src/Core/Draw/"
    click FocusSystem "https://github.com/sunnyyssh/ConsoleUI/tree/master/src/Core/FocusFlow/"
    click UIBase "https://github.com/sunnyyssh/ConsoleUI/tree/master/src/Core/UIElement/"
    click ExceptionSystem "https://github.com/sunnyyssh/ConsoleUI/tree/master/src/Core/Exceptions/"
    click DrawPipeline "https://github.com/sunnyyssh/ConsoleUI/tree/master/src/Core/Draw/Internal/"
    click EventSystem "https://github.com/sunnyyssh/ConsoleUI/tree/master/src/UIElements/Handlers/"
    click TextBlock "https://github.com/sunnyyssh/ConsoleUI/tree/master/src/UIElements/TextBlock/"
    click Button "https://github.com/sunnyyssh/ConsoleUI/tree/master/src/UIElements/Button/"
    click Rectangle "https://github.com/sunnyyssh/ConsoleUI/tree/master/src/UIElements/Geometry/Rectangle/"
    click Grid "https://github.com/sunnyyssh/ConsoleUI/tree/master/src/UIElements/Wrappers/Grid/"
    click StackPanel "https://github.com/sunnyyssh/ConsoleUI/tree/master/src/UIElements/Wrappers/StackPanel/"
    click Canvas "https://github.com/sunnyyssh/ConsoleUI/tree/master/src/UIElements/Wrappers/Canvas/"
    click TextBox "https://github.com/sunnyyssh/ConsoleUI/tree/master/src/UIElements/TextBox/"
    click OptionChooser "https://github.com/sunnyyssh/ConsoleUI/tree/master/src/UIElements/OptionChooser/"
    click Border "https://github.com/sunnyyssh/ConsoleUI/tree/master/src/UIElements/Borders/"
    click LineComp "https://github.com/sunnyyssh/ConsoleUI/tree/master/src/UIElements/Geometry/Line/"
    click BindingSystem "https://github.com/sunnyyssh/ConsoleUI/tree/master/src/UIElements/Binding/"

    %% Styles
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef ui fill:#4CAF50,stroke:#2E7D32,color:white
    classDef container fill:#FF9800,stroke:#EF6C00,color:white
    classDef interactive fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef composite fill:#F44336,stroke:#C62828,color:white
    classDef support fill:#607D8B,stroke:#37474F,color:white

    %% Legend
    subgraph Legend
        CoreL[Core Services]:::core
        UIL[Basic UI]:::ui
        ContainerL[Containers]:::container
        InteractiveL[Interactive]:::interactive
        CompositeL[Composite]:::composite
        SupportL[Support Systems]:::support
    end
```
