# padi2312/gunnel architecture

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

- Interactive diagram: https://gitdiagram.com/padi2312/gunnel
- Repository: https://github.com/padi2312/gunnel

## Overview

##### Main Components Identification
The application has three primary architectural layers:

a. Frontend Layer (Svelte-based UI):
- Located in the `/frontend` directory
- Uses Svelte with TypeScript
- Implements a component-based architecture
- Contains UI components and routing logic

b. Backend Layer (Go-based):
- Located in the `/internal` directory
- Handles core SSH tunnel management
- Manages configuration and state
- Provides system-level integration

c. Integration Layer (Wails):
- Connects frontend and backend
- Handles cross-platform compatibility
- Manages build and packaging

**[Frontend Layer]**

- UI Components
- Tunnel Management
- Settings
- Forms

- State Management
- Route Handling

**[Wails Bridge]**

**[Backend Layer]**

- Core Services
- Tunnel Manager
- SSH Agent
- Configuration

- Storage
- Local Store

**[System Integration]**

- SSH Connections
- Port Forwarding

##### Component Relationships

- Data flow between frontend and backend through Wails bridge
- SSH tunnel connections to remote servers
- Configuration data flow to/from storage
- User interaction flows

##### Key Technical Details

Frontend:
- Svelte + TypeScript stack
- Component hierarchy
- Route structure (/add, /edit, /settings)

Backend:
- SSH tunnel management
- Configuration handling
- Platform-specific SSH agent integration

Integration:
- Wails binding interface
- Cross-platform compatibility layer

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Frontend
        UI[UI Components]
        TM[Tunnel Management]
        SF[Settings & Forms]
        SM[State Management]
        RT[Route Handling]
    end

    subgraph Integration
        WB[Wails Bridge]
        EP[Entry Point]
    end

    subgraph Backend
        direction TB
        subgraph CoreServices
            TMG[Tunnel Manager]
            SSH[SSH Agent]
            CFG[Configuration]
            FWD[SSH Forwarding]
            RH[Request Handler]
        end

        subgraph Storage
            LS[Local Store]
        end
    end

    subgraph SystemIntegration
        USSH[Unix SSH Agent]
        WSSH[Windows SSH Agent]
        CONN[SSH Connections]
        PF[Port Forwarding]
    end

    %% Frontend Relationships
    UI --> TM
    UI --> SF
    UI --> SM
    SM --> RT

    %% Integration Layer
    Frontend --> WB
    WB --> Backend
    EP --> WB

    %% Backend Relationships
    TMG --> SSH
    TMG --> CFG
    TMG --> FWD
    RH --> TMG
    CFG --> LS

    %% System Integration
    SSH --> USSH
    SSH --> WSSH
    FWD --> CONN
    FWD --> PF

    %% Styling
    classDef frontend fill:#dae8fc,stroke:#6c8ebf
    classDef backend fill:#d5e8d4,stroke:#82b366
    classDef integration fill:#fff2cc,stroke:#d6b656
    classDef system fill:#f5f5f5,stroke:#666666

    %% Apply styles
    class UI,TM,SF,SM,RT frontend
    class TMG,SSH,CFG,FWD,RH,LS backend
    class WB,EP integration
    class USSH,WSSH,CONN,PF system

    %% Click events
    click UI "https://github.com/padi2312/gunnel/tree/main/frontend/src/lib/components"
    click TM "https://github.com/padi2312/gunnel/tree/main/frontend/src/lib/components/gunnel"
    click SF "https://github.com/padi2312/gunnel/tree/main/frontend/src/lib/components/gunnel/tunnelform"
    click RT "https://github.com/padi2312/gunnel/tree/main/frontend/src/routes"
    click SF "https://github.com/padi2312/gunnel/tree/main/frontend/src/routes/settings"
    click TMG "https://github.com/padi2312/gunnel/blob/main/internal/tunnel.go"
    click FWD "https://github.com/padi2312/gunnel/blob/main/internal/forwarder.go"
    click USSH "https://github.com/padi2312/gunnel/blob/main/internal/unix_ssh_agent.go"
    click WSSH "https://github.com/padi2312/gunnel/blob/main/internal/win_ssh_agent.go"
    click CFG "https://github.com/padi2312/gunnel/blob/main/internal/config.go"
    click LS "https://github.com/padi2312/gunnel/blob/main/internal/store.go"
    click RH "https://github.com/padi2312/gunnel/blob/main/internal/handler.go"
    click WB "https://github.com/padi2312/gunnel/blob/main/wails.json"
    click EP "https://github.com/padi2312/gunnel/blob/main/main.go"
```
