Skip to content

Gatez — Architecture Overview

The Three-Layer Gateway

                                    ┌─────────────────────────────────────────────┐
                                    │            CONTROL PLANE                     │
                                    │  ┌───────────────┐  ┌───────────────┐       │
                                    │  │   Operator     │  │   Developer   │       │
                                    │  │   Portal       │  │   Portal      │       │
                                    │  │   :3003        │  │   :3004       │       │
                                    │  └───────┬───────┘  └───────┬───────┘       │
                                    │          │                   │               │
                                    │  ┌───────┴───────────────────┴───────┐       │
                                    │  │     Control Plane API (:4001)     │       │
                                    │  │     Rust (axum + tokio)           │       │
                                    │  └──────┬──────┬──────┬──────┬──────┘       │
                                    └─────────┼──────┼──────┼──────┼──────────────┘
                                              │      │      │      │
              ┌───────────────────────────────┼──────┼──────┼──────┼───────────────────────┐
              │                               │      │      │      │                       │
              │   ┌───────────────────────────┼──────┼──────┼──────┼────────────────────┐  │
              │   │                           ▼      │      │      │                    │  │
              │   │   ┌─────────────────────────┐    │      │      │                    │  │
  Clients ────┼───┼──▶│  L1 — API GATEWAY       │    │      │      │                    │  │
  (HTTP,      │   │   │  Apache APISIX (:9080)   │    │      │      │                    │  │
   gRPC,      │   │   │                          │    │      │      │                    │  │
   WebSocket) │   │   │  • JWT auth (Keycloak)   │    │      │      │                    │  │
              │   │   │  • Per-tenant rate limit  │    │      │      │                    │  │
              │   │   │  • Request logging (CH)   │    │      │      │                    │  │
              │   │   │  • gRPC transcode         │    │      │      │                    │  │
              │   │   │  • WebSocket proxy        │    │      │      │                    │  │
              │   │   │  • Circuit breaker         │    │      │      │                    │  │
              │   │   │  • Traffic splitting       │    │      │      │                    │  │
              │   │   └──────────┬────────────────┘    │      │      │                    │  │
              │   │              │                      │      │      │                    │  │
              │   │              ▼                      │      │      │                    │  │
              │   │   ┌─────────────────────────┐      │      │      │                    │  │
              │   │   │  L2 — AI GATEWAY        │      │      │      │                    │  │
              │   │   │  Custom Rust (:4000)     │      │      │      │                    │  │
              │   │   │                          │      │      │      │                    │  │
              │   │   │  • Multi-model routing   │──────┘      │      │                    │  │
              │   │   │    (OpenAI, Anthropic,   │             │      │                    │  │
              │   │   │     Gemini, Ollama)      │             │      │                    │  │
              │   │   │  • PII redaction         │             │      │                    │  │
              │   │   │  • Token budget enforce  │             │      │                    │  │
              │   │   │  • Semantic cache         │             │      │                    │  │
              │   │   │    (Redis + Qdrant)       │             │      │                    │  │
              │   │   │  • SSE streaming          │             │      │                    │  │
              │   │   │  • Fallback + circuit brk │             │      │                    │  │
              │   │   └──────────┬────────────────┘             │      │                    │  │
              │   │              │                              │      │                    │  │
              │   │              ▼                              │      │                    │  │
              │   │   ┌─────────────────────────┐              │      │                    │  │
              │   │   │  L3 — AGENT GATEWAY     │              │      │                    │  │
              │   │   │  Custom Rust (:5001)     │──────────────┘      │                    │  │
              │   │   │                          │                     │                    │  │
              │   │   │  • MCP protocol          │                     │                    │  │
              │   │   │  • A2A protocol           │                     │                    │  │
              │   │   │  • Session management    │                     │                    │  │
              │   │   │  • Tool allowlists        │                     │                    │  │
              │   │   │  • HITL approval gates    │                     │                    │  │
              │   │   │  • Blast radius controls  │                     │                    │  │
              │   │   │  • Tool poisoning protect │                     │                    │  │
              │   │   └──────────────────────────┘                     │                    │  │
              │   │                                                    │                    │  │
              │   └────────────────────────────────────────────────────┼────────────────────┘  │
              │                    DATA PLANE                          │                       │
              │                                                       │                       │
              │   ┌───────────────────────────────────────────────────┼────────────────────┐  │
              │   │                 INFRASTRUCTURE                    │                    │  │
              │   │                                                   │                    │  │
              │   │  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌───────┴──────┐             │  │
              │   │  │  Redis   │ │ClickHouse│ │  Qdrant  │ │   Keycloak   │             │  │
              │   │  │  :6379   │ │  :8123   │ │  :6333   │ │    :8081     │             │  │
              │   │  │          │ │          │ │          │ │              │             │  │
              │   │  │ • Rate   │ │ • Request│ │ • Semantic│ │ • JWT issuer │             │  │
              │   │  │   limits │ │   logs   │ │   cache  │ │ • Realm/user │             │  │
              │   │  │ • Budgets│ │ • AI logs│ │   vectors│ │   management │             │  │
              │   │  │ • Session│ │ • Agent  │ │          │ │ • OIDC/SAML  │             │  │
              │   │  │   state  │ │   audit  │ │          │ │ • IdP broker │             │  │
              │   │  │ • Tenant │ │ • Mater. │ │          │ │              │             │  │
              │   │  │   config │ │   views  │ │          │ │              │             │  │
              │   │  └──────────┘ └──────────┘ └──────────┘ └──────────────┘             │  │
              │   │                                                                      │  │
              │   │  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────┐             │  │
              │   │  │   etcd   │ │Prometheus│ │  Grafana  │ │    Jaeger    │             │  │
              │   │  │  :2379   │ │  :9090   │ │  :3002   │ │   :16686     │             │  │
              │   │  │          │ │          │ │          │ │              │             │  │
              │   │  │ • APISIX │ │ • Metrics│ │ • Dashbds│ │ • Distrib.  │             │  │
              │   │  │   config │ │   from   │ │   (4 per │ │   tracing   │             │  │
              │   │  │   store  │ │   L1+L2  │ │   layer) │ │   L1→L2→L3  │             │  │
              │   │  │          │ │   +L3    │ │          │ │              │             │  │
              │   │  └──────────┘ └──────────┘ └──────────┘ └──────────────┘             │  │
              │   │                                                                      │  │
              │   └──────────────────────────────────────────────────────────────────────┘  │
              │                                                                             │
              └─────────────────────────────────────────────────────────────────────────────┘
                                         ON-PREMISES / PRIVATE CLOUD
                                      (Everything runs from container images)

Request Flow — API Call Through All 3 Layers

Data Isolation — Per-Tenant Architecture

Every data store isolates by tenant_id. No shared state leaks across tenants.

LayerIsolation Method
APISIXJWT claim extracts tenant_id → independent rate limit bucket per tenant
RedisKey prefix: {tenant_id}:budget:*, rl:{tenant_id}:*, policy:tenant:{tenant_id}
ClickHouseShared tables, WHERE tenant_id = '...' filter on every query
KeycloakGroups in shared gateway realm, or separate realms per tenant
Agent GatewaySessions scoped by tenant, tool allowlists per tenant, cross-tenant blocked

Port Map

ServiceInternal PortExternal PortPurpose
APISIX (proxy)90809080API traffic entry point
APISIX (admin)91809180Route/plugin management
APISIX (metrics)90919091Prometheus scrape
AI Gateway40004000LLM routing + cache + PII
Agent Gateway50005001MCP + A2A + sessions
Control Plane API40014001Coordinates all services
Operator Portal30033003Platform admin UI
Developer Portal30043004Tenant user UI
Redis63796380State store
ClickHouse81238123Analytics + audit
Keycloak80808081Identity + auth
Qdrant63336333Vector similarity cache
Prometheus90909090Metrics collection
Grafana30003002Dashboards
Jaeger1668616686Distributed tracing
etcd23792379APISIX config store
OTel Collector43174317Trace collection

Technology Stack

LayerTechnologyLanguageWhy
L1 API GatewayApache APISIXLua (plugins)50k TPS, battle-tested, plugin ecosystem
L2 AI GatewayCustom (axum)RustSub-ms overhead, zero-copy streaming
L3 Agent GatewayCustom (axum)RustSession state + protocol handling at speed
Control Plane APICustom (axum)RustCoordinates all services, same stack
Operator PortalReact + ViteTypeScript16-page admin console
Developer PortalReact + ViteTypeScript4-page tenant self-service
IdentityKeycloakJavaEnterprise IdP, OIDC/SAML/LDAP
AnalyticsClickHouseSQL50k+ writes/sec, columnar queries
CacheRedis-Rate limits, budgets, sessions, config
Vector SearchQdrantRustSemantic cache similarity
ObservabilityOTel + Prometheus + Grafana + Jaeger-Full stack, cross-layer tracing

Enterprise API + AI + Agent Gateway