# eeexun/gtt architecture

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

- Interactive diagram: https://gitdiagram.com/eeexun/gtt
- Repository: https://github.com/eeexun/gtt

## Overview

##### Project type and purpose
- This is a command-line TUI (Text User Interface) translation tool written in Go, named “gtt.”
- Purpose: Let users translate text between languages using multiple back-end services (Google, Bing, DeepL, ChatGPT, etc.) in a unified TUI.

##### File structure
- Top level
- main.go – entry point
- config.go, utils.go, key.go, ui.go – orchestrate config loading, keybindings, UI loops, helpers
- build/ & .github/ – Dockerfile, CI/CD workflows, packaging
- example/ – sample YAML configs for keymaps, server (API keys), themes
- internal/
- translate/
– core/ – shared translation logic (language definitions, server config, TTS)
– [apertium, bing, chatgpt, deepl, google, libre, reverso] – adapter implementations for each service
– translator.go – higher-level orchestration over all adapters
- go.mod, go.sum – Go modules

##### README for additional insights
- Lists supported translators and any special config requirements (API keys, hosts).
- Describes how to provide keymaps and theme via YAML in user’s XDG_CONFIG_HOME.
- Shows optional dependencies (xclip/wl-clipboard).
- Mentions Docker, AUR, nix, binary releases, build flags.

##### Elements
- UI layer (e.g., blue rectangle)
- Core & adapters (e.g., green rectangles)
- Protocols (HTTP/REST) and file formats (YAML)

##### Additional notes
- Optional Clipboard & TTS modules as side branches from the UI layer.
- Don’t over-engineer—focus on the four main tiers (UI, Core, Adapters, External) and config/style cross-cutting concerns.
- Use consistent iconography and grouping to make layers immediately recognizable.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Layer
    User["User & Terminal"]:::external

    %% CLI/TUI Layer
    subgraph "CLI/TUI Layer"
        Main["main.go"]:::ui
        UIEngine["UI Engine"]:::ui
        Keyb["Keybindings Manager"]:::ui
        Util["Utilities"]:::ui
    end

    %% Configuration Manager
    subgraph "Configuration Manager"
        Config["config.go"]:::config
        KeymapYAML["keymap.yaml"]:::config
        ServerYAML["server.yaml"]:::config
        ThemeYAML["theme.yaml"]:::config
    end

    %% Style/Theme Manager
    subgraph "Style/Theme Manager"
        Color["color.go"]:::config
        StyleCode["style.go"]:::config
    end

    %% Translation Core
    subgraph "Translation Core"
        LangDef["language.go"]:::core
        NameDef["name.go"]:::core
        ServerCfg["server.go"]:::core
        TTSCore["tts.go"]:::core
        CoreUtils["utils.go"]:::core
        Orchestrator["translator.go"]:::core
    end

    %% Translator Adapters
    subgraph "Translator Adapters"
        Aper["Apertium Adapter"]:::adapter
        Bing["Bing Adapter"]:::adapter
        ChatGPT["ChatGPT Adapter"]:::adapter
        Deepl["DeepL Adapter"]:::adapter
        Google["Google Adapter"]:::adapter
        Libre["Libre Adapter"]:::adapter
        Reverso["Reverso Adapter"]:::adapter
    end

    %% External Services
    subgraph "External Services"
        ES1["Google API"]:::external
        ES2["Bing API"]:::external
        ES3["DeepL API"]:::external
        ES4["ChatGPT API"]:::external
        ES5["Apertium API"]:::external
        ES6["LibreTranslate API"]:::external
        ES7["Reverso API"]:::external
    end

    %% Build & CI/CD
    subgraph "Build & CI/CD"
        Docker["Dockerfile"]:::config
        CI["Workflows"]:::config
    end

    %% Interactions
    User --> Main
    Main --> UIEngine
    Main --> Config
    Main --> Keyb
    Main --> Util

    UIEngine --> Config
    UIEngine --> Color
    UIEngine --> StyleCode
    UIEngine --> Orchestrator
    UIEngine --> TTSCore

    Config --> KeymapYAML
    Config --> ServerYAML
    Config --> ThemeYAML

    Color --> Color
    StyleCode --> StyleCode

    Orchestrator --> LangDef
    Orchestrator --> NameDef
    Orchestrator --> ServerCfg
    Orchestrator --> CoreUtils
    Orchestrator --> TTSCore

    Orchestrator --> Aper
    Orchestrator --> Bing
    Orchestrator --> ChatGPT
    Orchestrator --> Deepl
    Orchestrator --> Google
    Orchestrator --> Libre
    Orchestrator --> Reverso

    Aper --> ES5
    Bing --> ES2
    ChatGPT --> ES4
    Deepl --> ES3
    Google --> ES1
    Libre --> ES6
    Reverso --> ES7

    Docker --> Main
    CI --> Main

    %% Click Events
    click Main "https://github.com/eeexun/gtt/blob/master/main.go"
    click UIEngine "https://github.com/eeexun/gtt/blob/master/ui.go"
    click UIEngine "https://github.com/eeexun/gtt/tree/master/internal/ui/"
    click Config "https://github.com/eeexun/gtt/blob/master/config.go"
    click KeymapYAML "https://github.com/eeexun/gtt/blob/master/example/keymap.yaml"
    click ServerYAML "https://github.com/eeexun/gtt/blob/master/example/server.yaml"
    click ThemeYAML "https://github.com/eeexun/gtt/blob/master/example/theme.yaml"
    click Keyb "https://github.com/eeexun/gtt/blob/master/key.go"
    click Util "https://github.com/eeexun/gtt/blob/master/utils.go"
    click Color "https://github.com/eeexun/gtt/blob/master/internal/style/color.go"
    click StyleCode "https://github.com/eeexun/gtt/blob/master/internal/style/style.go"
    click LangDef "https://github.com/eeexun/gtt/blob/master/internal/translate/core/language.go"
    click NameDef "https://github.com/eeexun/gtt/blob/master/internal/translate/core/name.go"
    click ServerCfg "https://github.com/eeexun/gtt/blob/master/internal/translate/core/server.go"
    click TTSCore "https://github.com/eeexun/gtt/blob/master/internal/translate/core/tts.go"
    click CoreUtils "https://github.com/eeexun/gtt/blob/master/internal/translate/core/utils.go"
    click Orchestrator "https://github.com/eeexun/gtt/blob/master/internal/translate/translator.go"
    click Aper "https://github.com/eeexun/gtt/blob/master/internal/translate/apertium/translator.go"
    click Bing "https://github.com/eeexun/gtt/blob/master/internal/translate/bing/translator.go"
    click ChatGPT "https://github.com/eeexun/gtt/blob/master/internal/translate/chatgpt/translator.go"
    click Deepl "https://github.com/eeexun/gtt/blob/master/internal/translate/deepl/translator.go"
    click Google "https://github.com/eeexun/gtt/blob/master/internal/translate/google/translator.go"
    click Libre "https://github.com/eeexun/gtt/blob/master/internal/translate/libre/translator.go"
    click Reverso "https://github.com/eeexun/gtt/blob/master/internal/translate/reverso/translator.go"
    click Docker "https://github.com/eeexun/gtt/tree/master/build/Dockerfile"
    click CI "https://github.com/eeexun/gtt/tree/master/.github/workflows/"

    %% Styles
    classDef ui fill:#D6EAF8,stroke:#1B4F72,color:#1B2631
    classDef config fill:#FCF3CF,stroke:#7D6608,color:#784212
    classDef core fill:#D5F5E3,stroke:#196F3D,color:#145A32
    classDef adapter fill:#FADBD8,stroke:#C0392B,color:#641E16
    classDef external fill:#F9E79F,stroke:#7D6608,color:#7D6608
```
