# maestroai-company/opera-hub architecture

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

- Interactive diagram: https://gitdiagram.com/maestroai-company/opera-hub
- Repository: https://github.com/maestroai-company/opera-hub

## Overview

Opera Hub is a self-hosted hub for pairing Opera devices, synchronizing their data, sharing AI providers, and managing optional local models and MCP servers. The main runtime starts authenticated iroh endpoints and dispatches protocol handlers; paired clients initiate pairing, sync, and administration through the client library. The README documents capabilities beyond the sampled excerpts, so those branches are included with README evidence rather than implying their implementation was inspected.

Main entry points: [`crates/opera-hub/src/hub.rs`](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/hub.rs) (Hub runtime), [`crates/opera-hub/src/mcp/mod.rs`](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/mcp/mod.rs) (MCP server management), [`crates/opera-hub/src/protocols.rs`](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/protocols.rs) (Pairing flow), [`crates/opera-hub/src/db.rs`](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/db.rs) (Encrypted database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Hub entry"]
  node_cli["Hub CLI<br/>[main.rs]"]
  node_service["Background service<br/>[service.rs]"]
  node_hub["Hub runtime<br/>[hub.rs]"]
end

subgraph group_access["Pairing and access"]
  node_pairing["Pairing flow<br/>[protocols.rs]"]
  node_invite["Pairing codes<br/>[invite.rs]"]
  node_device_store["Device permissions<br/>[store.rs]"]
end

subgraph group_device["Device features"]
  node_client["Client library<br/>[lib.rs]"]
  node_proto["Shared protocol types<br/>[lib.rs]"]
  node_sync["Conversation sync<br/>[sync.rs]"]
  node_settings["Hub settings<br/>[settings.rs]"]
  node_lan["LAN discovery<br/>[lan.rs]"]
end

subgraph group_ai["AI and MCP"]
  node_providers["Provider sharing<br/>[providers.rs]"]
  node_llama["Local model runtime<br/>[llama.rs]"]
  node_mcp["MCP server management<br/>[mod.rs]"]
  node_mcp_install["MCP installation<br/>[install.rs]"]
  node_mcp_sandbox["MCP sandbox<br/>[mod.rs]"]
end

subgraph group_state["Hub state"]
  node_db[("Encrypted database<br/>[db.rs]")]
  node_config["Hub configuration<br/>[config.rs]"]
  node_updates["Hub updates<br/>[update.rs]"]
  node_usage["Usage accounting<br/>[usage.rs]"]
end

node_operator(("Hub operator"))
node_opera_devices(("Opera devices"))

node_operator -->|"runs commands"| node_cli
node_cli -.->|"controls service"| node_service
node_cli -->|"starts runtime"| node_hub
node_opera_devices -->|"uses hub client"| node_client
node_client -->|"connects securely"| node_hub
node_client -->|"uses shared types"| node_proto
node_hub -->|"routes requests"| node_pairing
node_pairing -->|"opens invite"| node_invite
node_pairing -->|"records paired device"| node_device_store
node_pairing -.->|"checks grants"| node_db
node_hub -->|"routes sync"| node_sync
node_hub -->|"loads settings"| node_settings
node_hub -->|"announces hub"| node_lan
node_hub -->|"routes provider requests"| node_providers
node_hub -->|"starts model runtime"| node_llama
node_hub -->|"starts MCP managers"| node_mcp
node_mcp -->|"installs servers"| node_mcp_install
node_mcp -->|"spawns isolated processes"| node_mcp_sandbox
node_mcp -->|"stores server secrets"| node_db
node_hub -.->|"opens encrypted store"| node_db
node_hub -->|"loads runtime config"| node_config
node_hub -.->|"checks for updates"| node_updates
node_sync -->|"reads and writes records"| node_db
node_providers -->|"uses local models"| node_llama
node_providers -->|"uses MCP tools"| node_mcp
node_hub -.->|"tracks usage"| node_usage
node_opera_devices -->|"syncs conversations"| node_sync
node_opera_devices -->|"manages hub"| node_settings
node_opera_devices -->|"manages models"| node_llama

click node_cli "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/main.rs"
click node_service "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/service.rs"
click node_hub "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/hub.rs"
click node_client "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub-client/src/lib.rs"
click node_proto "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub-proto/src/lib.rs"
click node_pairing "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/protocols.rs"
click node_invite "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/invite.rs"
click node_device_store "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/store.rs"
click node_sync "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/sync.rs"
click node_settings "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/settings.rs"
click node_lan "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/lan.rs"
click node_providers "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/providers.rs"
click node_llama "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/llama.rs"
click node_mcp "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/mcp/mod.rs"
click node_mcp_install "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/mcp/install.rs"
click node_mcp_sandbox "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/mcp/sandbox/mod.rs"
click node_db "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/db.rs"
click node_config "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/config.rs"
click node_updates "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/update.rs"
click node_usage "https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/usage.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_cli,node_service,node_hub toneBlue
class node_pairing,node_invite,node_device_store toneAmber
class node_client,node_proto,node_sync,node_settings,node_lan toneMint
class node_providers,node_llama,node_mcp,node_mcp_install,node_mcp_sandbox toneRose
class node_db,node_config,node_updates,node_usage,node_operator,node_opera_devices toneIndigo
```

## Components

### Hub entry

- [Hub CLI](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/main.rs): `crates/opera-hub/src/main.rs`
- [Background service](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/service.rs): `crates/opera-hub/src/service.rs`
- [Hub runtime](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/hub.rs): `crates/opera-hub/src/hub.rs`

### Pairing and access

- [Pairing flow](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/protocols.rs): `crates/opera-hub/src/protocols.rs`
- [Pairing codes](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/invite.rs): `crates/opera-hub/src/invite.rs`
- [Device permissions](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/store.rs): `crates/opera-hub/src/store.rs`

### Device features

- [Client library](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub-client/src/lib.rs): `crates/opera-hub-client/src/lib.rs`
- [Shared protocol types](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub-proto/src/lib.rs): `crates/opera-hub-proto/src/lib.rs`
- [Conversation sync](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/sync.rs): `crates/opera-hub/src/sync.rs`
- [Hub settings](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/settings.rs): `crates/opera-hub/src/settings.rs`
- [LAN discovery](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/lan.rs): `crates/opera-hub/src/lan.rs`

### AI and MCP

- [Provider sharing](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/providers.rs): `crates/opera-hub/src/providers.rs`
- [Local model runtime](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/llama.rs): `crates/opera-hub/src/llama.rs`
- [MCP server management](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/mcp/mod.rs): `crates/opera-hub/src/mcp/mod.rs`
- [MCP installation](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/mcp/install.rs): `crates/opera-hub/src/mcp/install.rs`
- [MCP sandbox](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/mcp/sandbox/mod.rs): `crates/opera-hub/src/mcp/sandbox/mod.rs`

### Hub state

- [Encrypted database](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/db.rs): `crates/opera-hub/src/db.rs`
- [Hub configuration](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/config.rs): `crates/opera-hub/src/config.rs`
- [Hub updates](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/update.rs): `crates/opera-hub/src/update.rs`
- [Usage accounting](https://github.com/maestroai-company/opera-hub/blob/main/crates/opera-hub/src/usage.rs): `crates/opera-hub/src/usage.rs`

### Other components

- **Hub operator**
- **Opera devices**

## Connections

- Hub operator → Hub CLI: runs commands (evidence: `README.md`)
- Hub CLI → Background service: controls service
- Hub CLI → Hub runtime: starts runtime (evidence: `README.md`)
- Opera devices → Client library: uses hub client (evidence: `README.md`)
- Client library → Hub runtime: connects securely (evidence: `README.md`)
- Client library → Shared protocol types: uses shared types (evidence: `crates/opera-hub-client/src/lib.rs`)
- Hub runtime → Pairing flow: routes requests (evidence: `crates/opera-hub/src/hub.rs`)
- Pairing flow → Pairing codes: opens invite (evidence: `crates/opera-hub/src/protocols.rs`)
- Pairing flow → Device permissions: records paired device (evidence: `crates/opera-hub/src/protocols.rs`)
- Pairing flow → Encrypted database: checks grants
- Hub runtime → Conversation sync: routes sync (evidence: `crates/opera-hub/src/hub.rs`)
- Hub runtime → Hub settings: loads settings (evidence: `crates/opera-hub/src/hub.rs`)
- Hub runtime → LAN discovery: announces hub (evidence: `crates/opera-hub/src/hub.rs`)
- Hub runtime → Provider sharing: routes provider requests (evidence: `crates/opera-hub/src/hub.rs`)
- Hub runtime → Local model runtime: starts model runtime (evidence: `crates/opera-hub/src/hub.rs`)
- Hub runtime → MCP server management: starts MCP managers (evidence: `crates/opera-hub/src/hub.rs`)
- MCP server management → MCP installation: installs servers (evidence: `crates/opera-hub/src/mcp/mod.rs`)
- MCP server management → MCP sandbox: spawns isolated processes (evidence: `crates/opera-hub/src/mcp/mod.rs`)
- MCP server management → Encrypted database: stores server secrets (evidence: `crates/opera-hub/src/mcp/mod.rs`)
- Hub runtime → Encrypted database: opens encrypted store (evidence: `crates/opera-hub/src/hub.rs`)
- Hub runtime → Hub configuration: loads runtime config (evidence: `crates/opera-hub/src/hub.rs`)
- Hub runtime → Hub updates: checks for updates (evidence: `crates/opera-hub/src/hub.rs`)
- Conversation sync → Encrypted database: reads and writes records (evidence: `crates/opera-hub/src/sync.rs`)
- Provider sharing → Local model runtime: uses local models (evidence: `crates/opera-hub/src/providers.rs`)
- Provider sharing → MCP server management: uses MCP tools (evidence: `crates/opera-hub/src/providers.rs`)
- Hub runtime → Usage accounting: tracks usage
- Opera devices → Conversation sync: syncs conversations (evidence: `README.md`)
- Opera devices → Hub settings: manages hub (evidence: `README.md`)
- Opera devices → Local model runtime: manages models (evidence: `README.md`)
