# iamdroppy/ztunnel-ssh architecture

> Architecture diagram of the GitHub repository iamdroppy/ztunnel-ssh, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iamdroppy/ztunnel-ssh
- Repository: https://github.com/iamdroppy/ztunnel-ssh

## Overview

ZTunnel is an SSH TCP port-forward manager, presented as a Blazor web app and a .NET MAUI app. The main workflow is to save SSH credentials, configure and enable local or remote forwards, then let the background service maintain the SSH session and report tunnel status. The README documents the product behavior; sampled service code confirms connection monitoring, reconnects, and live forward management. The MAUI pages and config-store implementation were not sampled, so their detailed interactions are not expanded here.

Main entry points: [`ZTunnel/Components/Pages`](https://github.com/iamdroppy/ztunnel-ssh/tree/master/ZTunnel/Components/Pages) (Web pages), [`ZTunnel/Services/SshTunnelService.cs`](https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Services/SshTunnelService.cs) (Web tunnel service), [`ZTunnel/Services/TunnelConfigStore.cs`](https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Services/TunnelConfigStore.cs) (Config store), [`ZTunnel/Program.cs`](https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Program.cs) (Web host)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webhost["Web host<br/>[Program.cs]"]
  node_webpages["Web pages"]
  node_dashboard["Tunnel dashboard<br/>[Home.razor]"]
  node_credentials["SSH credentials<br/>[HostDetail.razor]"]
  node_forwards["Forward editor<br/>[ForwardEdit.razor]"]
  node_setupguide["Server setup guide<br/>[Setup.razor]"]
end

subgraph group_mobile["MAUI experience"]
  node_maui["MAUI bootstrap<br/>[MauiProgram.cs]"]
  node_mauishell["MAUI shell<br/>[MainPage.xaml.cs]"]
  node_mauipages["MAUI pages<br/>[Pages]"]
end

subgraph group_runtime["Tunnel runtime"]
  node_webtunnel["Web tunnel service"]
  node_mauitunnel["MAUI tunnel service"]
end

subgraph group_domain["Configuration domain"]
  node_hostmodel["SSH host model<br/>[SshHost.cs]"]
  node_forwardmodel["Forward model<br/>[PortForward.cs]"]
  node_config["Config store"]
  node_configfile["Persistent config"]
end

node_user(("Operator"))
node_sshserver{{"SSH server"}}

node_user -->|"uses"| node_webpages
node_webhost -->|"routes"| node_webpages
node_webpages -.->|"includes"| node_dashboard
node_webpages -.->|"includes"| node_credentials
node_webpages -.->|"includes"| node_forwards
node_webpages -.->|"includes"| node_setupguide
node_credentials -.->|"saves settings"| node_config
node_forwards -.->|"updates forwards"| node_config
node_dashboard -.->|"reads status"| node_webtunnel
node_credentials -.->|"requests reconnect"| node_webtunnel
node_forwards -.->|"manages live forwards"| node_webtunnel
node_webhost -->|"hosts service"| node_webtunnel
node_webhost -->|"registers store"| node_config
node_webtunnel -->|"reads configuration"| node_config
node_config -->|"reads and writes"| node_configfile
node_webtunnel -->|"connects and forwards"| node_sshserver
node_user -.->|"uses"| node_mauipages
node_maui -.->|"starts app"| node_mauishell
node_mauipages -.->|"manages tunnels"| node_mauitunnel
node_maui -->|"registers service"| node_mauitunnel
node_mauitunnel -->|"connects and forwards"| node_sshserver

click node_webhost "https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Program.cs"
click node_webpages "https://github.com/iamdroppy/ztunnel-ssh/tree/master/ZTunnel/Components/Pages"
click node_dashboard "https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Components/Pages/Home.razor"
click node_credentials "https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Components/Pages/HostDetail.razor"
click node_forwards "https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Components/Pages/ForwardEdit.razor"
click node_setupguide "https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Components/Pages/Setup.razor"
click node_maui "https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel.MAUI/MauiProgram.cs"
click node_mauishell "https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel.MAUI/MainPage.xaml.cs"
click node_mauipages "https://github.com/iamdroppy/ztunnel-ssh/tree/master/ZTunnel.MAUI/Components/Pages"
click node_hostmodel "https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Models/SshHost.cs"
click node_forwardmodel "https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Models/PortForward.cs"
click node_config "https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Services/TunnelConfigStore.cs"
click node_webtunnel "https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Services/SshTunnelService.cs"
click node_mauitunnel "https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel.MAUI/Services/SshTunnelService.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webhost,node_webpages,node_dashboard,node_credentials,node_forwards,node_setupguide toneBlue
class node_maui,node_mauishell,node_mauipages toneAmber
class node_webtunnel,node_mauitunnel,node_sshserver toneMint
class node_hostmodel,node_forwardmodel,node_config,node_configfile toneRose
class node_user toneIndigo
```

## Components

### Web experience

- [Web host](https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Program.cs): `ZTunnel/Program.cs`
- [Web pages](https://github.com/iamdroppy/ztunnel-ssh/tree/master/ZTunnel/Components/Pages): `ZTunnel/Components/Pages`
- [Tunnel dashboard](https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Components/Pages/Home.razor): `ZTunnel/Components/Pages/Home.razor`
- [SSH credentials](https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Components/Pages/HostDetail.razor): `ZTunnel/Components/Pages/HostDetail.razor`
- [Forward editor](https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Components/Pages/ForwardEdit.razor): `ZTunnel/Components/Pages/ForwardEdit.razor`
- [Server setup guide](https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Components/Pages/Setup.razor): `ZTunnel/Components/Pages/Setup.razor`

### MAUI experience

- [MAUI bootstrap](https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel.MAUI/MauiProgram.cs): `ZTunnel.MAUI/MauiProgram.cs`
- [MAUI shell](https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel.MAUI/MainPage.xaml.cs): `ZTunnel.MAUI/MainPage.xaml.cs`
- [MAUI pages](https://github.com/iamdroppy/ztunnel-ssh/tree/master/ZTunnel.MAUI/Components/Pages): `ZTunnel.MAUI/Components/Pages`

### Tunnel runtime

- [Web tunnel service](https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Services/SshTunnelService.cs): `ZTunnel/Services/SshTunnelService.cs`
- [MAUI tunnel service](https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel.MAUI/Services/SshTunnelService.cs): `ZTunnel.MAUI/Services/SshTunnelService.cs`

### Configuration domain

- [SSH host model](https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Models/SshHost.cs): `ZTunnel/Models/SshHost.cs`
- [Forward model](https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Models/PortForward.cs): `ZTunnel/Models/PortForward.cs`
- [Config store](https://github.com/iamdroppy/ztunnel-ssh/blob/master/ZTunnel/Services/TunnelConfigStore.cs): `ZTunnel/Services/TunnelConfigStore.cs`
- **Persistent config**

### Other components

- **Operator**
- **SSH server**

## Connections

- Operator → Web pages: uses (evidence: `README.md`)
- Web host → Web pages: routes (evidence: `ZTunnel/Program.cs`)
- Web pages → Tunnel dashboard: includes (evidence: `README.md`)
- Web pages → SSH credentials: includes (evidence: `README.md`)
- Web pages → Forward editor: includes (evidence: `README.md`)
- Web pages → Server setup guide: includes (evidence: `README.md`)
- SSH credentials → Config store: saves settings (evidence: `README.md`)
- Forward editor → Config store: updates forwards (evidence: `README.md`)
- Tunnel dashboard → Web tunnel service: reads status (evidence: `README.md`)
- SSH credentials → Web tunnel service: requests reconnect (evidence: `README.md`)
- Forward editor → Web tunnel service: manages live forwards (evidence: `README.md`)
- Web host → Web tunnel service: hosts service (evidence: `ZTunnel/Program.cs`)
- Web host → Config store: registers store (evidence: `ZTunnel/Program.cs`)
- Web tunnel service → Config store: reads configuration (evidence: `ZTunnel/Services/SshTunnelService.cs`)
- Config store → Persistent config: reads and writes (evidence: `README.md`)
- Web tunnel service → SSH server: connects and forwards (evidence: `ZTunnel/Services/SshTunnelService.cs`)
- Operator → MAUI pages: uses (evidence: `README.md`)
- MAUI bootstrap → MAUI shell: starts app
- MAUI pages → MAUI tunnel service: manages tunnels (evidence: `README.md`)
- MAUI bootstrap → MAUI tunnel service: registers service (evidence: `ZTunnel.MAUI/MauiProgram.cs`)
- MAUI tunnel service → SSH server: connects and forwards (evidence: `ZTunnel.MAUI/Services/SshTunnelService.cs`)
