# kyncl/knot architecture

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

- Interactive diagram: https://gitdiagram.com/kyncl/knot
- Repository: https://github.com/kyncl/knot

## Overview

Knot is a Rust CLI/TUI for synchronizing directory trees (“knots”) across local and SSH-connected locations. The documented main workflow is to initialize configuration and run sync; the runtime includes configuration, file discovery, synchronization, and local/remote adapters. The README also identifies daemon monitoring, archive management, configuration changes, and filesystem inspection. Some command dispatch and mode internals were not excerpted, so those connections are shown only as unverified where useful.

Main entry points: [`src/cli/mod.rs`](https://github.com/kyncl/knot/blob/main/src/cli/mod.rs) (Commands), [`src/knot/manager.rs`](https://github.com/kyncl/knot/blob/main/src/knot/manager.rs) (Knot manager), [`src/modes/sync.rs`](https://github.com/kyncl/knot/blob/main/src/modes/sync.rs) (Sync mode), [`src/cli/modification/mod.rs`](https://github.com/kyncl/knot/blob/main/src/cli/modification/mod.rs) (Config editing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and TUI"]
  node_commands["Commands<br/>[mod.rs]"]
  node_init["Initialize config<br/>[init.rs]"]
  node_archive["Archive commands<br/>[archiving.rs]"]
  node_fileinspect["Filesystem inspect<br/>[file_system.rs]"]
  node_modify["Config editing<br/>[mod.rs]"]
  node_dashboard["Sync TUI<br/>[mod.rs]"]
end

subgraph group_config["Configuration"]
  node_configload["Config loader<br/>[configuration.rs]"]
  node_settings["Sync settings<br/>[mod.rs]"]
  node_remoteconfig["Remote config<br/>[remote.rs]"]
  node_ignore["Ignore rules<br/>[mod.rs]"]
end

subgraph group_sync["Synchronization"]
  node_syncmode["Sync mode<br/>[sync.rs]"]
  node_daemon["Change monitoring<br/>[main_sync.rs]"]
  node_archiveflow["Archive workflow<br/>[archiving.rs]"]
  node_setup["Knot setup<br/>[setup.rs]"]
  node_manager["Knot manager<br/>[manager.rs]"]
  node_crawler["Local crawler<br/>[file_crawler.rs]"]
  node_filemodel["File records<br/>[file.rs]"]
  node_diffs["File differences<br/>[file_diffs.rs]"]
end

subgraph group_transport["Storage and transport"]
  node_adapter["Knot adapters<br/>[mod.rs]"]
  node_localadapter["Local storage<br/>[mod.rs]"]
  node_sshadapter["SSH storage<br/>[mod.rs]"]
  node_sshpool["SSH connection pool<br/>[pool.rs]"]
  node_session["SSH session<br/>[mod.rs]"]
end

node_user(("Operator"))

node_user -->|"initializes"| node_init
node_user -->|"runs"| node_commands
node_commands -.->|"starts sync"| node_syncmode
node_commands -.->|"starts monitor"| node_daemon
node_commands -.->|"manages archives"| node_archiveflow
node_commands -->|"inspects files"| node_fileinspect
node_commands -->|"edits settings"| node_modify
node_commands -.->|"offers interface"| node_dashboard
node_init -.->|"creates config"| node_configload
node_modify -->|"loads config"| node_configload
node_configload -.->|"loads settings"| node_settings
node_modify -->|"loads remotes"| node_remoteconfig
node_settings -->|"builds ignore rules"| node_ignore
node_syncmode -.->|"coordinates knots"| node_manager
node_manager -->|"crawls source"| node_crawler
node_manager -->|"returns records"| node_filemodel
node_manager -->|"uses knot"| node_adapter
node_adapter -->|"dispatches local"| node_localadapter
node_adapter -->|"dispatches SSH"| node_sshadapter
node_localadapter -->|"uses crawler"| node_crawler
node_sshadapter -->|"acquires sessions"| node_sshpool
node_sshpool -->|"creates sessions"| node_session
node_syncmode -.->|"compares files"| node_diffs
node_syncmode -.->|"reports progress"| node_dashboard
node_archiveflow -.->|"uses knot data"| node_manager

click node_commands "https://github.com/kyncl/knot/blob/main/src/cli/mod.rs"
click node_init "https://github.com/kyncl/knot/blob/main/src/cli/subcommands/init.rs"
click node_archive "https://github.com/kyncl/knot/blob/main/src/cli/subcommands/archiving.rs"
click node_fileinspect "https://github.com/kyncl/knot/blob/main/src/cli/subcommands/file_system.rs"
click node_modify "https://github.com/kyncl/knot/blob/main/src/cli/modification/mod.rs"
click node_dashboard "https://github.com/kyncl/knot/blob/main/src/cli/visualization/dashboard/mod.rs"
click node_configload "https://github.com/kyncl/knot/blob/main/src/configuration/loader/configuration.rs"
click node_settings "https://github.com/kyncl/knot/blob/main/src/configuration/mod.rs"
click node_remoteconfig "https://github.com/kyncl/knot/blob/main/src/configuration/loader/remote.rs"
click node_syncmode "https://github.com/kyncl/knot/blob/main/src/modes/sync.rs"
click node_daemon "https://github.com/kyncl/knot/blob/main/src/modes/main_sync.rs"
click node_archiveflow "https://github.com/kyncl/knot/blob/main/src/modes/archiving.rs"
click node_setup "https://github.com/kyncl/knot/blob/main/src/modes/setup.rs"
click node_manager "https://github.com/kyncl/knot/blob/main/src/knot/manager.rs"
click node_crawler "https://github.com/kyncl/knot/blob/main/src/knot/adapters/local/file_crawler.rs"
click node_filemodel "https://github.com/kyncl/knot/blob/main/src/knot/file.rs"
click node_diffs "https://github.com/kyncl/knot/blob/main/src/knot/file_diffs.rs"
click node_adapter "https://github.com/kyncl/knot/blob/main/src/knot/adapters/mod.rs"
click node_localadapter "https://github.com/kyncl/knot/blob/main/src/knot/adapters/local/mod.rs"
click node_sshadapter "https://github.com/kyncl/knot/blob/main/src/knot/adapters/ssh/mod.rs"
click node_sshpool "https://github.com/kyncl/knot/blob/main/src/connection/ssh/pool.rs"
click node_session "https://github.com/kyncl/knot/blob/main/src/connection/ssh/mod.rs"
click node_ignore "https://github.com/kyncl/knot/blob/main/src/ignorer/mod.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_commands,node_init,node_archive,node_fileinspect,node_modify,node_dashboard toneBlue
class node_configload,node_settings,node_remoteconfig,node_ignore toneAmber
class node_syncmode,node_daemon,node_archiveflow,node_setup,node_manager,node_crawler,node_filemodel,node_diffs toneMint
class node_adapter,node_localadapter,node_sshadapter,node_sshpool,node_session toneRose
class node_user toneIndigo
```

## Components

### CLI and TUI

- [Commands](https://github.com/kyncl/knot/blob/main/src/cli/mod.rs): `src/cli/mod.rs`
- [Initialize config](https://github.com/kyncl/knot/blob/main/src/cli/subcommands/init.rs): `src/cli/subcommands/init.rs`
- [Archive commands](https://github.com/kyncl/knot/blob/main/src/cli/subcommands/archiving.rs): `src/cli/subcommands/archiving.rs`
- [Filesystem inspect](https://github.com/kyncl/knot/blob/main/src/cli/subcommands/file_system.rs): `src/cli/subcommands/file_system.rs`
- [Config editing](https://github.com/kyncl/knot/blob/main/src/cli/modification/mod.rs): `src/cli/modification/mod.rs`
- [Sync TUI](https://github.com/kyncl/knot/blob/main/src/cli/visualization/dashboard/mod.rs): `src/cli/visualization/dashboard/mod.rs`

### Configuration

- [Config loader](https://github.com/kyncl/knot/blob/main/src/configuration/loader/configuration.rs): `src/configuration/loader/configuration.rs`
- [Sync settings](https://github.com/kyncl/knot/blob/main/src/configuration/mod.rs): `src/configuration/mod.rs`
- [Remote config](https://github.com/kyncl/knot/blob/main/src/configuration/loader/remote.rs): `src/configuration/loader/remote.rs`
- [Ignore rules](https://github.com/kyncl/knot/blob/main/src/ignorer/mod.rs): `src/ignorer/mod.rs`

### Synchronization

- [Sync mode](https://github.com/kyncl/knot/blob/main/src/modes/sync.rs): `src/modes/sync.rs`
- [Change monitoring](https://github.com/kyncl/knot/blob/main/src/modes/main_sync.rs): `src/modes/main_sync.rs`
- [Archive workflow](https://github.com/kyncl/knot/blob/main/src/modes/archiving.rs): `src/modes/archiving.rs`
- [Knot setup](https://github.com/kyncl/knot/blob/main/src/modes/setup.rs): `src/modes/setup.rs`
- [Knot manager](https://github.com/kyncl/knot/blob/main/src/knot/manager.rs): `src/knot/manager.rs`
- [Local crawler](https://github.com/kyncl/knot/blob/main/src/knot/adapters/local/file_crawler.rs): `src/knot/adapters/local/file_crawler.rs`
- [File records](https://github.com/kyncl/knot/blob/main/src/knot/file.rs): `src/knot/file.rs`
- [File differences](https://github.com/kyncl/knot/blob/main/src/knot/file_diffs.rs): `src/knot/file_diffs.rs`

### Storage and transport

- [Knot adapters](https://github.com/kyncl/knot/blob/main/src/knot/adapters/mod.rs): `src/knot/adapters/mod.rs`
- [Local storage](https://github.com/kyncl/knot/blob/main/src/knot/adapters/local/mod.rs): `src/knot/adapters/local/mod.rs`
- [SSH storage](https://github.com/kyncl/knot/blob/main/src/knot/adapters/ssh/mod.rs): `src/knot/adapters/ssh/mod.rs`
- [SSH connection pool](https://github.com/kyncl/knot/blob/main/src/connection/ssh/pool.rs): `src/connection/ssh/pool.rs`
- [SSH session](https://github.com/kyncl/knot/blob/main/src/connection/ssh/mod.rs): `src/connection/ssh/mod.rs`

### Other components

- **Operator**

## Connections

- Operator → Initialize config: initializes
- Operator → Commands: runs
- Commands → Sync mode: starts sync
- Commands → Change monitoring: starts monitor
- Commands → Archive workflow: manages archives
- Commands → Filesystem inspect: inspects files (evidence: `src/cli/mod.rs`)
- Commands → Config editing: edits settings (evidence: `src/cli/mod.rs`)
- Commands → Sync TUI: offers interface
- Initialize config → Config loader: creates config
- Config editing → Config loader: loads config (evidence: `src/cli/modification/mod.rs`)
- Config loader → Sync settings: loads settings
- Config editing → Remote config: loads remotes (evidence: `src/cli/modification/mod.rs`)
- Sync settings → Ignore rules: builds ignore rules (evidence: `src/configuration/mod.rs`)
- Sync mode → Knot manager: coordinates knots
- Knot manager → Local crawler: crawls source (evidence: `src/knot/manager.rs`)
- Knot manager → File records: returns records (evidence: `src/knot/manager.rs`)
- Knot manager → Knot adapters: uses knot (evidence: `src/knot/manager.rs`)
- Knot adapters → Local storage: dispatches local (evidence: `src/knot/adapters/mod.rs`)
- Knot adapters → SSH storage: dispatches SSH (evidence: `src/knot/adapters/mod.rs`)
- Local storage → Local crawler: uses crawler (evidence: `src/knot/adapters/local/mod.rs`)
- SSH storage → SSH connection pool: acquires sessions (evidence: `src/knot/adapters/ssh/mod.rs`)
- SSH connection pool → SSH session: creates sessions (evidence: `src/connection/ssh/pool.rs`)
- Sync mode → File differences: compares files
- Sync mode → Sync TUI: reports progress
- Archive workflow → Knot manager: uses knot data
