# daeuniverse/dae architecture

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

- Interactive diagram: https://gitdiagram.com/daeuniverse/dae
- Repository: https://github.com/daeuniverse/dae

## Overview

dae is a Linux transparent proxy that splits traffic using eBPF and userspace forwarding. The principal workflow is configuration loading, policy construction, packet interception and routing, then direct or proxy egress; DNS has its own request, upstream, response, and cache stages. Runtime reloads replace policy generations while the session manager preserves established flows. The README documents process/MAC rules, automatic node selection, DNS, and proxy protocols. Some subsystem links are documented rather than verified in sampled callers; those are marked dashed.

Main entry points: [`control/dns_controller_handle.go`](https://github.com/daeuniverse/dae/blob/main/control/dns_controller_handle.go) (DNS controller), [`control/control_plane.go`](https://github.com/daeuniverse/dae/blob/main/control/control_plane.go) (Control plane), [`main.go`](https://github.com/daeuniverse/dae/blob/main/main.go) (CLI entry), [`cmd/run_reload_worker.go`](https://github.com/daeuniverse/dae/blob/main/cmd/run_reload_worker.go) (Reload worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime lifecycle"]
  node_entry["CLI entry<br/>[main.go]"]
  node_config["Config parser<br/>[parser.go]"]
  node_reload["Reload manager<br/>[reload_manager.go]"]
  node_reloadworker["Reload worker"]
  node_controlplane["Control plane<br/>[control_plane.go]"]
  node_sessions["Flow sessions<br/>[session_manager.go]"]
end

subgraph group_policy["Policy and routing"]
  node_routing["Traffic policy<br/>[ir.go]"]
end

subgraph group_traffic["Traffic forwarding"]
  node_outbounds["Outbound groups<br/>[dialer_group.go]"]
  node_dialer["Proxy dialers<br/>[dialer.go]"]
  node_health["Node health checks"]
  node_sniff["Protocol sniffing<br/>[sniffer.go]"]
end

subgraph group_dns["DNS services"]
  node_dnscontroller["DNS controller"]
  node_dnscache[("DNS cache")]
  node_dnsrequest["Request routing<br/>[request_routing.go]"]
  node_dnsresponse["Response routing"]
  node_dnsrouter["DNS upstream router<br/>[router.go]"]
  node_dnsclient["DNS client<br/>[client.go]"]
  node_dnstransport["DNS transports<br/>[wire.go]"]
end

subgraph group_kernel["Kernel datapath"]
  node_kernel{{"eBPF datapath<br/>[tproxy.c]"}}
  node_trace["Kernel tracing<br/>[trace.go]"]
end

node_user(("Operator"))

node_user -->|"runs"| node_entry
node_entry -.->|"loads config"| node_config
node_entry -.->|"starts runtime"| node_reload
node_reload -->|"queues reload"| node_reloadworker
node_reloadworker -->|"loads config"| node_config
node_reloadworker -->|"prepares generation"| node_controlplane
node_controlplane -.->|"uses sessions"| node_sessions
node_config -.->|"defines rules"| node_routing
node_controlplane -.->|"installs datapath"| node_kernel
node_controlplane -.->|"configures DNS"| node_dnscontroller
node_routing -.->|"selects egress"| node_outbounds
node_outbounds -->|"dispatches"| node_dialer
node_health -.->|"informs selection"| node_outbounds
node_sniff -.->|"supplies traffic metadata"| node_routing
node_dnscontroller -->|"reads and writes"| node_dnscache
node_dnscontroller -.->|"routes queries"| node_dnsrequest
node_dnscontroller -.->|"routes replies"| node_dnsresponse
node_dnscontroller -->|"resolves upstream"| node_dnsrouter
node_dnsrouter -->|"queries upstream"| node_dnsclient
node_dnsclient -->|"sends DNS"| node_dnstransport
node_kernel -.->|"supports tracing"| node_trace

click node_entry "https://github.com/daeuniverse/dae/blob/main/main.go"
click node_config "https://github.com/daeuniverse/dae/blob/main/config/parser.go"
click node_reload "https://github.com/daeuniverse/dae/blob/main/cmd/reload_manager.go"
click node_reloadworker "https://github.com/daeuniverse/dae/blob/main/cmd/run_reload_worker.go"
click node_controlplane "https://github.com/daeuniverse/dae/blob/main/control/control_plane.go"
click node_sessions "https://github.com/daeuniverse/dae/blob/main/control/session_manager.go"
click node_routing "https://github.com/daeuniverse/dae/blob/main/component/routing/ir.go"
click node_outbounds "https://github.com/daeuniverse/dae/blob/main/component/outbound/dialer_group.go"
click node_dialer "https://github.com/daeuniverse/dae/blob/main/component/outbound/dialer/dialer.go"
click node_health "https://github.com/daeuniverse/dae/blob/main/component/outbound/dialer/connectivity_check.go"
click node_sniff "https://github.com/daeuniverse/dae/blob/main/component/sniffing/sniffer.go"
click node_dnscontroller "https://github.com/daeuniverse/dae/blob/main/control/dns_controller_handle.go"
click node_dnscache "https://github.com/daeuniverse/dae/blob/main/control/dns_controller_cache.go"
click node_dnsrequest "https://github.com/daeuniverse/dae/blob/main/component/dns/request_routing.go"
click node_dnsresponse "https://github.com/daeuniverse/dae/blob/main/component/dns/response_routing.go"
click node_dnsrouter "https://github.com/daeuniverse/dae/blob/main/component/daedns/router.go"
click node_dnsclient "https://github.com/daeuniverse/dae/blob/main/component/daedns/client.go"
click node_dnstransport "https://github.com/daeuniverse/dae/blob/main/component/dnstransport/wire.go"
click node_kernel "https://github.com/daeuniverse/dae/blob/main/control/kern/tproxy.c"
click node_trace "https://github.com/daeuniverse/dae/blob/main/trace/trace.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_entry,node_config,node_reload,node_reloadworker,node_controlplane,node_sessions toneBlue
class node_routing toneAmber
class node_outbounds,node_dialer,node_health,node_sniff toneMint
class node_dnscontroller,node_dnscache,node_dnsrequest,node_dnsresponse,node_dnsrouter,node_dnsclient,node_dnstransport toneRose
class node_kernel,node_trace,node_user toneIndigo
```

## Components

### Runtime lifecycle

- [CLI entry](https://github.com/daeuniverse/dae/blob/main/main.go): `main.go`
- [Config parser](https://github.com/daeuniverse/dae/blob/main/config/parser.go): `config/parser.go`
- [Reload manager](https://github.com/daeuniverse/dae/blob/main/cmd/reload_manager.go): `cmd/reload_manager.go`
- [Reload worker](https://github.com/daeuniverse/dae/blob/main/cmd/run_reload_worker.go): `cmd/run_reload_worker.go`
- [Control plane](https://github.com/daeuniverse/dae/blob/main/control/control_plane.go): `control/control_plane.go`
- [Flow sessions](https://github.com/daeuniverse/dae/blob/main/control/session_manager.go): `control/session_manager.go`

### Policy and routing

- [Traffic policy](https://github.com/daeuniverse/dae/blob/main/component/routing/ir.go): `component/routing/ir.go`

### Traffic forwarding

- [Outbound groups](https://github.com/daeuniverse/dae/blob/main/component/outbound/dialer_group.go): `component/outbound/dialer_group.go`
- [Proxy dialers](https://github.com/daeuniverse/dae/blob/main/component/outbound/dialer/dialer.go): `component/outbound/dialer/dialer.go`
- [Node health checks](https://github.com/daeuniverse/dae/blob/main/component/outbound/dialer/connectivity_check.go): `component/outbound/dialer/connectivity_check.go`
- [Protocol sniffing](https://github.com/daeuniverse/dae/blob/main/component/sniffing/sniffer.go): `component/sniffing/sniffer.go`

### DNS services

- [DNS controller](https://github.com/daeuniverse/dae/blob/main/control/dns_controller_handle.go): `control/dns_controller_handle.go`
- [DNS cache](https://github.com/daeuniverse/dae/blob/main/control/dns_controller_cache.go): `control/dns_controller_cache.go`
- [Request routing](https://github.com/daeuniverse/dae/blob/main/component/dns/request_routing.go): `component/dns/request_routing.go`
- [Response routing](https://github.com/daeuniverse/dae/blob/main/component/dns/response_routing.go): `component/dns/response_routing.go`
- [DNS upstream router](https://github.com/daeuniverse/dae/blob/main/component/daedns/router.go): `component/daedns/router.go`
- [DNS client](https://github.com/daeuniverse/dae/blob/main/component/daedns/client.go): `component/daedns/client.go`
- [DNS transports](https://github.com/daeuniverse/dae/blob/main/component/dnstransport/wire.go): `component/dnstransport/wire.go`

### Kernel datapath

- [eBPF datapath](https://github.com/daeuniverse/dae/blob/main/control/kern/tproxy.c): `control/kern/tproxy.c`
- [Kernel tracing](https://github.com/daeuniverse/dae/blob/main/trace/trace.go): `trace/trace.go`

### Other components

- **Operator**

## Connections

- Operator → CLI entry: runs (evidence: `main.go`)
- CLI entry → Config parser: loads config
- CLI entry → Reload manager: starts runtime
- Reload manager → Reload worker: queues reload (evidence: `cmd/reload_manager.go`)
- Reload worker → Config parser: loads config (evidence: `cmd/run_reload_worker.go`)
- Reload worker → Control plane: prepares generation (evidence: `cmd/run_reload_worker.go`)
- Control plane → Flow sessions: uses sessions
- Config parser → Traffic policy: defines rules
- Control plane → eBPF datapath: installs datapath
- Control plane → DNS controller: configures DNS
- Traffic policy → Outbound groups: selects egress
- Outbound groups → Proxy dialers: dispatches (evidence: `component/outbound/dialer_group.go`)
- Node health checks → Outbound groups: informs selection
- Protocol sniffing → Traffic policy: supplies traffic metadata
- DNS controller → DNS cache: reads and writes (evidence: `control/dns_controller_handle.go`)
- DNS controller → Request routing: routes queries
- DNS controller → Response routing: routes replies
- DNS controller → DNS upstream router: resolves upstream (evidence: `control/dns_controller_handle.go`)
- DNS upstream router → DNS client: queries upstream (evidence: `component/daedns/client.go`)
- DNS client → DNS transports: sends DNS (evidence: `component/daedns/client.go`)
- eBPF datapath → Kernel tracing: supports tracing
