# flowgent-labs/flowgent architecture

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

- Interactive diagram: https://gitdiagram.com/flowgent-labs/flowgent
- Repository: https://github.com/flowgent-labs/flowgent

## Overview

Flowgent is a distributed AI-agent orchestration engine. A flow is configured through the namespace-scoped API, discovered and dispatched by the controller, scheduled by a per-flow JobManager, and executed by TaskManagers using DAG node executors; durable run/task state and human gates support pause, resume, and replay. Separate branches cover event and cron triggers, sandbox execution, notifications, A2A access, LLM providers, and optional x402 wallet signing. Edges cite README or shown source; unsampled subsystem wiring is omitted or marked unverified.

Main entry points: [`pkg/core/pkg/engine/taskmanager/taskmanager.go`](https://github.com/flowgent-labs/flowgent/blob/main/pkg/core/pkg/engine/taskmanager/taskmanager.go) (TaskManager), [`pkg/controller/pkg/controller.go`](https://github.com/flowgent-labs/flowgent/blob/main/pkg/controller/pkg/controller.go) (Flow controller), [`pkg/api/pkg/server.go`](https://github.com/flowgent-labs/flowgent/blob/main/pkg/api/pkg/server.go) (REST API), [`pkg/core/pkg/engine/executor/executor.go`](https://github.com/flowgent-labs/flowgent/blob/main/pkg/core/pkg/engine/executor/executor.go) (DAG node executors)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Access and configuration"]
  node_api["REST API<br/>[server.go]"]
  node_auth["Authentication<br/>[auth.go]"]
  node_config["Service configuration<br/>[config.go]"]
  node_a2a["A2A server<br/>[a2a.go]"]
end

subgraph group_orchestration["Flow orchestration"]
  node_controller["Flow controller<br/>[controller.go]"]
  node_discovery["Pod discovery<br/>[discovery.go]"]
  node_jobmanager["JobManager<br/>[jobmanager.go]"]
  node_triggers["Cron and webhook triggers<br/>[trigger.go]"]
end

subgraph group_runtime["Execution runtime"]
  node_taskmanager["TaskManager<br/>[taskmanager.go]"]
  node_executor["DAG node executors<br/>[executor.go]"]
  node_sandbox["Sandbox worker<br/>[sandboxmanager.go]"]
  node_llm["LLM providers<br/>[llm.go]"]
end

subgraph group_platform["State and integrations"]
  node_messager["Message transport<br/>[messager.go]"]
  node_store[("Durable state<br/>[store.go]")]
  node_notifier["Notifications<br/>[notifier.go]"]
  node_otel["OTEL tracing<br/>[otel.go]"]
end

subgraph group_economy["Economic layer"]
  node_wallet["Wallet manager<br/>[walletmanager.go]"]
  node_payment["x402 payment client<br/>[x402_httpclient.go]"]
end

node_user(("API clients"))
node_oidc(("OIDC provider"))
node_llmservice(("LLM services"))
node_notificationtargets(("Notification targets"))
node_kubernetes(("Kubernetes"))
node_paymentnetwork(("Payment network"))

node_user -->|"submits flows"| node_api
node_user -->|"uses agent protocol"| node_a2a
node_api -.->|"authenticates"| node_auth
node_oidc -->|"provides identity"| node_auth
node_controller -->|"discovers flows"| node_api
node_controller -.->|"selects shard"| node_discovery
node_controller -->|"dispatches per-flow"| node_jobmanager
node_jobmanager -->|"scales workers"| node_taskmanager
node_taskmanager -->|"executes plans"| node_executor
node_taskmanager -->|"resolves runtime resources"| node_api
node_taskmanager -.->|"consumes plans"| node_messager
node_executor -->|"invokes agents"| node_llm
node_executor -.->|"runs scripts"| node_sandbox
node_controller -->|"manages deployments"| node_kubernetes
node_triggers -.->|"starts runs"| node_jobmanager
node_api -.->|"persists runs and tasks"| node_store
node_executor -.->|"sends notifications"| node_notifier
node_notifier -->|"delivers messages"| node_notificationtargets
node_llm -.->|"calls providers"| node_llmservice
node_taskmanager -->|"records node spans"| node_otel
node_payment -->|"requests signing"| node_wallet
node_wallet -->|"publishes signed result"| node_messager
node_payment -->|"pays via x402"| node_paymentnetwork
node_config -.->|"configures runtime"| node_controller

click node_api "https://github.com/flowgent-labs/flowgent/blob/main/pkg/api/pkg/server.go"
click node_auth "https://github.com/flowgent-labs/flowgent/blob/main/pkg/api/pkg/auth/auth.go"
click node_config "https://github.com/flowgent-labs/flowgent/blob/main/pkg/config/pkg/config/config.go"
click node_controller "https://github.com/flowgent-labs/flowgent/blob/main/pkg/controller/pkg/controller.go"
click node_discovery "https://github.com/flowgent-labs/flowgent/blob/main/pkg/core/pkg/engine/discovery/discovery.go"
click node_jobmanager "https://github.com/flowgent-labs/flowgent/blob/main/pkg/core/pkg/engine/jobmanager/jobmanager.go"
click node_taskmanager "https://github.com/flowgent-labs/flowgent/blob/main/pkg/core/pkg/engine/taskmanager/taskmanager.go"
click node_executor "https://github.com/flowgent-labs/flowgent/blob/main/pkg/core/pkg/engine/executor/executor.go"
click node_sandbox "https://github.com/flowgent-labs/flowgent/blob/main/pkg/sandbox/pkg/sandboxmanager.go"
click node_messager "https://github.com/flowgent-labs/flowgent/blob/main/pkg/messager/pkg/messager.go"
click node_store "https://github.com/flowgent-labs/flowgent/blob/main/pkg/store/pkg/store.go"
click node_triggers "https://github.com/flowgent-labs/flowgent/blob/main/pkg/core/pkg/engine/trigger/trigger.go"
click node_llm "https://github.com/flowgent-labs/flowgent/blob/main/pkg/core/pkg/llm/llm.go"
click node_notifier "https://github.com/flowgent-labs/flowgent/blob/main/pkg/notifier/pkg/notifier.go"
click node_a2a "https://github.com/flowgent-labs/flowgent/blob/main/pkg/a2a/pkg/a2a.go"
click node_otel "https://github.com/flowgent-labs/flowgent/blob/main/pkg/common/pkg/tracing/otel.go"
click node_wallet "https://github.com/flowgent-labs/flowgent/blob/main/pkg/wallet/pkg/walletmanager.go"
click node_payment "https://github.com/flowgent-labs/flowgent/blob/main/pkg/core/pkg/client/x402_httpclient.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_api,node_auth,node_config,node_a2a,node_user toneBlue
class node_controller,node_discovery,node_jobmanager,node_triggers toneAmber
class node_taskmanager,node_executor,node_sandbox,node_llm toneMint
class node_messager,node_store,node_notifier,node_otel toneRose
class node_wallet,node_payment,node_oidc,node_llmservice,node_notificationtargets,node_kubernetes,node_paymentnetwork toneIndigo
```

## Components

### Access and configuration

- [REST API](https://github.com/flowgent-labs/flowgent/blob/main/pkg/api/pkg/server.go): `pkg/api/pkg/server.go`
- [Authentication](https://github.com/flowgent-labs/flowgent/blob/main/pkg/api/pkg/auth/auth.go): `pkg/api/pkg/auth/auth.go`
- [Service configuration](https://github.com/flowgent-labs/flowgent/blob/main/pkg/config/pkg/config/config.go): `pkg/config/pkg/config/config.go`
- [A2A server](https://github.com/flowgent-labs/flowgent/blob/main/pkg/a2a/pkg/a2a.go): `pkg/a2a/pkg/a2a.go`

### Flow orchestration

- [Flow controller](https://github.com/flowgent-labs/flowgent/blob/main/pkg/controller/pkg/controller.go): `pkg/controller/pkg/controller.go`
- [Pod discovery](https://github.com/flowgent-labs/flowgent/blob/main/pkg/core/pkg/engine/discovery/discovery.go): `pkg/core/pkg/engine/discovery/discovery.go`
- [JobManager](https://github.com/flowgent-labs/flowgent/blob/main/pkg/core/pkg/engine/jobmanager/jobmanager.go): `pkg/core/pkg/engine/jobmanager/jobmanager.go`
- [Cron and webhook triggers](https://github.com/flowgent-labs/flowgent/blob/main/pkg/core/pkg/engine/trigger/trigger.go): `pkg/core/pkg/engine/trigger/trigger.go`

### Execution runtime

- [TaskManager](https://github.com/flowgent-labs/flowgent/blob/main/pkg/core/pkg/engine/taskmanager/taskmanager.go): `pkg/core/pkg/engine/taskmanager/taskmanager.go`
- [DAG node executors](https://github.com/flowgent-labs/flowgent/blob/main/pkg/core/pkg/engine/executor/executor.go): `pkg/core/pkg/engine/executor/executor.go`
- [Sandbox worker](https://github.com/flowgent-labs/flowgent/blob/main/pkg/sandbox/pkg/sandboxmanager.go): `pkg/sandbox/pkg/sandboxmanager.go`
- [LLM providers](https://github.com/flowgent-labs/flowgent/blob/main/pkg/core/pkg/llm/llm.go): `pkg/core/pkg/llm/llm.go`

### State and integrations

- [Message transport](https://github.com/flowgent-labs/flowgent/blob/main/pkg/messager/pkg/messager.go): `pkg/messager/pkg/messager.go`
- [Durable state](https://github.com/flowgent-labs/flowgent/blob/main/pkg/store/pkg/store.go): `pkg/store/pkg/store.go`
- [Notifications](https://github.com/flowgent-labs/flowgent/blob/main/pkg/notifier/pkg/notifier.go): `pkg/notifier/pkg/notifier.go`
- [OTEL tracing](https://github.com/flowgent-labs/flowgent/blob/main/pkg/common/pkg/tracing/otel.go): `pkg/common/pkg/tracing/otel.go`

### Economic layer

- [Wallet manager](https://github.com/flowgent-labs/flowgent/blob/main/pkg/wallet/pkg/walletmanager.go): `pkg/wallet/pkg/walletmanager.go`
- [x402 payment client](https://github.com/flowgent-labs/flowgent/blob/main/pkg/core/pkg/client/x402_httpclient.go): `pkg/core/pkg/client/x402_httpclient.go`

### Other components

- **API clients**
- **OIDC provider**
- **LLM services**
- **Notification targets**
- **Kubernetes**
- **Payment network**

## Connections

- API clients → REST API: submits flows
- API clients → A2A server: uses agent protocol
- REST API → Authentication: authenticates
- OIDC provider → Authentication: provides identity
- Flow controller → REST API: discovers flows (evidence: `pkg/controller/pkg/controller.go`)
- Flow controller → Pod discovery: selects shard
- Flow controller → JobManager: dispatches per-flow
- JobManager → TaskManager: scales workers
- TaskManager → DAG node executors: executes plans (evidence: `pkg/core/pkg/engine/taskmanager/taskmanager.go`)
- TaskManager → REST API: resolves runtime resources (evidence: `pkg/core/pkg/engine/taskmanager/taskmanager.go`)
- TaskManager → Message transport: consumes plans
- DAG node executors → LLM providers: invokes agents
- DAG node executors → Sandbox worker: runs scripts
- Flow controller → Kubernetes: manages deployments (evidence: `pkg/controller/pkg/controller.go`)
- Cron and webhook triggers → JobManager: starts runs
- REST API → Durable state: persists runs and tasks
- DAG node executors → Notifications: sends notifications
- Notifications → Notification targets: delivers messages
- LLM providers → LLM services: calls providers
- TaskManager → OTEL tracing: records node spans
- x402 payment client → Wallet manager: requests signing (evidence: `pkg/wallet/pkg/walletmanager.go`)
- Wallet manager → Message transport: publishes signed result (evidence: `pkg/wallet/pkg/walletmanager.go`)
- x402 payment client → Payment network: pays via x402
- Service configuration → Flow controller: configures runtime
