# usrme/wishlistlite architecture

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

- Interactive diagram: https://gitdiagram.com/usrme/wishlistlite
- Repository: https://github.com/usrme/wishlistlite

## Overview

##### Main Components

a. Core Components:
- SSH Config Parser
- Interactive TUI (Terminal User Interface)
- Connection Manager
- Recent Connections Storage
- Clipboard Manager

b. External Dependencies:
- SSH Client
- SSH Agent
- File System (for config and recent connections)

**User Interface Layer**

**Business Logic Layer**

**System Integration Layer**

##### Specific Component Relationships

a. User Interface Components:
- Input handlers for keyboard interactions (keys.go)
- Connection status display

b. Business Logic:
- SSH Config Parser (parsing ~/.ssh/config)
- Connection Manager (handling SSH connections)
- Recent Connections Manager (managing recent.json)

c. System Integration:
- SSH Client Integration
- File System Access
- System Clipboard Integration

##### Data Flow Indicators

- Config file reading flow
- User input processing
- SSH connection establishment
- Recent connections data persistence

##### Important Technical Details

- Socket creation in /dev/shm
- SSH ControlMaster connection sharing
- Process transformation flow (from wishlistlite to ssh)

##### Startup Flow
**Config File → Parser → TUI Display**

##### Connection Flow
**User Input → TUI → Connection Manager → SSH Process → Host**

##### Recent Connections Flow
**User Action → Recent Manager → JSON Storage ↔ TUI Display**

This will give other engineers a clear understanding of both the high-level architecture and the unique technical aspects of Wishlist Lite.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["User Interface Layer"]
        TUI["Interactive TUI"]
        KeyHandler["Keyboard Input Handler"]
        Display["Connection Status Display"]
    end

    subgraph BL["Business Logic Layer"]
        ConnMgr["Connection Manager"]
        ConfigParser["SSH Config Parser"]
        RecentMgr["Recent Connections Manager"]
    end

    subgraph SI["System Integration Layer"]
        SSHClient["SSH Client"]
        FSys["File System"]
        Clipboard["System Clipboard"]
        SSHAgent["SSH Agent"]
    end

    subgraph Storage["Storage"]
        ConfigFile[("~/.ssh/config")]
        RecentJSON[("recent.json")]
        ControlSocket[("/dev/shm/socket")]
    end

    %% Relationships
    TUI --> KeyHandler
    TUI --> Display
    KeyHandler --> ConnMgr
    ConnMgr --> SSHClient
    ConnMgr --> ControlSocket
    ConfigParser --> ConfigFile
    RecentMgr --> RecentJSON
    SSHClient --> SSHAgent
    
    %% Data Flow
    ConfigFile --> ConfigParser
    ConfigParser --> TUI
    RecentJSON --> RecentMgr
    RecentMgr --> TUI
    ConnMgr --> SSHClient
    
    %% Click Events
    click TUI "https://github.com/usrme/wishlistlite/blob/main/gui.go"
    click KeyHandler "https://github.com/usrme/wishlistlite/blob/main/keys.go"
    click ConnMgr "https://github.com/usrme/wishlistlite/blob/main/main.go"
    click ConfigParser "https://github.com/usrme/wishlistlite/blob/main/utils.go"
    click RecentJSON "https://github.com/usrme/wishlistlite/blob/main/examples/recent.json"
    click ConfigFile "https://github.com/usrme/wishlistlite/tree/main/testdata/"

    %% Styling
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef logic fill:#2ecc71,stroke:#27ae60,color:white
    classDef system fill:#e74c3c,stroke:#c0392b,color:white
    classDef storage fill:#95a5a6,stroke:#7f8c8d,color:white

    class TUI,KeyHandler,Display ui
    class ConnMgr,ConfigParser,RecentMgr logic
    class SSHClient,FSys,Clipboard,SSHAgent system
    class ConfigFile,RecentJSON,ControlSocket storage

    %% Legend
    subgraph Legend
        UI_L["UI Components"]:::ui
        Logic_L["Business Logic"]:::logic
        System_L["System Integration"]:::system
        Storage_L["Storage"]:::storage
    end
```
