# freepik-company/customrouter architecture

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

- Interactive diagram: https://gitdiagram.com/freepik-company/customrouter
- Repository: https://github.com/freepik-company/customrouter

## Overview

CustomRouter is a Kubernetes operator plus an Envoy external processor for dynamic HTTP routing. Users define CustomHTTPRoute rules and an ExternalProcessorAttachment; the operator compiles routing rules into ConfigMaps and generates EnvoyFilters to connect an Istio gateway to the processor. The processor loads and matches routes, then returns routing decisions to Envoy for backend forwarding. The README documents the main control-plane flow; sampled source confirms server setup and ConfigMap loading, while several controller internals were not sampled.

Main entry points: [`internal/controller/customhttproute/sync.go`](https://github.com/freepik-company/customrouter/blob/master/internal/controller/customhttproute/sync.go) (Route reconciliation), [`api/v1alpha1/customhttproute_types.go`](https://github.com/freepik-company/customrouter/blob/master/api/v1alpha1/customhttproute_types.go) (CustomHTTPRoute API), [`internal/controller/externalprocessorattachment/sync.go`](https://github.com/freepik-company/customrouter/blob/master/internal/controller/externalprocessorattachment/sync.go) (Attachment reconciliation), [`pkg/routes/k8s_loader.go`](https://github.com/freepik-company/customrouter/blob/master/pkg/routes/k8s_loader.go) (ConfigMap route loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Kubernetes control plane"]
  node_custom_routes["CustomHTTPRoute API"]
  node_attachment_api["Processor attachment API"]
  node_route_webhook["Route admission"]
  node_operator["Operator manager<br/>[main.go]"]
  node_attachment_reconcile["Attachment reconciliation<br/>[sync.go]"]
  node_filter_builder["EnvoyFilter generation<br/>[envoyfilter.go]"]
end

subgraph group_compile["Route compilation"]
  node_route_reconcile["Route reconciliation<br/>[sync.go]"]
  node_route_expansion["Route expansion<br/>[expand.go]"]
  node_route_config[("Route ConfigMaps<br/>[sync.go]")]
end

subgraph group_processor["External processor"]
  node_extproc_entry["Processor startup<br/>[server.go]"]
  node_route_loader["ConfigMap route loader<br/>[k8s_loader.go]"]
  node_route_matcher["Request routing<br/>[router.go]"]
end

subgraph group_dataplane["Gateway dataplane"]
  node_envoy_filters["EnvoyFilter resources"]
  node_gateway["Istio gateway"]
  node_backend_services["Backend services"]
end

node_route_author(("Route author"))

node_route_author -->|"defines rules"| node_custom_routes
node_route_author -->|"configures attachment"| node_attachment_api
node_custom_routes -->|"admission validation"| node_route_webhook
node_operator -.->|"runs reconciliation"| node_route_reconcile
node_operator -.->|"runs reconciliation"| node_attachment_reconcile
node_custom_routes -->|"watched by"| node_route_reconcile
node_attachment_api -->|"watched by"| node_attachment_reconcile
node_route_reconcile -.->|"expands rules"| node_route_expansion
node_route_reconcile -->|"writes routes"| node_route_config
node_attachment_reconcile -.->|"builds filters"| node_filter_builder
node_filter_builder -->|"generates filters"| node_envoy_filters
node_envoy_filters -->|"configures gateway"| node_gateway
node_gateway -->|"ext_proc call"| node_extproc_entry
node_extproc_entry -->|"creates loader"| node_route_loader
node_route_config -->|"loads routes"| node_route_loader
node_route_loader -->|"provides routes"| node_route_matcher
node_route_matcher -->|"returns routing decision"| node_gateway
node_gateway -->|"forwards traffic"| node_backend_services

click node_custom_routes "https://github.com/freepik-company/customrouter/blob/master/api/v1alpha1/customhttproute_types.go"
click node_attachment_api "https://github.com/freepik-company/customrouter/blob/master/api/v1alpha1/externalprocessorattachment_types.go"
click node_route_webhook "https://github.com/freepik-company/customrouter/blob/master/internal/webhook/customhttproute_webhook.go"
click node_operator "https://github.com/freepik-company/customrouter/blob/master/cmd/main.go"
click node_route_reconcile "https://github.com/freepik-company/customrouter/blob/master/internal/controller/customhttproute/sync.go"
click node_route_expansion "https://github.com/freepik-company/customrouter/blob/master/pkg/routes/expand.go"
click node_route_config "https://github.com/freepik-company/customrouter/blob/master/internal/controller/customhttproute/sync.go"
click node_attachment_reconcile "https://github.com/freepik-company/customrouter/blob/master/internal/controller/externalprocessorattachment/sync.go"
click node_filter_builder "https://github.com/freepik-company/customrouter/blob/master/internal/controller/envoyfilter/envoyfilter.go"
click node_extproc_entry "https://github.com/freepik-company/customrouter/blob/master/internal/extproc/server.go"
click node_route_loader "https://github.com/freepik-company/customrouter/blob/master/pkg/routes/k8s_loader.go"
click node_route_matcher "https://github.com/freepik-company/customrouter/blob/master/internal/extproc/router.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_custom_routes,node_attachment_api,node_route_webhook,node_operator,node_attachment_reconcile,node_filter_builder toneBlue
class node_route_reconcile,node_route_expansion,node_route_config toneAmber
class node_extproc_entry,node_route_loader,node_route_matcher,node_route_author toneMint
class node_envoy_filters,node_gateway,node_backend_services toneRose
```

## Components

### Kubernetes control plane

- [CustomHTTPRoute API](https://github.com/freepik-company/customrouter/blob/master/api/v1alpha1/customhttproute_types.go): `api/v1alpha1/customhttproute_types.go`
- [Processor attachment API](https://github.com/freepik-company/customrouter/blob/master/api/v1alpha1/externalprocessorattachment_types.go): `api/v1alpha1/externalprocessorattachment_types.go`
- [Route admission](https://github.com/freepik-company/customrouter/blob/master/internal/webhook/customhttproute_webhook.go): `internal/webhook/customhttproute_webhook.go`
- [Operator manager](https://github.com/freepik-company/customrouter/blob/master/cmd/main.go): `cmd/main.go`
- [Attachment reconciliation](https://github.com/freepik-company/customrouter/blob/master/internal/controller/externalprocessorattachment/sync.go): `internal/controller/externalprocessorattachment/sync.go`
- [EnvoyFilter generation](https://github.com/freepik-company/customrouter/blob/master/internal/controller/envoyfilter/envoyfilter.go): `internal/controller/envoyfilter/envoyfilter.go`

### Route compilation

- [Route reconciliation](https://github.com/freepik-company/customrouter/blob/master/internal/controller/customhttproute/sync.go): `internal/controller/customhttproute/sync.go`
- [Route expansion](https://github.com/freepik-company/customrouter/blob/master/pkg/routes/expand.go): `pkg/routes/expand.go`
- [Route ConfigMaps](https://github.com/freepik-company/customrouter/blob/master/internal/controller/customhttproute/sync.go): `internal/controller/customhttproute/sync.go`

### External processor

- [Processor startup](https://github.com/freepik-company/customrouter/blob/master/internal/extproc/server.go): `internal/extproc/server.go`
- [ConfigMap route loader](https://github.com/freepik-company/customrouter/blob/master/pkg/routes/k8s_loader.go): `pkg/routes/k8s_loader.go`
- [Request routing](https://github.com/freepik-company/customrouter/blob/master/internal/extproc/router.go): `internal/extproc/router.go`

### Gateway dataplane

- **EnvoyFilter resources**
- **Istio gateway**
- **Backend services**

### Other components

- **Route author**

## Connections

- Route author → CustomHTTPRoute API: defines rules (evidence: `README.md`)
- Route author → Processor attachment API: configures attachment (evidence: `README.md`)
- CustomHTTPRoute API → Route admission: admission validation (evidence: `internal/webhook/customhttproute_webhook.go`)
- Operator manager → Route reconciliation: runs reconciliation
- Operator manager → Attachment reconciliation: runs reconciliation
- CustomHTTPRoute API → Route reconciliation: watched by (evidence: `README.md`)
- Processor attachment API → Attachment reconciliation: watched by (evidence: `README.md`)
- Route reconciliation → Route expansion: expands rules
- Route reconciliation → Route ConfigMaps: writes routes (evidence: `README.md`)
- Attachment reconciliation → EnvoyFilter generation: builds filters
- EnvoyFilter generation → EnvoyFilter resources: generates filters (evidence: `README.md`)
- EnvoyFilter resources → Istio gateway: configures gateway (evidence: `README.md`)
- Istio gateway → Processor startup: ext_proc call (evidence: `README.md`)
- Processor startup → ConfigMap route loader: creates loader (evidence: `internal/extproc/server.go`)
- Route ConfigMaps → ConfigMap route loader: loads routes (evidence: `README.md`)
- ConfigMap route loader → Request routing: provides routes (evidence: `internal/extproc/router.go`)
- Request routing → Istio gateway: returns routing decision (evidence: `README.md`)
- Istio gateway → Backend services: forwards traffic (evidence: `README.md`)
