# sunset-go/sshportforward architecture

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

- Interactive diagram: https://gitdiagram.com/sunset-go/sshportforward
- Repository: https://github.com/sunset-go/sshportforward

## Overview

This is a desktop SSH port-forwarding manager: users configure hosts and authentication, define forwarding rules, connect to create tunnels, and inspect connection status, traffic, and logs. Vue components manage these workflows through shared composables and Tauri commands; Rust handlers persist configuration and control SSH sessions. The top-level README describes a starter template rather than the product, so the architecture is inferred from the source index and excerpts. Some frontend-to-command mappings are not shown directly and are marked unverified.

Main entry points: [`src/components/layout/AppShell.vue`](https://github.com/sunset-go/sshportforward/blob/main/src/components/layout/AppShell.vue) (App shell), [`src/composables/useSshTunnel.ts`](https://github.com/sunset-go/sshportforward/blob/main/src/composables/useSshTunnel.ts) (Tunnel state), [`src-tauri/src/commands`](https://github.com/sunset-go/sshportforward/tree/main/src-tauri/src/commands) (Tauri commands), [`src-tauri/src/commands/tunnel.rs`](https://github.com/sunset-go/sshportforward/blob/main/src-tauri/src/commands/tunnel.rs) (Tunnel commands)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Desktop interface"]
  node_shell["App shell<br/>[AppShell.vue]"]
  node_host_ui["Host management<br/>[AddHostDialog.vue]"]
  node_connect_ui["Connection panel<br/>[ConnectPanel.vue]"]
  node_rules_ui["Forwarding rules"]
  node_rule_table["Rule table<br/>[RuleTable.vue]"]
  node_auth_ui["Authentication fields<br/>[AuthFields.vue]"]
  node_logs_ui["Log console<br/>[LogConsole.vue]"]
  node_sidebar["Sidebar and hosts<br/>[SideBar.vue]"]
  node_settings_ui["Settings panel<br/>[SettingsPanel.vue]"]
end

subgraph group_frontend["Frontend state"]
  node_tunnel_state["Tunnel state<br/>[useSshTunnel.ts]"]
  node_settings_state["Settings state<br/>[useSettings.ts]"]
  node_prefs["Text preferences<br/>[usePrefs.ts]"]
  node_types["Shared data types<br/>[index.ts]"]
end

subgraph group_backend["Rust services"]
  node_commands["Tauri commands"]
  node_tunnel_cmd["Tunnel commands<br/>[tunnel.rs]"]
  node_host_cmd["Host commands<br/>[hosts.rs]"]
  node_settings_cmd["Settings commands<br/>[settings.rs]"]
  node_logs_cmd["Log commands<br/>[logs.rs]"]
end

subgraph group_storage["Persistence and security"]
  node_crypto["Credential encryption<br/>[crypto.rs]"]
  node_db[("SQLite access<br/>[db.rs]")]
  node_models["Data models<br/>[models.rs]"]
end

subgraph group_runtime["Tunnel runtime"]
  node_ssh["SSH engine<br/>[ssh.rs]"]
end

node_user(("User"))
node_ssh_server(("SSH server"))

node_user -->|"uses"| node_shell
node_shell -->|"renders"| node_host_ui
node_shell -->|"renders"| node_connect_ui
node_shell -->|"renders"| node_rules_ui
node_shell -->|"renders"| node_logs_ui
node_shell -->|"renders"| node_settings_ui
node_shell -->|"renders"| node_sidebar
node_rules_ui -->|"renders"| node_rule_table
node_host_ui -->|"renders"| node_auth_ui
node_host_ui -->|"uses"| node_tunnel_state
node_auth_ui -->|"inspects keys"| node_tunnel_state
node_connect_ui -->|"uses"| node_tunnel_state
node_rule_table -->|"edits rules"| node_tunnel_state
node_logs_ui -->|"reads logs"| node_tunnel_state
node_sidebar -->|"uses"| node_tunnel_state
node_settings_ui -->|"updates"| node_settings_state
node_settings_state -.->|"invokes settings"| node_settings_cmd
node_tunnel_state -.->|"invokes commands"| node_commands
node_commands -->|"registers"| node_host_cmd
node_commands -->|"registers"| node_tunnel_cmd
node_commands -->|"registers"| node_settings_cmd
node_commands -->|"registers"| node_logs_cmd
node_host_cmd -->|"reads and writes"| node_db
node_host_cmd -->|"encrypts credentials"| node_crypto
node_host_cmd -->|"converts records"| node_models
node_settings_cmd -->|"persists settings"| node_db
node_logs_cmd -->|"reads and writes"| node_db
node_tunnel_cmd -->|"loads configuration"| node_db
node_tunnel_cmd -->|"loads host data"| node_host_cmd
node_tunnel_cmd -->|"decrypts credentials"| node_crypto
node_tunnel_cmd -->|"starts session"| node_ssh
node_ssh -.->|"connects"| node_ssh_server
node_db -.->|"maps records"| node_models

click node_shell "https://github.com/sunset-go/sshportforward/blob/main/src/components/layout/AppShell.vue"
click node_host_ui "https://github.com/sunset-go/sshportforward/blob/main/src/components/dialog/AddHostDialog.vue"
click node_connect_ui "https://github.com/sunset-go/sshportforward/blob/main/src/components/panels/ConnectPanel.vue"
click node_rules_ui "https://github.com/sunset-go/sshportforward/blob/main/src/components/PortForwardPanel.vue"
click node_rule_table "https://github.com/sunset-go/sshportforward/blob/main/src/components/RuleTable.vue"
click node_auth_ui "https://github.com/sunset-go/sshportforward/blob/main/src/components/common/AuthFields.vue"
click node_logs_ui "https://github.com/sunset-go/sshportforward/blob/main/src/components/LogConsole.vue"
click node_sidebar "https://github.com/sunset-go/sshportforward/blob/main/src/components/layout/SideBar.vue"
click node_settings_ui "https://github.com/sunset-go/sshportforward/blob/main/src/components/panels/SettingsPanel.vue"
click node_tunnel_state "https://github.com/sunset-go/sshportforward/blob/main/src/composables/useSshTunnel.ts"
click node_settings_state "https://github.com/sunset-go/sshportforward/blob/main/src/composables/useSettings.ts"
click node_prefs "https://github.com/sunset-go/sshportforward/blob/main/src/composables/usePrefs.ts"
click node_types "https://github.com/sunset-go/sshportforward/blob/main/src/types/index.ts"
click node_commands "https://github.com/sunset-go/sshportforward/tree/main/src-tauri/src/commands"
click node_tunnel_cmd "https://github.com/sunset-go/sshportforward/blob/main/src-tauri/src/commands/tunnel.rs"
click node_host_cmd "https://github.com/sunset-go/sshportforward/blob/main/src-tauri/src/commands/hosts.rs"
click node_settings_cmd "https://github.com/sunset-go/sshportforward/blob/main/src-tauri/src/commands/settings.rs"
click node_logs_cmd "https://github.com/sunset-go/sshportforward/blob/main/src-tauri/src/commands/logs.rs"
click node_ssh "https://github.com/sunset-go/sshportforward/blob/main/src-tauri/src/ssh.rs"
click node_crypto "https://github.com/sunset-go/sshportforward/blob/main/src-tauri/src/crypto.rs"
click node_db "https://github.com/sunset-go/sshportforward/blob/main/src-tauri/src/db.rs"
click node_models "https://github.com/sunset-go/sshportforward/blob/main/src-tauri/src/models.rs"

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_shell,node_host_ui,node_connect_ui,node_rules_ui,node_rule_table,node_auth_ui,node_logs_ui,node_sidebar,node_settings_ui,node_user toneBlue
class node_tunnel_state,node_settings_state,node_prefs,node_types toneAmber
class node_commands,node_tunnel_cmd,node_host_cmd,node_settings_cmd,node_logs_cmd,node_ssh_server toneMint
class node_crypto,node_db,node_models toneRose
class node_ssh toneIndigo
```

## Components

### Desktop interface

- [App shell](https://github.com/sunset-go/sshportforward/blob/main/src/components/layout/AppShell.vue): `src/components/layout/AppShell.vue`
- [Host management](https://github.com/sunset-go/sshportforward/blob/main/src/components/dialog/AddHostDialog.vue): `src/components/dialog/AddHostDialog.vue`
- [Connection panel](https://github.com/sunset-go/sshportforward/blob/main/src/components/panels/ConnectPanel.vue): `src/components/panels/ConnectPanel.vue`
- [Forwarding rules](https://github.com/sunset-go/sshportforward/blob/main/src/components/PortForwardPanel.vue): `src/components/PortForwardPanel.vue`
- [Rule table](https://github.com/sunset-go/sshportforward/blob/main/src/components/RuleTable.vue): `src/components/RuleTable.vue`
- [Authentication fields](https://github.com/sunset-go/sshportforward/blob/main/src/components/common/AuthFields.vue): `src/components/common/AuthFields.vue`
- [Log console](https://github.com/sunset-go/sshportforward/blob/main/src/components/LogConsole.vue): `src/components/LogConsole.vue`
- [Sidebar and hosts](https://github.com/sunset-go/sshportforward/blob/main/src/components/layout/SideBar.vue): `src/components/layout/SideBar.vue`
- [Settings panel](https://github.com/sunset-go/sshportforward/blob/main/src/components/panels/SettingsPanel.vue): `src/components/panels/SettingsPanel.vue`

### Frontend state

- [Tunnel state](https://github.com/sunset-go/sshportforward/blob/main/src/composables/useSshTunnel.ts): `src/composables/useSshTunnel.ts`
- [Settings state](https://github.com/sunset-go/sshportforward/blob/main/src/composables/useSettings.ts): `src/composables/useSettings.ts`
- [Text preferences](https://github.com/sunset-go/sshportforward/blob/main/src/composables/usePrefs.ts): `src/composables/usePrefs.ts`
- [Shared data types](https://github.com/sunset-go/sshportforward/blob/main/src/types/index.ts): `src/types/index.ts`

### Rust services

- [Tauri commands](https://github.com/sunset-go/sshportforward/tree/main/src-tauri/src/commands): `src-tauri/src/commands`
- [Tunnel commands](https://github.com/sunset-go/sshportforward/blob/main/src-tauri/src/commands/tunnel.rs): `src-tauri/src/commands/tunnel.rs`
- [Host commands](https://github.com/sunset-go/sshportforward/blob/main/src-tauri/src/commands/hosts.rs): `src-tauri/src/commands/hosts.rs`
- [Settings commands](https://github.com/sunset-go/sshportforward/blob/main/src-tauri/src/commands/settings.rs): `src-tauri/src/commands/settings.rs`
- [Log commands](https://github.com/sunset-go/sshportforward/blob/main/src-tauri/src/commands/logs.rs): `src-tauri/src/commands/logs.rs`

### Persistence and security

- [Credential encryption](https://github.com/sunset-go/sshportforward/blob/main/src-tauri/src/crypto.rs): `src-tauri/src/crypto.rs`
- [SQLite access](https://github.com/sunset-go/sshportforward/blob/main/src-tauri/src/db.rs): `src-tauri/src/db.rs`
- [Data models](https://github.com/sunset-go/sshportforward/blob/main/src-tauri/src/models.rs): `src-tauri/src/models.rs`

### Tunnel runtime

- [SSH engine](https://github.com/sunset-go/sshportforward/blob/main/src-tauri/src/ssh.rs): `src-tauri/src/ssh.rs`

### Other components

- **User**
- **SSH server**

## Connections

- User → App shell: uses
- App shell → Host management: renders (evidence: `src/components/layout/AppShell.vue`)
- App shell → Connection panel: renders (evidence: `src/components/layout/AppShell.vue`)
- App shell → Forwarding rules: renders (evidence: `src/components/layout/AppShell.vue`)
- App shell → Log console: renders (evidence: `src/components/layout/AppShell.vue`)
- App shell → Settings panel: renders (evidence: `src/components/layout/AppShell.vue`)
- App shell → Sidebar and hosts: renders (evidence: `src/components/layout/AppShell.vue`)
- Forwarding rules → Rule table: renders (evidence: `src/components/PortForwardPanel.vue`)
- Host management → Authentication fields: renders
- Host management → Tunnel state: uses (evidence: `src/components/dialog/AddHostDialog.vue`)
- Authentication fields → Tunnel state: inspects keys (evidence: `src/components/common/AuthFields.vue`)
- Connection panel → Tunnel state: uses (evidence: `src/components/panels/ConnectPanel.vue`)
- Rule table → Tunnel state: edits rules (evidence: `src/components/RuleTable.vue`)
- Log console → Tunnel state: reads logs (evidence: `src/components/LogConsole.vue`)
- Sidebar and hosts → Tunnel state: uses (evidence: `src/components/layout/SideBar.vue`)
- Settings panel → Settings state: updates (evidence: `src/components/panels/SettingsPanel.vue`)
- Settings state → Settings commands: invokes settings
- Tunnel state → Tauri commands: invokes commands
- Tauri commands → Host commands: registers (evidence: `src-tauri/src/commands/mod.rs`)
- Tauri commands → Tunnel commands: registers (evidence: `src-tauri/src/commands/mod.rs`)
- Tauri commands → Settings commands: registers (evidence: `src-tauri/src/commands/mod.rs`)
- Tauri commands → Log commands: registers (evidence: `src-tauri/src/commands/mod.rs`)
- Host commands → SQLite access: reads and writes (evidence: `src-tauri/src/commands/hosts.rs`)
- Host commands → Credential encryption: encrypts credentials (evidence: `src-tauri/src/commands/hosts.rs`)
- Host commands → Data models: converts records (evidence: `src-tauri/src/commands/hosts.rs`)
- Settings commands → SQLite access: persists settings (evidence: `src-tauri/src/settings.rs`)
- Log commands → SQLite access: reads and writes (evidence: `src-tauri/src/commands/logs.rs`)
- Tunnel commands → SQLite access: loads configuration (evidence: `src-tauri/src/commands/tunnel.rs`)
- Tunnel commands → Host commands: loads host data (evidence: `src-tauri/src/commands/tunnel.rs`)
- Tunnel commands → Credential encryption: decrypts credentials (evidence: `src-tauri/src/commands/tunnel.rs`)
- Tunnel commands → SSH engine: starts session (evidence: `src-tauri/src/commands/tunnel.rs`)
- SSH engine → SSH server: connects
- SQLite access → Data models: maps records
