# block/buzz architecture

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

- Interactive diagram: https://gitdiagram.com/block/buzz
- Repository: https://github.com/block/buzz

## Overview

#### Purpose and entry points
Buzz is a self-hostable, Nostr-based collaboration workspace where people, agents, workflows, git activity, and media become signed events on a community-scoped relay. The primary server entry point is `crates/buzz-relay/src/main.rs`; Rust workspace membership and binaries are defined by `Cargo.toml`. Main client entry points are the Tauri desktop app (`desktop/src/main.tsx`, `desktop/src-tauri/src/main.rs`), Flutter mobile app (`mobile/lib/main.dart`), web Git/invite client (`web/src/main.tsx`), and agent-oriented CLI (`crates/buzz-cli/src/main.rs`).

#### Relay as authoritative event boundary
`buzz-relay` is the system of record and protocol/API boundary: it accepts WebSocket Nostr traffic and REST operations for channels, events, media, workflows, git, admin, and invitations. Routing and shared runtime state are centered in `crates/buzz-relay/src/router.rs`, `crates/buzz-relay/src/state.rs`, and `crates/buzz-relay/src/handlers/ingest.rs`. Event ingestion applies admission, authz/moderation, persistence, subscriptions, and side effects; APIs expose specialized HTTP surfaces under `crates/buzz-relay/src/api/`.

#### Protocol, identity, and tenancy
Core domain types, event kinds, channel/filter semantics, identity presence, and pairing live in the I/O-free `buzz-core` crate: `crates/buzz-core/src/event.rs`, `crates/buzz-core/src/channel.rs`, and `crates/buzz-core/src/tenant.rs`. Authentication uses Nostr NIP-42/NIP-98 and replay/rate-limit protections in `crates/buzz-auth/src/nip42.rs`, `crates/buzz-auth/src/nip98.rs`, and `crates/buzz-auth/src/rate_limit.rs`. Tenant/community isolation is host-derived at the relay boundary; shared backing services must not create a user-visible cross-community namespace.

#### Persistence, distribution, and audit
Postgres persists events and domain projections, migrations, partitioning, and repository/workflow state through `crates/buzz-db/src/lib.rs`, `crates/buzz-db/src/event.rs`, and `crates/buzz-db/src/partition.rs`; schema evolution is in `migrations/`. Redis-backed pub/sub distributes live events, presence, typing, cache invalidation, and connection control via `crates/buzz-pubsub/src/publisher.rs` and `crates/buzz-pubsub/src/subscriber.rs`. Search is Postgres FTS (`crates/buzz-search/src/query.rs`), while tamper-evident action/event history is handled by `crates/buzz-audit/src/service.rs`.

#### Collaboration and project services
Channels, DMs, threads, reactions, moderation, and feeds share the signed-event substrate. Relay handlers translate events into domain effects (`crates/buzz-relay/src/handlers/event.rs`, `crates/buzz-relay/src/handlers/moderation_commands.rs`). Git hosting is an HTTP/event bridge with object-store-oriented pack/CAS handling in `crates/buzz-relay/src/api/git/transport.rs`, `crates/buzz-relay/src/api/git/cas_publish.rs`, and `crates/buzz-relay/src/api/git/store.rs`. Media validates/uploads records and produces thumbnails through `crates/buzz-media/src/upload.rs`, `crates/buzz-media/src/storage.rs`, and `crates/buzz-media/src/thumbnail.rs`.

#### Agents, automation, and mesh compute
Agents use the same identities and event channels as users. `buzz-cli` is the JSON-oriented automation client; `buzz-acp` bridges ACP clients to Buzz/MCP (`crates/buzz-acp/src/main.rs`, `crates/buzz-acp/src/relay.rs`); `buzz-agent` implements agent runtime/configuration (`crates/buzz-agent/src/agent.rs`, `crates/buzz-agent/src/mcp.rs`). Workflow definitions/execution are isolated in `crates/buzz-workflow/src/schema.rs` and `crates/buzz-workflow/src/executor.rs`. Optional relay mesh/shared model routing is provided by `crates/buzz-relay-mesh/src/runtime.rs` and relay boot integration in `crates/buzz-relay/src/mesh_boot.rs`.

#### Client and deployment boundaries
The desktop app is the richest client: React feature modules call a Tauri Rust backend, which owns local state, secrets, relay sync, managed agent processes, and native media/audio capabilities (`desktop/src/shared/api/relayClient.ts`, `desktop/src-tauri/src/event_sync.rs`, `desktop/src-tauri/src/managed_agents/runtime.rs`). Mobile independently implements Nostr relay/session behavior in Flutter (`mobile/lib/shared/relay/relay_client.dart`). Deployment targets Docker Compose and Kubernetes Helm, provisioning Postgres, Redis, and S3-compatible MinIO/object storage: `deploy/compose/compose.yml`, `deploy/charts/buzz/templates/deployment.yaml`, and `deploy/charts/buzz/templates/quickstart-minio.yaml`.

Main entry points: [`crates/buzz-relay/src/router.rs`](https://github.com/block/buzz/blob/main/crates/buzz-relay/src/router.rs) (Relay router & state), [`crates/buzz-relay/src/handlers/ingest.rs`](https://github.com/block/buzz/blob/main/crates/buzz-relay/src/handlers/ingest.rs) (Event ingestion), [`crates/buzz-db/src/lib.rs`](https://github.com/block/buzz/blob/main/crates/buzz-db/src/lib.rs) (Postgres), [`deploy/compose/compose.yml`](https://github.com/block/buzz/blob/main/deploy/compose/compose.yml) (Deployment targets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Clients &amp; automation"]
  node_desktop_ui["Desktop React app<br/>Tauri frontend<br/>[main.tsx]"]
  node_desktop_native["Desktop native backend<br/>Tauri Rust<br/>[main.rs]"]
  node_mobile["Mobile app<br/>Flutter client<br/>[main.dart]"]
  node_web["Web Git &amp; invite client<br/>web client<br/>[main.tsx]"]
  node_cli["Automation CLI<br/>JSON CLI<br/>[main.rs]"]
  node_acp_agent["ACP &amp; agent runtime<br/>agent integration<br/>[main.rs]"]
end

subgraph group_relay["Authoritative relay"]
  node_relay_router{{"Relay router &amp; state<br/>HTTP/WebSocket boundary<br/>[router.rs]"}}
  node_ingest["Event ingestion<br/>admission pipeline<br/>[ingest.rs]"]
end

subgraph group_services["Domain services"]
  node_core["Core protocol domain<br/>I/O-free Rust crate<br/>[event.rs]"]
  node_auth["Nostr auth &amp; limits<br/>security service<br/>[nip42.rs]"]
  node_collaboration["Collaboration effects<br/>event handlers<br/>[event.rs]"]
  node_git["Git bridge &amp; CAS<br/>Git HTTP service<br/>[transport.rs]"]
  node_media["Media pipeline<br/>upload service<br/>[upload.rs]"]
  node_workflow["Workflow executor<br/>automation engine<br/>[executor.rs]"]
  node_mesh["Relay mesh<br/>optional model routing<br/>[runtime.rs]"]
  node_search["Postgres FTS<br/>search queries<br/>[query.rs]"]
  node_audit["Tamper-evident audit<br/>history service<br/>[service.rs]"]
end

subgraph group_infra["Backing infrastructure"]
  node_postgres[("Postgres<br/>event &amp; projection store<br/>[lib.rs]")]
  node_redis["Redis pub/sub<br/>live distribution<br/>[publisher.rs]"]
  node_object_store[("S3-compatible storage<br/>object storage")]
  node_deployment["Deployment targets<br/>Compose &amp; Helm<br/>[compose.yml]"]
end

node_desktop_ui -->|"invokes"| node_desktop_native
node_desktop_native -->|"relay sync"| node_relay_router
node_mobile -->|"Nostr sessions"| node_relay_router
node_web -->|"Git &amp; invites"| node_relay_router
node_cli -->|"automation events"| node_relay_router
node_acp_agent -->|"agent events"| node_relay_router
node_relay_router -->|"signed events"| node_ingest
node_relay_router -->|"Git API"| node_git
node_relay_router -->|"media API"| node_media
node_relay_router -->|"workflow API"| node_workflow
node_relay_router -->|"authenticates"| node_auth
node_relay_router -->|"host-derived tenant context"| node_core
node_ingest -->|"validates semantics"| node_core
node_ingest -->|"authorizes"| node_auth
node_ingest -->|"persists events"| node_postgres
node_ingest -->|"publishes live updates"| node_redis
node_ingest -->|"domain effects"| node_collaboration
node_ingest -->|"records history"| node_audit
node_collaboration -->|"updates projections"| node_postgres
node_git -->|"repository state"| node_postgres
node_git -->|"packs &amp; CAS objects"| node_object_store
node_media -->|"uploads &amp; thumbnails"| node_object_store
node_media -->|"media records"| node_postgres
node_workflow -->|"definitions &amp; runs"| node_postgres
node_search -->|"FTS queries"| node_postgres
node_relay_router -->|"search API"| node_search
node_relay_router -.->|"optional routing"| node_mesh
node_deployment -->|"deploys"| node_relay_router
node_deployment -->|"provisions"| node_postgres
node_deployment -->|"provisions"| node_redis
node_deployment -->|"provisions"| node_object_store

click node_desktop_ui "https://github.com/block/buzz/blob/main/desktop/src/main.tsx"
click node_desktop_native "https://github.com/block/buzz/blob/main/desktop/src-tauri/src/main.rs"
click node_mobile "https://github.com/block/buzz/blob/main/mobile/lib/main.dart"
click node_web "https://github.com/block/buzz/blob/main/web/src/main.tsx"
click node_cli "https://github.com/block/buzz/blob/main/crates/buzz-cli/src/main.rs"
click node_acp_agent "https://github.com/block/buzz/blob/main/crates/buzz-acp/src/main.rs"
click node_relay_router "https://github.com/block/buzz/blob/main/crates/buzz-relay/src/router.rs"
click node_ingest "https://github.com/block/buzz/blob/main/crates/buzz-relay/src/handlers/ingest.rs"
click node_core "https://github.com/block/buzz/blob/main/crates/buzz-core/src/event.rs"
click node_auth "https://github.com/block/buzz/blob/main/crates/buzz-auth/src/nip42.rs"
click node_collaboration "https://github.com/block/buzz/blob/main/crates/buzz-relay/src/handlers/event.rs"
click node_git "https://github.com/block/buzz/blob/main/crates/buzz-relay/src/api/git/transport.rs"
click node_media "https://github.com/block/buzz/blob/main/crates/buzz-media/src/upload.rs"
click node_workflow "https://github.com/block/buzz/blob/main/crates/buzz-workflow/src/executor.rs"
click node_mesh "https://github.com/block/buzz/blob/main/crates/buzz-relay-mesh/src/runtime.rs"
click node_postgres "https://github.com/block/buzz/blob/main/crates/buzz-db/src/lib.rs"
click node_redis "https://github.com/block/buzz/blob/main/crates/buzz-pubsub/src/publisher.rs"
click node_search "https://github.com/block/buzz/blob/main/crates/buzz-search/src/query.rs"
click node_audit "https://github.com/block/buzz/blob/main/crates/buzz-audit/src/service.rs"
click node_object_store "https://github.com/block/buzz/blob/main/deploy/charts/buzz/templates/quickstart-minio.yaml"
click node_deployment "https://github.com/block/buzz/blob/main/deploy/compose/compose.yml"

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_desktop_ui,node_desktop_native,node_mobile,node_web,node_cli,node_acp_agent toneBlue
class node_relay_router,node_ingest toneAmber
class node_core,node_auth,node_collaboration,node_git,node_media,node_workflow,node_mesh,node_search,node_audit toneMint
class node_postgres,node_redis,node_object_store,node_deployment toneRose
```

## Components

### Clients & automation

- [Desktop React app](https://github.com/block/buzz/blob/main/desktop/src/main.tsx): Tauri frontend · `desktop/src/main.tsx`
- [Desktop native backend](https://github.com/block/buzz/blob/main/desktop/src-tauri/src/main.rs): Tauri Rust · Owns local state, sync, secrets, agents, and native media. · `desktop/src-tauri/src/main.rs`
- [Mobile app](https://github.com/block/buzz/blob/main/mobile/lib/main.dart): Flutter client · `mobile/lib/main.dart`
- [Web Git & invite client](https://github.com/block/buzz/blob/main/web/src/main.tsx): web client · `web/src/main.tsx`
- [Automation CLI](https://github.com/block/buzz/blob/main/crates/buzz-cli/src/main.rs): JSON CLI · `crates/buzz-cli/src/main.rs`
- [ACP & agent runtime](https://github.com/block/buzz/blob/main/crates/buzz-acp/src/main.rs): agent integration · Bridges ACP/MCP clients and runs Buzz agents. · `crates/buzz-acp/src/main.rs`

### Authoritative relay

- [Relay router & state](https://github.com/block/buzz/blob/main/crates/buzz-relay/src/router.rs): HTTP/WebSocket boundary · Community-scoped API and Nostr protocol entry point. · `crates/buzz-relay/src/router.rs`
- [Event ingestion](https://github.com/block/buzz/blob/main/crates/buzz-relay/src/handlers/ingest.rs): admission pipeline · Applies admission, authorization, persistence, subscriptions, and side effects. · `crates/buzz-relay/src/handlers/ingest.rs`

### Domain services

- [Core protocol domain](https://github.com/block/buzz/blob/main/crates/buzz-core/src/event.rs): I/O-free Rust crate · Defines signed events, channels, filters, identity, pairing, and tenancy. · `crates/buzz-core/src/event.rs`
- [Nostr auth & limits](https://github.com/block/buzz/blob/main/crates/buzz-auth/src/nip42.rs): security service · NIP-42/NIP-98 authentication with replay and rate-limit protection. · `crates/buzz-auth/src/nip42.rs`
- [Collaboration effects](https://github.com/block/buzz/blob/main/crates/buzz-relay/src/handlers/event.rs): event handlers · Channels, DMs, threads, reactions, feeds, and moderation. · `crates/buzz-relay/src/handlers/event.rs`
- [Git bridge & CAS](https://github.com/block/buzz/blob/main/crates/buzz-relay/src/api/git/transport.rs): Git HTTP service · Publishes packs and objects through object-store-oriented CAS. · `crates/buzz-relay/src/api/git/transport.rs`
- [Media pipeline](https://github.com/block/buzz/blob/main/crates/buzz-media/src/upload.rs): upload service · Validates uploads, records media, and creates thumbnails. · `crates/buzz-media/src/upload.rs`
- [Workflow executor](https://github.com/block/buzz/blob/main/crates/buzz-workflow/src/executor.rs): automation engine · `crates/buzz-workflow/src/executor.rs`
- [Relay mesh](https://github.com/block/buzz/blob/main/crates/buzz-relay-mesh/src/runtime.rs): optional model routing · `crates/buzz-relay-mesh/src/runtime.rs`
- [Postgres FTS](https://github.com/block/buzz/blob/main/crates/buzz-search/src/query.rs): search queries · `crates/buzz-search/src/query.rs`
- [Tamper-evident audit](https://github.com/block/buzz/blob/main/crates/buzz-audit/src/service.rs): history service · `crates/buzz-audit/src/service.rs`

### Backing infrastructure

- [Postgres](https://github.com/block/buzz/blob/main/crates/buzz-db/src/lib.rs): event & projection store · Persists events, projections, partitions, repository, and workflow state. · `crates/buzz-db/src/lib.rs`
- [Redis pub/sub](https://github.com/block/buzz/blob/main/crates/buzz-pubsub/src/publisher.rs): live distribution · Distributes events, presence, typing, invalidation, and connection control. · `crates/buzz-pubsub/src/publisher.rs`
- [S3-compatible storage](https://github.com/block/buzz/blob/main/deploy/charts/buzz/templates/quickstart-minio.yaml): object storage · Provisioned as MinIO in quickstart deployments. · `deploy/charts/buzz/templates/quickstart-minio.yaml`
- [Deployment targets](https://github.com/block/buzz/blob/main/deploy/compose/compose.yml): Compose & Helm · Deploys relay with Postgres, Redis, and object storage. · `deploy/compose/compose.yml`

## Connections

- Desktop React app → Desktop native backend: invokes
- Desktop native backend → Relay router & state: relay sync
- Mobile app → Relay router & state: Nostr sessions
- Web Git & invite client → Relay router & state: Git & invites
- Automation CLI → Relay router & state: automation events
- ACP & agent runtime → Relay router & state: agent events
- Relay router & state → Event ingestion: signed events
- Relay router & state → Git bridge & CAS: Git API
- Relay router & state → Media pipeline: media API
- Relay router & state → Workflow executor: workflow API
- Relay router & state → Nostr auth & limits: authenticates
- Relay router & state → Core protocol domain: host-derived tenant context
- Event ingestion → Core protocol domain: validates semantics
- Event ingestion → Nostr auth & limits: authorizes
- Event ingestion → Postgres: persists events
- Event ingestion → Redis pub/sub: publishes live updates
- Event ingestion → Collaboration effects: domain effects
- Event ingestion → Tamper-evident audit: records history
- Collaboration effects → Postgres: updates projections
- Git bridge & CAS → Postgres: repository state
- Git bridge & CAS → S3-compatible storage: packs & CAS objects
- Media pipeline → S3-compatible storage: uploads & thumbnails
- Media pipeline → Postgres: media records
- Workflow executor → Postgres: definitions & runs
- Postgres FTS → Postgres: FTS queries
- Relay router & state → Postgres FTS: search API
- Relay router & state → Relay mesh: optional routing
- Deployment targets → Relay router & state: deploys
- Deployment targets → Postgres: provisions
- Deployment targets → Redis pub/sub: provisions
- Deployment targets → S3-compatible storage: provisions
