# thing-t6/tcp-proxy-server architecture

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

- Interactive diagram: https://gitdiagram.com/thing-t6/tcp-proxy-server
- Repository: https://github.com/thing-t6/tcp-proxy-server

## Overview

This Java project provides a TCP proxy workflow: a user supplies a listener port and origin, the proxy accepts a client, opens a connection to the origin, and forwards framed messages in both directions on separate threads. It also includes standalone client and echo-server programs. The README describes broader bidirectional stream handling; the excerpts show UTF-framed forwarding and a single accepted proxy connection. The edges below follow the visible calls and configuration; no unsampled implementation is assumed.

Main entry points: [`src/TcpProxy.java`](https://github.com/thing-t6/tcp-proxy-server/blob/main/src/TcpProxy.java) (Proxy session worker), [`src/Client.java`](https://github.com/thing-t6/tcp-proxy-server/blob/main/src/Client.java) (Example client), [`src/Server.java`](https://github.com/thing-t6/tcp-proxy-server/blob/main/src/Server.java) (Example server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_proxy["Proxy runtime"]
  node_cli["CLI configuration<br/>[TcpProxy.java]"]
  node_listener["TCP listener<br/>[TcpProxy.java]"]
  node_worker["Proxy session worker<br/>[TcpProxy.java]"]
  node_client_to_target["Client-to-target pipe<br/>[TcpProxy.java]"]
  node_target_to_client["Target-to-client pipe<br/>[TcpProxy.java]"]
end

subgraph group_examples["Standalone examples"]
  node_client["Example client<br/>[Client.java]"]
  node_server["Example server<br/>[Server.java]"]
end

node_user(("Proxy operator"))
node_origin(("Origin service"))

node_user -->|"provides flags"| node_cli
node_cli -->|"configures"| node_listener
node_listener -->|"starts worker"| node_worker
node_worker -->|"opens socket"| node_origin
node_worker -->|"starts pipe"| node_client_to_target
node_worker -->|"starts pipe"| node_target_to_client
node_client_to_target -->|"forwards frames"| node_origin
node_target_to_client -->|"forwards frames"| node_listener
node_client -->|"sends frames"| node_server

click node_cli "https://github.com/thing-t6/tcp-proxy-server/blob/main/src/TcpProxy.java"
click node_listener "https://github.com/thing-t6/tcp-proxy-server/blob/main/src/TcpProxy.java"
click node_worker "https://github.com/thing-t6/tcp-proxy-server/blob/main/src/TcpProxy.java"
click node_client_to_target "https://github.com/thing-t6/tcp-proxy-server/blob/main/src/TcpProxy.java"
click node_target_to_client "https://github.com/thing-t6/tcp-proxy-server/blob/main/src/TcpProxy.java"
click node_client "https://github.com/thing-t6/tcp-proxy-server/blob/main/src/Client.java"
click node_server "https://github.com/thing-t6/tcp-proxy-server/blob/main/src/Server.java"

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_listener,node_worker,node_client_to_target,node_target_to_client toneBlue
class node_client,node_server toneAmber
class node_user,node_origin toneIndigo
```

## Components

### Proxy runtime

- [CLI configuration](https://github.com/thing-t6/tcp-proxy-server/blob/main/src/TcpProxy.java): `src/TcpProxy.java`
- [TCP listener](https://github.com/thing-t6/tcp-proxy-server/blob/main/src/TcpProxy.java): `src/TcpProxy.java`
- [Proxy session worker](https://github.com/thing-t6/tcp-proxy-server/blob/main/src/TcpProxy.java): `src/TcpProxy.java`
- [Client-to-target pipe](https://github.com/thing-t6/tcp-proxy-server/blob/main/src/TcpProxy.java): `src/TcpProxy.java`
- [Target-to-client pipe](https://github.com/thing-t6/tcp-proxy-server/blob/main/src/TcpProxy.java): `src/TcpProxy.java`

### Standalone examples

- [Example client](https://github.com/thing-t6/tcp-proxy-server/blob/main/src/Client.java): `src/Client.java`
- [Example server](https://github.com/thing-t6/tcp-proxy-server/blob/main/src/Server.java): `src/Server.java`

### Other components

- **Proxy operator**
- **Origin service**

## Connections

- Proxy operator → CLI configuration: provides flags (evidence: `README.md`)
- CLI configuration → TCP listener: configures (evidence: `src/TcpProxy.java`)
- TCP listener → Proxy session worker: starts worker (evidence: `src/TcpProxy.java`)
- Proxy session worker → Origin service: opens socket (evidence: `src/TcpProxy.java`)
- Proxy session worker → Client-to-target pipe: starts pipe (evidence: `src/TcpProxy.java`)
- Proxy session worker → Target-to-client pipe: starts pipe (evidence: `src/TcpProxy.java`)
- Client-to-target pipe → Origin service: forwards frames (evidence: `src/TcpProxy.java`)
- Target-to-client pipe → TCP listener: forwards frames (evidence: `src/TcpProxy.java`)
- Example client → Example server: sends frames (evidence: `src/Client.java`)
