# ebouther/opencode-unlimited-proxy architecture

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

- Interactive diagram: https://gitdiagram.com/ebouther/opencode-unlimited-proxy
- Repository: https://github.com/ebouther/opencode-unlimited-proxy

## Overview

This repository packages a self-hosted OpenAI-compatible gateway configuration and an optional legacy WARP/proxy pool. The main workflow sends client requests to the external opencode2api engine, which applies the free-tier-compatible request identity and routes through egress to OpenCode. The legacy mode measures and de-duplicates WARP exits; a separate probe checks upstream gate behavior. The engine implementation itself is external, so its internal request handling is represented only where the README documents it. Some legacy links are documented rather than shown in sampled source.

Main entry points: [`stack/docker-compose.yml`](https://github.com/ebouther/opencode-unlimited-proxy/blob/main/stack/docker-compose.yml) (Compose services), [`stack/dedupe/dedupe.py`](https://github.com/ebouther/opencode-unlimited-proxy/blob/main/stack/dedupe/dedupe.py) (Egress deduplicator), [`scripts/proxy-pool.py`](https://github.com/ebouther/opencode-unlimited-proxy/blob/main/scripts/proxy-pool.py) (Proxy validator), [`stack/config.json`](https://github.com/ebouther/opencode-unlimited-proxy/blob/main/stack/config.json) (Proxy pool settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["Gateway"]
  node_engine["opencode2api engine"]
  node_config["Engine config<br/>[config.json]"]
  node_upstream["OpenCode inference"]
end

subgraph group_egress["Egress pool"]
  node_engine_warp["Engine WARP pool"]
  node_proxy_config["Proxy pool settings<br/>[config.json]"]
  node_warp_rotator["WARP rotator<br/>[rotator.py]"]
  node_tinyproxy["CONNECT proxy"]
  node_dedupe["Egress deduplicator<br/>[dedupe.py]"]
  node_drain_markers[("Drain markers<br/>[dedupe.py]")]
end

subgraph group_operations["Pool operations"]
  node_compose_generator["Compose generator"]
  node_compose["Compose services<br/>[docker-compose.yml]"]
  node_warp_manager["Container manager<br/>[manager.py]"]
end

subgraph group_validation["Validation"]
  node_probe["Gate probe<br/>[gate-probe.py]"]
  node_proxy_tool["Proxy validator<br/>[proxy-pool.py]"]
end

node_clients(("API clients"))
node_operator(("Operator"))

node_clients -->|"sends requests"| node_engine
node_engine -->|"forwards inference"| node_upstream
node_config -->|"configures"| node_engine
node_engine -->|"rotates egress"| node_engine_warp
node_proxy_config -->|"selects proxy mode"| node_engine
node_compose_generator -->|"generates services"| node_compose
node_compose_generator -->|"updates settings"| node_proxy_config
node_compose -->|"starts service"| node_dedupe
node_compose -->|"starts service"| node_tinyproxy
node_compose -.->|"starts service"| node_warp_rotator
node_dedupe -->|"measures and rotates"| node_warp_rotator
node_dedupe -->|"writes markers"| node_drain_markers
node_tinyproxy -.->|"watches markers"| node_drain_markers
node_warp_manager -->|"recreates containers"| node_compose
node_operator -->|"triggers refresh"| node_warp_manager
node_operator -->|"runs gate checks"| node_probe
node_probe -->|"sends test requests"| node_upstream
node_operator -->|"validates proxies"| node_proxy_tool
node_proxy_tool -->|"tests reachability"| node_upstream
node_proxy_tool -->|"updates settings"| node_proxy_config

click node_config "https://github.com/ebouther/opencode-unlimited-proxy/blob/main/stack/config.json"
click node_proxy_config "https://github.com/ebouther/opencode-unlimited-proxy/blob/main/stack/config.json"
click node_compose_generator "https://github.com/ebouther/opencode-unlimited-proxy/blob/main/stack/generate-compose.py"
click node_compose "https://github.com/ebouther/opencode-unlimited-proxy/blob/main/stack/docker-compose.yml"
click node_warp_rotator "https://github.com/ebouther/opencode-unlimited-proxy/blob/main/stack/warp/rotator.py"
click node_warp_manager "https://github.com/ebouther/opencode-unlimited-proxy/blob/main/stack/warp/manager.py"
click node_tinyproxy "https://github.com/ebouther/opencode-unlimited-proxy/tree/main/stack/tinyproxy"
click node_dedupe "https://github.com/ebouther/opencode-unlimited-proxy/blob/main/stack/dedupe/dedupe.py"
click node_drain_markers "https://github.com/ebouther/opencode-unlimited-proxy/blob/main/stack/dedupe/dedupe.py"
click node_probe "https://github.com/ebouther/opencode-unlimited-proxy/blob/main/scripts/gate-probe.py"
click node_proxy_tool "https://github.com/ebouther/opencode-unlimited-proxy/blob/main/scripts/proxy-pool.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_engine,node_config,node_upstream,node_clients toneBlue
class node_engine_warp,node_proxy_config,node_warp_rotator,node_tinyproxy,node_dedupe,node_drain_markers toneAmber
class node_compose_generator,node_compose,node_warp_manager toneMint
class node_probe,node_proxy_tool toneRose
class node_operator toneIndigo
```

## Components

### Gateway

- **opencode2api engine**
- [Engine config](https://github.com/ebouther/opencode-unlimited-proxy/blob/main/stack/config.json): `stack/config.json`
- **OpenCode inference**

### Egress pool

- **Engine WARP pool**
- [Proxy pool settings](https://github.com/ebouther/opencode-unlimited-proxy/blob/main/stack/config.json): `stack/config.json`
- [WARP rotator](https://github.com/ebouther/opencode-unlimited-proxy/blob/main/stack/warp/rotator.py): `stack/warp/rotator.py`
- [CONNECT proxy](https://github.com/ebouther/opencode-unlimited-proxy/tree/main/stack/tinyproxy): `stack/tinyproxy`
- [Egress deduplicator](https://github.com/ebouther/opencode-unlimited-proxy/blob/main/stack/dedupe/dedupe.py): `stack/dedupe/dedupe.py`
- [Drain markers](https://github.com/ebouther/opencode-unlimited-proxy/blob/main/stack/dedupe/dedupe.py): `stack/dedupe/dedupe.py`

### Pool operations

- [Compose generator](https://github.com/ebouther/opencode-unlimited-proxy/blob/main/stack/generate-compose.py): `stack/generate-compose.py`
- [Compose services](https://github.com/ebouther/opencode-unlimited-proxy/blob/main/stack/docker-compose.yml): `stack/docker-compose.yml`
- [Container manager](https://github.com/ebouther/opencode-unlimited-proxy/blob/main/stack/warp/manager.py): `stack/warp/manager.py`

### Validation

- [Gate probe](https://github.com/ebouther/opencode-unlimited-proxy/blob/main/scripts/gate-probe.py): `scripts/gate-probe.py`
- [Proxy validator](https://github.com/ebouther/opencode-unlimited-proxy/blob/main/scripts/proxy-pool.py): `scripts/proxy-pool.py`

### Other components

- **API clients**
- **Operator**

## Connections

- API clients → opencode2api engine: sends requests (evidence: `README.md`)
- opencode2api engine → OpenCode inference: forwards inference (evidence: `README.md`)
- Engine config → opencode2api engine: configures (evidence: `README.md`)
- opencode2api engine → Engine WARP pool: rotates egress (evidence: `README.md`)
- Proxy pool settings → opencode2api engine: selects proxy mode (evidence: `README.md`)
- Compose generator → Compose services: generates services (evidence: `stack/generate-compose.py`)
- Compose generator → Proxy pool settings: updates settings (evidence: `stack/generate-compose.py`)
- Compose services → Egress deduplicator: starts service
- Compose services → CONNECT proxy: starts service
- Compose services → WARP rotator: starts service (evidence: `README.md`)
- Egress deduplicator → WARP rotator: measures and rotates (evidence: `stack/dedupe/dedupe.py`)
- Egress deduplicator → Drain markers: writes markers (evidence: `stack/dedupe/dedupe.py`)
- CONNECT proxy → Drain markers: watches markers (evidence: `README.md`)
- Container manager → Compose services: recreates containers (evidence: `stack/warp/manager.py`)
- Operator → Container manager: triggers refresh (evidence: `stack/warp/manager.py`)
- Operator → Gate probe: runs gate checks (evidence: `scripts/gate-probe.py`)
- Gate probe → OpenCode inference: sends test requests (evidence: `scripts/gate-probe.py`)
- Operator → Proxy validator: validates proxies (evidence: `scripts/proxy-pool.py`)
- Proxy validator → OpenCode inference: tests reachability (evidence: `scripts/proxy-pool.py`)
- Proxy validator → Proxy pool settings: updates settings (evidence: `scripts/proxy-pool.py`)
