# getbindu/bindu architecture

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

- Interactive diagram: https://gitdiagram.com/getbindu/bindu
- Repository: https://github.com/getbindu/bindu

## Overview

#### Purpose and entry points
Bindu is an agent connectivity layer: it exposes arbitrary agent handlers through A2A JSON-RPC, assigns/verifies DID identity, enforces auth and payments, and manages asynchronous tasks. Python users enter through `bindu.penguin.bindufy.bindufy`; CLI commands enter via `bindu/cli/__main__.py`. The primary server composition is in `bindu/server/applications.py`. Polyglot SDKs use the shared gRPC contract in `proto/agent_handler.proto`.

#### Agent bootstrap, manifest, and runtime
`bindufy()` turns a user handler plus deployment/skills configuration into a running Bindu agent. It validates and enriches configuration, creates DID/mTLS material, loads skill manifests, and starts the server. Core bootstrap paths are `bindu/penguin/bindufy.py`, `bindu/penguin/manifest.py`, and `bindu/penguin/did_setup.py`. Runtime execution is abstracted behind providers: local/in-process behavior and Boxd cloud deployment live in `bindu/runtime/in_process.py`, `bindu/runtime/boxd_provider.py`, and `bindu/runtime/source_packager.py`.

#### A2A request-to-task pipeline
The HTTP server exposes A2A protocol endpoints including agent cards, messages, task lookup/streaming, skills, negotiation, and health/metrics. Endpoint adapters in `bindu/server/endpoints/a2a_protocol.py` and `bindu/server/endpoints/agent_card.py` delegate to message, context, and task handlers in `bindu/server/handlers/`. `bindu/server/task_manager.py` is the main lifecycle boundary: inbound JSON-RPC messages become persisted task/context/message state, user handlers execute asynchronously, and responses are normalized back into A2A task results. Manifest processing is offloaded through `bindu/server/workers/manifest_worker.py`.

#### Security and identity boundary
Before agent code sees a request, middleware applies independent transport, authorization, and message-authorship checks. mTLS certificates are provisioned/renewed through Smallstep CA integration in `bindu/extensions/mtls/step_ca_client.py` and enforced by `bindu/server/middleware/auth/mtls.py`. OAuth2 clients/tokens are managed against Ory Hydra through `bindu/auth/hydra/client.py` and `bindu/server/middleware/auth/hydra.py`. DID signature validation and DID-backed agent behavior are implemented in `bindu/extensions/did/did_agent_extension.py` and `bindu/utils/did/signature.py`. These layers bind the same agent identity across certificate SAN, Hydra client identity, and signed payload claims.

#### State, scheduling, payments, and notifications
Storage and scheduling are provider-backed boundaries rather than hard dependencies: memory implementations support local operation, while Postgres stores task data and Redis drives retries/timeouts or recurring work. Key paths are `bindu/server/storage/factory.py`, `bindu/server/storage/postgres_storage.py`, and `bindu/server/scheduler/redis_scheduler.py`; Alembic migrations under `alembic/versions/` define database evolution. x402 middleware gates protected calls before handler execution and tracks payment sessions/nonces in `bindu/server/middleware/x402/x402_middleware.py` and `bindu/server/middleware/x402/payment_session_manager.py`. Task-state webhooks are dispatched by `bindu/server/notifications/push_manager.py`.

#### Cross-language protocol and clients
The Python gRPC server/client layer bridges non-Python SDKs to the same core agent process: `bindu/grpc/server.py`, `bindu/grpc/service.py`, and generated bindings under `bindu/grpc/generated/`. TypeScript SDK launch/client code is in `sdks/typescript/src/core-launcher.ts` and `sdks/typescript/src/client.ts`; Kotlin equivalents are `sdks/kotlin/src/main/kotlin/com/getbindu/sdk/CoreLauncher.kt` and `BinduAgent.kt`. Public exposure can be added through the tunnel manager in `bindu/tunneling/manager.py`.

#### Gateway and operator inbox
The repository also contains two separate TypeScript applications. `gateway/src/index.ts` starts an orchestration service whose planner selects Bindu-agent skills/tools (`gateway/src/planner/index.ts`, `gateway/src/planner/skill-tool.ts`), maintains LLM session continuity, and calls remote agents through its Bindu client. `inbox/server/index.ts` and `inbox/src/main.tsx` form a Gmail-like operator UI/backend for viewing agent conversations, managing agents, and receiving live streams. These are consumers of the Bindu protocol, not replacements for the Python agent core.

Main entry points: [`bindu/server/middleware/auth/mtls.py`](https://github.com/getbindu/bindu/blob/main/bindu/server/middleware/auth/mtls.py) (Auth middleware), [`bindu/server/task_manager.py`](https://github.com/getbindu/bindu/blob/main/bindu/server/task_manager.py) (Task manager), [`bindu/server/endpoints/a2a_protocol.py`](https://github.com/getbindu/bindu/blob/main/bindu/server/endpoints/a2a_protocol.py) (A2A HTTP endpoints), [`bindu/penguin/bindufy.py`](https://github.com/getbindu/bindu/blob/main/bindu/penguin/bindufy.py) (Python API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_python_core["Python agent core"]
  node_python_api["Python API<br/>entry point<br/>[bindufy.py]"]
  node_cli["CLI<br/>entry point<br/>[__main__.py]"]
  node_bootstrap["Manifest and DID bootstrap<br/>[manifest.py]"]
  node_server_app["Server composition<br/>application assembly<br/>[applications.py]"]
  node_a2a_endpoints["A2A HTTP endpoints<br/>protocol adapter<br/>[a2a_protocol.py]"]
  node_task_manager["Task manager<br/>async lifecycle<br/>[task_manager.py]"]
  node_manifest_worker["Manifest worker<br/>background worker<br/>[manifest_worker.py]"]
  node_runtime["Runtime providers<br/>execution provider<br/>[in_process.py]"]
  node_source_packager["Source packager<br/>deployment packaging<br/>[source_packager.py]"]
end

subgraph group_security["Identity and security"]
  node_did_setup["DID setup<br/>identity provisioning<br/>[did_setup.py]"]
  node_auth_middleware["Auth middleware<br/>request security<br/>[mtls.py]"]
  node_did_validation["DID signatures<br/>message identity<br/>[signature.py]"]
  node_hydra{{"Ory Hydra<br/>OAuth2 provider<br/>[client.py]"}}
  node_step_ca{{"Smallstep CA<br/>mTLS provider<br/>[step_ca_client.py]"}}
  node_payments["x402 payments<br/>payment gate<br/>[x402_middleware.py]"]
end

subgraph group_state["State and operations"]
  node_storage[("Storage providers<br/>task persistence<br/>[factory.py]")]
  node_scheduler["Redis scheduler<br/>job scheduler<br/>[redis_scheduler.py]"]
  node_notifications["Push manager<br/>webhook dispatcher<br/>[push_manager.py]"]
end

subgraph group_clients["Protocol clients and consumers"]
  node_grpc_contract["Agent handler contract<br/>gRPC protocol"]
  node_grpc_bridge["Python gRPC bridge<br/>gRPC server<br/>[server.py]"]
  node_gateway["Gateway<br/>TypeScript orchestrator<br/>[index.ts]"]
  node_inbox["Operator inbox<br/>TypeScript application<br/>[index.ts]"]
end

node_python_api -->|"configures"| node_bootstrap
node_cli -->|"invokes"| node_python_api
node_bootstrap -->|"provisions identity"| node_did_setup
node_bootstrap -->|"selects runtime"| node_runtime
node_runtime -.->|"packages cloud source"| node_source_packager
node_python_api -->|"starts"| node_server_app
node_server_app -->|"serves"| node_a2a_endpoints
node_a2a_endpoints -->|"passes through"| node_auth_middleware
node_auth_middleware -->|"admits requests"| node_task_manager
node_auth_middleware -->|"verifies mTLS"| node_step_ca
node_auth_middleware -->|"validates OAuth2"| node_hydra
node_auth_middleware -->|"validates authorship"| node_did_validation
node_auth_middleware -->|"enforces payment"| node_payments
node_task_manager -->|"persists state"| node_storage
node_task_manager -->|"executes handler"| node_runtime
node_task_manager -->|"schedules lifecycle work"| node_scheduler
node_task_manager -->|"emits state changes"| node_notifications
node_server_app -->|"offloads manifests"| node_manifest_worker
node_grpc_contract -->|"defines service"| node_grpc_bridge
node_grpc_bridge -->|"uses core lifecycle"| node_task_manager
node_gateway -->|"calls remote agents"| node_a2a_endpoints
node_inbox -->|"views agent activity"| node_a2a_endpoints

click node_python_api "https://github.com/getbindu/bindu/blob/main/bindu/penguin/bindufy.py"
click node_cli "https://github.com/getbindu/bindu/blob/main/bindu/cli/__main__.py"
click node_bootstrap "https://github.com/getbindu/bindu/blob/main/bindu/penguin/manifest.py"
click node_did_setup "https://github.com/getbindu/bindu/blob/main/bindu/penguin/did_setup.py"
click node_server_app "https://github.com/getbindu/bindu/blob/main/bindu/server/applications.py"
click node_a2a_endpoints "https://github.com/getbindu/bindu/blob/main/bindu/server/endpoints/a2a_protocol.py"
click node_task_manager "https://github.com/getbindu/bindu/blob/main/bindu/server/task_manager.py"
click node_manifest_worker "https://github.com/getbindu/bindu/blob/main/bindu/server/workers/manifest_worker.py"
click node_runtime "https://github.com/getbindu/bindu/blob/main/bindu/runtime/in_process.py"
click node_source_packager "https://github.com/getbindu/bindu/blob/main/bindu/runtime/source_packager.py"
click node_auth_middleware "https://github.com/getbindu/bindu/blob/main/bindu/server/middleware/auth/mtls.py"
click node_did_validation "https://github.com/getbindu/bindu/blob/main/bindu/utils/did/signature.py"
click node_hydra "https://github.com/getbindu/bindu/blob/main/bindu/auth/hydra/client.py"
click node_step_ca "https://github.com/getbindu/bindu/blob/main/bindu/extensions/mtls/step_ca_client.py"
click node_payments "https://github.com/getbindu/bindu/blob/main/bindu/server/middleware/x402/x402_middleware.py"
click node_storage "https://github.com/getbindu/bindu/blob/main/bindu/server/storage/factory.py"
click node_scheduler "https://github.com/getbindu/bindu/blob/main/bindu/server/scheduler/redis_scheduler.py"
click node_notifications "https://github.com/getbindu/bindu/blob/main/bindu/server/notifications/push_manager.py"
click node_grpc_contract "https://github.com/getbindu/bindu/blob/main/proto/agent_handler.proto"
click node_grpc_bridge "https://github.com/getbindu/bindu/blob/main/bindu/grpc/server.py"
click node_gateway "https://github.com/getbindu/bindu/blob/main/gateway/src/index.ts"
click node_inbox "https://github.com/getbindu/bindu/blob/main/inbox/server/index.ts"

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_python_api,node_cli,node_bootstrap,node_server_app,node_a2a_endpoints,node_task_manager,node_manifest_worker,node_runtime,node_source_packager toneBlue
class node_did_setup,node_auth_middleware,node_did_validation,node_hydra,node_step_ca,node_payments toneAmber
class node_storage,node_scheduler,node_notifications toneMint
class node_grpc_contract,node_grpc_bridge,node_gateway,node_inbox toneRose
```

## Components

### Python agent core

- [Python API](https://github.com/getbindu/bindu/blob/main/bindu/penguin/bindufy.py): entry point · Turns a handler and deployment configuration into an agent. · `bindu/penguin/bindufy.py`
- [CLI](https://github.com/getbindu/bindu/blob/main/bindu/cli/__main__.py): entry point · `bindu/cli/__main__.py`
- [Manifest and DID bootstrap](https://github.com/getbindu/bindu/blob/main/bindu/penguin/manifest.py): bootstrap · Validates configuration, loads skills, and creates identity material. · `bindu/penguin/manifest.py`
- [Server composition](https://github.com/getbindu/bindu/blob/main/bindu/server/applications.py): application assembly · `bindu/server/applications.py`
- [A2A HTTP endpoints](https://github.com/getbindu/bindu/blob/main/bindu/server/endpoints/a2a_protocol.py): protocol adapter · Exposes agent cards, messages, tasks, skills, negotiation, and health endpoints. · `bindu/server/endpoints/a2a_protocol.py`
- [Task manager](https://github.com/getbindu/bindu/blob/main/bindu/server/task_manager.py): async lifecycle · Persists inbound work, invokes handlers, and returns normalized A2A tasks. · `bindu/server/task_manager.py`
- [Manifest worker](https://github.com/getbindu/bindu/blob/main/bindu/server/workers/manifest_worker.py): background worker · `bindu/server/workers/manifest_worker.py`
- [Runtime providers](https://github.com/getbindu/bindu/blob/main/bindu/runtime/in_process.py): execution provider · Supports in-process execution and Boxd cloud deployment. · `bindu/runtime/in_process.py`
- [Source packager](https://github.com/getbindu/bindu/blob/main/bindu/runtime/source_packager.py): deployment packaging · `bindu/runtime/source_packager.py`

### Identity and security

- [DID setup](https://github.com/getbindu/bindu/blob/main/bindu/penguin/did_setup.py): identity provisioning · `bindu/penguin/did_setup.py`
- [Auth middleware](https://github.com/getbindu/bindu/blob/main/bindu/server/middleware/auth/mtls.py): request security · Enforces mTLS, OAuth2, DID authorship, and payment gates before handlers run. · `bindu/server/middleware/auth/mtls.py`
- [DID signatures](https://github.com/getbindu/bindu/blob/main/bindu/utils/did/signature.py): message identity · `bindu/utils/did/signature.py`
- [Ory Hydra](https://github.com/getbindu/bindu/blob/main/bindu/auth/hydra/client.py): OAuth2 provider · `bindu/auth/hydra/client.py`
- [Smallstep CA](https://github.com/getbindu/bindu/blob/main/bindu/extensions/mtls/step_ca_client.py): mTLS provider · Provisions and renews certificates. · `bindu/extensions/mtls/step_ca_client.py`
- [x402 payments](https://github.com/getbindu/bindu/blob/main/bindu/server/middleware/x402/x402_middleware.py): payment gate · Tracks payment sessions and nonces for protected calls. · `bindu/server/middleware/x402/x402_middleware.py`

### State and operations

- [Storage providers](https://github.com/getbindu/bindu/blob/main/bindu/server/storage/factory.py): task persistence · Memory and Postgres-backed task, context, and message state. · `bindu/server/storage/factory.py`
- [Redis scheduler](https://github.com/getbindu/bindu/blob/main/bindu/server/scheduler/redis_scheduler.py): job scheduler · Drives retries, timeouts, and recurring work. · `bindu/server/scheduler/redis_scheduler.py`
- [Push manager](https://github.com/getbindu/bindu/blob/main/bindu/server/notifications/push_manager.py): webhook dispatcher · Dispatches task-state webhooks. · `bindu/server/notifications/push_manager.py`

### Protocol clients and consumers

- [Agent handler contract](https://github.com/getbindu/bindu/blob/main/proto/agent_handler.proto): gRPC protocol · Shared contract for polyglot SDKs and the Python core. · `proto/agent_handler.proto`
- [Python gRPC bridge](https://github.com/getbindu/bindu/blob/main/bindu/grpc/server.py): gRPC server · Bridges non-Python SDK calls into the core agent process. · `bindu/grpc/server.py`
- [Gateway](https://github.com/getbindu/bindu/blob/main/gateway/src/index.ts): TypeScript orchestrator · Plans skills/tools and calls remote Bindu agents. · `gateway/src/index.ts`
- [Operator inbox](https://github.com/getbindu/bindu/blob/main/inbox/server/index.ts): TypeScript application · Conversation and agent-management UI with live streams. · `inbox/server/index.ts`

## Connections

- Python API → Manifest and DID bootstrap: configures
- CLI → Python API: invokes
- Manifest and DID bootstrap → DID setup: provisions identity
- Manifest and DID bootstrap → Runtime providers: selects runtime
- Runtime providers → Source packager: packages cloud source
- Python API → Server composition: starts
- Server composition → A2A HTTP endpoints: serves
- A2A HTTP endpoints → Auth middleware: passes through
- Auth middleware → Task manager: admits requests
- Auth middleware → Smallstep CA: verifies mTLS
- Auth middleware → Ory Hydra: validates OAuth2
- Auth middleware → DID signatures: validates authorship
- Auth middleware → x402 payments: enforces payment
- Task manager → Storage providers: persists state
- Task manager → Runtime providers: executes handler
- Task manager → Redis scheduler: schedules lifecycle work
- Task manager → Push manager: emits state changes
- Server composition → Manifest worker: offloads manifests
- Agent handler contract → Python gRPC bridge: defines service
- Python gRPC bridge → Task manager: uses core lifecycle
- Gateway → A2A HTTP endpoints: calls remote agents
- Operator inbox → A2A HTTP endpoints: views agent activity
