# fsquirt/freewpfshell architecture

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

- Interactive diagram: https://gitdiagram.com/fsquirt/freewpfshell
- Repository: https://github.com/fsquirt/freewpfshell

## Overview

FreeWPFShell is a Windows WPF SSH client paired with a Rust Linux monitoring agent. The main workflow is user → host/session connection → interactive terminal, with session-level branches for SFTP, monitoring, and tunnels; users can also open system-management and network tools. The graph includes documented agent capabilities whose Rust dispatch is visible, while some WPF wiring and fallback details are supported by the README rather than sampled implementation. Optional IP geolocation is shown separately.

Main entry points: [`Services/SshSessionService.cs`](https://github.com/fsquirt/freewpfshell/blob/master/Services/SshSessionService.cs) (SSH session), [`linux-monitor/src/main.rs`](https://github.com/fsquirt/freewpfshell/blob/master/linux-monitor/src/main.rs) (Agent protocol), [`Repositories/KeyRepository.cs`](https://github.com/fsquirt/freewpfshell/blob/master/Repositories/KeyRepository.cs) (Key repository), [`Share/SshTerminalConnection.cs`](https://github.com/fsquirt/freewpfshell/blob/master/Share/SshTerminalConnection.cs) (Terminal connection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["SSH client"]
  node_main["Main window<br/>[MainForm.xaml.cs]"]
  node_session["SSH session"]
  node_terminal["Terminal connection"]
  node_terminal_ui["Terminal view"]
end

subgraph group_files["File transfer"]
  node_sftp_page["SFTP page"]
  node_sftp_service["Remote files"]
  node_transfers["Transfer manager"]
end

subgraph group_monitor["Monitoring agent"]
  node_monitor_service["Monitor service"]
  node_agent["Agent protocol<br/>[main.rs]"]
  node_stats["Stats collector<br/>[stats_collector.rs]"]
  node_sysmanage["System management"]
  node_services["Service manager<br/>[service_manager.rs]"]
  node_cron["Cron manager<br/>[cron_manager.rs]"]
  node_utmp["Login records<br/>[utmp_parser.rs]"]
end

subgraph group_tools["Network tools"]
  node_traceroute["Traceroute view"]
  node_geolocation["IP geolocation<br/>[IpGeoService.cs]"]
  node_tunnels["Tunnel service<br/>[TunnelService.cs]"]
  node_tunnel_manager["Active tunnels"]
end

subgraph group_security["Credentials"]
  node_keys_ui["Key manager"]
  node_keys[("Key repository<br/>[KeyRepository.cs]")]
  node_key_store[("Local key data")]
  node_credential_service[("Windows credentials")]
end

node_user(("User"))
node_ssh_host(("SSH host"))

node_user -->|"opens"| node_main
node_main -->|"starts session"| node_session
node_session -->|"connects"| node_ssh_host
node_session -->|"creates"| node_terminal
node_terminal_ui -->|"sends input"| node_terminal
node_terminal -->|"streams output"| node_terminal_ui
node_session -->|"uses"| node_sftp_service
node_sftp_page -->|"requests files"| node_sftp_service
node_sftp_page -->|"tracks transfers"| node_transfers
node_session -->|"starts monitoring"| node_monitor_service
node_monitor_service -->|"requests status"| node_agent
node_agent -->|"collects stats"| node_stats
node_sysmanage -->|"requests operations"| node_monitor_service
node_agent -->|"dispatches service ops"| node_services
node_agent -->|"dispatches cron ops"| node_cron
node_agent -->|"reads login records"| node_utmp
node_user -->|"starts trace"| node_traceroute
node_traceroute -.->|"looks up hops"| node_geolocation
node_session -->|"manages forwards"| node_tunnels
node_tunnels -->|"registers tunnels"| node_tunnel_manager
node_keys_ui -->|"imports and deletes"| node_keys
node_session -->|"loads key"| node_keys
node_keys -->|"reads and writes"| node_key_store
node_keys -->|"protects passphrase"| node_credential_service

click node_main "https://github.com/fsquirt/freewpfshell/blob/master/Views/MainForm.xaml.cs"
click node_session "https://github.com/fsquirt/freewpfshell/blob/master/Services/SshSessionService.cs"
click node_terminal "https://github.com/fsquirt/freewpfshell/blob/master/Share/SshTerminalConnection.cs"
click node_terminal_ui "https://github.com/fsquirt/freewpfshell/blob/master/ViewModels/TerminalViewModel.cs"
click node_sftp_page "https://github.com/fsquirt/freewpfshell/blob/master/Views/SftpTransferPage.xaml.cs"
click node_sftp_service "https://github.com/fsquirt/freewpfshell/blob/master/Services/RemoteFileService.cs"
click node_transfers "https://github.com/fsquirt/freewpfshell/blob/master/Services/SftpTransferManager.cs"
click node_monitor_service "https://github.com/fsquirt/freewpfshell/blob/master/Services/SshMonitorService.cs"
click node_agent "https://github.com/fsquirt/freewpfshell/blob/master/linux-monitor/src/main.rs"
click node_stats "https://github.com/fsquirt/freewpfshell/blob/master/linux-monitor/src/stats_collector.rs"
click node_sysmanage "https://github.com/fsquirt/freewpfshell/blob/master/ViewModels/SystemManagementViewModel.cs"
click node_services "https://github.com/fsquirt/freewpfshell/blob/master/linux-monitor/src/service_manager.rs"
click node_cron "https://github.com/fsquirt/freewpfshell/blob/master/linux-monitor/src/cron_manager.rs"
click node_utmp "https://github.com/fsquirt/freewpfshell/blob/master/linux-monitor/src/utmp_parser.rs"
click node_traceroute "https://github.com/fsquirt/freewpfshell/blob/master/ViewModels/TracerouteViewModel.cs"
click node_geolocation "https://github.com/fsquirt/freewpfshell/blob/master/Share/IpGeoService.cs"
click node_tunnels "https://github.com/fsquirt/freewpfshell/blob/master/Services/TunnelService.cs"
click node_tunnel_manager "https://github.com/fsquirt/freewpfshell/blob/master/Share/SshTunnelManager.cs"
click node_keys_ui "https://github.com/fsquirt/freewpfshell/blob/master/UserForm/KeyManagerWindow.xaml.cs"
click node_keys "https://github.com/fsquirt/freewpfshell/blob/master/Repositories/KeyRepository.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_main,node_session,node_terminal,node_terminal_ui,node_user toneBlue
class node_sftp_page,node_sftp_service,node_transfers toneAmber
class node_monitor_service,node_agent,node_stats,node_sysmanage,node_services,node_cron,node_utmp toneMint
class node_traceroute,node_geolocation,node_tunnels,node_tunnel_manager toneRose
class node_keys_ui,node_keys,node_key_store,node_credential_service,node_ssh_host toneIndigo
```

## Components

### SSH client

- [Main window](https://github.com/fsquirt/freewpfshell/blob/master/Views/MainForm.xaml.cs): `Views/MainForm.xaml.cs`
- [SSH session](https://github.com/fsquirt/freewpfshell/blob/master/Services/SshSessionService.cs): `Services/SshSessionService.cs`
- [Terminal connection](https://github.com/fsquirt/freewpfshell/blob/master/Share/SshTerminalConnection.cs): `Share/SshTerminalConnection.cs`
- [Terminal view](https://github.com/fsquirt/freewpfshell/blob/master/ViewModels/TerminalViewModel.cs): `ViewModels/TerminalViewModel.cs`

### File transfer

- [SFTP page](https://github.com/fsquirt/freewpfshell/blob/master/Views/SftpTransferPage.xaml.cs): `Views/SftpTransferPage.xaml.cs`
- [Remote files](https://github.com/fsquirt/freewpfshell/blob/master/Services/RemoteFileService.cs): `Services/RemoteFileService.cs`
- [Transfer manager](https://github.com/fsquirt/freewpfshell/blob/master/Services/SftpTransferManager.cs): `Services/SftpTransferManager.cs`

### Monitoring agent

- [Monitor service](https://github.com/fsquirt/freewpfshell/blob/master/Services/SshMonitorService.cs): `Services/SshMonitorService.cs`
- [Agent protocol](https://github.com/fsquirt/freewpfshell/blob/master/linux-monitor/src/main.rs): `linux-monitor/src/main.rs`
- [Stats collector](https://github.com/fsquirt/freewpfshell/blob/master/linux-monitor/src/stats_collector.rs): `linux-monitor/src/stats_collector.rs`
- [System management](https://github.com/fsquirt/freewpfshell/blob/master/ViewModels/SystemManagementViewModel.cs): `ViewModels/SystemManagementViewModel.cs`
- [Service manager](https://github.com/fsquirt/freewpfshell/blob/master/linux-monitor/src/service_manager.rs): `linux-monitor/src/service_manager.rs`
- [Cron manager](https://github.com/fsquirt/freewpfshell/blob/master/linux-monitor/src/cron_manager.rs): `linux-monitor/src/cron_manager.rs`
- [Login records](https://github.com/fsquirt/freewpfshell/blob/master/linux-monitor/src/utmp_parser.rs): `linux-monitor/src/utmp_parser.rs`

### Network tools

- [Traceroute view](https://github.com/fsquirt/freewpfshell/blob/master/ViewModels/TracerouteViewModel.cs): `ViewModels/TracerouteViewModel.cs`
- [IP geolocation](https://github.com/fsquirt/freewpfshell/blob/master/Share/IpGeoService.cs): `Share/IpGeoService.cs`
- [Tunnel service](https://github.com/fsquirt/freewpfshell/blob/master/Services/TunnelService.cs): `Services/TunnelService.cs`
- [Active tunnels](https://github.com/fsquirt/freewpfshell/blob/master/Share/SshTunnelManager.cs): `Share/SshTunnelManager.cs`

### Credentials

- [Key manager](https://github.com/fsquirt/freewpfshell/blob/master/UserForm/KeyManagerWindow.xaml.cs): `UserForm/KeyManagerWindow.xaml.cs`
- [Key repository](https://github.com/fsquirt/freewpfshell/blob/master/Repositories/KeyRepository.cs): `Repositories/KeyRepository.cs`
- **Local key data**
- **Windows credentials**

### Other components

- **User**
- **SSH host**

## Connections

- User → Main window: opens
- Main window → SSH session: starts session
- SSH session → SSH host: connects
- SSH session → Terminal connection: creates
- Terminal view → Terminal connection: sends input
- Terminal connection → Terminal view: streams output
- SSH session → Remote files: uses
- SFTP page → Remote files: requests files
- SFTP page → Transfer manager: tracks transfers
- SSH session → Monitor service: starts monitoring
- Monitor service → Agent protocol: requests status
- Agent protocol → Stats collector: collects stats
- System management → Monitor service: requests operations
- Agent protocol → Service manager: dispatches service ops
- Agent protocol → Cron manager: dispatches cron ops
- Agent protocol → Login records: reads login records
- User → Traceroute view: starts trace
- Traceroute view → IP geolocation: looks up hops
- SSH session → Tunnel service: manages forwards
- Tunnel service → Active tunnels: registers tunnels
- Key manager → Key repository: imports and deletes
- SSH session → Key repository: loads key
- Key repository → Local key data: reads and writes
- Key repository → Windows credentials: protects passphrase
