# tinyhumansai/opencompany architecture

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

- Interactive diagram: https://gitdiagram.com/tinyhumansai/opencompany
- Repository: https://github.com/tinyhumansai/opencompany

## Overview

OpenCompany is a desktop/hosted operating runtime for a one-person business: an operator selects or configures a company, then durable company services coordinate agent desks and workflows into recorded work. The README documents hive episodes, cross-desk referrals, approvals, and journal-backed history; the source index supports the runtime, configuration, persistence, and console boundaries. Several product subsystems are visible only in the tree or README, so their internal call edges are omitted rather than inferred.

Main entry points: [`crates/opencompany-core/src/company/runtime.rs`](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/company/runtime.rs) (Company runtime), [`crates/opencompany-core/src/server/routes.rs`](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/server/routes.rs) (HTTP server), [`frontend/src/api/client.ts`](https://github.com/tinyhumansai/opencompany/blob/main/frontend/src/api/client.ts) (Console API client), [`crates/opencompany-core/src/company/mod.rs`](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/company/mod.rs) (Company definition)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_company["Company setup"]
  node_config["Runtime configuration<br/>[config.rs]"]
  node_companydef["Company definition<br/>[mod.rs]"]
  node_setup["Roster setup<br/>[setup.rs]"]
end

subgraph group_runtime["Agent runtime"]
  node_runtime["Company runtime<br/>[runtime.rs]"]
  node_workflow["Workflow execution<br/>[runner.rs]"]
  node_journal[("Run journal<br/>[journal.rs]")]
  node_brain["Agent cognition<br/>[hosted.rs]"]
  node_hive["Desk coordination<br/>[routing.rs]"]
  node_acp["Local agent protocol<br/>[client.rs]"]
end

subgraph group_domain["Business capabilities"]
  node_inference["Inference routing<br/>[inference.rs]"]
  node_mcp["Tool integrations<br/>[mcp.rs]"]
  node_ledger["Business ledgers<br/>[engine.rs]"]
  node_search["Company search<br/>[store.rs]"]
  node_feedback["Feedback triage<br/>[service.rs]"]
end

subgraph group_platform["Host and persistence"]
  node_server["HTTP server<br/>[routes.rs]"]
  node_auth["User authentication<br/>[routes.rs]"]
  node_memory["Memory engine API<br/>[memory_engine.rs]"]
  node_store[("Durable storage<br/>[mod.rs]")]
end

subgraph group_console["Operator surfaces"]
  node_desktop["Desktop app<br/>[main.rs]"]
  node_consoleui["Web console<br/>[App.tsx]"]
  node_api["Console API client<br/>[client.ts]"]
  node_setupui["Setup flow"]
end

node_operator(("Operator"))
node_externalagent{{"OpenHuman runtime"}}
node_model{{"Inference service"}}

node_operator -->|"launches"| node_desktop
node_operator -->|"operates"| node_consoleui
node_consoleui -.->|"requests"| node_api
node_setupui -.->|"submits setup"| node_api
node_api -.->|"calls API"| node_server
node_server -.->|"routes auth"| node_auth
node_server -->|"routes engine"| node_memory
node_config -->|"configures"| node_companydef
node_companydef -->|"defines roster"| node_setup
node_setup -.->|"starts company"| node_runtime
node_runtime -.->|"runs agents"| node_brain
node_runtime -->|"coordinates desks"| node_hive
node_runtime -.->|"runs workflows"| node_workflow
node_runtime -->|"records rounds"| node_journal
node_runtime -->|"uses ports"| node_store
node_brain -->|"hosted by"| node_externalagent
node_hive -->|"routes decisions"| node_model
node_runtime -.->|"local agent link"| node_acp
node_runtime -.->|"resolves models"| node_inference
node_runtime -.->|"dispatches tools"| node_mcp
node_runtime -.->|"updates records"| node_ledger
node_runtime -.->|"queries knowledge"| node_search
node_runtime -.->|"triages feedback"| node_feedback
node_memory -->|"rebuilds companies"| node_runtime
node_store -.->|"persists events"| node_journal

click node_desktop "https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-app/src/main.rs"
click node_consoleui "https://github.com/tinyhumansai/opencompany/blob/main/frontend/src/App.tsx"
click node_api "https://github.com/tinyhumansai/opencompany/blob/main/frontend/src/api/client.ts"
click node_setupui "https://github.com/tinyhumansai/opencompany/blob/main/frontend/src/setup/SetupController.tsx"
click node_config "https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/app/config.rs"
click node_companydef "https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/company/mod.rs"
click node_setup "https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/company/setup.rs"
click node_runtime "https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/company/runtime.rs"
click node_workflow "https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/workflows/runner.rs"
click node_journal "https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/runtime/journal.rs"
click node_brain "https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/brain/hosted.rs"
click node_hive "https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/hive/routing.rs"
click node_acp "https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-app/src/acp/client.rs"
click node_inference "https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/company/inference.rs"
click node_mcp "https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/company/mcp.rs"
click node_ledger "https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/ledger/engine.rs"
click node_search "https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/company/search/store.rs"
click node_feedback "https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/feedback/service.rs"
click node_server "https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/server/routes.rs"
click node_auth "https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/server/users/routes.rs"
click node_memory "https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/server/ops/memory_engine.rs"
click node_store "https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/store/mod.rs"

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_config,node_companydef,node_setup toneBlue
class node_runtime,node_workflow,node_journal,node_brain,node_hive,node_acp toneAmber
class node_inference,node_mcp,node_ledger,node_search,node_feedback toneMint
class node_server,node_auth,node_memory,node_store toneRose
class node_desktop,node_consoleui,node_api,node_setupui,node_operator,node_externalagent,node_model toneIndigo
```

## Components

### Company setup

- [Runtime configuration](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/app/config.rs): `crates/opencompany-core/src/app/config.rs`
- [Company definition](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/company/mod.rs): `crates/opencompany-core/src/company/mod.rs`
- [Roster setup](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/company/setup.rs): `crates/opencompany-core/src/company/setup.rs`

### Agent runtime

- [Company runtime](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/company/runtime.rs): `crates/opencompany-core/src/company/runtime.rs`
- [Workflow execution](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/workflows/runner.rs): `crates/opencompany-core/src/workflows/runner.rs`
- [Run journal](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/runtime/journal.rs): `crates/opencompany-core/src/runtime/journal.rs`
- [Agent cognition](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/brain/hosted.rs): `crates/opencompany-core/src/brain/hosted.rs`
- [Desk coordination](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/hive/routing.rs): `crates/opencompany-core/src/hive/routing.rs`
- [Local agent protocol](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-app/src/acp/client.rs): `crates/opencompany-app/src/acp/client.rs`

### Business capabilities

- [Inference routing](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/company/inference.rs): `crates/opencompany-core/src/company/inference.rs`
- [Tool integrations](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/company/mcp.rs): `crates/opencompany-core/src/company/mcp.rs`
- [Business ledgers](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/ledger/engine.rs): `crates/opencompany-core/src/ledger/engine.rs`
- [Company search](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/company/search/store.rs): `crates/opencompany-core/src/company/search/store.rs`
- [Feedback triage](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/feedback/service.rs): `crates/opencompany-core/src/feedback/service.rs`

### Host and persistence

- [HTTP server](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/server/routes.rs): `crates/opencompany-core/src/server/routes.rs`
- [User authentication](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/server/users/routes.rs): `crates/opencompany-core/src/server/users/routes.rs`
- [Memory engine API](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/server/ops/memory_engine.rs): `crates/opencompany-core/src/server/ops/memory_engine.rs`
- [Durable storage](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-core/src/store/mod.rs): `crates/opencompany-core/src/store/mod.rs`

### Operator surfaces

- [Desktop app](https://github.com/tinyhumansai/opencompany/blob/main/crates/opencompany-app/src/main.rs): `crates/opencompany-app/src/main.rs`
- [Web console](https://github.com/tinyhumansai/opencompany/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Console API client](https://github.com/tinyhumansai/opencompany/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Setup flow](https://github.com/tinyhumansai/opencompany/blob/main/frontend/src/setup/SetupController.tsx): `frontend/src/setup/SetupController.tsx`

### Other components

- **Operator**
- **OpenHuman runtime**
- **Inference service**

## Connections

- Operator → Desktop app: launches (evidence: `README.md`)
- Operator → Web console: operates (evidence: `README.md`)
- Web console → Console API client: requests
- Setup flow → Console API client: submits setup
- Console API client → HTTP server: calls API
- HTTP server → User authentication: routes auth
- HTTP server → Memory engine API: routes engine (evidence: `crates/opencompany-core/src/server/ops/memory_engine.rs`)
- Runtime configuration → Company definition: configures (evidence: `crates/opencompany-core/src/app/config.rs`)
- Company definition → Roster setup: defines roster (evidence: `crates/opencompany-core/src/company/mod.rs`)
- Roster setup → Company runtime: starts company
- Company runtime → Agent cognition: runs agents
- Company runtime → Desk coordination: coordinates desks (evidence: `README.md`)
- Company runtime → Workflow execution: runs workflows
- Company runtime → Run journal: records rounds (evidence: `README.md`)
- Company runtime → Durable storage: uses ports (evidence: `crates/opencompany-core/src/store/mod.rs`)
- Agent cognition → OpenHuman runtime: hosted by (evidence: `README.md`)
- Desk coordination → Inference service: routes decisions (evidence: `README.md`)
- Company runtime → Local agent protocol: local agent link
- Company runtime → Inference routing: resolves models
- Company runtime → Tool integrations: dispatches tools
- Company runtime → Business ledgers: updates records
- Company runtime → Company search: queries knowledge
- Company runtime → Feedback triage: triages feedback
- Memory engine API → Company runtime: rebuilds companies (evidence: `crates/opencompany-core/src/server/ops/memory_engine.rs`)
- Durable storage → Run journal: persists events
