# souravberaakaspeed/xiryn architecture

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

- Interactive diagram: https://gitdiagram.com/souravberaakaspeed/xiryn
- Repository: https://github.com/souravberaakaspeed/xiryn

## Overview

Xiryn is a self-hosted personal-agent app: users create agents or squads, configure models, then send durable chat turns and follow work in each agent’s isolated Docker desktop. The runtime combines provider-backed reasoning with workstation, web, memory, and approval-gated vault tools; SQLite stores local state. Telegram offers optional remote control. README documents additional behavior such as desktop takeover, speech input, and notifications; those are represented where the tree supports a component, while unsampled wiring is not inferred.

Main entry points: [`lib/agent/runtime.ts`](https://github.com/souravberaakaspeed/xiryn/blob/main/lib/agent/runtime.ts) (Turn runtime), [`lib/agent/tools.ts`](https://github.com/souravberaakaspeed/xiryn/blob/main/lib/agent/tools.ts) (Agent tools), [`db/index.ts`](https://github.com/souravberaakaspeed/xiryn/blob/main/db/index.ts) (SQLite database), [`app/(workspace)/page.tsx`](https://github.com/souravberaakaspeed/xiryn/blob/main/app/(workspace)/page.tsx) (Workspace pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Workspace experience"]
  node_workspace["Workspace pages<br/>[page.tsx]"]
  node_thread_ui["Thread interface<br/>[thread-view.tsx]"]
  node_thread_start["Start thread<br/>[start-thread.tsx]"]
  node_settings_ui["Settings<br/>[settings-form.tsx]"]
  node_workbench_ui["Workbench<br/>[screen.tsx]"]
end

subgraph group_agent["Agent execution"]
  node_turn_api["Turn endpoint<br/>[route.ts]"]
  node_agent_runtime["Turn runtime<br/>[runtime.ts]"]
  node_agent_tools["Agent tools<br/>[tools.ts]"]
  node_instructions["Agent instructions<br/>[instructions.ts]"]
  node_provider_registry["Model providers<br/>[registry.ts]"]
  node_model_catalog["Model catalog<br/>[catalog.ts]"]
end

subgraph group_operations["Local operations"]
  node_workstation["Agent workstation<br/>[workstation.ts]"]
  node_docker["Docker control<br/>[docker.ts]"]
  node_web_research["Web research<br/>[web.ts]"]
  node_vault["Encrypted vault<br/>[vault.ts]"]
  node_vault_requests["Vault approvals<br/>[vault-requests.ts]"]
end

subgraph group_integrations["Remote integrations"]
  node_telegram_bridge["Telegram bridge<br/>[bridge.ts]"]
  node_telegram_service["Telegram API<br/>[api.ts]"]
  node_event_stream["Live events<br/>[events.ts]"]
end

subgraph group_persistence["Local state"]
  node_db[("SQLite database<br/>[index.ts]")]
  node_schema["Data schema<br/>[schema.ts]"]
  node_config["Settings service<br/>[config.ts]"]
  node_workspace_queries["Workspace queries<br/>[workspace.ts]"]
end

node_person(("User"))
node_web_service{{"Web search service"}}
node_model_service{{"Model provider"}}
node_docker_service{{"Docker engine"}}
node_telegram_user(("Telegram user"))

node_person -->|"opens"| node_workspace
node_workspace -->|"loads data"| node_workspace_queries
node_workspace_queries -->|"queries"| node_db
node_workspace -.->|"starts chat"| node_thread_start
node_thread_start -->|"opens thread"| node_thread_ui
node_person -->|"sends message"| node_thread_ui
node_thread_ui -.->|"submits turn"| node_turn_api
node_turn_api -->|"starts turn"| node_agent_runtime
node_agent_runtime -->|"executes tools"| node_agent_tools
node_agent_runtime -->|"loads instructions"| node_instructions
node_agent_runtime -->|"resolves model"| node_provider_registry
node_provider_registry -.->|"calls provider"| node_model_service
node_agent_tools -->|"controls desktop"| node_workstation
node_workstation -->|"manages containers"| node_docker
node_docker -.->|"controls"| node_docker_service
node_agent_tools -->|"searches web"| node_web_research
node_web_research -.->|"requests research"| node_web_service
node_agent_tools -->|"uses approved secrets"| node_vault
node_agent_tools -.->|"checks approval"| node_vault_requests
node_settings_ui -->|"updates settings"| node_config
node_settings_ui -->|"selects models"| node_model_catalog
node_model_catalog -.->|"lists providers"| node_provider_registry
node_workbench_ui -->|"controls workstation"| node_workstation
node_agent_runtime -->|"persists turns"| node_db
node_db -->|"uses schema"| node_schema
node_config -->|"reads and writes"| node_db
node_agent_runtime -->|"publishes progress"| node_event_stream
node_telegram_user -->|"messages bot"| node_telegram_bridge
node_telegram_bridge -->|"starts turns"| node_agent_runtime
node_telegram_bridge -->|"sends and polls"| node_telegram_service
node_telegram_service -.->|"delivers replies"| node_telegram_user

click node_workspace "https://github.com/souravberaakaspeed/xiryn/blob/main/app/(workspace)/page.tsx"
click node_thread_ui "https://github.com/souravberaakaspeed/xiryn/blob/main/components/thread/thread-view.tsx"
click node_thread_start "https://github.com/souravberaakaspeed/xiryn/blob/main/components/thread/start-thread.tsx"
click node_settings_ui "https://github.com/souravberaakaspeed/xiryn/blob/main/components/settings/settings-form.tsx"
click node_workbench_ui "https://github.com/souravberaakaspeed/xiryn/blob/main/components/workbench/screen.tsx"
click node_turn_api "https://github.com/souravberaakaspeed/xiryn/blob/main/app/api/threads/%5BthreadId%5D/turn/route.ts"
click node_agent_runtime "https://github.com/souravberaakaspeed/xiryn/blob/main/lib/agent/runtime.ts"
click node_agent_tools "https://github.com/souravberaakaspeed/xiryn/blob/main/lib/agent/tools.ts"
click node_instructions "https://github.com/souravberaakaspeed/xiryn/blob/main/lib/agent/instructions.ts"
click node_provider_registry "https://github.com/souravberaakaspeed/xiryn/blob/main/lib/providers/registry.ts"
click node_model_catalog "https://github.com/souravberaakaspeed/xiryn/blob/main/lib/providers/catalog.ts"
click node_workstation "https://github.com/souravberaakaspeed/xiryn/blob/main/lib/workstation.ts"
click node_docker "https://github.com/souravberaakaspeed/xiryn/blob/main/lib/docker.ts"
click node_web_research "https://github.com/souravberaakaspeed/xiryn/blob/main/lib/web.ts"
click node_vault "https://github.com/souravberaakaspeed/xiryn/blob/main/lib/vault.ts"
click node_vault_requests "https://github.com/souravberaakaspeed/xiryn/blob/main/lib/vault-requests.ts"
click node_telegram_bridge "https://github.com/souravberaakaspeed/xiryn/blob/main/lib/telegram/bridge.ts"
click node_telegram_service "https://github.com/souravberaakaspeed/xiryn/blob/main/lib/telegram/api.ts"
click node_event_stream "https://github.com/souravberaakaspeed/xiryn/blob/main/lib/events.ts"
click node_db "https://github.com/souravberaakaspeed/xiryn/blob/main/db/index.ts"
click node_schema "https://github.com/souravberaakaspeed/xiryn/blob/main/db/schema.ts"
click node_config "https://github.com/souravberaakaspeed/xiryn/blob/main/lib/config.ts"
click node_workspace_queries "https://github.com/souravberaakaspeed/xiryn/blob/main/queries/workspace.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_workspace,node_thread_ui,node_thread_start,node_settings_ui,node_workbench_ui,node_person,node_telegram_user toneBlue
class node_turn_api,node_agent_runtime,node_agent_tools,node_instructions,node_provider_registry,node_model_catalog toneAmber
class node_workstation,node_docker,node_web_research,node_vault,node_vault_requests toneMint
class node_telegram_bridge,node_telegram_service,node_event_stream toneRose
class node_db,node_schema,node_config,node_workspace_queries,node_web_service,node_model_service,node_docker_service toneIndigo
```

## Components

### Workspace experience

- [Workspace pages](https://github.com/souravberaakaspeed/xiryn/blob/main/app/(workspace)/page.tsx): `app/(workspace)/page.tsx`
- [Thread interface](https://github.com/souravberaakaspeed/xiryn/blob/main/components/thread/thread-view.tsx): `components/thread/thread-view.tsx`
- [Start thread](https://github.com/souravberaakaspeed/xiryn/blob/main/components/thread/start-thread.tsx): `components/thread/start-thread.tsx`
- [Settings](https://github.com/souravberaakaspeed/xiryn/blob/main/components/settings/settings-form.tsx): `components/settings/settings-form.tsx`
- [Workbench](https://github.com/souravberaakaspeed/xiryn/blob/main/components/workbench/screen.tsx): `components/workbench/screen.tsx`

### Agent execution

- [Turn endpoint](https://github.com/souravberaakaspeed/xiryn/blob/main/app/api/threads/%5BthreadId%5D/turn/route.ts): `app/api/threads/[threadId]/turn/route.ts`
- [Turn runtime](https://github.com/souravberaakaspeed/xiryn/blob/main/lib/agent/runtime.ts): `lib/agent/runtime.ts`
- [Agent tools](https://github.com/souravberaakaspeed/xiryn/blob/main/lib/agent/tools.ts): `lib/agent/tools.ts`
- [Agent instructions](https://github.com/souravberaakaspeed/xiryn/blob/main/lib/agent/instructions.ts): `lib/agent/instructions.ts`
- [Model providers](https://github.com/souravberaakaspeed/xiryn/blob/main/lib/providers/registry.ts): `lib/providers/registry.ts`
- [Model catalog](https://github.com/souravberaakaspeed/xiryn/blob/main/lib/providers/catalog.ts): `lib/providers/catalog.ts`

### Local operations

- [Agent workstation](https://github.com/souravberaakaspeed/xiryn/blob/main/lib/workstation.ts): `lib/workstation.ts`
- [Docker control](https://github.com/souravberaakaspeed/xiryn/blob/main/lib/docker.ts): `lib/docker.ts`
- [Web research](https://github.com/souravberaakaspeed/xiryn/blob/main/lib/web.ts): `lib/web.ts`
- [Encrypted vault](https://github.com/souravberaakaspeed/xiryn/blob/main/lib/vault.ts): `lib/vault.ts`
- [Vault approvals](https://github.com/souravberaakaspeed/xiryn/blob/main/lib/vault-requests.ts): `lib/vault-requests.ts`

### Remote integrations

- [Telegram bridge](https://github.com/souravberaakaspeed/xiryn/blob/main/lib/telegram/bridge.ts): `lib/telegram/bridge.ts`
- [Telegram API](https://github.com/souravberaakaspeed/xiryn/blob/main/lib/telegram/api.ts): `lib/telegram/api.ts`
- [Live events](https://github.com/souravberaakaspeed/xiryn/blob/main/lib/events.ts): `lib/events.ts`

### Local state

- [SQLite database](https://github.com/souravberaakaspeed/xiryn/blob/main/db/index.ts): `db/index.ts`
- [Data schema](https://github.com/souravberaakaspeed/xiryn/blob/main/db/schema.ts): `db/schema.ts`
- [Settings service](https://github.com/souravberaakaspeed/xiryn/blob/main/lib/config.ts): `lib/config.ts`
- [Workspace queries](https://github.com/souravberaakaspeed/xiryn/blob/main/queries/workspace.ts): `queries/workspace.ts`

### Other components

- **User**
- **Web search service**
- **Model provider**
- **Docker engine**
- **Telegram user**

## Connections

- User → Workspace pages: opens (evidence: `README.md`)
- Workspace pages → Workspace queries: loads data (evidence: `app/(workspace)/page.tsx`)
- Workspace queries → SQLite database: queries (evidence: `queries/workspace.ts`)
- Workspace pages → Start thread: starts chat
- Start thread → Thread interface: opens thread (evidence: `components/thread/start-thread.tsx`)
- User → Thread interface: sends message (evidence: `README.md`)
- Thread interface → Turn endpoint: submits turn
- Turn endpoint → Turn runtime: starts turn (evidence: `app/api/threads/[threadId]/turn/route.ts`)
- Turn runtime → Agent tools: executes tools (evidence: `lib/agent/runtime.ts`)
- Turn runtime → Agent instructions: loads instructions (evidence: `lib/agent/runtime.ts`)
- Turn runtime → Model providers: resolves model (evidence: `lib/agent/runtime.ts`)
- Model providers → Model provider: calls provider
- Agent tools → Agent workstation: controls desktop (evidence: `lib/agent/tools.ts`)
- Agent workstation → Docker control: manages containers (evidence: `lib/workstation.ts`)
- Docker control → Docker engine: controls
- Agent tools → Web research: searches web (evidence: `lib/agent/tools.ts`)
- Web research → Web search service: requests research
- Agent tools → Encrypted vault: uses approved secrets (evidence: `lib/agent/tools.ts`)
- Agent tools → Vault approvals: checks approval
- Settings → Settings service: updates settings (evidence: `components/settings/settings-form.tsx`)
- Settings → Model catalog: selects models
- Model catalog → Model providers: lists providers
- Workbench → Agent workstation: controls workstation (evidence: `components/workbench/screen.tsx`)
- Turn runtime → SQLite database: persists turns (evidence: `lib/agent/runtime.ts`)
- SQLite database → Data schema: uses schema (evidence: `db/index.ts`)
- Settings service → SQLite database: reads and writes (evidence: `lib/config.ts`)
- Turn runtime → Live events: publishes progress (evidence: `lib/agent/runtime.ts`)
- Telegram user → Telegram bridge: messages bot (evidence: `README.md`)
- Telegram bridge → Turn runtime: starts turns (evidence: `lib/telegram/bridge.ts`)
- Telegram bridge → Telegram API: sends and polls (evidence: `lib/telegram/bridge.ts`)
- Telegram API → Telegram user: delivers replies
