# funye/terminal-tool architecture

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

- Interactive diagram: https://gitdiagram.com/funye/terminal-tool
- Repository: https://github.com/funye/terminal-tool

## Overview

##### Project type and purpose
- This is a small command-line “terminal tool” whose sole purpose is to let users select one of many servers from a JSON file and then open an SSH session (either by password or by key) in an automated, interactive way.

##### File structure
Top-level files:
- config.json      – stores an array of server definitions (name, host, port, credentials…)
- start.sh         – the entry-point script that reads config.json, presents a menu, and dispatches to one of the SSH scripts
- ssh_password.sh  – handles spawning an SSH session with password-based login
- ssh_sshkey.sh    – handles spawning an SSH session with key-based login
- ssh_password.sh / ssh_sshkey.sh both use “spawn” and “jq” to parse and drive interactive SSH
- readme.md        – describes setup, usage, and dependencies

##### README for additional insights
- The tool depends on:
- jq (for JSON parsing)
- spawn (for automating interactive SSH prompts)
- standard “ssh” CLI
- Usage flow: clone → configure config.json → run start.sh → choose server → connect → (optionally alias the launcher)

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User (CLI)"]:::user
    start["start.sh"]:::script
    config["config.json"]:::datastore
    jq["jq (JSON Parser)"]:::external
    menu["Menu Renderer"]:::script
    pass["ssh_password.sh"]:::script
    key["ssh_sshkey.sh"]:::script
    spawn["spawn (Expect-like)"]:::external
    sshcli["ssh CLI"]:::external
    server["Remote SSH Server(s)"]:::external
    readme["readme.md"]:::docs

    User -->|"invokes"| start
    start -->|"read JSON"| config
    start -->|"invoke jq"| jq
    start -->|"display menu"| menu
    menu -->|"user selects entry"| start
    start -.->|"password flow"| pass
    start -.->|"key flow"| key
    pass -->|"uses spawn"| spawn
    key -->|"uses spawn"| spawn
    spawn -->|"spawns ssh process"| sshcli
    sshcli -->|"connect"| server

    click start "https://github.com/funye/terminal-tool/blob/master/start.sh"
    click config "https://github.com/funye/terminal-tool/blob/master/config.json"
    click pass "https://github.com/funye/terminal-tool/blob/master/ssh_password.sh"
    click key "https://github.com/funye/terminal-tool/blob/master/ssh_sshkey.sh"
    click readme "https://github.com/funye/terminal-tool/blob/master/readme.md"

    classDef script fill:#D6EAF8,stroke:#2980B9,stroke-width:2px;
    classDef external fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef datastore fill:#EBEDEF,stroke:#95A5A6,stroke-width:2px;
    classDef user fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
    classDef docs fill:#EBEDEF,stroke:#7F8C8D,stroke-width:2px;
```
