# phonsadboy/atrium-th architecture

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

- Interactive diagram: https://gitdiagram.com/phonsadboy/atrium-th
- Repository: https://github.com/phonsadboy/atrium-th

## Overview

ATRIUM is a local-first AI-company workspace: a user chats with an Executive, work can be routed to departments, and the system exposes tasks, artifacts, memory, and runtime status through its UI. The frontend communicates with the FastAPI service over REST and WebSocket; backend orchestration, persistence, providers, and tools support the workflow. The README also documents provider options, media capabilities, and local visual automation. Some backend wiring is unsampled, so uncertain links are omitted or marked unverified.

Main entry points: [`system/app/chat_tools.py`](https://github.com/phonsadboy/atrium-th/blob/main/system/app/chat_tools.py) (Chat and tool flow), [`system/app/engine.py`](https://github.com/phonsadboy/atrium-th/blob/main/system/app/engine.py) (Company engine), [`system/app/db/repo.py`](https://github.com/phonsadboy/atrium-th/blob/main/system/app/db/repo.py) (Data repository), [`system/app/memory/embeddings.py`](https://github.com/phonsadboy/atrium-th/blob/main/system/app/memory/embeddings.py) (Embedding layer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Workspace UI"]
  node_ui_app["Workspace UI<br/>[App.tsx]"]
  node_company_state["Company state client<br/>[useCompany.ts]"]
  node_api_client["REST and WS client<br/>[ApiClient.ts]"]
end

subgraph group_service["Backend Workflow"]
  node_api_service["FastAPI service<br/>[main.py]"]
  node_engine["Company engine<br/>[engine.py]"]
  node_chat_tools["Chat and tool flow<br/>[chat_tools.py]"]
  node_department_routing["Department routing<br/>[router.py]"]
  node_task_review["Task review scheduling<br/>[task_review.py]"]
  node_catalog["Company catalog<br/>[catalog.py]"]
  node_threads["Thread identifiers<br/>[threads.py]"]
end

subgraph group_knowledge["Memory and Data"]
  node_repository[("Data repository<br/>[repo.py]")]
  node_memory_ledger["Memory ledger<br/>[ledger.py]"]
  node_memory_retrieval["Memory retrieval<br/>[retrieval.py]"]
  node_embeddings["Embedding layer<br/>[embeddings.py]"]
end

subgraph group_integrations["Providers and Tools"]
  node_provider_registry["Provider registry<br/>[registry.py]"]
  node_oauth["ChatGPT OAuth<br/>[chatgpt_oauth.py]"]
  node_host_bridge["Host automation<br/>[host_bridge.py]"]
  node_visual_bridge["Visual automation<br/>[visual_bridge.py]"]
end

subgraph group_capabilities["Media and Operations"]
  node_file_intake["File intake<br/>[file_intake.py]"]
  node_image_generation["Image generation"]
  node_video_editing["Video editing<br/>[video_editing.py]"]
end

node_user(("Workspace user"))
node_external_providers{{"LLM providers"}}
node_local_embeddings{{"Ollama or embedding API"}}

node_user -->|"uses"| node_ui_app
node_ui_app -.->|"renders state"| node_company_state
node_company_state -->|"creates client"| node_api_client
node_api_client -->|"REST and WS"| node_api_service
node_api_service -.->|"dispatches work"| node_engine
node_engine -->|"runs chat tools"| node_chat_tools
node_engine -.->|"routes departments"| node_department_routing
node_engine -.->|"schedules reviews"| node_task_review
node_engine -.->|"reads and writes"| node_repository
node_chat_tools -->|"reads and writes"| node_repository
node_chat_tools -->|"uses catalog"| node_catalog
node_chat_tools -->|"uses identifiers"| node_threads
node_repository -->|"uses ledger"| node_memory_ledger
node_repository -->|"uses embeddings"| node_embeddings
node_memory_ledger -->|"creates vectors"| node_embeddings
node_memory_retrieval -.->|"uses embeddings"| node_embeddings
node_embeddings -->|"requests vectors"| node_local_embeddings
node_chat_tools -.->|"uses provider layer"| node_provider_registry
node_provider_registry -.->|"calls models"| node_external_providers
node_oauth -.->|"authenticates account"| node_external_providers
node_chat_tools -.->|"dispatches tools"| node_host_bridge
node_host_bridge -->|"uses visual helpers"| node_visual_bridge
node_chat_tools -->|"processes uploads"| node_file_intake
node_chat_tools -->|"invokes generation"| node_image_generation
node_chat_tools -.->|"invokes editing"| node_video_editing

click node_ui_app "https://github.com/phonsadboy/atrium-th/blob/main/ui/src/App.tsx"
click node_company_state "https://github.com/phonsadboy/atrium-th/blob/main/ui/src/state/useCompany.ts"
click node_api_client "https://github.com/phonsadboy/atrium-th/blob/main/ui/src/contract/ApiClient.ts"
click node_api_service "https://github.com/phonsadboy/atrium-th/blob/main/system/app/main.py"
click node_engine "https://github.com/phonsadboy/atrium-th/blob/main/system/app/engine.py"
click node_chat_tools "https://github.com/phonsadboy/atrium-th/blob/main/system/app/chat_tools.py"
click node_department_routing "https://github.com/phonsadboy/atrium-th/blob/main/system/app/org/router.py"
click node_task_review "https://github.com/phonsadboy/atrium-th/blob/main/system/app/task_review.py"
click node_catalog "https://github.com/phonsadboy/atrium-th/blob/main/system/app/catalog.py"
click node_threads "https://github.com/phonsadboy/atrium-th/blob/main/system/app/threads.py"
click node_repository "https://github.com/phonsadboy/atrium-th/blob/main/system/app/db/repo.py"
click node_memory_ledger "https://github.com/phonsadboy/atrium-th/blob/main/system/app/memory/ledger.py"
click node_memory_retrieval "https://github.com/phonsadboy/atrium-th/blob/main/system/app/memory/retrieval.py"
click node_embeddings "https://github.com/phonsadboy/atrium-th/blob/main/system/app/memory/embeddings.py"
click node_provider_registry "https://github.com/phonsadboy/atrium-th/blob/main/system/app/provider/registry.py"
click node_oauth "https://github.com/phonsadboy/atrium-th/blob/main/system/app/provider/chatgpt_oauth.py"
click node_host_bridge "https://github.com/phonsadboy/atrium-th/blob/main/system/app/tools/host_bridge.py"
click node_visual_bridge "https://github.com/phonsadboy/atrium-th/blob/main/system/app/tools/visual_bridge.py"
click node_file_intake "https://github.com/phonsadboy/atrium-th/blob/main/system/app/file_intake.py"
click node_image_generation "https://github.com/phonsadboy/atrium-th/blob/main/system/app/image_generation.py"
click node_video_editing "https://github.com/phonsadboy/atrium-th/blob/main/system/app/video_editing.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_ui_app,node_company_state,node_api_client,node_user toneBlue
class node_api_service,node_engine,node_chat_tools,node_department_routing,node_task_review,node_catalog,node_threads toneAmber
class node_repository,node_memory_ledger,node_memory_retrieval,node_embeddings,node_local_embeddings toneMint
class node_provider_registry,node_oauth,node_host_bridge,node_visual_bridge toneRose
class node_file_intake,node_image_generation,node_video_editing,node_external_providers toneIndigo
```

## Components

### Workspace UI

- [Workspace UI](https://github.com/phonsadboy/atrium-th/blob/main/ui/src/App.tsx): `ui/src/App.tsx`
- [Company state client](https://github.com/phonsadboy/atrium-th/blob/main/ui/src/state/useCompany.ts): `ui/src/state/useCompany.ts`
- [REST and WS client](https://github.com/phonsadboy/atrium-th/blob/main/ui/src/contract/ApiClient.ts): `ui/src/contract/ApiClient.ts`

### Backend Workflow

- [FastAPI service](https://github.com/phonsadboy/atrium-th/blob/main/system/app/main.py): `system/app/main.py`
- [Company engine](https://github.com/phonsadboy/atrium-th/blob/main/system/app/engine.py): `system/app/engine.py`
- [Chat and tool flow](https://github.com/phonsadboy/atrium-th/blob/main/system/app/chat_tools.py): `system/app/chat_tools.py`
- [Department routing](https://github.com/phonsadboy/atrium-th/blob/main/system/app/org/router.py): `system/app/org/router.py`
- [Task review scheduling](https://github.com/phonsadboy/atrium-th/blob/main/system/app/task_review.py): `system/app/task_review.py`
- [Company catalog](https://github.com/phonsadboy/atrium-th/blob/main/system/app/catalog.py): `system/app/catalog.py`
- [Thread identifiers](https://github.com/phonsadboy/atrium-th/blob/main/system/app/threads.py): `system/app/threads.py`

### Memory and Data

- [Data repository](https://github.com/phonsadboy/atrium-th/blob/main/system/app/db/repo.py): `system/app/db/repo.py`
- [Memory ledger](https://github.com/phonsadboy/atrium-th/blob/main/system/app/memory/ledger.py): `system/app/memory/ledger.py`
- [Memory retrieval](https://github.com/phonsadboy/atrium-th/blob/main/system/app/memory/retrieval.py): `system/app/memory/retrieval.py`
- [Embedding layer](https://github.com/phonsadboy/atrium-th/blob/main/system/app/memory/embeddings.py): `system/app/memory/embeddings.py`

### Providers and Tools

- [Provider registry](https://github.com/phonsadboy/atrium-th/blob/main/system/app/provider/registry.py): `system/app/provider/registry.py`
- [ChatGPT OAuth](https://github.com/phonsadboy/atrium-th/blob/main/system/app/provider/chatgpt_oauth.py): `system/app/provider/chatgpt_oauth.py`
- [Host automation](https://github.com/phonsadboy/atrium-th/blob/main/system/app/tools/host_bridge.py): `system/app/tools/host_bridge.py`
- [Visual automation](https://github.com/phonsadboy/atrium-th/blob/main/system/app/tools/visual_bridge.py): `system/app/tools/visual_bridge.py`

### Media and Operations

- [File intake](https://github.com/phonsadboy/atrium-th/blob/main/system/app/file_intake.py): `system/app/file_intake.py`
- [Image generation](https://github.com/phonsadboy/atrium-th/blob/main/system/app/image_generation.py): `system/app/image_generation.py`
- [Video editing](https://github.com/phonsadboy/atrium-th/blob/main/system/app/video_editing.py): `system/app/video_editing.py`

### Other components

- **Workspace user**
- **LLM providers**
- **Ollama or embedding API**

## Connections

- Workspace user → Workspace UI: uses
- Workspace UI → Company state client: renders state
- Company state client → REST and WS client: creates client (evidence: `ui/src/state/useCompany.ts`)
- REST and WS client → FastAPI service: REST and WS
- FastAPI service → Company engine: dispatches work
- Company engine → Chat and tool flow: runs chat tools (evidence: `system/app/engine.py`)
- Company engine → Department routing: routes departments
- Company engine → Task review scheduling: schedules reviews (evidence: `system/app/engine.py`)
- Company engine → Data repository: reads and writes (evidence: `system/app/engine.py`)
- Chat and tool flow → Data repository: reads and writes (evidence: `system/app/chat_tools.py`)
- Chat and tool flow → Company catalog: uses catalog (evidence: `system/app/chat_tools.py`)
- Chat and tool flow → Thread identifiers: uses identifiers (evidence: `system/app/chat_tools.py`)
- Data repository → Memory ledger: uses ledger (evidence: `system/app/db/repo.py`)
- Data repository → Embedding layer: uses embeddings (evidence: `system/app/db/repo.py`)
- Memory ledger → Embedding layer: creates vectors (evidence: `system/app/memory/ledger.py`)
- Memory retrieval → Embedding layer: uses embeddings
- Embedding layer → Ollama or embedding API: requests vectors (evidence: `system/app/memory/embeddings.py`)
- Chat and tool flow → Provider registry: uses provider layer (evidence: `system/app/chat_tools.py`)
- Provider registry → LLM providers: calls models
- ChatGPT OAuth → LLM providers: authenticates account
- Chat and tool flow → Host automation: dispatches tools (evidence: `system/app/chat_tools.py`)
- Host automation → Visual automation: uses visual helpers (evidence: `system/app/tools/host_bridge.py`)
- Chat and tool flow → File intake: processes uploads (evidence: `system/app/chat_tools.py`)
- Chat and tool flow → Image generation: invokes generation (evidence: `system/app/chat_tools.py`)
- Chat and tool flow → Video editing: invokes editing (evidence: `system/app/chat_tools.py`)
