# openabdev/openab architecture

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

- Interactive diagram: https://gitdiagram.com/openabdev/openab
- Repository: https://github.com/openabdev/openab

## Overview

#### Purpose and Entrypoints
OpenAB is a Rust “thin broker” that connects chat platforms to ACP-compatible coding agents. The primary executable starts from `src/main.rs`; it hosts Discord/Slack and optionally embedded gateway adapters. Core reusable broker logic is in `crates/openab-core/src/lib.rs`. Separate binaries provide the standalone gateway, native agent, control plane, ACP adapter, auth proxy, and ECS operator.

#### Broker Core: Inbound Turn to Agent Session
Platform events are normalized into dispatchable turns, then routed by thread/session identity to a pooled ACP agent process. The core boundary is ACP JSON-RPC over child-process stdio; chat-specific logic should not cross it.
- `crates/openab-core/src/dispatch.rs`
- `crates/openab-core/src/bot_turns.rs`
- `crates/openab-core/src/acp/pool.rs`
- `crates/openab-core/src/acp/connection.rs`

The pool owns one agent process per conversation thread, enforces concurrency and TTL, and streams agent output back through the originating adapter.

#### Native Chat Adapters and Reply Behavior
Discord and Slack are first-class in-process integrations. They enforce platform authorization/triggering, create or follow threads, render markdown/media, stream edits, and apply reactions. Agent output directives affect reply targeting and presentation before outbound delivery.
- `crates/openab-core/src/discord.rs`
- `crates/openab-core/src/slack.rs`
- `crates/openab-core/src/directives.rs`
- `crates/openab-core/src/format.rs`

#### Gateway Boundary for Additional Platforms
The gateway isolates webhook/API and platform protocol handling for Telegram, LINE, Feishu/Lark, Google Chat, WeCom, and Teams. It can run independently and communicate with OpenAB over WebSocket/ACP, or be linked into the unified binary. This preserves the same dispatcher-to-ACP boundary regardless of platform.
- `crates/openab-gateway/src/main.rs`
- `crates/openab-gateway/src/adapters/acp_server.rs`
- `crates/openab-gateway/src/adapters/telegram.rs`
- `src/unified_adapter.rs`

Gateway configuration/schema validation is formalized by `crates/openab-gateway/schemas/acp-v1.schema.json`.

#### Agent Backends and AgentCore
Configured agent commands run locally as ACP stdio processes, allowing multiple external CLIs without broker changes. ACP protocol, process launch, and remote AgentCore adaptation reside in core. AgentCore replaces the local CLI execution boundary with AWS Bedrock AgentCore runtime invocation.
- `crates/openab-core/src/acp/protocol.rs`
- `crates/openab-core/src/adapter.rs`
- `crates/openab-core/src/acp/agentcore.rs`
- `agentcore/runtimes/kiro/run.sh`

A native Rust agent is separately executable and exposes ACP, LLM, skills, and tools:
- `openab-agent/src/main.rs`
- `openab-agent/src/agent.rs`
- `openab-agent/src/mcp.rs`

#### MCP and Control-Plane Extensions
The MCP crate provides agent-facing tool/runtime integration, including auth, OAuth, native Gmail, LLM access, source discovery, and circuit breaking. The preview control plane is a separate WebSocket service for agent registration, routing, and policy-authorized delegation.
- `crates/openab-mcp/src/mcp/runtime.rs`
- `crates/openab-mcp/src/mcp/facade.rs`
- `crates/openab-cp/src/server.rs`
- `crates/openab-cp/src/router.rs`

#### State, Security, and Lifecycle
Configuration centralizes platform credentials, agent command, pool limits, and environment expansion. Persistent local storage supports auth/session-related data; secrets and trust checks form key security boundaries. Startup/shutdown hooks and cron jobs add operational automation outside message turns.
- `crates/openab-core/src/config.rs`
- `crates/openab-core/src/secrets.rs`
- `crates/openab-core/src/trust.rs`
- `crates/openab-core/src/cron.rs`

#### Deployment and Infrastructure
Container images package OpenAB with selected agent runtimes; Kubernetes deployment persists agent authentication under `/data` via PVC. Helm supports broker-plus-gateway deployment. AWS ECS/Fargate provisioning is managed by `oabctl`, including networking, IAM, S3, Cloud Map, API Gateway/VPC Link webhook ingress, and secrets.
- `Dockerfile`
- `charts/openab/templates/deployment.yaml`
- `k8s/deployment.yaml`
- `operator/src/control_plane.rs`

Main entry points: [`crates/openab-core/src/acp/pool.rs`](https://github.com/openabdev/openab/blob/main/crates/openab-core/src/acp/pool.rs) (ACP session pool), [`src/main.rs`](https://github.com/openabdev/openab/blob/main/src/main.rs) (OpenAB executable), [`crates/openab-core/src/lib.rs`](https://github.com/openabdev/openab/blob/main/crates/openab-core/src/lib.rs) (Broker core), [`crates/openab-core/src/directives.rs`](https://github.com/openabdev/openab/blob/main/crates/openab-core/src/directives.rs) (Reply directives & formatting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_broker["OpenAB Broker"]
  node_openab["OpenAB executable<br/>Rust binary<br/>[main.rs]"]
  node_core["Broker core<br/>Rust library<br/>[lib.rs]"]
  node_turns["Turn dispatch<br/>routing layer<br/>[dispatch.rs]"]
  node_bot_turns["Bot turns<br/>turn model<br/>[bot_turns.rs]"]
end

subgraph group_platforms["Platform Adapters"]
  node_discord["Discord adapter<br/>in-process adapter<br/>[discord.rs]"]
  node_slack["Slack adapter<br/>in-process adapter<br/>[slack.rs]"]
  node_presentation["Reply directives &amp; formatting<br/>presentation layer<br/>[directives.rs]"]
  node_gateway["Standalone gateway<br/>Rust binary<br/>[main.rs]"]
  node_gateway_acp["Gateway ACP server<br/>WebSocket/ACP adapter<br/>[acp_server.rs]"]
  node_telegram["Gateway platforms<br/>webhook/API adapters<br/>[telegram.rs]"]
end

subgraph group_agents["Agent Runtime"]
  node_agent_pool["ACP session pool<br/>process pool<br/>[pool.rs]"]
  node_acp_connection["ACP stdio connection<br/>JSON-RPC transport<br/>[connection.rs]"]
  node_agent_commands["Configured agent CLIs<br/>external processes<br/>[adapter.rs]"]
  node_agentcore["AWS AgentCore adapter<br/>remote runtime adapter<br/>[agentcore.rs]"]
  node_native_agent["Native Rust agent<br/>ACP binary<br/>[main.rs]"]
end

subgraph group_extensions["Extensions"]
  node_mcp["MCP runtime<br/>tool integration<br/>[runtime.rs]"]
  node_control_plane["Control plane<br/>WebSocket service<br/>[server.rs]"]
end

subgraph group_operations["Operations"]
  node_security["Secrets &amp; trust<br/>security boundary<br/>[secrets.rs]"]
  node_lifecycle["Lifecycle automation<br/>cron hooks<br/>[cron.rs]"]
  node_deployment["Container &amp; Kubernetes deployment<br/>deployment manifests<br/>[deployment.yaml]"]
  node_ecs_operator["ECS operator<br/>AWS provisioner<br/>[control_plane.rs]"]
end

node_openab -->|"hosts"| node_core
node_openab -->|"runs"| node_discord
node_openab -->|"runs"| node_slack
node_discord -->|"normalizes events"| node_bot_turns
node_slack -->|"normalizes events"| node_bot_turns
node_bot_turns -->|"dispatches"| node_turns
node_turns -->|"routes by thread"| node_agent_pool
node_agent_pool -->|"owns sessions"| node_acp_connection
node_acp_connection -->|"ACP over stdio"| node_agent_commands
node_agent_pool -.->|"optional remote backend"| node_agentcore
node_native_agent -->|"uses tools"| node_mcp
node_agent_commands -.->|"can access tools"| node_mcp
node_agent_pool -->|"streams output"| node_presentation
node_presentation -->|"edits and replies"| node_discord
node_presentation -->|"edits and replies"| node_slack
node_telegram -->|"platform events"| node_gateway
node_gateway -->|"serves"| node_gateway_acp
node_gateway_acp -->|"WebSocket/ACP turns"| node_turns
node_core -->|"uses credentials and trust"| node_security
node_core -->|"runs hooks and jobs"| node_lifecycle
node_control_plane -.->|"authorized delegation"| node_agent_pool
node_deployment -->|"deploys"| node_openab
node_deployment -.->|"deploys with broker"| node_gateway
node_ecs_operator -->|"provisions service infrastructure"| node_control_plane

click node_openab "https://github.com/openabdev/openab/blob/main/src/main.rs"
click node_core "https://github.com/openabdev/openab/blob/main/crates/openab-core/src/lib.rs"
click node_turns "https://github.com/openabdev/openab/blob/main/crates/openab-core/src/dispatch.rs"
click node_bot_turns "https://github.com/openabdev/openab/blob/main/crates/openab-core/src/bot_turns.rs"
click node_agent_pool "https://github.com/openabdev/openab/blob/main/crates/openab-core/src/acp/pool.rs"
click node_acp_connection "https://github.com/openabdev/openab/blob/main/crates/openab-core/src/acp/connection.rs"
click node_agent_commands "https://github.com/openabdev/openab/blob/main/crates/openab-core/src/adapter.rs"
click node_agentcore "https://github.com/openabdev/openab/blob/main/crates/openab-core/src/acp/agentcore.rs"
click node_native_agent "https://github.com/openabdev/openab/blob/main/openab-agent/src/main.rs"
click node_discord "https://github.com/openabdev/openab/blob/main/crates/openab-core/src/discord.rs"
click node_slack "https://github.com/openabdev/openab/blob/main/crates/openab-core/src/slack.rs"
click node_presentation "https://github.com/openabdev/openab/blob/main/crates/openab-core/src/directives.rs"
click node_gateway "https://github.com/openabdev/openab/blob/main/crates/openab-gateway/src/main.rs"
click node_gateway_acp "https://github.com/openabdev/openab/blob/main/crates/openab-gateway/src/adapters/acp_server.rs"
click node_telegram "https://github.com/openabdev/openab/blob/main/crates/openab-gateway/src/adapters/telegram.rs"
click node_mcp "https://github.com/openabdev/openab/blob/main/crates/openab-mcp/src/mcp/runtime.rs"
click node_control_plane "https://github.com/openabdev/openab/blob/main/crates/openab-cp/src/server.rs"
click node_security "https://github.com/openabdev/openab/blob/main/crates/openab-core/src/secrets.rs"
click node_lifecycle "https://github.com/openabdev/openab/blob/main/crates/openab-core/src/cron.rs"
click node_deployment "https://github.com/openabdev/openab/blob/main/k8s/deployment.yaml"
click node_ecs_operator "https://github.com/openabdev/openab/blob/main/operator/src/control_plane.rs"

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_openab,node_core,node_turns,node_bot_turns toneBlue
class node_discord,node_slack,node_presentation,node_gateway,node_gateway_acp,node_telegram toneAmber
class node_agent_pool,node_acp_connection,node_agent_commands,node_agentcore,node_native_agent toneMint
class node_mcp,node_control_plane toneRose
class node_security,node_lifecycle,node_deployment,node_ecs_operator toneIndigo
```

## Components

### OpenAB Broker

Primary executable and reusable turn-routing core.

- [OpenAB executable](https://github.com/openabdev/openab/blob/main/src/main.rs): Rust binary · `src/main.rs`
- [Broker core](https://github.com/openabdev/openab/blob/main/crates/openab-core/src/lib.rs): Rust library · Shared broker boundary for all OpenAB entrypoints. · `crates/openab-core/src/lib.rs`
- [Turn dispatch](https://github.com/openabdev/openab/blob/main/crates/openab-core/src/dispatch.rs): routing layer · Normalizes inbound events and routes by thread identity. · `crates/openab-core/src/dispatch.rs`
- [Bot turns](https://github.com/openabdev/openab/blob/main/crates/openab-core/src/bot_turns.rs): turn model · `crates/openab-core/src/bot_turns.rs`

### Platform Adapters

Native and gateway-isolated chat integrations.

- [Discord adapter](https://github.com/openabdev/openab/blob/main/crates/openab-core/src/discord.rs): in-process adapter · `crates/openab-core/src/discord.rs`
- [Slack adapter](https://github.com/openabdev/openab/blob/main/crates/openab-core/src/slack.rs): in-process adapter · `crates/openab-core/src/slack.rs`
- [Reply directives & formatting](https://github.com/openabdev/openab/blob/main/crates/openab-core/src/directives.rs): presentation layer · Selects reply target and renders streamed markdown or media. · `crates/openab-core/src/directives.rs`
- [Standalone gateway](https://github.com/openabdev/openab/blob/main/crates/openab-gateway/src/main.rs): Rust binary · Protocol boundary for additional chat platforms. · `crates/openab-gateway/src/main.rs`
- [Gateway ACP server](https://github.com/openabdev/openab/blob/main/crates/openab-gateway/src/adapters/acp_server.rs): WebSocket/ACP adapter · Connects gateway platform events to OpenAB's ACP boundary. · `crates/openab-gateway/src/adapters/acp_server.rs`
- [Gateway platforms](https://github.com/openabdev/openab/blob/main/crates/openab-gateway/src/adapters/telegram.rs): webhook/API adapters · Telegram plus LINE, Feishu, Google Chat, WeCom, and Teams integrations. · `crates/openab-gateway/src/adapters/telegram.rs`

### Agent Runtime

ACP process, remote runtime, and native-agent execution paths.

- [ACP session pool](https://github.com/openabdev/openab/blob/main/crates/openab-core/src/acp/pool.rs): process pool · Maintains one bounded, TTL-managed agent process per conversation thread. · `crates/openab-core/src/acp/pool.rs`
- [ACP stdio connection](https://github.com/openabdev/openab/blob/main/crates/openab-core/src/acp/connection.rs): JSON-RPC transport · Child-process stdio boundary between broker and local agents. · `crates/openab-core/src/acp/connection.rs`
- [Configured agent CLIs](https://github.com/openabdev/openab/blob/main/crates/openab-core/src/adapter.rs): external processes · `crates/openab-core/src/adapter.rs`
- [AWS AgentCore adapter](https://github.com/openabdev/openab/blob/main/crates/openab-core/src/acp/agentcore.rs): remote runtime adapter · Replaces local CLI invocation with Bedrock AgentCore. · `crates/openab-core/src/acp/agentcore.rs`
- [Native Rust agent](https://github.com/openabdev/openab/blob/main/openab-agent/src/main.rs): ACP binary · Separately runnable agent with LLM, skills, and tools. · `openab-agent/src/main.rs`

### Extensions

Tool runtime and delegated-agent control plane.

- [MCP runtime](https://github.com/openabdev/openab/blob/main/crates/openab-mcp/src/mcp/runtime.rs): tool integration · Agent-facing tools, OAuth/auth, Gmail, LLM access, and discovery. · `crates/openab-mcp/src/mcp/runtime.rs`
- [Control plane](https://github.com/openabdev/openab/blob/main/crates/openab-cp/src/server.rs): WebSocket service · Registers agents, routes requests, and authorizes delegation. · `crates/openab-cp/src/server.rs`

### Operations

Security, lifecycle, and deployment concerns.

- [Secrets & trust](https://github.com/openabdev/openab/blob/main/crates/openab-core/src/secrets.rs): security boundary · Protects credentials and validates trusted interactions. · `crates/openab-core/src/secrets.rs`
- [Lifecycle automation](https://github.com/openabdev/openab/blob/main/crates/openab-core/src/cron.rs): cron hooks · Startup, shutdown, and scheduled operational work. · `crates/openab-core/src/cron.rs`
- [Container & Kubernetes deployment](https://github.com/openabdev/openab/blob/main/k8s/deployment.yaml): deployment manifests · Packages OpenAB and persists agent authentication on PVC-backed storage. · `k8s/deployment.yaml`
- [ECS operator](https://github.com/openabdev/openab/blob/main/operator/src/control_plane.rs): AWS provisioner · Provisions Fargate networking, IAM, ingress, and secrets. · `operator/src/control_plane.rs`

## Connections

- OpenAB executable → Broker core: hosts
- OpenAB executable → Discord adapter: runs
- OpenAB executable → Slack adapter: runs
- Discord adapter → Bot turns: normalizes events
- Slack adapter → Bot turns: normalizes events
- Bot turns → Turn dispatch: dispatches
- Turn dispatch → ACP session pool: routes by thread
- ACP session pool → ACP stdio connection: owns sessions
- ACP stdio connection → Configured agent CLIs: ACP over stdio
- ACP session pool → AWS AgentCore adapter: optional remote backend
- Native Rust agent → MCP runtime: uses tools
- Configured agent CLIs → MCP runtime: can access tools
- ACP session pool → Reply directives & formatting: streams output
- Reply directives & formatting → Discord adapter: edits and replies
- Reply directives & formatting → Slack adapter: edits and replies
- Gateway platforms → Standalone gateway: platform events
- Standalone gateway → Gateway ACP server: serves
- Gateway ACP server → Turn dispatch: WebSocket/ACP turns
- Broker core → Secrets & trust: uses credentials and trust
- Broker core → Lifecycle automation: runs hooks and jobs
- Control plane → ACP session pool: authorized delegation
- Container & Kubernetes deployment → OpenAB executable: deploys
- Container & Kubernetes deployment → Standalone gateway: deploys with broker
- ECS operator → Control plane: provisions service infrastructure
