# shanmukhasaireddy13/termchat-server architecture

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

- Interactive diagram: https://gitdiagram.com/shanmukhasaireddy13/termchat-server
- Repository: https://github.com/shanmukhasaireddy13/termchat-server

## Overview

Termchat is a terminal-and-web chat product backed by a cloud server, with image exchange and AI assistance; its package also exposes robotics, vision, and IoT scripts. The main workflow is CLI setup and configuration, terminal messaging over WebSockets, server-side broadcast/history, and web participation. Images are downloaded and rendered locally; AI queries can run from the CLI or chat. The README documents the web/server workflow and capabilities; some server dispatch details and the root-level duplicate code runner are not fully shown in the excerpts.

Main entry points: [`termchat/cli.py`](https://github.com/shanmukhasaireddy13/termchat-server/blob/main/termchat/cli.py) (CLI Entry), [`termchat/client.py`](https://github.com/shanmukhasaireddy13/termchat-server/blob/main/termchat/client.py) (Chat Session), [`server/main.py`](https://github.com/shanmukhasaireddy13/termchat-server/blob/main/server/main.py) (Messaging Server), [`termchat/ai.py`](https://github.com/shanmukhasaireddy13/termchat-server/blob/main/termchat/ai.py) (Client AI Adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Terminal Client"]
  node_cli["CLI Entry<br/>[cli.py]"]
  node_config[("Preferences<br/>[config.py]")]
  node_terminal_client["Chat Session<br/>[client.py]"]
  node_image_viewer["Image Handling<br/>[viewer.py]"]
end

subgraph group_server["Chat Server"]
  node_web_app["Web Interface<br/>[app.js]"]
  node_server_app["Messaging Server<br/>[main.py]"]
  node_server_ai["Server AI Adapter<br/>[ai.py]"]
end

subgraph group_ai["AI Assistant"]
  node_client_ai["Client AI Adapter<br/>[ai.py]"]
end

subgraph group_robotics["Robotics and IoT"]
  node_code_cli["Code Commands<br/>[__main__.py]"]
  node_code_runner["Script Runner<br/>[runner.py]"]
  node_robotics_scripts["Robotics and Vision Scripts"]
  node_root_code_runner["Root Script Runner<br/>[runner.py]"]
end

node_terminal_user(("Terminal User"))
node_web_users(("Web Users"))
node_llm_services{{"LLM Providers"}}

node_terminal_user -->|"starts session"| node_cli
node_cli -->|"loads preferences"| node_config
node_cli -->|"starts client"| node_terminal_client
node_terminal_client -->|"exchanges messages"| node_server_app
node_web_users -->|"uses chat"| node_web_app
node_web_app -->|"exchanges messages"| node_server_app
node_server_app -.->|"routes AI queries"| node_server_ai
node_server_ai -->|"requests completions"| node_llm_services
node_cli -->|"runs one-shot queries"| node_client_ai
node_terminal_client -->|"answers local queries"| node_client_ai
node_client_ai -->|"requests completions"| node_llm_services
node_terminal_client -->|"handles received images"| node_image_viewer
node_code_cli -->|"dispatches commands"| node_code_runner
node_cli -->|"dispatches code commands"| node_code_runner
node_code_runner -->|"runs scripts"| node_robotics_scripts

click node_cli "https://github.com/shanmukhasaireddy13/termchat-server/blob/main/termchat/cli.py"
click node_config "https://github.com/shanmukhasaireddy13/termchat-server/blob/main/termchat/config.py"
click node_terminal_client "https://github.com/shanmukhasaireddy13/termchat-server/blob/main/termchat/client.py"
click node_image_viewer "https://github.com/shanmukhasaireddy13/termchat-server/blob/main/termchat/viewer.py"
click node_web_app "https://github.com/shanmukhasaireddy13/termchat-server/blob/main/server/static/app.js"
click node_server_app "https://github.com/shanmukhasaireddy13/termchat-server/blob/main/server/main.py"
click node_server_ai "https://github.com/shanmukhasaireddy13/termchat-server/blob/main/server/ai.py"
click node_client_ai "https://github.com/shanmukhasaireddy13/termchat-server/blob/main/termchat/ai.py"
click node_code_cli "https://github.com/shanmukhasaireddy13/termchat-server/blob/main/termchat/codes/__main__.py"
click node_code_runner "https://github.com/shanmukhasaireddy13/termchat-server/blob/main/termchat/codes/runner.py"
click node_robotics_scripts "https://github.com/shanmukhasaireddy13/termchat-server/tree/main/termchat/codes/python"
click node_root_code_runner "https://github.com/shanmukhasaireddy13/termchat-server/blob/main/codes/runner.py"

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_cli,node_config,node_terminal_client,node_image_viewer,node_terminal_user,node_web_users toneBlue
class node_web_app,node_server_app,node_server_ai toneAmber
class node_client_ai toneMint
class node_code_cli,node_code_runner,node_robotics_scripts,node_root_code_runner toneRose
class node_llm_services toneIndigo
```

## Components

### Terminal Client

- [CLI Entry](https://github.com/shanmukhasaireddy13/termchat-server/blob/main/termchat/cli.py): `termchat/cli.py`
- [Preferences](https://github.com/shanmukhasaireddy13/termchat-server/blob/main/termchat/config.py): `termchat/config.py`
- [Chat Session](https://github.com/shanmukhasaireddy13/termchat-server/blob/main/termchat/client.py): `termchat/client.py`
- [Image Handling](https://github.com/shanmukhasaireddy13/termchat-server/blob/main/termchat/viewer.py): `termchat/viewer.py`

### Chat Server

- [Web Interface](https://github.com/shanmukhasaireddy13/termchat-server/blob/main/server/static/app.js): `server/static/app.js`
- [Messaging Server](https://github.com/shanmukhasaireddy13/termchat-server/blob/main/server/main.py): `server/main.py`
- [Server AI Adapter](https://github.com/shanmukhasaireddy13/termchat-server/blob/main/server/ai.py): `server/ai.py`

### AI Assistant

- [Client AI Adapter](https://github.com/shanmukhasaireddy13/termchat-server/blob/main/termchat/ai.py): `termchat/ai.py`

### Robotics and IoT

- [Code Commands](https://github.com/shanmukhasaireddy13/termchat-server/blob/main/termchat/codes/__main__.py): `termchat/codes/__main__.py`
- [Script Runner](https://github.com/shanmukhasaireddy13/termchat-server/blob/main/termchat/codes/runner.py): `termchat/codes/runner.py`
- [Robotics and Vision Scripts](https://github.com/shanmukhasaireddy13/termchat-server/tree/main/termchat/codes/python): `termchat/codes/python`
- [Root Script Runner](https://github.com/shanmukhasaireddy13/termchat-server/blob/main/codes/runner.py): `codes/runner.py`

### Other components

- **Terminal User**
- **Web Users**
- **LLM Providers**

## Connections

- Terminal User → CLI Entry: starts session (evidence: `README.md`)
- CLI Entry → Preferences: loads preferences (evidence: `termchat/cli.py`)
- CLI Entry → Chat Session: starts client (evidence: `termchat/cli.py`)
- Chat Session → Messaging Server: exchanges messages (evidence: `README.md`)
- Web Users → Web Interface: uses chat (evidence: `README.md`)
- Web Interface → Messaging Server: exchanges messages (evidence: `README.md`)
- Messaging Server → Server AI Adapter: routes AI queries (evidence: `server/main.py`)
- Server AI Adapter → LLM Providers: requests completions (evidence: `server/ai.py`)
- CLI Entry → Client AI Adapter: runs one-shot queries (evidence: `termchat/cli.py`)
- Chat Session → Client AI Adapter: answers local queries (evidence: `termchat/client.py`)
- Client AI Adapter → LLM Providers: requests completions (evidence: `termchat/ai.py`)
- Chat Session → Image Handling: handles received images (evidence: `termchat/client.py`)
- Code Commands → Script Runner: dispatches commands (evidence: `termchat/codes/__main__.py`)
- CLI Entry → Script Runner: dispatches code commands (evidence: `termchat/cli.py`)
- Script Runner → Robotics and Vision Scripts: runs scripts (evidence: `termchat/codes/runner.py`)
