# openbmb/staffdeck architecture

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

- Interactive diagram: https://gitdiagram.com/openbmb/staffdeck
- Repository: https://github.com/openbmb/staffdeck

## Overview

StaffDeck is an enterprise platform for building and operating digital employees. The principal workflow runs from configuring an employee and its SOP, knowledge, and capabilities, through a user or scheduled task, to model-guided execution of business operations and a traceable result. The README also describes channels, citations, memory, human takeover, and feedback as product capabilities. The map combines those documented stages with the sampled Harness v3 composition and execution layers; links for unsampled subsystems are marked unverified rather than inferred as direct calls.

Main entry points: [`backend/src/staffdeck_harness/bridge/engine_host.py`](https://github.com/openbmb/staffdeck/blob/main/backend/src/staffdeck_harness/bridge/engine_host.py) (Harness v3 Engine), [`backend/app/main.py`](https://github.com/openbmb/staffdeck/blob/main/backend/app/main.py) (Application API), [`backend/app/core/turn_coordinator.py`](https://github.com/openbmb/staffdeck/blob/main/backend/app/core/turn_coordinator.py) (Turn Coordinator), [`frontend-enterprise/src/App.tsx`](https://github.com/openbmb/staffdeck/blob/main/frontend-enterprise/src/App.tsx) (Enterprise UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User Experience"]
  node_web["Enterprise UI<br/>[App.tsx]"]
  node_api["Application API<br/>[main.py]"]
  node_chat["Chat Session<br/>[useChatSession.ts]"]
  node_channel["IM Channels"]
end

subgraph group_employee["Employee Setup"]
  node_staff["Digital Employees<br/>[agents.py]"]
  node_sop["Procedural SOPs"]
  node_composition["Composition Snapshot<br/>[compiler.py]"]
  node_registry["Module Registry<br/>[registry.py]"]
end

subgraph group_execution["Execution Runtime"]
  node_coordinator["Turn Coordinator"]
  node_engine["Harness v3 Engine<br/>[engine_host.py]"]
  node_model["Model Service<br/>[client.py]"]
end

subgraph group_capabilities["Business Capabilities"]
  node_tools["Business Operations<br/>[tool_executor.py]"]
  node_knowledge["Knowledge Retrieval<br/>[service.py]"]
  node_general["General Skills<br/>[runner.py]"]
  node_scheduled["Scheduled Tasks<br/>[worker.py]"]
end

subgraph group_state["State and Improvement"]
  node_database[("Application Data<br/>[models.py]")]
  node_memory["Long-term Memory<br/>[service.py]"]
  node_traces["Execution Traces<br/>[event_log.py]"]
  node_feedback["Feedback Loop<br/>[service.py]"]
  node_human["Human Takeover"]
end

node_user(("User"))

node_user -->|"uses"| node_web
node_web -.->|"requests"| node_api
node_user -.->|"messages"| node_channel
node_web -.->|"opens chat"| node_chat
node_chat -.->|"submits turn"| node_api
node_api -.->|"manages"| node_staff
node_staff -->|"configures"| node_sop
node_staff -->|"composes"| node_composition
node_registry -->|"provides hooks"| node_composition
node_api -.->|"starts turns"| node_coordinator
node_coordinator -->|"dispatches"| node_engine
node_engine -.->|"runs model stages"| node_model
node_engine -.->|"invokes operations"| node_tools
node_engine -.->|"retrieves sources"| node_knowledge
node_engine -.->|"uses skills"| node_general
node_scheduled -.->|"starts work"| node_coordinator
node_knowledge -.->|"reads indexed content"| node_database
node_memory -.->|"stores memories"| node_database
node_engine -.->|"records activity"| node_traces
node_user -->|"provides feedback"| node_feedback
node_engine -->|"requests takeover"| node_human
node_channel -.->|"routes messages"| node_coordinator

click node_web "https://github.com/openbmb/staffdeck/blob/main/frontend-enterprise/src/App.tsx"
click node_api "https://github.com/openbmb/staffdeck/blob/main/backend/app/main.py"
click node_chat "https://github.com/openbmb/staffdeck/blob/main/frontend-enterprise/src/pages/chat/useChatSession.ts"
click node_channel "https://github.com/openbmb/staffdeck/tree/main/backend/app/channels"
click node_staff "https://github.com/openbmb/staffdeck/blob/main/backend/app/api/agents.py"
click node_sop "https://github.com/openbmb/staffdeck/tree/main/backend/app/skills"
click node_composition "https://github.com/openbmb/staffdeck/blob/main/backend/src/staffdeck_harness/composition/compiler.py"
click node_registry "https://github.com/openbmb/staffdeck/blob/main/backend/src/staffdeck_harness/modules/registry.py"
click node_coordinator "https://github.com/openbmb/staffdeck/blob/main/backend/app/core/turn_coordinator.py"
click node_engine "https://github.com/openbmb/staffdeck/blob/main/backend/src/staffdeck_harness/bridge/engine_host.py"
click node_model "https://github.com/openbmb/staffdeck/blob/main/backend/app/llm/client.py"
click node_tools "https://github.com/openbmb/staffdeck/blob/main/backend/app/tools/tool_executor.py"
click node_knowledge "https://github.com/openbmb/staffdeck/blob/main/backend/app/knowledge/service.py"
click node_general "https://github.com/openbmb/staffdeck/blob/main/backend/app/general_skills/runner.py"
click node_scheduled "https://github.com/openbmb/staffdeck/blob/main/backend/app/scheduled_tasks/worker.py"
click node_database "https://github.com/openbmb/staffdeck/blob/main/backend/app/db/models.py"
click node_memory "https://github.com/openbmb/staffdeck/blob/main/backend/app/memory/service.py"
click node_traces "https://github.com/openbmb/staffdeck/blob/main/backend/app/observability/event_log.py"
click node_feedback "https://github.com/openbmb/staffdeck/blob/main/backend/app/feedback/service.py"
click node_human "https://github.com/openbmb/staffdeck/blob/main/backend/app/core/human_handoff_service.py"

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_api,node_chat,node_channel,node_user toneBlue
class node_staff,node_sop,node_composition,node_registry toneAmber
class node_coordinator,node_engine,node_model toneMint
class node_tools,node_knowledge,node_general,node_scheduled toneRose
class node_database,node_memory,node_traces,node_feedback,node_human toneIndigo
```

## Components

### User Experience

- [Enterprise UI](https://github.com/openbmb/staffdeck/blob/main/frontend-enterprise/src/App.tsx): `frontend-enterprise/src/App.tsx`
- [Application API](https://github.com/openbmb/staffdeck/blob/main/backend/app/main.py): `backend/app/main.py`
- [Chat Session](https://github.com/openbmb/staffdeck/blob/main/frontend-enterprise/src/pages/chat/useChatSession.ts): `frontend-enterprise/src/pages/chat/useChatSession.ts`
- [IM Channels](https://github.com/openbmb/staffdeck/tree/main/backend/app/channels): `backend/app/channels`

### Employee Setup

- [Digital Employees](https://github.com/openbmb/staffdeck/blob/main/backend/app/api/agents.py): `backend/app/api/agents.py`
- [Procedural SOPs](https://github.com/openbmb/staffdeck/tree/main/backend/app/skills): `backend/app/skills`
- [Composition Snapshot](https://github.com/openbmb/staffdeck/blob/main/backend/src/staffdeck_harness/composition/compiler.py): `backend/src/staffdeck_harness/composition/compiler.py`
- [Module Registry](https://github.com/openbmb/staffdeck/blob/main/backend/src/staffdeck_harness/modules/registry.py): `backend/src/staffdeck_harness/modules/registry.py`

### Execution Runtime

- [Turn Coordinator](https://github.com/openbmb/staffdeck/blob/main/backend/app/core/turn_coordinator.py): `backend/app/core/turn_coordinator.py`
- [Harness v3 Engine](https://github.com/openbmb/staffdeck/blob/main/backend/src/staffdeck_harness/bridge/engine_host.py): `backend/src/staffdeck_harness/bridge/engine_host.py`
- [Model Service](https://github.com/openbmb/staffdeck/blob/main/backend/app/llm/client.py): `backend/app/llm/client.py`

### Business Capabilities

- [Business Operations](https://github.com/openbmb/staffdeck/blob/main/backend/app/tools/tool_executor.py): `backend/app/tools/tool_executor.py`
- [Knowledge Retrieval](https://github.com/openbmb/staffdeck/blob/main/backend/app/knowledge/service.py): `backend/app/knowledge/service.py`
- [General Skills](https://github.com/openbmb/staffdeck/blob/main/backend/app/general_skills/runner.py): `backend/app/general_skills/runner.py`
- [Scheduled Tasks](https://github.com/openbmb/staffdeck/blob/main/backend/app/scheduled_tasks/worker.py): `backend/app/scheduled_tasks/worker.py`

### State and Improvement

- [Application Data](https://github.com/openbmb/staffdeck/blob/main/backend/app/db/models.py): `backend/app/db/models.py`
- [Long-term Memory](https://github.com/openbmb/staffdeck/blob/main/backend/app/memory/service.py): `backend/app/memory/service.py`
- [Execution Traces](https://github.com/openbmb/staffdeck/blob/main/backend/app/observability/event_log.py): `backend/app/observability/event_log.py`
- [Feedback Loop](https://github.com/openbmb/staffdeck/blob/main/backend/app/feedback/service.py): `backend/app/feedback/service.py`
- [Human Takeover](https://github.com/openbmb/staffdeck/blob/main/backend/app/core/human_handoff_service.py): `backend/app/core/human_handoff_service.py`

### Other components

- **User**

## Connections

- User → Enterprise UI: uses (evidence: `README.md`)
- Enterprise UI → Application API: requests
- User → IM Channels: messages
- Enterprise UI → Chat Session: opens chat
- Chat Session → Application API: submits turn
- Application API → Digital Employees: manages (evidence: `backend/app/main.py`)
- Digital Employees → Procedural SOPs: configures (evidence: `README.md`)
- Digital Employees → Composition Snapshot: composes (evidence: `backend/src/staffdeck_harness/composition/compiler.py`)
- Module Registry → Composition Snapshot: provides hooks (evidence: `backend/src/staffdeck_harness/composition/compiler.py`)
- Application API → Turn Coordinator: starts turns
- Turn Coordinator → Harness v3 Engine: dispatches (evidence: `backend/src/staffdeck_harness/bridge/engine_host.py`)
- Harness v3 Engine → Model Service: runs model stages
- Harness v3 Engine → Business Operations: invokes operations
- Harness v3 Engine → Knowledge Retrieval: retrieves sources
- Harness v3 Engine → General Skills: uses skills
- Scheduled Tasks → Turn Coordinator: starts work
- Knowledge Retrieval → Application Data: reads indexed content
- Long-term Memory → Application Data: stores memories
- Harness v3 Engine → Execution Traces: records activity (evidence: `backend/src/staffdeck_harness/bridge/engine_host.py`)
- User → Feedback Loop: provides feedback (evidence: `README.md`)
- Harness v3 Engine → Human Takeover: requests takeover (evidence: `README.md`)
- IM Channels → Turn Coordinator: routes messages
