# teratermproject/teraterm architecture

> Architecture diagram of the GitHub repository teratermproject/teraterm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/teratermproject/teraterm
- Repository: https://github.com/teratermproject/teraterm

## Overview

##### Main components
- Core Terminal Emulator Engine:
– This is found primarily in the “teraterm” directory (and possibly “TTProxy” for advanced network or proxy handling).
– It comprises the main terminal UI, window management, input handling, and display (using Win32 APIs).
- Communication & Protocol Handlers:
– Code for handling various connections (serial, telnet, SSH, etc.) appears in directories like “teraterm”, “ttssh2”, “ttssh2/argon2”, “ttssh2/libsshagentc”, “ttssh2/ttxssh” and possibly “cygwin” support for Unix emulation.
– These components manage the low-level system calls, protocol negotiation, and network I/O.
- Plugin and Extension Support:
– Directories such as “ttpmenu”, “ttpmacro”, “ttssh2” (with its various submodules) indicate that the system supports external plugins and built-in macro functions.
– The “TTX…” directories (like TTXAdditional, TTXKanjiMenu, TTXSamples) provide sample extensions or additional functionalities that might be loaded or activated in a plugin-like manner.
- Supporting Libraries & External Dependencies:
– “libs” and the “buildtools” directories indicate usage of external libraries (e.g., OpenSSL, LibreSSL, zlib, oniguruma, SFMT) and scripts to configure or build them.
– They might be wrapped by custom CMake modules that feed into the build system.
- Build, Testing, and Deployment Infrastructure:
– The project includes CI configurations (.github/workflows for msbuild and cmake), various installer scripts and packaging tools (“installer” directory), as well as tests (“tests”).
– These represent the integration and deployment pipelines that ensure the application is built correctly across platforms.

##### Relationships and data flows
- At the center, the terminal emulator core acts as the “orchestrator,” interfacing with UI components (user inputs, windowing), and calling into connection modules.
- Plugin and macro layers “hook” into the core terminal processing so that macros and plugins (like TTX samples and TTPMacro) extend or modify behavior.
- The build system (CMake, MSBuild solution files) feeds into the automation/CI pipelines and is integrated with the installer tools that produce final releases.

##### Architectural patterns and design principles
- Modular Architecture: The project is split into distinct functional modules (core engine, communication, plugins, libraries, and build infrastructure).
- Separation of Concerns: UI, protocol handling, and platform abstraction are separated (e.g., by the “teraterm/common” and “teraterm/teraterm” subdirectories) so that changes in one area do not disrupt another.
- Plug-in Architecture: The existence of many extension-sample directories and separate plugin modules demonstrates a design that supports extensibility and easy feature addition.

- Top layer: User Interface (Windows UI, terminal display, input handling)
- Middle layer: Core Engine, Communication Protocol Handlers, and Plugin system
- Lower layer: External Libraries and system-level dependencies
- Side layer: Build, test, and packaging/installer infrastructure

## Diagram (Mermaid)

```mermaid
graph TD
    %% Terminal Emulator Core
    subgraph "Terminal Emulator Core"
        CE1["Main Terminal Engine (teraterm/teraterm)"]:::core
        CE2["Common UI & Utilities (teraterm/common)"]:::core
    end

    %% Communication & Protocol Handlers
    subgraph "Communication & Protocol Handlers"
        CP1["Proxy & Network Hook (TTProxy)"]:::comm
        CP2["SSH Protocols (ttssh2)"]:::comm
        CP3["Cygwin Support (cygwin)"]:::comm
        CP2a["SSH Extension: ttxssh (ttssh2/ttxssh)"]:::comm
        CP2b["Argon2 Module (ttssh2/ttxssh2/argon2)"]:::comm
    end

    %% Plugin & Extension Support
    subgraph "Plugin & Extension Support"
        PL1["Macro & Plugin Framework (teraterm/ttpmacro)"]:::plugin
        PL2["TTPMENU Plugin (ttpmenu)"]:::plugin
        PL3a["TTXAdditional"]:::plugin
        PL3b["TTXKanjiMenu"]:::plugin
        PL3c["TTXSamples"]:::plugin
    end

    %% Supporting Libraries & Dependencies
    subgraph "Supporting Libraries & Dependencies"
        LB1["External Libraries (libs)"]:::libs
        LB2["Build Tools (buildtools)"]:::libs
        LB3["Additional Tools (tools)"]:::libs
    end

    %% Build, Testing & Deployment Infrastructure
    subgraph "Build, Testing & Deployment Infrastructure"
        INF1["GitHub Workflows (.github/workflows)"]:::infra
        INF2["CI Scripts (ci_scripts)"]:::infra
        INF3["Installer & Packaging (installer)"]:::infra
        INF4["Automated Tests (tests)"]:::infra
    end

    %% Connections from Core to Communication
    CE1 -->|"calls"| CP1
    CE1 -->|"calls"| CP2
    CE1 -->|"calls"| CP3
    CP2 -->|"includes"| CP2a
    CP2 -->|"includes"| CP2b

    %% Connections from Core to Plugins
    CE1 -->|"hooks"| PL1

    %% Plugin integration flow
    PL1 -->|"integrates"| PL2
    PL2 -->|"utilizes"| PL3a
    PL2 -->|"utilizes"| PL3b
    PL2 -->|"utilizes"| PL3c

    %% Dependencies on External Libraries
    CE1 -->|"depends_on"| LB1
    CP1 -->|"depends_on"| LB1
    PL1 -->|"depends_on"| LB1

    %% Build Infrastructure integration
    INF1 -->|"triggers_build"| CE1
    INF2 -->|"executes"| INF4
    INF3 -->|"packages"| CE1
    INF4 -->|"tests"| CE1

    %% Class Definitions for colours
    classDef core fill:#f9a,stroke:#333,stroke-width:2px;
    classDef comm fill:#bbf,stroke:#333,stroke-width:2px;
    classDef plugin fill:#afa,stroke:#333,stroke-width:2px;
    classDef libs fill:#ff9,stroke:#333,stroke-width:2px;
    classDef infra fill:#fdd,stroke:#333,stroke-width:2px;

    %% Click Events
    click CE1 "https://github.com/teratermproject/teraterm/tree/main/teraterm/teraterm"
    click CE2 "https://github.com/teratermproject/teraterm/tree/main/teraterm/common"
    click CP1 "https://github.com/teratermproject/teraterm/tree/main/TTProxy"
    click CP2 "https://github.com/teratermproject/teraterm/tree/main/ttssh2"
    click CP2a "https://github.com/teratermproject/teraterm/tree/main/ttssh2/ttxssh"
    click CP2b "https://github.com/teratermproject/teraterm/tree/main/ttssh2/argon2"
    click CP3 "https://github.com/teratermproject/teraterm/tree/main/cygwin"
    click PL1 "https://github.com/teratermproject/teraterm/tree/main/teraterm/ttpmacro"
    click PL2 "https://github.com/teratermproject/teraterm/tree/main/ttpmenu"
    click PL3a "https://github.com/teratermproject/teraterm/tree/main/TTXAdditional"
    click PL3b "https://github.com/teratermproject/teraterm/tree/main/TTXKanjiMenu"
    click PL3c "https://github.com/teratermproject/teraterm/tree/main/TTXSamples"
    click LB1 "https://github.com/teratermproject/teraterm/tree/main/libs"
    click LB2 "https://github.com/teratermproject/teraterm/tree/main/buildtools"
    click LB3 "https://github.com/teratermproject/teraterm/tree/main/tools"
    click INF1 "https://github.com/teratermproject/teraterm/tree/main/.github/workflows"
    click INF2 "https://github.com/teratermproject/teraterm/tree/main/ci_scripts"
    click INF3 "https://github.com/teratermproject/teraterm/tree/main/installer"
    click INF4 "https://github.com/teratermproject/teraterm/tree/main/tests"
```
