# agentgateway/agentgateway architecture

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

- Interactive diagram: https://gitdiagram.com/agentgateway/agentgateway
- Repository: https://github.com/agentgateway/agentgateway
- Video tour (about a minute): https://gitdiagram.com/agentgateway/agentgateway/video

## Overview

Agentgateway is an AI-native proxy for LLM, MCP, and A2A traffic, with standalone and Kubernetes deployment modes. The primary workflow is a client request entering the proxy, being routed to a model or tool/agent backend, and receiving a response; security, policy, and telemetry provide cross-cutting controls. The README documents major capabilities, while the source index supports selected internal links. Unsampled areas are represented by their exact tree paths, but their internal call relationships are not inferred.

Main entry points: [`crates/agentgateway/src/http/mod.rs`](https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/http/mod.rs) (HTTP proxy), [`controller/pkg/controller/gw_controller.go`](https://github.com/agentgateway/agentgateway/blob/main/controller/pkg/controller/gw_controller.go) (Gateway controller), [`crates/agentgateway/src/llm/model_router.rs`](https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/llm/model_router.rs) (LLM routing), [`crates/agentgateway/src/client/mod.rs`](https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/client/mod.rs) (Backend client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Proxy runtime"]
  node_run["Runtime entry<br/>[run.rs]"]
  node_proxy["HTTP proxy<br/>[mod.rs]"]
  node_client_transport["Backend client<br/>[mod.rs]"]
  node_ui["Built-in UI<br/>[main.tsx]"]
end

subgraph group_protocols["AI protocols"]
  node_llm["LLM routing<br/>[model_router.rs]"]
  node_mcp["MCP gateway<br/>[router.rs]"]
  node_a2a["A2A gateway<br/>[mod.rs]"]
  node_inference["Inference routing<br/>[discovery.rs]"]
end

subgraph group_security["Security and policy"]
  node_guardrails["LLM guardrails<br/>[mod.rs]"]
  node_auth["HTTP authentication<br/>[mod.rs]"]
  node_cel["CEL policies<br/>[mod.rs]"]
  node_tls["TLS transport<br/>[tls.rs]"]
end

subgraph group_operations["Configuration and telemetry"]
  node_config["Runtime config<br/>[config.rs]"]
  node_state["State manager<br/>[state_manager.rs]"]
  node_config_store[("Dynamic config store<br/>[config_store.rs]")]
  node_resource["Resource loading"]
  node_telemetry["Telemetry<br/>[mod.rs]"]
end

subgraph group_kubernetes["Kubernetes control plane"]
  node_controller["Gateway controller<br/>[gw_controller.go]"]
  node_translator["Gateway translator"]
  node_syncer["xDS syncer"]
end

node_client_actor(("Client"))
node_provider{{"Model providers"}}
node_tools{{"Tools and data"}}
node_agents{{"External agents"}}
node_kube_api[("Kubernetes API")]

node_client_actor -->|"sends requests"| node_proxy
node_proxy -->|"routes LLM"| node_llm
node_proxy -->|"routes MCP"| node_mcp
node_proxy -->|"routes A2A"| node_a2a
node_proxy -->|"applies auth"| node_auth
node_proxy -->|"checks policies"| node_cel
node_proxy -->|"filters content"| node_guardrails
node_llm -->|"selects models"| node_inference
node_llm -->|"forwards requests"| node_provider
node_mcp -->|"connects tools"| node_tools
node_a2a -->|"communicates with"| node_agents
node_proxy -->|"uses backend client"| node_client_transport
node_client_transport -->|"configures TLS"| node_tls
node_proxy -->|"emits telemetry"| node_telemetry
node_run -.->|"loads configuration"| node_config
node_state -->|"uses config store"| node_config_store
node_config_store -->|"loads resources"| node_resource
node_controller -->|"reconciles gateways"| node_kube_api
node_controller -.->|"translates config"| node_translator
node_controller -.->|"publishes xDS"| node_syncer

click node_run "https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway-app/src/commands/run.rs"
click node_config "https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/config.rs"
click node_state "https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/state_manager.rs"
click node_config_store "https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/config_store.rs"
click node_resource "https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/resource_manager.rs"
click node_proxy "https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/http/mod.rs"
click node_llm "https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/llm/model_router.rs"
click node_mcp "https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/mcp/router.rs"
click node_a2a "https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/a2a/mod.rs"
click node_inference "https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/llm/discovery.rs"
click node_guardrails "https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/llm/policy/mod.rs"
click node_auth "https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/http/auth/mod.rs"
click node_cel "https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/cel/mod.rs"
click node_client_transport "https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/client/mod.rs"
click node_tls "https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/transport/tls.rs"
click node_telemetry "https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/telemetry/mod.rs"
click node_controller "https://github.com/agentgateway/agentgateway/blob/main/controller/pkg/controller/gw_controller.go"
click node_translator "https://github.com/agentgateway/agentgateway/tree/main/controller/pkg/agentgateway/translator"
click node_syncer "https://github.com/agentgateway/agentgateway/tree/main/controller/pkg/syncer"
click node_ui "https://github.com/agentgateway/agentgateway/blob/main/ui/src/main.tsx"

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_run,node_proxy,node_client_transport,node_ui,node_client_actor toneBlue
class node_llm,node_mcp,node_a2a,node_inference,node_kube_api toneAmber
class node_guardrails,node_auth,node_cel,node_tls toneMint
class node_config,node_state,node_config_store,node_resource,node_telemetry toneRose
class node_controller,node_translator,node_syncer,node_provider,node_tools,node_agents toneIndigo
```

## Components

### Proxy runtime

- [Runtime entry](https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway-app/src/commands/run.rs): `crates/agentgateway-app/src/commands/run.rs`
- [HTTP proxy](https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/http/mod.rs): `crates/agentgateway/src/http/mod.rs`
- [Backend client](https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/client/mod.rs): `crates/agentgateway/src/client/mod.rs`
- [Built-in UI](https://github.com/agentgateway/agentgateway/blob/main/ui/src/main.tsx): `ui/src/main.tsx`

### AI protocols

- [LLM routing](https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/llm/model_router.rs): `crates/agentgateway/src/llm/model_router.rs`
- [MCP gateway](https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/mcp/router.rs): `crates/agentgateway/src/mcp/router.rs`
- [A2A gateway](https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/a2a/mod.rs): `crates/agentgateway/src/a2a/mod.rs`
- [Inference routing](https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/llm/discovery.rs): `crates/agentgateway/src/llm/discovery.rs`

### Security and policy

- [LLM guardrails](https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/llm/policy/mod.rs): `crates/agentgateway/src/llm/policy/mod.rs`
- [HTTP authentication](https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/http/auth/mod.rs): `crates/agentgateway/src/http/auth/mod.rs`
- [CEL policies](https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/cel/mod.rs): `crates/agentgateway/src/cel/mod.rs`
- [TLS transport](https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/transport/tls.rs): `crates/agentgateway/src/transport/tls.rs`

### Configuration and telemetry

- [Runtime config](https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/config.rs): `crates/agentgateway/src/config.rs`
- [State manager](https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/state_manager.rs): `crates/agentgateway/src/state_manager.rs`
- [Dynamic config store](https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/config_store.rs): `crates/agentgateway/src/config_store.rs`
- [Resource loading](https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/resource_manager.rs): `crates/agentgateway/src/resource_manager.rs`
- [Telemetry](https://github.com/agentgateway/agentgateway/blob/main/crates/agentgateway/src/telemetry/mod.rs): `crates/agentgateway/src/telemetry/mod.rs`

### Kubernetes control plane

- [Gateway controller](https://github.com/agentgateway/agentgateway/blob/main/controller/pkg/controller/gw_controller.go): `controller/pkg/controller/gw_controller.go`
- [Gateway translator](https://github.com/agentgateway/agentgateway/tree/main/controller/pkg/agentgateway/translator): `controller/pkg/agentgateway/translator`
- [xDS syncer](https://github.com/agentgateway/agentgateway/tree/main/controller/pkg/syncer): `controller/pkg/syncer`

### Other components

- **Client**
- **Model providers**
- **Tools and data**
- **External agents**
- **Kubernetes API**

## Connections

- Client → HTTP proxy: sends requests (evidence: `README.md`)
- HTTP proxy → LLM routing: routes LLM (evidence: `README.md`)
- HTTP proxy → MCP gateway: routes MCP (evidence: `README.md`)
- HTTP proxy → A2A gateway: routes A2A (evidence: `README.md`)
- HTTP proxy → HTTP authentication: applies auth (evidence: `README.md`)
- HTTP proxy → CEL policies: checks policies (evidence: `README.md`)
- HTTP proxy → LLM guardrails: filters content (evidence: `README.md`)
- LLM routing → Inference routing: selects models (evidence: `README.md`)
- LLM routing → Model providers: forwards requests (evidence: `README.md`)
- MCP gateway → Tools and data: connects tools (evidence: `README.md`)
- A2A gateway → External agents: communicates with (evidence: `README.md`)
- HTTP proxy → Backend client: uses backend client (evidence: `crates/agentgateway/src/http/mod.rs`)
- Backend client → TLS transport: configures TLS (evidence: `crates/agentgateway/src/client/mod.rs`)
- HTTP proxy → Telemetry: emits telemetry (evidence: `crates/agentgateway/src/http/mod.rs`)
- Runtime entry → Runtime config: loads configuration
- State manager → Dynamic config store: uses config store (evidence: `crates/agentgateway/src/state_manager.rs`)
- Dynamic config store → Resource loading: loads resources (evidence: `crates/agentgateway/src/config_store.rs`)
- Gateway controller → Kubernetes API: reconciles gateways (evidence: `controller/pkg/controller/gw_controller.go`)
- Gateway controller → Gateway translator: translates config
- Gateway controller → xDS syncer: publishes xDS
