# aiwip/super-proxy architecture

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

- Interactive diagram: https://gitdiagram.com/aiwip/super-proxy
- Repository: https://github.com/aiwip/super-proxy

## Overview

Super Proxy accepts client connections, reads its YAML rules, selects a destination and forwarding method, then relays traffic to an upstream server. Its documented capabilities include transparent forwarding for HTTP, HTTPS, and other TCP traffic, plus plain-HTTP rewriting with TLS termination for CONNECT requests. The graph separates startup and connection handling, rule-based routing, and traffic methods. Relationships are limited to calls and data transfers shown in the excerpts or documented in the README.

Main entry points: [`src/main.go`](https://github.com/aiwip/super-proxy/blob/master/src/main.go) (Connection Handler), [`src/route.go`](https://github.com/aiwip/super-proxy/blob/master/src/route.go) (Route Executor), [`src/methods.go`](https://github.com/aiwip/super-proxy/blob/master/src/methods.go) (Plain Rewriter), [`src/config.go`](https://github.com/aiwip/super-proxy/blob/master/src/config.go) (Rule Matcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Proxy Runtime"]
  node_startup["Startup Setup<br/>[main.go]"]
  node_listener["TCP Listener<br/>[main.go]"]
  node_connection_handler["Connection Handler<br/>[main.go]"]
end

subgraph group_routing["Rule Routing"]
  node_rule_matcher["Rule Matcher<br/>[config.go]"]
  node_route_executor["Route Executor<br/>[route.go]"]
end

subgraph group_traffic["Traffic Methods"]
  node_transparent_forwarder["Transparent Forwarder<br/>[methods.go]"]
  node_plain_rewriter["Plain Rewriter<br/>[methods.go]"]
end

node_operator(("Proxy Operator"))
node_client(("Proxy Client"))
node_config_file["YAML Config"]
node_credentials["TLS Credentials"]
node_upstream(("Upstream Server"))

node_operator -->|"configures"| node_startup
node_config_file -->|"loads YAML"| node_startup
node_credentials -->|"provides paths"| node_startup
node_startup -->|"starts"| node_listener
node_client -->|"connects"| node_listener
node_listener -->|"dispatches"| node_connection_handler
node_connection_handler -->|"selects route"| node_rule_matcher
node_connection_handler -->|"dials destination"| node_upstream
node_connection_handler -->|"runs method"| node_route_executor
node_route_executor -->|"invokes method"| node_transparent_forwarder
node_route_executor -->|"invokes method"| node_plain_rewriter
node_transparent_forwarder -->|"copies traffic"| node_upstream
node_plain_rewriter -->|"loads keypair"| node_credentials
node_plain_rewriter -->|"rewrites and relays"| node_upstream

click node_startup "https://github.com/aiwip/super-proxy/blob/master/src/main.go"
click node_listener "https://github.com/aiwip/super-proxy/blob/master/src/main.go"
click node_connection_handler "https://github.com/aiwip/super-proxy/blob/master/src/main.go"
click node_rule_matcher "https://github.com/aiwip/super-proxy/blob/master/src/config.go"
click node_route_executor "https://github.com/aiwip/super-proxy/blob/master/src/route.go"
click node_transparent_forwarder "https://github.com/aiwip/super-proxy/blob/master/src/methods.go"
click node_plain_rewriter "https://github.com/aiwip/super-proxy/blob/master/src/methods.go"

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_startup,node_listener,node_connection_handler,node_client toneBlue
class node_rule_matcher,node_route_executor toneAmber
class node_transparent_forwarder,node_plain_rewriter,node_upstream toneMint
class node_operator,node_config_file,node_credentials toneIndigo
```

## Components

### Proxy Runtime

- [Startup Setup](https://github.com/aiwip/super-proxy/blob/master/src/main.go): `src/main.go`
- [TCP Listener](https://github.com/aiwip/super-proxy/blob/master/src/main.go): `src/main.go`
- [Connection Handler](https://github.com/aiwip/super-proxy/blob/master/src/main.go): `src/main.go`

### Rule Routing

- [Rule Matcher](https://github.com/aiwip/super-proxy/blob/master/src/config.go): `src/config.go`
- [Route Executor](https://github.com/aiwip/super-proxy/blob/master/src/route.go): `src/route.go`

### Traffic Methods

- [Transparent Forwarder](https://github.com/aiwip/super-proxy/blob/master/src/methods.go): `src/methods.go`
- [Plain Rewriter](https://github.com/aiwip/super-proxy/blob/master/src/methods.go): `src/methods.go`

### Other components

- **Proxy Operator**
- **Proxy Client**
- **YAML Config**
- **TLS Credentials**
- **Upstream Server**

## Connections

- Proxy Operator → Startup Setup: configures (evidence: `README.md`)
- YAML Config → Startup Setup: loads YAML (evidence: `src/main.go`)
- TLS Credentials → Startup Setup: provides paths (evidence: `src/main.go`)
- Startup Setup → TCP Listener: starts (evidence: `src/main.go`)
- Proxy Client → TCP Listener: connects (evidence: `README.md`)
- TCP Listener → Connection Handler: dispatches (evidence: `src/main.go`)
- Connection Handler → Rule Matcher: selects route (evidence: `src/main.go`)
- Connection Handler → Upstream Server: dials destination (evidence: `src/main.go`)
- Connection Handler → Route Executor: runs method (evidence: `src/main.go`)
- Route Executor → Transparent Forwarder: invokes method (evidence: `src/route.go`)
- Route Executor → Plain Rewriter: invokes method (evidence: `src/route.go`)
- Transparent Forwarder → Upstream Server: copies traffic (evidence: `src/methods.go`)
- Plain Rewriter → TLS Credentials: loads keypair (evidence: `src/methods.go`)
- Plain Rewriter → Upstream Server: rewrites and relays (evidence: `src/methods.go`)
