# hgalexx/hg.secureshellsync architecture

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

- Interactive diagram: https://gitdiagram.com/hgalexx/hg.secureshellsync
- Repository: https://github.com/hgalexx/hg.secureshellsync

## Overview

Hg.SecureShellSync is a KeePass plugin that synchronizes a KeePass database with an SFTP-hosted copy. The documented workflow is triggered manually or on open, save, or a timer; the plugin uses saved connection settings, transfers the remote database, and synchronizes it with the local database. The plugin also provides diagnostics and runtime dependency resolution. The central synchronization implementation is in one large file, so its stages share that path. Some wiring is documented but not visible in the excerpts; those relationships are cited to the README.

Main entry points: [`Hg.SecureShellSync/Hg.SecureShellSyncExt.cs`](https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/Hg.SecureShellSyncExt.cs) (Plugin lifecycle), [`Hg.SecureShellSync/HgLog.cs`](https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/HgLog.cs) (Session logging), [`Hg.SecureShellSync/HgUrl.cs`](https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/HgUrl.cs) (URL dialog), [`Hg.SecureShellSync/HgSyncResult.cs`](https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/HgSyncResult.cs) (Sync result)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_plugin["KeePass plugin"]
  node_plugin_core["Plugin lifecycle"]
  node_triggers["Sync triggers"]
  node_settings["Connection settings"]
  node_url_dialog["URL dialog<br/>[HgUrl.cs]"]
end

subgraph group_sync["Synchronization"]
  node_sync_flow["Sync orchestration"]
  node_sftp_transfer["SFTP transfer"]
  node_database_merge["Database merge"]
  node_local_database[("KeePass database")]
  node_remote_server[("SFTP server")]
  node_sync_result["Sync result<br/>[HgSyncResult.cs]"]
end

subgraph group_support["Runtime support"]
  node_diagnostics["Diagnostics UI"]
  node_logging["Session logging<br/>[HgLog.cs]"]
  node_assembly_resolver["Assembly resolver"]
end

node_keepass(("KeePass"))

node_keepass -->|"hosts plugin"| node_plugin_core
node_plugin_core -->|"installs resolver"| node_assembly_resolver
node_plugin_core -->|"resets logging"| node_logging
node_plugin_core -.->|"registers triggers"| node_triggers
node_keepass -.->|"opens or saves"| node_triggers
node_triggers -.->|"starts sync"| node_sync_flow
node_plugin_core -->|"loads settings"| node_settings
node_settings -->|"opens dialog"| node_url_dialog
node_sync_flow -->|"runs transfer"| node_sftp_transfer
node_sftp_transfer -->|"downloads database"| node_remote_server
node_sftp_transfer -->|"uploads database"| node_remote_server
node_sync_flow -.->|"merges changes"| node_database_merge
node_database_merge -.->|"opens local data"| node_local_database
node_database_merge -.->|"returns outcome"| node_sync_result
node_sync_flow -->|"records diagnostics"| node_logging
node_diagnostics -->|"views log"| node_logging

click node_plugin_core "https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/Hg.SecureShellSyncExt.cs"
click node_triggers "https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/Hg.SecureShellSyncExt.cs"
click node_settings "https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/Hg.SecureShellSyncExt.cs"
click node_url_dialog "https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/HgUrl.cs"
click node_sync_flow "https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/Hg.SecureShellSyncExt.cs"
click node_sftp_transfer "https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/Hg.SecureShellSyncExt.cs"
click node_database_merge "https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/Hg.SecureShellSyncExt.cs"
click node_sync_result "https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/HgSyncResult.cs"
click node_diagnostics "https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/Hg.SecureShellSyncExt.cs"
click node_logging "https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/HgLog.cs"
click node_assembly_resolver "https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/HgAssemblyResolver.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_plugin_core,node_triggers,node_settings,node_url_dialog toneBlue
class node_sync_flow,node_sftp_transfer,node_database_merge,node_local_database,node_remote_server,node_sync_result toneAmber
class node_diagnostics,node_logging,node_assembly_resolver toneMint
class node_keepass toneIndigo
```

## Components

### KeePass plugin

- [Plugin lifecycle](https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/Hg.SecureShellSyncExt.cs): `Hg.SecureShellSync/Hg.SecureShellSyncExt.cs`
- [Sync triggers](https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/Hg.SecureShellSyncExt.cs): `Hg.SecureShellSync/Hg.SecureShellSyncExt.cs`
- [Connection settings](https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/Hg.SecureShellSyncExt.cs): `Hg.SecureShellSync/Hg.SecureShellSyncExt.cs`
- [URL dialog](https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/HgUrl.cs): `Hg.SecureShellSync/HgUrl.cs`

### Synchronization

- [Sync orchestration](https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/Hg.SecureShellSyncExt.cs): `Hg.SecureShellSync/Hg.SecureShellSyncExt.cs`
- [SFTP transfer](https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/Hg.SecureShellSyncExt.cs): `Hg.SecureShellSync/Hg.SecureShellSyncExt.cs`
- [Database merge](https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/Hg.SecureShellSyncExt.cs): `Hg.SecureShellSync/Hg.SecureShellSyncExt.cs`
- **KeePass database**
- **SFTP server**
- [Sync result](https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/HgSyncResult.cs): `Hg.SecureShellSync/HgSyncResult.cs`

### Runtime support

- [Diagnostics UI](https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/Hg.SecureShellSyncExt.cs): `Hg.SecureShellSync/Hg.SecureShellSyncExt.cs`
- [Session logging](https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/HgLog.cs): `Hg.SecureShellSync/HgLog.cs`
- [Assembly resolver](https://github.com/hgalexx/hg.secureshellsync/blob/main/Hg.SecureShellSync/HgAssemblyResolver.cs): `Hg.SecureShellSync/HgAssemblyResolver.cs`

### Other components

- **KeePass**

## Connections

- KeePass → Plugin lifecycle: hosts plugin (evidence: `Hg.SecureShellSync/Hg.SecureShellSyncExt.cs`)
- Plugin lifecycle → Assembly resolver: installs resolver (evidence: `Hg.SecureShellSync/Hg.SecureShellSyncExt.cs`)
- Plugin lifecycle → Session logging: resets logging (evidence: `Hg.SecureShellSync/Hg.SecureShellSyncExt.cs`)
- Plugin lifecycle → Sync triggers: registers triggers (evidence: `Hg.SecureShellSync/Hg.SecureShellSyncExt.cs`)
- KeePass → Sync triggers: opens or saves (evidence: `README.md`)
- Sync triggers → Sync orchestration: starts sync (evidence: `README.md`)
- Plugin lifecycle → Connection settings: loads settings (evidence: `Hg.SecureShellSync/Hg.SecureShellSyncExt.cs`)
- Connection settings → URL dialog: opens dialog (evidence: `Hg.SecureShellSync/Hg.SecureShellSyncExt.cs`)
- Sync orchestration → SFTP transfer: runs transfer (evidence: `Hg.SecureShellSync/Hg.SecureShellSyncExt.cs`)
- SFTP transfer → SFTP server: downloads database (evidence: `Hg.SecureShellSync/Hg.SecureShellSyncExt.cs`)
- SFTP transfer → SFTP server: uploads database (evidence: `Hg.SecureShellSync/Hg.SecureShellSyncExt.cs`)
- Sync orchestration → Database merge: merges changes (evidence: `README.md`)
- Database merge → KeePass database: opens local data (evidence: `README.md`)
- Database merge → Sync result: returns outcome
- Sync orchestration → Session logging: records diagnostics (evidence: `Hg.SecureShellSync/Hg.SecureShellSyncExt.cs`)
- Diagnostics UI → Session logging: views log (evidence: `Hg.SecureShellSync/Hg.SecureShellSyncExt.cs`)
