# socketteer/loom architecture

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

- Interactive diagram: https://gitdiagram.com/socketteer/loom
- Repository: https://github.com/socketteer/loom

## Overview

Main Components to Include:

##### User Interface Layer (View)
- Using a large container at the top
- Sub-components:
- Read Mode View
- Tree View
- Block Multiverse Interface
- Dialog Systems

##### Controller Layer
- Event handling and user interaction flow
- To both View and Model layers

##### Model Layer
- At the bottom
- Components:
- Tree Data Structure
- Node Management
- State Management

##### External Services
- On the right side
- Include:
- OpenAI GPT-3 API
- AI21 API
- GooseAI API
- Local LLama.cpp Integration

##### Utility Layer
- On the left side
- Utilities by function:
- File Operations
- Canvas Utilities
- Text Processing
- Keybindings

##### Connection Types
- Double lines: API communications

##### Component Organization

**[Static Resources] -----> [View Layer]**

**[Utilities] ------------> [Controller] <-----> [External Services]**

- [Model Layer]

- [File Storage]

##### Detailed Component Breakdown

View Layer:
- .py
- panes.py
- tree_vis.py
- styles.py

Controller Layer:
- controller.py
- keybindings
- dialog management

Model Layer:
- model.py
- block_multiverse.py
- modules.py

Utilities:
- file_utils.py
- canvas_util.py
- gpt_util.py
- tokenizer.py

##### Additional Elements
- Version/environment information
- Configuration flow from config/ directory
- Error handling paths

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["User Interface Layer"]
        RMV["Read Mode View"]:::ui
        TV["Tree View"]:::ui
        BMI["Block Multiverse Interface"]:::ui
        DS["Dialog Systems"]:::ui
        SR["Static Resources"]:::ui
    end

    subgraph CL["Controller Layer"]
        CTRL["Controller"]:::controller
        KB["Keybindings"]:::controller
        DM["Dialog Management"]:::controller
    end

    subgraph ML["Model Layer"]
        MDL["Model"]:::model
        BM["Block Multiverse"]:::model
        MOD["Modules"]:::model
        TD["Tree Data Structure"]:::model
    end

    subgraph ES["External Services"]
        GPT["OpenAI GPT-3"]:::external
        AI21["AI21"]:::external
        GA["GooseAI"]:::external
        LLAMA["Local LLama.cpp"]:::external
    end

    subgraph UT["Utility Layer"]
        FO["File Operations"]:::utility
        CU["Canvas Utilities"]:::utility
        TP["Text Processing"]:::utility
        TU["Tree Utilities"]:::utility
    end

    subgraph CF["Configuration"]
        GP["Generation Presets"]:::config
        IF["Interfaces"]:::config
        PR["Prompts"]:::config
        TR["Transformers"]:::config
    end

    %% Connections
    UI --> CL
    CL --> ML
    CL <--> ES
    UT --> CL
    CF --> CL
    SR --> UI

    %% Styling
    classDef ui fill:#a8d1f0
    classDef controller fill:#90EE90
    classDef model fill:#FFE5B4
    classDef external fill:#DDA0DD
    classDef utility fill:#D3D3D3
    classDef config fill:#F0E68C

    %% Click events
    click RMV "https://github.com/socketteer/loom/blob/main/view/display.py"
    click TV "https://github.com/socketteer/loom/blob/main/view/tree_vis.py"
    click BMI "https://github.com/socketteer/loom/blob/main/components/block_multiverse.py"
    click DS "https://github.com/socketteer/loom/blob/main/components/dialogs.py"
    click SR "https://github.com/socketteer/loom/tree/main/static/icons"
    click CTRL "https://github.com/socketteer/loom/blob/main/controller.py"
    click KB "https://github.com/socketteer/loom/blob/main/util/keybindings.py"
    click MDL "https://github.com/socketteer/loom/blob/main/model.py"
    click BM "https://github.com/socketteer/loom/blob/main/components/block_multiverse.py"
    click MOD "https://github.com/socketteer/loom/blob/main/components/modules.py"
    click GPT "https://github.com/socketteer/loom/blob/main/gpt.py"
    click FO "https://github.com/socketteer/loom/blob/main/util/file_utils.py"
    click CU "https://github.com/socketteer/loom/blob/main/util/canvas_util.py"
    click TP "https://github.com/socketteer/loom/blob/main/util/tokenizer.py"
    click TU "https://github.com/socketteer/loom/blob/main/util/util_tree.py"
    click GP "https://github.com/socketteer/loom/tree/main/config/generation_presets"
    click IF "https://github.com/socketteer/loom/tree/main/config/interfaces"
    click PR "https://github.com/socketteer/loom/tree/main/config/prompts"
    click TR "https://github.com/socketteer/loom/tree/main/config/transformers"
```
