# thesherwood/mentat architecture

> Architecture diagram of the GitHub repository thesherwood/mentat, 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/thesherwood/mentat
- Repository: https://github.com/thesherwood/mentat

## Overview

##### Main Components

a. Core Components:
- TiddlyWiki Base System (foundation layer)
- Plugin Management System
- UI/UX Layer

b. Plugin Hierarchy (from most basic to most complex):
##### Mentat Plugin (builds on all previous plugins)

**┌─────────────────────────────────────────────┐**
- Mentat                     │
- (Window Management & Workspace Organization) │
- ┤
- Engine                     │
- (Customizable HUD Console)           │
- ┤
- Volant                     │
- (Draggable & Resizable Tiddlers)      │
- ┤
- Repopup                     │
- (Popup Positioning System)          │
- ┤
- TiddlyWiki Core               │
- ┘

##### Component Details

For each plugin component, show:

a. Repopup Plugin:
- Popup management system
- Screen boundary detection
- Popup repositioning logic

b. Volant Plugin:
- Drag & resize functionality
- Tag-based activation ($:/Volant, $:/VolantAbsolute)
- Volant-Rapid extension for quick resizing

c. Engine Plugin:
- HUD console system
- Tool management
- Tiddler swapping mechanism

d. Mentat Plugin:
- Workspace management
- Window archiving system
- Layout management
- Session handling

##### Data Flow Indicators

- Plugin dependencies (bottom-up)
- User interaction flows
- Event propagation
- State management

##### Integration Points

Highlight:
- Plugin interaction points
- TiddlyWiki core integration
- Event handling system
- Template override points

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        L1[Component]:::component
        L2[(Database)]:::database
        L3([Service]):::service
        L4>"User Interface"]:::ui
        L5{{"Configuration"}}:::config
        L6[[Plugin]]:::plugin
    end

    subgraph TW["TiddlyWiki Core Layer"]
        Core[TiddlyWiki Base System]:::core
    end

    subgraph RP["Repopup Plugin Layer"]
        Repopup[[Repopup Plugin]]:::plugin
        click Repopup "https://github.com/theSherwood/Mentat/tree/master/src/tiddlers/system/plugins/admls/repopup/"
        RepopupLogic([Popup Management]):::service
        click RepopupLogic "https://github.com/theSherwood/Mentat/blob/master/src/tiddlers/system/plugins/admls/repopup/startup/repopup.js"
        RepopupDocs[Documentation]:::component
        click RepopupDocs "https://github.com/theSherwood/Mentat/blob/master/src/tiddlers/system/plugins/admls/repopup/readme.tid"
    end

    subgraph VOL["Volant Plugin Layer"]
        Volant[[Volant Plugin]]:::plugin
        click Volant "https://github.com/theSherwood/Mentat/tree/master/src/tiddlers/system/plugins/admls/volant/"
        VolantLogic([Drag & Resize System]):::service
        click VolantLogic "https://github.com/theSherwood/Mentat/blob/master/src/tiddlers/system/plugins/admls/volant/globals/volant.js"
        VolantConfig{{"Volant Configuration"}}:::config
        click VolantConfig "https://github.com/theSherwood/Mentat/tree/master/src/tiddlers/system/config/Volant/"
        VolantWidget([Widget Handler]):::service
        click VolantWidget "https://github.com/theSherwood/Mentat/blob/master/src/tiddlers/system/plugins/admls/volant/widgets/volant.js"
        VolantState[(State Management)]:::database
        click VolantState "https://github.com/theSherwood/Mentat/tree/master/src/tiddlers/system/config/Volant/$_/state/"
    end

    subgraph ENG["Engine Plugin Layer"]
        Engine[[Engine Plugin]]:::plugin
        click Engine "https://github.com/theSherwood/Mentat/tree/master/src/tiddlers/system/plugins/admls/engine/"
        EngineConfig{{"Engine Configuration"}}:::config
        click EngineConfig "https://github.com/theSherwood/Mentat/tree/master/src/tiddlers/system/config/Engine/"
        EngineUI>"UI Components"]:::ui
        click EngineUI "https://github.com/theSherwood/Mentat/tree/master/src/tiddlers/system/plugins/admls/engine/ui/"
        EngineTemplates[Templates]:::component
        click EngineTemplates "https://github.com/theSherwood/Mentat/tree/master/src/tiddlers/system/plugins/admls/engine/templates/"
    end

    subgraph MEN["Mentat Plugin Layer"]
        Mentat[[Mentat Plugin]]:::plugin
        click Mentat "https://github.com/theSherwood/Mentat/tree/master/src/tiddlers/system/plugins/admls/mentat/"
        MentatLogic([Core Logic]):::service
        click MentatLogic "https://github.com/theSherwood/Mentat/blob/master/src/tiddlers/system/plugins/admls/mentat/globals/mentat.js"
        WindowMgmt([Window Management]):::service
        click WindowMgmt "https://github.com/theSherwood/Mentat/tree/master/src/tiddlers/system/plugins/admls/mentat/templates/WindowViewTemplate/"
        LayoutMgmt{{"Layout Management"}}:::config
        click LayoutMgmt "https://github.com/theSherwood/Mentat/tree/master/src/tiddlers/system/config/Mentat/layouts/"
        SessionMgmt{{"Session Management"}}:::config
        click SessionMgmt "https://github.com/theSherwood/Mentat/tree/master/src/tiddlers/system/config/Mentat/sessions/"
        WindowConfig{{"Window Configuration"}}:::config
        click WindowConfig "https://github.com/theSherwood/Mentat/tree/master/src/tiddlers/system/config/Mentat/windows/"
        MentatState[(State Management)]:::database
        click MentatState "https://github.com/theSherwood/Mentat/tree/master/src/tiddlers/system/plugins/admls/mentat/state/"
        UIComponents>"UI Components"]:::ui
        click UIComponents "https://github.com/theSherwood/Mentat/tree/master/src/tiddlers/system/plugins/admls/mentat/ui/Buttons/"
        Styles[Styles]:::component
        click Styles "https://github.com/theSherwood/Mentat/tree/master/src/tiddlers/system/plugins/admls/mentat/styles/"
    end

    %% Connections
    Core --> Repopup
    Repopup --> RepopupLogic
    Repopup --> RepopupDocs
    
    Repopup --> Volant
    Volant --> VolantLogic
    Volant --> VolantConfig
    Volant --> VolantWidget
    VolantLogic --> VolantState
    
    Volant --> Engine
    Engine --> EngineConfig
    Engine --> EngineUI
    Engine --> EngineTemplates
    
    Engine --> Mentat
    Mentat --> MentatLogic
    Mentat --> WindowMgmt
    Mentat --> LayoutMgmt
    Mentat --> SessionMgmt
    Mentat --> WindowConfig
    Mentat --> MentatState
    Mentat --> UIComponents
    Mentat --> Styles

    %% Styles
    classDef core fill:#d3d3d3
    classDef plugin fill:#b3e0ff,stroke:#0066cc
    classDef service fill:#ffcc99,stroke:#ff9933
    classDef component fill:#ffffff,stroke:#333333
    classDef database fill:#f9f,stroke:#c0c
    classDef ui fill:#ffb366,stroke:#cc7a00
    classDef config fill:#99ff99,stroke:#33cc33
```
