# shenseanchen/waku-agent architecture

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

- Interactive diagram: https://gitdiagram.com/shenseanchen/waku-agent
- Repository: https://github.com/shenseanchen/waku-agent

## Overview

Waku is a local-first personal AI assistant: a user sends a message through a terminal or other gateway, the app assembles configuration, memory, tools, and a model client, and the agent loop returns a response while emitting trace data. Memory retrieval and consolidation, graph workflows, dashboard/voice interfaces, and evaluation are meaningful branches of that workflow. The tree and excerpts also show a distinct hosted multi-tenant platform. Some subsystem links are documented by the README or source index; unsampled implementation details are not inferred.

Main entry points: [`waku/app.py`](https://github.com/shenseanchen/waku-agent/blob/main/waku/app.py) (Waku App), [`waku/memory/brain.py`](https://github.com/shenseanchen/waku-agent/blob/main/waku/memory/brain.py) (Memory Brain), [`hosted/gateway/app.py`](https://github.com/shenseanchen/waku-agent/blob/main/hosted/gateway/app.py) (Hosted Gateway), [`waku/loop/agent.py`](https://github.com/shenseanchen/waku-agent/blob/main/waku/loop/agent.py) (Agent Loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["Assistant Interfaces"]
  node_gateways["Chat Gateways"]
  node_dashboard["Dashboard<br/>[dashboard.py]"]
  node_voice["Voice Gateway<br/>[voice.py]"]
end

subgraph group_runtime["Agent Runtime"]
  node_app["Waku App<br/>[app.py]"]
  node_config["Configuration<br/>[config.py]"]
  node_loop["Agent Loop<br/>[agent.py]"]
  node_models["Model Adapters<br/>[models.py]"]
  node_tools["Tool Registry<br/>[registry.py]"]
  node_workflows["Graph Workflows<br/>[triage.py]"]
  node_graph_engine["Graph Engine<br/>[engine.py]"]
  node_session["Runtime Session<br/>[session.py]"]
end

subgraph group_memory["Memory"]
  node_memory["Memory Brain<br/>[brain.py]"]
  node_memory_gates["Memory Gates<br/>[retrieval_gate.py]"]
  node_consolidation["Memory Consolidation<br/>[consolidation.py]"]
  node_memory_stores[("Memory Stores<br/>[store.py]")]
  node_episodic_store[("Episodic Store<br/>[store.py]")]
  node_procedural_skills["Procedural Skills<br/>[loader.py]"]
  node_state_db[("Local State DB<br/>[db.py]")]
end

subgraph group_ops["Operations"]
  node_tracing["Turn Tracing<br/>[tracing.py]"]
  node_observability["Observability<br/>[observability.py]"]
  node_evals["Eval and Release Gate<br/>[turn_evals.py]"]
end

subgraph group_hosted["Hosted Platform"]
  node_hosted_gateway["Hosted Gateway<br/>[app.py]"]
  node_tenant_core["Tenant Core<br/>[tenant.py]"]
  node_hosted_store[("Control Store<br/>[store.py]")]
  node_launcher["Container Launcher<br/>[launch.py]"]
  node_spawner_client["Spawner Client<br/>[spawner_client.py]"]
  node_spawner["Container Spawner<br/>[service.py]"]
  node_docker_runtime["Docker Runtime<br/>[docker.py]"]
  node_proxy["Metering Proxy<br/>[app.py]"]
end

node_user(("User"))
node_external_model(("Model Provider"))

node_user -->|"sends message"| node_gateways
node_gateways -->|"calls respond"| node_app
node_user -->|"uses cockpit"| node_dashboard
node_dashboard -->|"invokes agent"| node_app
node_voice -->|"calls assistant"| node_app
node_app -->|"loads settings"| node_config
node_app -->|"opens state"| node_state_db
node_app -->|"assembles tools"| node_tools
node_app -->|"assembles memory"| node_memory
node_app -->|"creates session"| node_session
node_app -->|"runs turn"| node_loop
node_app -->|"tries triage"| node_workflows
node_app -->|"records turn"| node_tracing
node_loop -->|"executes tools"| node_tools
node_loop -.->|"requests completion"| node_external_model
node_models -->|"reads provider settings"| node_config
node_workflows -->|"runs graph"| node_graph_engine
node_session -->|"reads settings"| node_config
node_memory -->|"uses retrieval gate"| node_memory_gates
node_memory -->|"uses consolidation"| node_consolidation
node_memory -->|"configures semantic store"| node_memory_stores
node_memory -->|"configures episodic store"| node_episodic_store
node_memory -->|"loads skills"| node_procedural_skills
node_tracing -->|"emits events"| node_observability
node_evals -.->|"uses turn traces"| node_tracing
node_user -.->|"uses hosted service"| node_hosted_gateway
node_hosted_gateway -->|"uses tenant rules"| node_tenant_core
node_hosted_gateway -->|"uses control store"| node_hosted_store
node_hosted_gateway -->|"dispatches launches"| node_launcher
node_launcher -->|"requests containers"| node_spawner_client
node_spawner_client -->|"sends socket requests"| node_spawner
node_spawner -->|"dispatches operations"| node_docker_runtime
node_docker_runtime -.->|"hosts tenant agent"| node_external_model
node_external_model -.->|"sends metered calls"| node_proxy

click node_gateways "https://github.com/shenseanchen/waku-agent/tree/main/waku/gateway"
click node_dashboard "https://github.com/shenseanchen/waku-agent/blob/main/waku/ops/dashboard.py"
click node_voice "https://github.com/shenseanchen/waku-agent/blob/main/waku/gateway/voice.py"
click node_app "https://github.com/shenseanchen/waku-agent/blob/main/waku/app.py"
click node_config "https://github.com/shenseanchen/waku-agent/blob/main/waku/config.py"
click node_loop "https://github.com/shenseanchen/waku-agent/blob/main/waku/loop/agent.py"
click node_models "https://github.com/shenseanchen/waku-agent/blob/main/waku/loop/models.py"
click node_tools "https://github.com/shenseanchen/waku-agent/blob/main/waku/tools/registry.py"
click node_workflows "https://github.com/shenseanchen/waku-agent/blob/main/waku/graph/workflows/triage.py"
click node_graph_engine "https://github.com/shenseanchen/waku-agent/blob/main/waku/graph/engine.py"
click node_session "https://github.com/shenseanchen/waku-agent/blob/main/waku/runtime/session.py"
click node_memory "https://github.com/shenseanchen/waku-agent/blob/main/waku/memory/brain.py"
click node_memory_gates "https://github.com/shenseanchen/waku-agent/blob/main/waku/memory/retrieval_gate.py"
click node_consolidation "https://github.com/shenseanchen/waku-agent/blob/main/waku/memory/consolidation.py"
click node_memory_stores "https://github.com/shenseanchen/waku-agent/blob/main/waku/memory/semantic/store.py"
click node_episodic_store "https://github.com/shenseanchen/waku-agent/blob/main/waku/memory/episodic/store.py"
click node_procedural_skills "https://github.com/shenseanchen/waku-agent/blob/main/waku/memory/procedural/loader.py"
click node_state_db "https://github.com/shenseanchen/waku-agent/blob/main/waku/db.py"
click node_tracing "https://github.com/shenseanchen/waku-agent/blob/main/waku/ops/tracing.py"
click node_observability "https://github.com/shenseanchen/waku-agent/blob/main/waku/ops/observability.py"
click node_evals "https://github.com/shenseanchen/waku-agent/blob/main/waku/ops/turn_evals.py"
click node_hosted_gateway "https://github.com/shenseanchen/waku-agent/blob/main/hosted/gateway/app.py"
click node_tenant_core "https://github.com/shenseanchen/waku-agent/blob/main/hosted/core/tenant.py"
click node_hosted_store "https://github.com/shenseanchen/waku-agent/blob/main/hosted/gateway/store.py"
click node_launcher "https://github.com/shenseanchen/waku-agent/blob/main/hosted/gateway/launch.py"
click node_spawner_client "https://github.com/shenseanchen/waku-agent/blob/main/hosted/gateway/spawner_client.py"
click node_spawner "https://github.com/shenseanchen/waku-agent/blob/main/hosted/spawner/service.py"
click node_docker_runtime "https://github.com/shenseanchen/waku-agent/blob/main/hosted/spawner/docker.py"
click node_proxy "https://github.com/shenseanchen/waku-agent/blob/main/hosted/proxy/app.py"

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_gateways,node_dashboard,node_voice,node_user toneBlue
class node_app,node_config,node_loop,node_models,node_tools,node_workflows,node_graph_engine,node_session toneAmber
class node_memory,node_memory_gates,node_consolidation,node_memory_stores,node_episodic_store,node_procedural_skills,node_state_db toneMint
class node_tracing,node_observability,node_evals toneRose
class node_hosted_gateway,node_tenant_core,node_hosted_store,node_launcher,node_spawner_client,node_spawner,node_docker_runtime,node_proxy,node_external_model toneIndigo
```

## Components

### Assistant Interfaces

- [Chat Gateways](https://github.com/shenseanchen/waku-agent/tree/main/waku/gateway): `waku/gateway`
- [Dashboard](https://github.com/shenseanchen/waku-agent/blob/main/waku/ops/dashboard.py): `waku/ops/dashboard.py`
- [Voice Gateway](https://github.com/shenseanchen/waku-agent/blob/main/waku/gateway/voice.py): `waku/gateway/voice.py`

### Agent Runtime

- [Waku App](https://github.com/shenseanchen/waku-agent/blob/main/waku/app.py): `waku/app.py`
- [Configuration](https://github.com/shenseanchen/waku-agent/blob/main/waku/config.py): `waku/config.py`
- [Agent Loop](https://github.com/shenseanchen/waku-agent/blob/main/waku/loop/agent.py): `waku/loop/agent.py`
- [Model Adapters](https://github.com/shenseanchen/waku-agent/blob/main/waku/loop/models.py): `waku/loop/models.py`
- [Tool Registry](https://github.com/shenseanchen/waku-agent/blob/main/waku/tools/registry.py): `waku/tools/registry.py`
- [Graph Workflows](https://github.com/shenseanchen/waku-agent/blob/main/waku/graph/workflows/triage.py): `waku/graph/workflows/triage.py`
- [Graph Engine](https://github.com/shenseanchen/waku-agent/blob/main/waku/graph/engine.py): `waku/graph/engine.py`
- [Runtime Session](https://github.com/shenseanchen/waku-agent/blob/main/waku/runtime/session.py): `waku/runtime/session.py`

### Memory

- [Memory Brain](https://github.com/shenseanchen/waku-agent/blob/main/waku/memory/brain.py): `waku/memory/brain.py`
- [Memory Gates](https://github.com/shenseanchen/waku-agent/blob/main/waku/memory/retrieval_gate.py): `waku/memory/retrieval_gate.py`
- [Memory Consolidation](https://github.com/shenseanchen/waku-agent/blob/main/waku/memory/consolidation.py): `waku/memory/consolidation.py`
- [Memory Stores](https://github.com/shenseanchen/waku-agent/blob/main/waku/memory/semantic/store.py): `waku/memory/semantic/store.py`
- [Episodic Store](https://github.com/shenseanchen/waku-agent/blob/main/waku/memory/episodic/store.py): `waku/memory/episodic/store.py`
- [Procedural Skills](https://github.com/shenseanchen/waku-agent/blob/main/waku/memory/procedural/loader.py): `waku/memory/procedural/loader.py`
- [Local State DB](https://github.com/shenseanchen/waku-agent/blob/main/waku/db.py): `waku/db.py`

### Operations

- [Turn Tracing](https://github.com/shenseanchen/waku-agent/blob/main/waku/ops/tracing.py): `waku/ops/tracing.py`
- [Observability](https://github.com/shenseanchen/waku-agent/blob/main/waku/ops/observability.py): `waku/ops/observability.py`
- [Eval and Release Gate](https://github.com/shenseanchen/waku-agent/blob/main/waku/ops/turn_evals.py): `waku/ops/turn_evals.py`

### Hosted Platform

- [Hosted Gateway](https://github.com/shenseanchen/waku-agent/blob/main/hosted/gateway/app.py): `hosted/gateway/app.py`
- [Tenant Core](https://github.com/shenseanchen/waku-agent/blob/main/hosted/core/tenant.py): `hosted/core/tenant.py`
- [Control Store](https://github.com/shenseanchen/waku-agent/blob/main/hosted/gateway/store.py): `hosted/gateway/store.py`
- [Container Launcher](https://github.com/shenseanchen/waku-agent/blob/main/hosted/gateway/launch.py): `hosted/gateway/launch.py`
- [Spawner Client](https://github.com/shenseanchen/waku-agent/blob/main/hosted/gateway/spawner_client.py): `hosted/gateway/spawner_client.py`
- [Container Spawner](https://github.com/shenseanchen/waku-agent/blob/main/hosted/spawner/service.py): `hosted/spawner/service.py`
- [Docker Runtime](https://github.com/shenseanchen/waku-agent/blob/main/hosted/spawner/docker.py): `hosted/spawner/docker.py`
- [Metering Proxy](https://github.com/shenseanchen/waku-agent/blob/main/hosted/proxy/app.py): `hosted/proxy/app.py`

### Other components

- **User**
- **Model Provider**

## Connections

- User → Chat Gateways: sends message (evidence: `README.md`)
- Chat Gateways → Waku App: calls respond (evidence: `waku/app.py`)
- User → Dashboard: uses cockpit (evidence: `README.md`)
- Dashboard → Waku App: invokes agent (evidence: `waku/ops/dashboard.py`)
- Voice Gateway → Waku App: calls assistant (evidence: `waku/gateway/voice.py`)
- Waku App → Configuration: loads settings (evidence: `waku/app.py`)
- Waku App → Local State DB: opens state (evidence: `waku/app.py`)
- Waku App → Tool Registry: assembles tools (evidence: `waku/app.py`)
- Waku App → Memory Brain: assembles memory (evidence: `waku/app.py`)
- Waku App → Runtime Session: creates session (evidence: `waku/app.py`)
- Waku App → Agent Loop: runs turn (evidence: `waku/app.py`)
- Waku App → Graph Workflows: tries triage (evidence: `waku/app.py`)
- Waku App → Turn Tracing: records turn (evidence: `waku/app.py`)
- Agent Loop → Tool Registry: executes tools (evidence: `waku/loop/agent.py`)
- Agent Loop → Model Provider: requests completion (evidence: `waku/loop/agent.py`)
- Model Adapters → Configuration: reads provider settings (evidence: `waku/loop/models.py`)
- Graph Workflows → Graph Engine: runs graph (evidence: `waku/graph/workflows/triage.py`)
- Runtime Session → Configuration: reads settings (evidence: `waku/runtime/session.py`)
- Memory Brain → Memory Gates: uses retrieval gate
- Memory Brain → Memory Consolidation: uses consolidation
- Memory Brain → Memory Stores: configures semantic store
- Memory Brain → Episodic Store: configures episodic store
- Memory Brain → Procedural Skills: loads skills
- Turn Tracing → Observability: emits events (evidence: `waku/ops/tracing.py`)
- Eval and Release Gate → Turn Tracing: uses turn traces (evidence: `README.md`)
- User → Hosted Gateway: uses hosted service (evidence: `README.md`)
- Hosted Gateway → Tenant Core: uses tenant rules (evidence: `hosted/gateway/app.py`)
- Hosted Gateway → Control Store: uses control store (evidence: `hosted/gateway/app.py`)
- Hosted Gateway → Container Launcher: dispatches launches (evidence: `hosted/gateway/app.py`)
- Container Launcher → Spawner Client: requests containers (evidence: `hosted/gateway/launch.py`)
- Spawner Client → Container Spawner: sends socket requests (evidence: `hosted/gateway/spawner_client.py`)
- Container Spawner → Docker Runtime: dispatches operations (evidence: `hosted/spawner/service.py`)
- Docker Runtime → Model Provider: hosts tenant agent
- Model Provider → Metering Proxy: sends metered calls (evidence: `hosted/proxy/app.py`)
