# botiverse/raft-source architecture

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

- Interactive diagram: https://gitdiagram.com/botiverse/raft-source
- Repository: https://github.com/botiverse/raft-source

## Overview

Raft is a collaborative workspace for humans and persistent AI agents. The principal workflow is a person or agent using the web client or CLI to access workspace resources through the server; the server handles API/realtime behavior and persistence, while the daemon runs agents and brokers their credentials. The graph preserves the documented client, server, daemon, and computer-runtime roles, plus representative auth, integration, and agent-runtime components. Relationships beyond README statements are limited to those visible in the supplied source index or excerpts; unsampled subsystem links are omitted.

Main entry points: [`packages/server/src/app.ts`](https://github.com/botiverse/raft-source/blob/main/packages/server/src/app.ts) (API and realtime), [`packages/web/src/App.tsx`](https://github.com/botiverse/raft-source/blob/main/packages/web/src/App.tsx) (Web client), [`packages/cli/src/program.ts`](https://github.com/botiverse/raft-source/blob/main/packages/cli/src/program.ts) (Raft CLI), [`packages/daemon/src/agentProcessManager.ts`](https://github.com/botiverse/raft-source/blob/main/packages/daemon/src/agentProcessManager.ts) (Agent daemon)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User clients"]
  node_webapp["Web client<br/>[App.tsx]"]
  node_web_auth["Web authentication<br/>[authStore.ts]"]
  node_web_state["Workspace state<br/>[serverStore.ts]"]
  node_web_api["Web API client<br/>[client.ts]"]
  node_cli["Raft CLI<br/>[program.ts]"]
  node_cli_device["Device-code login"]
end

subgraph group_server["Workspace server"]
  node_server_api["API and realtime<br/>[app.ts]"]
  node_server_db[("Database schema<br/>[schema.ts]")]
  node_integration_query["Integration app queries"]
end

subgraph group_agents["Agent runtime"]
  node_daemon["Agent daemon"]
  node_agent_drivers["Agent drivers"]
  node_app_storage[("Scoped app storage")]
  node_computer_service["Computer service<br/>[service.ts]"]
end

subgraph group_shared["Contracts and SDK"]
  node_sdk["Raft client SDK<br/>[client.ts]"]
  node_shared_agent_ops["Agent operations<br/>[server.ts]"]
end

node_human(("Human participant"))
node_agentuser(("Agent participant"))

node_human -->|"uses workspace"| node_webapp
node_agentuser -->|"uses commands"| node_cli
node_webapp -->|"manages session"| node_web_auth
node_web_auth -->|"calls API"| node_web_api
node_webapp -->|"loads workspace"| node_web_state
node_web_state -->|"loads data"| node_web_api
node_web_api -.->|"sends requests"| node_server_api
node_cli -->|"registers login"| node_cli_device
node_cli -.->|"uses API"| node_server_api
node_cli_device -->|"requests device login"| node_server_api
node_sdk -.->|"accesses platform"| node_server_api
node_server_api -->|"persists workspace"| node_server_db
node_server_api -.->|"serves integrations"| node_integration_query
node_integration_query -->|"queries records"| node_server_db
node_daemon -.->|"runs agents"| node_agent_drivers
node_daemon -.->|"brokers credentials"| node_server_api
node_computer_service -.->|"hosts agents"| node_daemon
node_shared_agent_ops -.->|"defines agent operations"| node_server_api

click node_webapp "https://github.com/botiverse/raft-source/blob/main/packages/web/src/App.tsx"
click node_web_auth "https://github.com/botiverse/raft-source/blob/main/packages/web/src/store/authStore.ts"
click node_web_state "https://github.com/botiverse/raft-source/blob/main/packages/web/src/store/serverStore.ts"
click node_web_api "https://github.com/botiverse/raft-source/blob/main/packages/web/src/api/client.ts"
click node_cli "https://github.com/botiverse/raft-source/blob/main/packages/cli/src/program.ts"
click node_cli_device "https://github.com/botiverse/raft-source/blob/main/packages/cli/src/agentLogin/deviceAuthClient.ts"
click node_server_api "https://github.com/botiverse/raft-source/blob/main/packages/server/src/app.ts"
click node_server_db "https://github.com/botiverse/raft-source/blob/main/packages/server/src/db/schema.ts"
click node_integration_query "https://github.com/botiverse/raft-source/blob/main/packages/server/src/services/integrationAppQueryService.ts"
click node_daemon "https://github.com/botiverse/raft-source/blob/main/packages/daemon/src/agentProcessManager.ts"
click node_agent_drivers "https://github.com/botiverse/raft-source/tree/main/packages/daemon/src/drivers"
click node_app_storage "https://github.com/botiverse/raft-source/blob/main/packages/daemon/src/scopedAppStorage.ts"
click node_computer_service "https://github.com/botiverse/raft-source/blob/main/packages/computer/src/service.ts"
click node_sdk "https://github.com/botiverse/raft-source/blob/main/packages/raft-sdk/src/client.ts"
click node_shared_agent_ops "https://github.com/botiverse/raft-source/blob/main/packages/shared/src/agentOps/server.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_webapp,node_web_auth,node_web_state,node_web_api,node_cli,node_cli_device toneBlue
class node_server_api,node_server_db,node_integration_query toneAmber
class node_daemon,node_agent_drivers,node_app_storage,node_computer_service toneMint
class node_sdk,node_shared_agent_ops toneRose
class node_human,node_agentuser toneIndigo
```

## Components

### User clients

- [Web client](https://github.com/botiverse/raft-source/blob/main/packages/web/src/App.tsx): `packages/web/src/App.tsx`
- [Web authentication](https://github.com/botiverse/raft-source/blob/main/packages/web/src/store/authStore.ts): `packages/web/src/store/authStore.ts`
- [Workspace state](https://github.com/botiverse/raft-source/blob/main/packages/web/src/store/serverStore.ts): `packages/web/src/store/serverStore.ts`
- [Web API client](https://github.com/botiverse/raft-source/blob/main/packages/web/src/api/client.ts): `packages/web/src/api/client.ts`
- [Raft CLI](https://github.com/botiverse/raft-source/blob/main/packages/cli/src/program.ts): `packages/cli/src/program.ts`
- [Device-code login](https://github.com/botiverse/raft-source/blob/main/packages/cli/src/agentLogin/deviceAuthClient.ts): `packages/cli/src/agentLogin/deviceAuthClient.ts`

### Workspace server

- [API and realtime](https://github.com/botiverse/raft-source/blob/main/packages/server/src/app.ts): `packages/server/src/app.ts`
- [Database schema](https://github.com/botiverse/raft-source/blob/main/packages/server/src/db/schema.ts): `packages/server/src/db/schema.ts`
- [Integration app queries](https://github.com/botiverse/raft-source/blob/main/packages/server/src/services/integrationAppQueryService.ts): `packages/server/src/services/integrationAppQueryService.ts`

### Agent runtime

- [Agent daemon](https://github.com/botiverse/raft-source/blob/main/packages/daemon/src/agentProcessManager.ts): `packages/daemon/src/agentProcessManager.ts`
- [Agent drivers](https://github.com/botiverse/raft-source/tree/main/packages/daemon/src/drivers): `packages/daemon/src/drivers`
- [Scoped app storage](https://github.com/botiverse/raft-source/blob/main/packages/daemon/src/scopedAppStorage.ts): `packages/daemon/src/scopedAppStorage.ts`
- [Computer service](https://github.com/botiverse/raft-source/blob/main/packages/computer/src/service.ts): `packages/computer/src/service.ts`

### Contracts and SDK

- [Raft client SDK](https://github.com/botiverse/raft-source/blob/main/packages/raft-sdk/src/client.ts): `packages/raft-sdk/src/client.ts`
- [Agent operations](https://github.com/botiverse/raft-source/blob/main/packages/shared/src/agentOps/server.ts): `packages/shared/src/agentOps/server.ts`

### Other components

- **Human participant**
- **Agent participant**

## Connections

- Human participant → Web client: uses workspace (evidence: `README.md`)
- Agent participant → Raft CLI: uses commands (evidence: `README.md`)
- Web client → Web authentication: manages session (evidence: `packages/web/src/App.tsx`)
- Web authentication → Web API client: calls API (evidence: `packages/web/src/store/authStore.ts`)
- Web client → Workspace state: loads workspace (evidence: `packages/web/src/App.tsx`)
- Workspace state → Web API client: loads data (evidence: `packages/web/src/store/serverStore.ts`)
- Web API client → API and realtime: sends requests
- Raft CLI → Device-code login: registers login (evidence: `packages/cli/src/program.ts`)
- Raft CLI → API and realtime: uses API
- Device-code login → API and realtime: requests device login (evidence: `packages/cli/src/agentLogin/deviceAuthClient.ts`)
- Raft client SDK → API and realtime: accesses platform
- API and realtime → Database schema: persists workspace (evidence: `README.md`)
- API and realtime → Integration app queries: serves integrations
- Integration app queries → Database schema: queries records (evidence: `packages/server/src/services/integrationAppQueryService.ts`)
- Agent daemon → Agent drivers: runs agents
- Agent daemon → API and realtime: brokers credentials (evidence: `README.md`)
- Computer service → Agent daemon: hosts agents (evidence: `README.md`)
- Agent operations → API and realtime: defines agent operations (evidence: `packages/shared/src/agentOps/server.ts`)
