# spytensor/muster architecture

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

- Interactive diagram: https://gitdiagram.com/spytensor/muster
- Repository: https://github.com/spytensor/muster

## Overview

Muster is an enterprise agent workspace paired with an administrative control plane and a governed agent runtime. Employees use the web, desktop, or iOS client to sign in, chat with an agent, and work with files and project materials; the server runs the request through policy-controlled tools and returns the result. Administrators govern agent identities, approvals, access, usage, traces, and audit records. The graph preserves documented integrations and major product areas; several server subsystems are represented by their exact directories because their implementations were not sampled.

Main entry points: [`apps/server/src/app.ts`](https://github.com/spytensor/muster/blob/main/apps/server/src/app.ts) (HTTP application), [`apps/server/src/runtime`](https://github.com/spytensor/muster/tree/main/apps/server/src/runtime) (Agent runtime), [`apps/server/src/runtime/run/gateway.ts`](https://github.com/spytensor/muster/blob/main/apps/server/src/runtime/run/gateway.ts) (Tool gateway), [`apps/server/src/audit.ts`](https://github.com/spytensor/muster/blob/main/apps/server/src/audit.ts) (Audit records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Employee clients"]
  node_web["Web workspace<br/>[App.tsx]"]
  node_webchat["Chat workflow<br/>[useConversation.ts]"]
  node_desktop["Desktop client<br/>[main.ts]"]
  node_mobile["iOS client<br/>[App.tsx]"]
  node_mobilechat["Mobile chat<br/>[Chat.tsx]"]
  node_mobileapi["Mobile API client<br/>[api.ts]"]
  node_admin["Admin console<br/>[Overview.tsx]"]
end

subgraph group_server["Server services"]
  node_serverapp["HTTP application<br/>[app.ts]"]
  node_auth["Sign-in and sessions<br/>[app-routes.ts]"]
  node_projects["Projects and items<br/>[projects.ts]"]
end

subgraph group_runtime["Governed runtime"]
  node_runtime["Agent runtime"]
  node_gateway{{"Tool gateway<br/>[gateway.ts]"}}
  node_sandbox["Code sandbox<br/>[runner.ts]"]
  node_models["Model providers<br/>[models.ts]"]
end

subgraph group_control["Company control plane"]
  node_governance["Agent governance<br/>[roles.ts]"]
  node_directory["Directory and SSO"]
  node_audit[("Audit records<br/>[audit.ts]")]
  node_protocol["Identity and events<br/>[events.ts]"]
end

subgraph group_data["Files and persistence"]
  node_files["File services<br/>[service.ts]"]
  node_extract["File extraction<br/>[extract.ts]"]
  node_database[("Database<br/>[db.ts]")]
end

node_employee(("Employee"))
node_personnel(("Company administrator"))

node_employee -->|"uses"| node_web
node_employee -->|"uses"| node_desktop
node_employee -->|"uses"| node_mobile
node_web -->|"opens chat"| node_webchat
node_employee -->|"chats with"| node_mobilechat
node_mobilechat -->|"sends requests"| node_mobileapi
node_webchat -->|"sends requests"| node_serverapp
node_mobileapi -->|"calls API"| node_serverapp
node_desktop -->|"connects to"| node_serverapp
node_serverapp -->|"routes sign-in"| node_auth
node_serverapp -->|"runs agents"| node_runtime
node_runtime -->|"dispatches tools"| node_gateway
node_gateway -->|"checks policy"| node_governance
node_runtime -->|"requests completions"| node_models
node_gateway -->|"runs code"| node_sandbox
node_serverapp -->|"serves projects"| node_projects
node_serverapp -->|"serves files"| node_files
node_files -->|"extracts content"| node_extract
node_files -->|"stores metadata"| node_database
node_serverapp -->|"persists state"| node_database
node_personnel -->|"governs agents"| node_admin
node_admin -->|"manages workspace"| node_serverapp
node_serverapp -->|"enforces controls"| node_governance
node_serverapp -->|"supports identity"| node_directory
node_serverapp -->|"records activity"| node_audit
node_audit -->|"writes events"| node_database
node_audit -->|"uses event definitions"| node_protocol

click node_web "https://github.com/spytensor/muster/blob/main/apps/web/src/App.tsx"
click node_webchat "https://github.com/spytensor/muster/blob/main/apps/web/src/app/chat/useConversation.ts"
click node_desktop "https://github.com/spytensor/muster/blob/main/apps/desktop/src/main.ts"
click node_mobile "https://github.com/spytensor/muster/blob/main/apps/mobile/App.tsx"
click node_mobilechat "https://github.com/spytensor/muster/blob/main/apps/mobile/src/screens/Chat.tsx"
click node_mobileapi "https://github.com/spytensor/muster/blob/main/apps/mobile/src/lib/api.ts"
click node_serverapp "https://github.com/spytensor/muster/blob/main/apps/server/src/app.ts"
click node_auth "https://github.com/spytensor/muster/blob/main/apps/server/src/auth/app-routes.ts"
click node_projects "https://github.com/spytensor/muster/blob/main/apps/server/src/projects.ts"
click node_files "https://github.com/spytensor/muster/blob/main/apps/server/src/files/service.ts"
click node_extract "https://github.com/spytensor/muster/blob/main/apps/server/src/files/extract.ts"
click node_database "https://github.com/spytensor/muster/blob/main/apps/server/src/db.ts"
click node_runtime "https://github.com/spytensor/muster/tree/main/apps/server/src/runtime"
click node_gateway "https://github.com/spytensor/muster/blob/main/apps/server/src/runtime/run/gateway.ts"
click node_sandbox "https://github.com/spytensor/muster/blob/main/apps/sandbox/src/runner.ts"
click node_models "https://github.com/spytensor/muster/blob/main/apps/server/src/runtime/models.ts"
click node_governance "https://github.com/spytensor/muster/blob/main/apps/server/src/roles.ts"
click node_directory "https://github.com/spytensor/muster/tree/main/apps/server/src/directory"
click node_admin "https://github.com/spytensor/muster/blob/main/apps/web/src/pages/Overview.tsx"
click node_audit "https://github.com/spytensor/muster/blob/main/apps/server/src/audit.ts"
click node_protocol "https://github.com/spytensor/muster/blob/main/packages/protocol/src/events.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_web,node_webchat,node_desktop,node_mobile,node_mobilechat,node_mobileapi,node_admin toneBlue
class node_serverapp,node_auth,node_projects toneAmber
class node_runtime,node_gateway,node_sandbox,node_models toneMint
class node_governance,node_directory,node_audit,node_protocol toneRose
class node_files,node_extract,node_database,node_employee,node_personnel toneIndigo
```

## Components

### Employee clients

- [Web workspace](https://github.com/spytensor/muster/blob/main/apps/web/src/App.tsx): `apps/web/src/App.tsx`
- [Chat workflow](https://github.com/spytensor/muster/blob/main/apps/web/src/app/chat/useConversation.ts): `apps/web/src/app/chat/useConversation.ts`
- [Desktop client](https://github.com/spytensor/muster/blob/main/apps/desktop/src/main.ts): `apps/desktop/src/main.ts`
- [iOS client](https://github.com/spytensor/muster/blob/main/apps/mobile/App.tsx): `apps/mobile/App.tsx`
- [Mobile chat](https://github.com/spytensor/muster/blob/main/apps/mobile/src/screens/Chat.tsx): `apps/mobile/src/screens/Chat.tsx`
- [Mobile API client](https://github.com/spytensor/muster/blob/main/apps/mobile/src/lib/api.ts): `apps/mobile/src/lib/api.ts`
- [Admin console](https://github.com/spytensor/muster/blob/main/apps/web/src/pages/Overview.tsx): `apps/web/src/pages/Overview.tsx`

### Server services

- [HTTP application](https://github.com/spytensor/muster/blob/main/apps/server/src/app.ts): `apps/server/src/app.ts`
- [Sign-in and sessions](https://github.com/spytensor/muster/blob/main/apps/server/src/auth/app-routes.ts): `apps/server/src/auth/app-routes.ts`
- [Projects and items](https://github.com/spytensor/muster/blob/main/apps/server/src/projects.ts): `apps/server/src/projects.ts`

### Governed runtime

- [Agent runtime](https://github.com/spytensor/muster/tree/main/apps/server/src/runtime): `apps/server/src/runtime`
- [Tool gateway](https://github.com/spytensor/muster/blob/main/apps/server/src/runtime/run/gateway.ts): `apps/server/src/runtime/run/gateway.ts`
- [Code sandbox](https://github.com/spytensor/muster/blob/main/apps/sandbox/src/runner.ts): `apps/sandbox/src/runner.ts`
- [Model providers](https://github.com/spytensor/muster/blob/main/apps/server/src/runtime/models.ts): `apps/server/src/runtime/models.ts`

### Company control plane

- [Agent governance](https://github.com/spytensor/muster/blob/main/apps/server/src/roles.ts): `apps/server/src/roles.ts`
- [Directory and SSO](https://github.com/spytensor/muster/tree/main/apps/server/src/directory): `apps/server/src/directory`
- [Audit records](https://github.com/spytensor/muster/blob/main/apps/server/src/audit.ts): `apps/server/src/audit.ts`
- [Identity and events](https://github.com/spytensor/muster/blob/main/packages/protocol/src/events.ts): `packages/protocol/src/events.ts`

### Files and persistence

- [File services](https://github.com/spytensor/muster/blob/main/apps/server/src/files/service.ts): `apps/server/src/files/service.ts`
- [File extraction](https://github.com/spytensor/muster/blob/main/apps/server/src/files/extract.ts): `apps/server/src/files/extract.ts`
- [Database](https://github.com/spytensor/muster/blob/main/apps/server/src/db.ts): `apps/server/src/db.ts`

### Other components

- **Employee**
- **Company administrator**

## Connections

- Employee → Web workspace: uses (evidence: `README.md`)
- Employee → Desktop client: uses (evidence: `README.md`)
- Employee → iOS client: uses (evidence: `README.md`)
- Web workspace → Chat workflow: opens chat (evidence: `README.md`)
- Employee → Mobile chat: chats with (evidence: `README.md`)
- Mobile chat → Mobile API client: sends requests (evidence: `apps/mobile/src/screens/Chat.tsx`)
- Chat workflow → HTTP application: sends requests (evidence: `apps/web/src/app/chat/useConversation.ts`)
- Mobile API client → HTTP application: calls API (evidence: `apps/mobile/src/lib/api.ts`)
- Desktop client → HTTP application: connects to (evidence: `apps/desktop/src/main.ts`)
- HTTP application → Sign-in and sessions: routes sign-in (evidence: `apps/server/src/app.ts`)
- HTTP application → Agent runtime: runs agents (evidence: `README.md`)
- Agent runtime → Tool gateway: dispatches tools (evidence: `README.md`)
- Tool gateway → Agent governance: checks policy (evidence: `README.md`)
- Agent runtime → Model providers: requests completions (evidence: `README.md`)
- Tool gateway → Code sandbox: runs code (evidence: `README.md`)
- HTTP application → Projects and items: serves projects (evidence: `apps/server/src/projectItemRoutes.ts`)
- HTTP application → File services: serves files (evidence: `README.md`)
- File services → File extraction: extracts content (evidence: `apps/server/src/files/service.ts`)
- File services → Database: stores metadata (evidence: `apps/server/src/files/service.ts`)
- HTTP application → Database: persists state (evidence: `README.md`)
- Company administrator → Admin console: governs agents (evidence: `README.md`)
- Admin console → HTTP application: manages workspace (evidence: `README.md`)
- HTTP application → Agent governance: enforces controls (evidence: `README.md`)
- HTTP application → Directory and SSO: supports identity (evidence: `README.md`)
- HTTP application → Audit records: records activity (evidence: `apps/server/src/app.ts`)
- Audit records → Database: writes events (evidence: `apps/server/src/audit.ts`)
- Audit records → Identity and events: uses event definitions (evidence: `apps/server/src/audit.ts`)
