# tomiyou/ivyterm architecture

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

## Overview

##### Main Components

a. GUI Layer (GTK4)
- Window hierarchy using normal_widgets and tmux_widgets
- Settings window component
- Application configuration system

b. Terminal Management
- VTE (Virtual Terminal Emulator) integration
- Local terminal handling
- SSH connection handling

c. Tmux Integration
- Control mode interface
- Layout management
- Command parsing and execution

##### Component Relationships

**[User Interface]**

- [Normal Mode]──────[Normal Widgets]
- Terminal Container
- VTE Integration

- [Tmux Mode]───────[Tmux Widgets]
- Terminal Container
- Layout Management
- Tmux Control Interface

- [Settings]────────[Configuration]
- General Settings
- Keybindings
- Tmux Settings

- [Core Services]
- SSH Handler
- Tmux API

##### Key Architectural Patterns to Highlight

a. Widget Hierarchy
- Separation between normal_widgets and tmux_widgets
- Common container/layout pattern
- Toplevel, window, and terminal components

b. Tmux Integration
- Control mode communication flow
- Layout parsing and management
- Demonstrate command sending/receiving

c. Configuration System
- Relationship between settings and components
- How keybindings are managed
- Where configuration is stored/loaded

##### Implementation Details

- GTK4/libadwaita as the UI framework
- VTE for terminal emulation
- SSH connectivity
- Tmux control mode protocol
- Configuration storage

##### Data Flow Indicators

Key interactions:
- User input → Keyboard handler → Terminal/Tmux
- Tmux control mode → Parser → Widget updates
- Configuration changes → Component updates
- SSH connection → Tmux session establishment

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["User Interface Layer"]
        NormalMode["Normal Mode"]
        TmuxMode["Tmux Mode"]
        Settings["Settings Interface"]:::settings
    end

    subgraph NormalWidgets["Normal Mode Components"]
        NormalWindow["Window Management"]:::normal
        NormalTerminal["Terminal Widget"]:::normal
    end

    subgraph TmuxWidgets["Tmux Mode Components"]
        TmuxWindow["Window Management"]:::tmux
        TmuxTerminal["Terminal Widget"]:::tmux
        LayoutMgr["Layout Management"]:::tmux
    end

    subgraph Config["Configuration System"]
        TermConfig["Terminal Configuration"]:::config
        TmuxConfig["Tmux Configuration"]:::config
        KeyConfig["Keyboard Configuration"]:::config
    end

    subgraph Core["Core Services"]
        AppCore["Application Core"]:::core
        SSHHandler["SSH Handler"]:::core
        VTE["VTE Integration"]:::core
    end

    subgraph TmuxAPI["Tmux Integration"]
        TmuxControl["Tmux API"]:::tmux_api
        LayoutParser["Layout Parser"]:::tmux_api
        CmdSender["Command Sender"]:::tmux_api
        CmdReceiver["Command Receiver"]:::tmux_api
    end

    %% Relationships
    NormalMode --> NormalWidgets
    TmuxMode --> TmuxWidgets
    NormalWindow --> NormalTerminal
    TmuxWindow --> TmuxTerminal
    TmuxWindow --> LayoutMgr
    LayoutMgr --> LayoutParser
    TmuxMode --> TmuxAPI
    TmuxAPI --> SSHHandler
    Settings --> Config
    Config --> AppCore
    AppCore --> VTE
    TmuxControl --> CmdSender
    TmuxControl --> CmdReceiver

    %% Click Events
    click NormalMode "https://github.com/Tomiyou/ivyterm/tree/master/src/normal_widgets/"
    click TmuxMode "https://github.com/Tomiyou/ivyterm/tree/master/src/tmux_widgets/"
    click Settings "https://github.com/Tomiyou/ivyterm/tree/master/src/settings_window/"
    click TermConfig "https://github.com/Tomiyou/ivyterm/blob/master/src/config/terminal.rs"
    click TmuxConfig "https://github.com/Tomiyou/ivyterm/blob/master/src/config/tmux.rs"
    click SSHHandler "https://github.com/Tomiyou/ivyterm/blob/master/src/ssh.rs"
    click TmuxControl "https://github.com/Tomiyou/ivyterm/tree/master/src/tmux_api/"
    click LayoutParser "https://github.com/Tomiyou/ivyterm/blob/master/src/tmux_api/parse_layout.rs"
    click CmdSender "https://github.com/Tomiyou/ivyterm/blob/master/src/tmux_api/send.rs"
    click CmdReceiver "https://github.com/Tomiyou/ivyterm/blob/master/src/tmux_api/receive.rs"
    click KeyConfig "https://github.com/Tomiyou/ivyterm/blob/master/src/keyboard/keybindings.rs"
    click AppCore "https://github.com/Tomiyou/ivyterm/tree/master/src/application/"
    click NormalTerminal "https://github.com/Tomiyou/ivyterm/tree/master/src/normal_widgets/terminal/"
    click TmuxTerminal "https://github.com/Tomiyou/ivyterm/tree/master/src/tmux_widgets/terminal/"
    click NormalWindow "https://github.com/Tomiyou/ivyterm/tree/master/src/normal_widgets/window/"
    click TmuxWindow "https://github.com/Tomiyou/ivyterm/tree/master/src/tmux_widgets/window/"

    %% Styling
    classDef normal fill:#3498db
    classDef tmux fill:#e67e22
    classDef settings fill:#9b59b6
    classDef config fill:#8e44ad
    classDef core fill:#2ecc71
    classDef tmux_api fill:#e67e22

    %% Legend
    subgraph Legend
        L1["Normal Mode Components"]:::normal
        L2["Tmux Components"]:::tmux
        L3["Settings"]:::settings
        L4["Configuration"]:::config
        L5["Core Services"]:::core
    end
```
