# hdb-studio/tcp-api architecture

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

- Interactive diagram: https://gitdiagram.com/hdb-studio/tcp-api
- Repository: https://github.com/hdb-studio/tcp-api

## Overview

This repository is a LAN client/server messaging tool, with GUI client and server variants across version directories. The main workflow is to inspect network details, find a server, connect over TCP, and exchange messages; server variants also support UDP discovery, and newer sampled servers add optional TLS and compression. The README describes LAN use and an unstable beta. Sampled client/server protocol behavior differs, so the graph shows the connection and message transfer without implying compatible encoding. The API command branch is included based on its source.

Main entry points: [`TCP V2.0.0 Beta version/Client.py`](https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V2.0.0%20Beta%20version/Client.py) (GUI Client), [`TCP V2.1.0 Beta version/sever.py`](https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V2.1.0%20Beta%20version/sever.py) (TCP Server), [`TCP V1.0.0/API/off,r/offr.py`](https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V1.0.0/API/off%2Cr/offr.py) (Command Server), [`TCP V1.0.0/API/off,r`](https://github.com/hdb-studio/tcp-api/tree/main/TCP%20V1.0.0/API/off%2Cr) (Power Actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client"]
  node_gui["GUI Client<br/>[Client.py]"]
  node_network["Network Info<br/>[Client.py]"]
  node_scan["LAN Scan<br/>[Client.py]"]
  node_tcpclient["TCP Client<br/>[Client.py]"]
end

subgraph group_server["Server"]
  node_server["TCP Server<br/>[sever.py]"]
  node_session["Client Handler<br/>[sever.py]"]
  node_discovery["UDP Discovery<br/>[sever.py]"]
  node_tls["TLS Option<br/>[sever.py]"]
end

subgraph group_commands["Remote Commands"]
  node_api["Command Server<br/>[offr.py]"]
  node_actions["Power Actions<br/>[off,r]"]
end

node_user(("User"))
node_peer(("LAN Peer"))

node_user -->|"uses"| node_gui
node_gui -->|"reads details"| node_network
node_gui -->|"starts scan"| node_scan
node_scan -->|"probes TCP"| node_peer
node_gui -->|"connects and sends"| node_tcpclient
node_tcpclient -->|"TCP messages"| node_server
node_server -.->|"optionally wraps"| node_tls
node_server -->|"dispatches client"| node_session
node_session -->|"sends response"| node_tcpclient
node_server -->|"starts listener"| node_discovery
node_peer -->|"UDP query"| node_discovery
node_discovery -->|"UDP response"| node_peer
node_peer -->|"sends command"| node_api
node_api -->|"runs batch files"| node_actions

click node_gui "https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V2.0.0%20Beta%20version/Client.py"
click node_network "https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V2.0.0%20Beta%20version/Client.py"
click node_scan "https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V2.0.0%20Beta%20version/Client.py"
click node_tcpclient "https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V2.0.0%20Beta%20version/Client.py"
click node_server "https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V2.1.0%20Beta%20version/sever.py"
click node_session "https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V2.1.0%20Beta%20version/sever.py"
click node_discovery "https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V2.1.0%20Beta%20version/sever.py"
click node_tls "https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V2.1.0%20Beta%20version/sever.py"
click node_api "https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V1.0.0/API/off%2Cr/offr.py"
click node_actions "https://github.com/hdb-studio/tcp-api/tree/main/TCP%20V1.0.0/API/off%2Cr"

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_gui,node_network,node_scan,node_tcpclient,node_user toneBlue
class node_server,node_session,node_discovery,node_tls toneAmber
class node_api,node_actions toneMint
class node_peer toneIndigo
```

## Components

### Client

- [GUI Client](https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V2.0.0%20Beta%20version/Client.py): `TCP V2.0.0 Beta version/Client.py`
- [Network Info](https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V2.0.0%20Beta%20version/Client.py): `TCP V2.0.0 Beta version/Client.py`
- [LAN Scan](https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V2.0.0%20Beta%20version/Client.py): `TCP V2.0.0 Beta version/Client.py`
- [TCP Client](https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V2.0.0%20Beta%20version/Client.py): `TCP V2.0.0 Beta version/Client.py`

### Server

- [TCP Server](https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V2.1.0%20Beta%20version/sever.py): `TCP V2.1.0 Beta version/sever.py`
- [Client Handler](https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V2.1.0%20Beta%20version/sever.py): `TCP V2.1.0 Beta version/sever.py`
- [UDP Discovery](https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V2.1.0%20Beta%20version/sever.py): `TCP V2.1.0 Beta version/sever.py`
- [TLS Option](https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V2.1.0%20Beta%20version/sever.py): `TCP V2.1.0 Beta version/sever.py`

### Remote Commands

- [Command Server](https://github.com/hdb-studio/tcp-api/blob/main/TCP%20V1.0.0/API/off%2Cr/offr.py): `TCP V1.0.0/API/off,r/offr.py`
- [Power Actions](https://github.com/hdb-studio/tcp-api/tree/main/TCP%20V1.0.0/API/off%2Cr): `TCP V1.0.0/API/off,r`

### Other components

- **User**
- **LAN Peer**

## Connections

- User → GUI Client: uses
- GUI Client → Network Info: reads details
- GUI Client → LAN Scan: starts scan
- LAN Scan → LAN Peer: probes TCP
- GUI Client → TCP Client: connects and sends
- TCP Client → TCP Server: TCP messages
- TCP Server → TLS Option: optionally wraps
- TCP Server → Client Handler: dispatches client
- Client Handler → TCP Client: sends response
- TCP Server → UDP Discovery: starts listener
- LAN Peer → UDP Discovery: UDP query
- UDP Discovery → LAN Peer: UDP response
- LAN Peer → Command Server: sends command
- Command Server → Power Actions: runs batch files
