# shirakumo/alloy architecture

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

- Interactive diagram: https://gitdiagram.com/shirakumo/alloy
- Repository: https://github.com/shirakumo/alloy

## Overview

##### Main Components Overview

a) Core Protocol Layer (Bottom)
- Units & Geometry
- Elements & Containers
- Events System
- Focus Management
- Layout System
- Observable System
- Data Protocol
- Component Protocol
- Renderer Protocol
- UI Protocol

b) Implementation Layer (Middle)
- Standard Components (buttons, combos, sliders, etc.)
- Layout Implementations (border, grid, linear, etc.)
- Focus Chain Implementations
- Data Representations
- Structure Implementations (windows, queries, etc.)

c) Renderer Layer (Top)
- OpenGL Renderer
- GLFW Integration
- Simple Renderer
- SVG Renderer
- Windowing System

##### Component Relationships

- Blue: Core protocols
- Green: Standard implementations
- Orange: Rendering systems
- Purple: External integrations
- Gray: Support systems

##### Detailed Elements

For each major component, include:
- Required methods
- Key interfaces
- Main responsibilities

- Available concrete implementations
- Key features
- Integration points

##### Integration Points

Highlight:
- Renderer integration points
- Windowing system connections
- Component extension mechanisms
- Data binding system

##### Flow Representations

Flows for:
- Event handling
- Layout computation
- Focus management
- Rendering pipeline
- Data binding

##### Event and focus propagation paths

Keep the abstraction level high enough to show the overall architecture while including enough detail to understand the relationships between different protocols and implementations.

Remember to include notes about the project's current design phase status and potential for change, as mentioned in the README.

- Implement new renderers
- Custom components
- Integrate with existing systems
- Extend the protocol system
- Understand the flow of operations

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Core Protocol Layer"
        direction TB
        Units["Units & Geometry"]:::core
        Container["Container System"]:::core
        Events["Events System"]:::core
        Focus["Focus Management"]:::core
        Layout["Layout System"]:::core
        Observable["Observable System"]:::core
        CompProto["Component Protocol"]:::core
        RenderProto["Renderer Protocol"]:::core
        UIProto["UI Protocol"]:::core
    end

    subgraph "Implementation Layer"
        direction TB
        subgraph "Standard Components"
            BaseComp["Base Components"]:::impl
            Button["Button"]:::impl
            Slider["Slider"]:::impl
            Combo["Combo"]:::impl
            TextInput["Text Input"]:::impl
        end

        subgraph "Layout Implementations"
            GridLayout["Grid Layout"]:::impl
            BorderLayout["Border Layout"]:::impl
            LinearLayout["Linear Layout"]:::impl
            ConstraintLayout["Constraint Layout"]:::impl
        end

        subgraph "Structure Implementations"
            Windows["Windows"]:::impl
            Dialogs["Dialogs"]:::impl
            Menus["Menus"]:::impl
            Queries["Query Interface"]:::impl
        end

        subgraph "Animation System"
            Animation["Core Animation"]:::impl
            Easing["Easing Functions"]:::impl
            Interpolation["Interpolation"]:::impl
        end
    end

    subgraph "Renderer Layer"
        OpenGL["OpenGL Renderer"]:::renderer
        GLFW["GLFW Integration"]:::renderer
        Simple["Simple Renderer"]:::renderer
        Framebuffer["Framebuffer Renderer"]:::renderer
    end

    %% Core Protocol Relationships
    Units --> Container
    Container --> Events
    Events --> Focus
    Focus --> Layout
    Observable --> CompProto
    CompProto --> RenderProto
    RenderProto --> UIProto

    %% Implementation Dependencies
    BaseComp -.-> CompProto
    Button & Slider & Combo & TextInput -.-> BaseComp
    GridLayout & BorderLayout & LinearLayout & ConstraintLayout -.-> Layout
    Windows & Dialogs & Menus & Queries -.-> UIProto
    Animation --> Observable
    Easing & Interpolation --> Animation

    %% Renderer Implementation
    OpenGL & GLFW & Simple & Framebuffer -.-> RenderProto

    %% Click Events
    click Units "https://github.com/shirakumo/alloy/blob/master//units.lisp"
    click Container "https://github.com/shirakumo/alloy/blob/master//container.lisp"
    click Events "https://github.com/shirakumo/alloy/blob/master//events.lisp"
    click Focus "https://github.com/shirakumo/alloy/blob/master//focus-tree.lisp"
    click Layout "https://github.com/shirakumo/alloy/blob/master//layout.lisp"
    click Observable "https://github.com/shirakumo/alloy/blob/master//observable.lisp"
    click CompProto "https://github.com/shirakumo/alloy/blob/master//component.lisp"
    click RenderProto "https://github.com/shirakumo/alloy/blob/master//renderer.lisp"
    click UIProto "https://github.com/shirakumo/alloy/blob/master//ui.lisp"
    click BaseComp "https://github.com/shirakumo/alloy/blob/master//components/base.lisp"
    click Button "https://github.com/shirakumo/alloy/blob/master//components/button.lisp"
    click Slider "https://github.com/shirakumo/alloy/blob/master//components/slider.lisp"
    click Combo "https://github.com/shirakumo/alloy/blob/master//components/combo.lisp"
    click TextInput "https://github.com/shirakumo/alloy/blob/master//components/text-input.lisp"
    click GridLayout "https://github.com/shirakumo/alloy/blob/master//layouts/grid.lisp"
    click BorderLayout "https://github.com/shirakumo/alloy/blob/master//layouts/border.lisp"
    click LinearLayout "https://github.com/shirakumo/alloy/blob/master//layouts/linear.lisp"
    click ConstraintLayout "https://github.com/shirakumo/alloy/tree/master//layouts/constraint"
    click Windows "https://github.com/shirakumo/alloy/blob/master//structures/window.lisp"
    click Dialogs "https://github.com/shirakumo/alloy/blob/master//structures/dialog.lisp"
    click Menus "https://github.com/shirakumo/alloy/blob/master//structures/menu.lisp"
    click Queries "https://github.com/shirakumo/alloy/blob/master//structures/query.lisp"
    click Animation "https://github.com/shirakumo/alloy/blob/master//animation/animation.lisp"
    click Easing "https://github.com/shirakumo/alloy/blob/master//animation/easing.lisp"
    click Interpolation "https://github.com/shirakumo/alloy/blob/master//animation/lerp.lisp"
    click OpenGL "https://github.com/shirakumo/alloy/tree/master//renderers/opengl"
    click GLFW "https://github.com/shirakumo/alloy/tree/master//renderers/glfw"
    click Simple "https://github.com/shirakumo/alloy/tree/master//renderers/simple"
    click Framebuffer "https://github.com/shirakumo/alloy/tree/master//renderers/framebuffers"

    %% Styling
    classDef core fill:#a8dadc,stroke:#457b9d
    classDef impl fill:#e9c46a,stroke:#f4a261
    classDef renderer fill:#2a9d8f,stroke:#264653
    
    %% Legend
    subgraph Legend
        L1["Core Protocol"]:::core
        L2["Implementation"]:::impl
        L3["Renderer"]:::renderer
        L4[" "] -.- L5[" "]
        L6[" "] --> L7[" "]
    end
```
