# storytold/voder-proxy architecture

> Architecture diagram of the GitHub repository storytold/voder-proxy, 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/storytold/voder-proxy
- Repository: https://github.com/storytold/voder-proxy

## Overview

voder-proxy is an HTTP reverse proxy/load balancer for the voder TTS service. Clients send speech requests or other traffic; the proxy decodes speech payloads, selects a voice-specific backend (or default route), retries speech requests, and returns backend responses. It also provides a health endpoint and optional New Relic transaction logging. The graph follows the sampled Rust source and README; backend services and New Relic are external, and no unsampled implementation details are inferred.

Main entry points: [`src/main.rs`](https://github.com/storytold/voder-proxy/blob/master/src/main.rs) (Request dispatcher), [`src/speak_proxy.rs`](https://github.com/storytold/voder-proxy/blob/master/src/speak_proxy.rs) (Speech retry handling), [`src/newrelic_logger.rs`](https://github.com/storytold/voder-proxy/blob/master/src/newrelic_logger.rs) (New Relic logger), [`src/api.rs`](https://github.com/storytold/voder-proxy/blob/master/src/api.rs) (Speech request decoding)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingress["HTTP ingress"]
  node_listener["HTTP listener<br/>[main.rs]"]
  node_dispatcher["Request dispatcher<br/>[main.rs]"]
  node_health["Health response<br/>[main.rs]"]
end

subgraph group_speech["Speech proxy"]
  node_router["Backend router<br/>[main.rs]"]
  node_request_decode["Speech request decoding<br/>[api.rs]"]
  node_retry["Speech retry handling<br/>[speak_proxy.rs]"]
  node_request_build["Internal request builder<br/>[speak_proxy.rs]"]
  node_response["Response annotation<br/>[speak_proxy.rs]"]
  node_errors["Proxy error responses<br/>[api.rs]"]
end

subgraph group_ops["Configuration and telemetry"]
  node_bootstrap["Server bootstrap<br/>[main.rs]"]
  node_config["Proxy configuration<br/>[proxy_configs.toml]"]
  node_telemetry["New Relic logger<br/>[newrelic_logger.rs]"]
end

node_client(("HTTP clients"))
node_backend{{"TTS backends"}}
node_newrelic{{"New Relic"}}

node_client -->|"sends requests"| node_listener
node_bootstrap -->|"loads settings"| node_config
node_bootstrap -->|"builds routes"| node_router
node_bootstrap -->|"starts server"| node_listener
node_listener -->|"dispatches requests"| node_dispatcher
node_dispatcher -->|"routes speech"| node_retry
node_dispatcher -->|"answers health"| node_health
node_dispatcher -->|"selects fallback"| node_router
node_dispatcher -->|"starts transactions"| node_telemetry
node_retry -->|"decodes payload"| node_request_decode
node_retry -->|"selects voice host"| node_router
node_retry -->|"retries request"| node_request_build
node_request_build -->|"forwards speech"| node_backend
node_retry -->|"annotates success"| node_response
node_retry -->|"returns retry error"| node_errors
node_dispatcher -->|"forwards unmatched traffic"| node_backend
node_bootstrap -->|"configures logger"| node_telemetry
node_telemetry -.->|"records transactions"| node_newrelic

click node_bootstrap "https://github.com/storytold/voder-proxy/blob/master/src/main.rs"
click node_config "https://github.com/storytold/voder-proxy/blob/master/proxy_configs.toml"
click node_listener "https://github.com/storytold/voder-proxy/blob/master/src/main.rs"
click node_dispatcher "https://github.com/storytold/voder-proxy/blob/master/src/main.rs"
click node_health "https://github.com/storytold/voder-proxy/blob/master/src/main.rs"
click node_router "https://github.com/storytold/voder-proxy/blob/master/src/main.rs"
click node_request_decode "https://github.com/storytold/voder-proxy/blob/master/src/api.rs"
click node_retry "https://github.com/storytold/voder-proxy/blob/master/src/speak_proxy.rs"
click node_request_build "https://github.com/storytold/voder-proxy/blob/master/src/speak_proxy.rs"
click node_response "https://github.com/storytold/voder-proxy/blob/master/src/speak_proxy.rs"
click node_errors "https://github.com/storytold/voder-proxy/blob/master/src/api.rs"
click node_telemetry "https://github.com/storytold/voder-proxy/blob/master/src/newrelic_logger.rs"

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_listener,node_dispatcher,node_health,node_client toneBlue
class node_router,node_request_decode,node_retry,node_request_build,node_response,node_errors toneAmber
class node_bootstrap,node_config,node_telemetry toneMint
class node_backend,node_newrelic toneIndigo
```

## Components

### HTTP ingress

- [HTTP listener](https://github.com/storytold/voder-proxy/blob/master/src/main.rs): `src/main.rs`
- [Request dispatcher](https://github.com/storytold/voder-proxy/blob/master/src/main.rs): `src/main.rs`
- [Health response](https://github.com/storytold/voder-proxy/blob/master/src/main.rs): `src/main.rs`

### Speech proxy

- [Backend router](https://github.com/storytold/voder-proxy/blob/master/src/main.rs): `src/main.rs`
- [Speech request decoding](https://github.com/storytold/voder-proxy/blob/master/src/api.rs): `src/api.rs`
- [Speech retry handling](https://github.com/storytold/voder-proxy/blob/master/src/speak_proxy.rs): `src/speak_proxy.rs`
- [Internal request builder](https://github.com/storytold/voder-proxy/blob/master/src/speak_proxy.rs): `src/speak_proxy.rs`
- [Response annotation](https://github.com/storytold/voder-proxy/blob/master/src/speak_proxy.rs): `src/speak_proxy.rs`
- [Proxy error responses](https://github.com/storytold/voder-proxy/blob/master/src/api.rs): `src/api.rs`

### Configuration and telemetry

- [Server bootstrap](https://github.com/storytold/voder-proxy/blob/master/src/main.rs): `src/main.rs`
- [Proxy configuration](https://github.com/storytold/voder-proxy/blob/master/proxy_configs.toml): `proxy_configs.toml`
- [New Relic logger](https://github.com/storytold/voder-proxy/blob/master/src/newrelic_logger.rs): `src/newrelic_logger.rs`

### Other components

- **HTTP clients**
- **TTS backends**
- **New Relic**

## Connections

- HTTP clients → HTTP listener: sends requests (evidence: `src/main.rs`)
- Server bootstrap → Proxy configuration: loads settings (evidence: `src/main.rs`)
- Server bootstrap → Backend router: builds routes (evidence: `src/main.rs`)
- Server bootstrap → HTTP listener: starts server (evidence: `src/main.rs`)
- HTTP listener → Request dispatcher: dispatches requests (evidence: `src/main.rs`)
- Request dispatcher → Speech retry handling: routes speech (evidence: `src/main.rs`)
- Request dispatcher → Health response: answers health (evidence: `src/main.rs`)
- Request dispatcher → Backend router: selects fallback (evidence: `src/main.rs`)
- Request dispatcher → New Relic logger: starts transactions (evidence: `src/main.rs`)
- Speech retry handling → Speech request decoding: decodes payload (evidence: `src/speak_proxy.rs`)
- Speech retry handling → Backend router: selects voice host (evidence: `src/speak_proxy.rs`)
- Speech retry handling → Internal request builder: retries request (evidence: `src/speak_proxy.rs`)
- Internal request builder → TTS backends: forwards speech (evidence: `src/speak_proxy.rs`)
- Speech retry handling → Response annotation: annotates success (evidence: `src/speak_proxy.rs`)
- Speech retry handling → Proxy error responses: returns retry error (evidence: `src/speak_proxy.rs`)
- Request dispatcher → TTS backends: forwards unmatched traffic (evidence: `src/main.rs`)
- Server bootstrap → New Relic logger: configures logger (evidence: `src/main.rs`)
- New Relic logger → New Relic: records transactions (evidence: `src/newrelic_logger.rs`)
