# kingtoolbox/windterm architecture

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

- Interactive diagram: https://gitdiagram.com/kingtoolbox/windterm
- Repository: https://github.com/kingtoolbox/windterm

## Overview

WindTerm is a cross-platform SSH/Telnet/serial terminal and file-transfer client, but this tree exposes only selected libraries and reusable components—not the main application, terminal renderer, or UI orchestration. The documented user workflow is to configure a session, connect and authenticate, then use a terminal or transfer files; the available sources chiefly show libssh’s client/server and protocol internals, Telnet definitions, PTY backends, widgets, and Onigmo. README claims preserve major product capabilities, but links to unsampled application stages are omitted rather than inferred.

Main entry points: [`src/libssh/src/client.c`](https://github.com/kingtoolbox/windterm/blob/master/src/libssh/src/client.c) (SSH client), [`src/libssh/src/server.c`](https://github.com/kingtoolbox/windterm/blob/master/src/libssh/src/server.c) (SSH server), [`src/libssh/include/libssh/session.h`](https://github.com/kingtoolbox/windterm/blob/master/src/libssh/include/libssh/session.h) (Session internals), [`src/libssh/include/libssh/packet.h`](https://github.com/kingtoolbox/windterm/blob/master/src/libssh/include/libssh/packet.h) (Packet processing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ssh["SSH library"]
  node_ssh_api["SSH API and state<br/>[libssh.h]"]
  node_ssh_client["SSH client<br/>[client.c]"]
  node_ssh_auth["SSH authentication<br/>[auth.c]"]
  node_ssh_server["SSH server<br/>[server.c]"]
  node_ssh_packet["Packet processing<br/>[packet.h]"]
  node_ssh_session["Session internals<br/>[session.h]"]
  node_ssh_crypto["Key exchange and crypto<br/>[kex.h]"]
  node_ssh_keys["Keys and PKI<br/>[pki.h]"]
  node_ssh_channels["SSH channels<br/>[channels.h]"]
  node_sftp["SFTP and SCP<br/>[sftp.c]"]
  node_ssh_socket["SSH socket<br/>[socket.h]"]
end

subgraph group_terminal["Terminal transports"]
  node_telnet["Telnet protocol<br/>[TelnetProtocol.cpp]"]
  node_pty["PTY backends<br/>[UnixPty.cpp]"]
  node_windows_pty["Windows PTY<br/>[WinPty.cpp]"]
  node_conpty["ConPTY backend<br/>[ConPty.cpp]"]
end

subgraph group_regex["Regex engine"]
  node_regex_parse["Regex parsing<br/>[regparse.c]"]
  node_regex_compile["Regex compilation<br/>[regcomp.c]"]
  node_regex_exec["Regex execution<br/>[regexec.c]"]
  node_regex_encoding["Encoding support<br/>[regenc.c]"]
  node_encoding_tables["Unicode and encodings<br/>[unicode.c]"]
end

subgraph group_ui["Widgets and utilities"]
  node_popup["Popup widget<br/>[PopupWidget.cpp]"]
  node_scrollbar["Scroll bar<br/>[ScrollBar.cpp]"]
  node_splitter["Splitter<br/>[Splitter.cpp]"]
  node_crypto_util["Crypto utility<br/>[Cryptographic.cpp]"]
  node_thread_local["Thread-local utility<br/>[ThreadLocal.cpp]"]
end

node_user(("WindTerm user"))
node_session_setup["Session setup"]
node_remote_host(("SSH or remote host"))

node_user -->|"configures"| node_session_setup
node_session_setup -.->|"starts SSH"| node_ssh_api
node_ssh_api -.->|"invokes client"| node_ssh_client
node_ssh_client -->|"connects to"| node_remote_host
node_ssh_client -->|"uses state"| node_ssh_session
node_ssh_client -->|"writes through"| node_ssh_socket
node_ssh_client -->|"uses packets"| node_ssh_packet
node_ssh_client -->|"uses key exchange"| node_ssh_crypto
node_ssh_client -->|"uses keys"| node_ssh_keys
node_ssh_auth -->|"updates state"| node_ssh_session
node_ssh_auth -->|"handles auth packets"| node_ssh_packet
node_ssh_server -->|"uses state"| node_ssh_session
node_ssh_server -->|"sends packets"| node_ssh_packet
node_ssh_server -->|"exports keys"| node_ssh_keys
node_ssh_server -->|"uses key exchange"| node_ssh_crypto
node_ssh_session -->|"tracks channels"| node_ssh_channels
node_user -->|"opens Telnet"| node_telnet
node_user -->|"opens local shell"| node_pty
node_user -->|"opens local shell"| node_windows_pty
node_user -->|"opens local shell"| node_conpty
node_regex_compile -->|"uses parser declarations"| node_regex_parse
node_regex_parse -->|"uses encoding API"| node_regex_encoding
node_user -.->|"uses interface"| node_popup
node_user -.->|"uses interface"| node_scrollbar
node_user -.->|"uses interface"| node_splitter

click node_ssh_api "https://github.com/kingtoolbox/windterm/blob/master/src/libssh/include/libssh/libssh.h"
click node_ssh_client "https://github.com/kingtoolbox/windterm/blob/master/src/libssh/src/client.c"
click node_ssh_auth "https://github.com/kingtoolbox/windterm/blob/master/src/libssh/src/auth.c"
click node_ssh_server "https://github.com/kingtoolbox/windterm/blob/master/src/libssh/src/server.c"
click node_ssh_packet "https://github.com/kingtoolbox/windterm/blob/master/src/libssh/include/libssh/packet.h"
click node_ssh_session "https://github.com/kingtoolbox/windterm/blob/master/src/libssh/include/libssh/session.h"
click node_ssh_crypto "https://github.com/kingtoolbox/windterm/blob/master/src/libssh/include/libssh/kex.h"
click node_ssh_keys "https://github.com/kingtoolbox/windterm/blob/master/src/libssh/include/libssh/pki.h"
click node_ssh_channels "https://github.com/kingtoolbox/windterm/blob/master/src/libssh/include/libssh/channels.h"
click node_sftp "https://github.com/kingtoolbox/windterm/blob/master/src/libssh/src/sftp.c"
click node_ssh_socket "https://github.com/kingtoolbox/windterm/blob/master/src/libssh/include/libssh/socket.h"
click node_telnet "https://github.com/kingtoolbox/windterm/blob/master/src/Protocols/TelnetProtocol.cpp"
click node_pty "https://github.com/kingtoolbox/windterm/blob/master/src/Pty/UnixPty.cpp"
click node_windows_pty "https://github.com/kingtoolbox/windterm/blob/master/src/Pty/WinPty.cpp"
click node_conpty "https://github.com/kingtoolbox/windterm/blob/master/src/Pty/ConPty.cpp"
click node_regex_parse "https://github.com/kingtoolbox/windterm/blob/master/src/Onigmo/regparse.c"
click node_regex_compile "https://github.com/kingtoolbox/windterm/blob/master/src/Onigmo/regcomp.c"
click node_regex_exec "https://github.com/kingtoolbox/windterm/blob/master/src/Onigmo/regexec.c"
click node_regex_encoding "https://github.com/kingtoolbox/windterm/blob/master/src/Onigmo/regenc.c"
click node_encoding_tables "https://github.com/kingtoolbox/windterm/blob/master/src/Onigmo/enc/unicode.c"
click node_popup "https://github.com/kingtoolbox/windterm/blob/master/src/Widgets/PopupWidget.cpp"
click node_scrollbar "https://github.com/kingtoolbox/windterm/blob/master/src/Widgets/ScrollBar.cpp"
click node_splitter "https://github.com/kingtoolbox/windterm/blob/master/src/Widgets/Splitter.cpp"
click node_crypto_util "https://github.com/kingtoolbox/windterm/blob/master/src/Utility/Cryptographic.cpp"
click node_thread_local "https://github.com/kingtoolbox/windterm/blob/master/src/Utility/ThreadLocal.cpp"

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_ssh_api,node_ssh_client,node_ssh_auth,node_ssh_server,node_ssh_packet,node_ssh_session,node_ssh_crypto,node_ssh_keys,node_ssh_channels,node_sftp,node_ssh_socket,node_user toneBlue
class node_telnet,node_pty,node_windows_pty,node_conpty toneAmber
class node_regex_parse,node_regex_compile,node_regex_exec,node_regex_encoding,node_encoding_tables toneMint
class node_popup,node_scrollbar,node_splitter,node_crypto_util,node_thread_local toneRose
class node_session_setup,node_remote_host toneIndigo
```

## Components

### SSH library

- [SSH API and state](https://github.com/kingtoolbox/windterm/blob/master/src/libssh/include/libssh/libssh.h): `src/libssh/include/libssh/libssh.h`
- [SSH client](https://github.com/kingtoolbox/windterm/blob/master/src/libssh/src/client.c): `src/libssh/src/client.c`
- [SSH authentication](https://github.com/kingtoolbox/windterm/blob/master/src/libssh/src/auth.c): `src/libssh/src/auth.c`
- [SSH server](https://github.com/kingtoolbox/windterm/blob/master/src/libssh/src/server.c): `src/libssh/src/server.c`
- [Packet processing](https://github.com/kingtoolbox/windterm/blob/master/src/libssh/include/libssh/packet.h): `src/libssh/include/libssh/packet.h`
- [Session internals](https://github.com/kingtoolbox/windterm/blob/master/src/libssh/include/libssh/session.h): `src/libssh/include/libssh/session.h`
- [Key exchange and crypto](https://github.com/kingtoolbox/windterm/blob/master/src/libssh/include/libssh/kex.h): `src/libssh/include/libssh/kex.h`
- [Keys and PKI](https://github.com/kingtoolbox/windterm/blob/master/src/libssh/include/libssh/pki.h): `src/libssh/include/libssh/pki.h`
- [SSH channels](https://github.com/kingtoolbox/windterm/blob/master/src/libssh/include/libssh/channels.h): `src/libssh/include/libssh/channels.h`
- [SFTP and SCP](https://github.com/kingtoolbox/windterm/blob/master/src/libssh/src/sftp.c): `src/libssh/src/sftp.c`
- [SSH socket](https://github.com/kingtoolbox/windterm/blob/master/src/libssh/include/libssh/socket.h): `src/libssh/include/libssh/socket.h`

### Terminal transports

- [Telnet protocol](https://github.com/kingtoolbox/windterm/blob/master/src/Protocols/TelnetProtocol.cpp): `src/Protocols/TelnetProtocol.cpp`
- [PTY backends](https://github.com/kingtoolbox/windterm/blob/master/src/Pty/UnixPty.cpp): `src/Pty/UnixPty.cpp`
- [Windows PTY](https://github.com/kingtoolbox/windterm/blob/master/src/Pty/WinPty.cpp): `src/Pty/WinPty.cpp`
- [ConPTY backend](https://github.com/kingtoolbox/windterm/blob/master/src/Pty/ConPty.cpp): `src/Pty/ConPty.cpp`

### Regex engine

- [Regex parsing](https://github.com/kingtoolbox/windterm/blob/master/src/Onigmo/regparse.c): `src/Onigmo/regparse.c`
- [Regex compilation](https://github.com/kingtoolbox/windterm/blob/master/src/Onigmo/regcomp.c): `src/Onigmo/regcomp.c`
- [Regex execution](https://github.com/kingtoolbox/windterm/blob/master/src/Onigmo/regexec.c): `src/Onigmo/regexec.c`
- [Encoding support](https://github.com/kingtoolbox/windterm/blob/master/src/Onigmo/regenc.c): `src/Onigmo/regenc.c`
- [Unicode and encodings](https://github.com/kingtoolbox/windterm/blob/master/src/Onigmo/enc/unicode.c): `src/Onigmo/enc/unicode.c`

### Widgets and utilities

- [Popup widget](https://github.com/kingtoolbox/windterm/blob/master/src/Widgets/PopupWidget.cpp): `src/Widgets/PopupWidget.cpp`
- [Scroll bar](https://github.com/kingtoolbox/windterm/blob/master/src/Widgets/ScrollBar.cpp): `src/Widgets/ScrollBar.cpp`
- [Splitter](https://github.com/kingtoolbox/windterm/blob/master/src/Widgets/Splitter.cpp): `src/Widgets/Splitter.cpp`
- [Crypto utility](https://github.com/kingtoolbox/windterm/blob/master/src/Utility/Cryptographic.cpp): `src/Utility/Cryptographic.cpp`
- [Thread-local utility](https://github.com/kingtoolbox/windterm/blob/master/src/Utility/ThreadLocal.cpp): `src/Utility/ThreadLocal.cpp`

### Other components

- **WindTerm user**
- **Session setup**
- **SSH or remote host**

## Connections

- WindTerm user → Session setup: configures (evidence: `README.md`)
- Session setup → SSH API and state: starts SSH
- SSH API and state → SSH client: invokes client
- SSH client → SSH or remote host: connects to (evidence: `README.md`)
- SSH client → Session internals: uses state (evidence: `src/libssh/src/client.c`)
- SSH client → SSH socket: writes through (evidence: `src/libssh/src/client.c`)
- SSH client → Packet processing: uses packets (evidence: `src/libssh/src/client.c`)
- SSH client → Key exchange and crypto: uses key exchange (evidence: `src/libssh/src/client.c`)
- SSH client → Keys and PKI: uses keys (evidence: `src/libssh/src/client.c`)
- SSH authentication → Session internals: updates state (evidence: `src/libssh/src/auth.c`)
- SSH authentication → Packet processing: handles auth packets (evidence: `src/libssh/src/auth.c`)
- SSH server → Session internals: uses state (evidence: `src/libssh/src/server.c`)
- SSH server → Packet processing: sends packets (evidence: `src/libssh/src/server.c`)
- SSH server → Keys and PKI: exports keys (evidence: `src/libssh/src/server.c`)
- SSH server → Key exchange and crypto: uses key exchange (evidence: `src/libssh/src/server.c`)
- Session internals → SSH channels: tracks channels (evidence: `src/libssh/include/libssh/session.h`)
- WindTerm user → Telnet protocol: opens Telnet (evidence: `README.md`)
- WindTerm user → PTY backends: opens local shell (evidence: `README.md`)
- WindTerm user → Windows PTY: opens local shell (evidence: `README.md`)
- WindTerm user → ConPTY backend: opens local shell (evidence: `README.md`)
- Regex compilation → Regex parsing: uses parser declarations (evidence: `src/Onigmo/regcomp.c`)
- Regex parsing → Encoding support: uses encoding API (evidence: `src/Onigmo/regparse.c`)
- WindTerm user → Popup widget: uses interface
- WindTerm user → Scroll bar: uses interface
- WindTerm user → Splitter: uses interface
