# opencharm-labs/opencharm architecture

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

- Interactive diagram: https://gitdiagram.com/opencharm-labs/opencharm
- Repository: https://github.com/opencharm-labs/opencharm

## Overview

OpenCharm gives an existing AI agent a face and voice through a paired charm. In the main runtime flow, a user pairs a device, holds its key to speak, and receives the agent’s response as text and synthesized speech; the CLI starts and administers charmd, which mediates device sessions, agent turns, and voice processing. The repository also includes a desktop charm and browser emulator, plus a product website and promotional film. Edges are limited to README statements and relationships visible in indexed or excerpted files; unsampled wiring is omitted.

Main entry points: [`packages/charmd/src/daemon.ts`](https://github.com/opencharm-labs/opencharm/blob/main/packages/charmd/src/daemon.ts) (charmd service), [`firmware/core/src/app.cpp`](https://github.com/opencharm-labs/opencharm/blob/main/firmware/core/src/app.cpp) (Charm firmware), [`packages/cli/src/main.ts`](https://github.com/opencharm-labs/opencharm/blob/main/packages/cli/src/main.ts) (OpenCharm CLI), [`packages/charmd/src/device/session.ts`](https://github.com/opencharm-labs/opencharm/blob/main/packages/charmd/src/device/session.ts) (Device session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and Admin"]
  node_cli["OpenCharm CLI<br/>[main.ts]"]
  node_admin["Pair and admin commands<br/>[admin.ts]"]
  node_mcp["Agent charm tools<br/>[server.ts]"]
end

subgraph group_daemon["Charm Daemon"]
  node_daemon["charmd service<br/>[daemon.ts]"]
  node_wiring["Runtime wiring<br/>[wiring.ts]"]
  node_session["Device session<br/>[session.ts]"]
  node_pairing["Pairing and authentication<br/>[pairing.ts]"]
  node_state[("Charm state store<br/>[state-store.ts]")]
  node_turn["Agent turn<br/>[turn.ts]"]
  node_agent["Agent adapters"]
  node_voice["Speech providers"]
  node_protocol["Device protocol<br/>[messages.ts]"]
end

subgraph group_device["Device Experience"]
  node_board["Charm firmware<br/>[app.cpp]"]
  node_view["Display rendering<br/>[lvgl_view.cpp]"]
  node_sim["Browser emulator<br/>[sim_main.cpp]"]
end

subgraph group_desktop["Desktop Charm"]
  node_desktop["Desktop charm<br/>[lib.rs]"]
end

subgraph group_web["Web and Film"]
  node_web["Product website<br/>[page.tsx]"]
  node_faces["Face design system<br/>[charm-face.js]"]
  node_film["Product film<br/>[notch-timeline.ts]"]
end

node_user(("Charm user"))
node_agent_service["Configured AI agent"]
node_speech_service["Speech model"]

node_user -->|"runs commands"| node_cli
node_cli -->|"dispatches commands"| node_admin
node_cli -->|"starts service"| node_daemon
node_admin -->|"sends admin requests"| node_daemon
node_cli -->|"starts tools"| node_mcp
node_mcp -->|"sends charm commands"| node_daemon
node_daemon -.->|"configures runtime"| node_wiring
node_wiring -.->|"connects sessions"| node_session
node_session -->|"uses pairing"| node_pairing
node_session -->|"reads and writes"| node_state
node_session -->|"routes turn commands"| node_turn
node_turn -->|"invokes agent"| node_agent
node_turn -->|"transcribes and speaks"| node_voice
node_user -->|"speaks and presses"| node_board
node_board -->|"sends audio and messages"| node_daemon
node_daemon -.->|"sends face and speech"| node_board
node_board -->|"renders display"| node_view
node_sim -->|"runs firmware"| node_board
node_user -->|"talks through desktop"| node_desktop
node_desktop -.->|"connects to service"| node_daemon
node_agent -.->|"adapts requests"| node_agent_service
node_voice -.->|"uses speech models"| node_speech_service
node_web -->|"uses face designs"| node_faces
node_film -->|"draws product faces"| node_faces

click node_cli "https://github.com/opencharm-labs/opencharm/blob/main/packages/cli/src/main.ts"
click node_admin "https://github.com/opencharm-labs/opencharm/blob/main/packages/cli/src/commands/admin.ts"
click node_mcp "https://github.com/opencharm-labs/opencharm/blob/main/packages/cli/src/mcp/server.ts"
click node_daemon "https://github.com/opencharm-labs/opencharm/blob/main/packages/charmd/src/daemon.ts"
click node_wiring "https://github.com/opencharm-labs/opencharm/blob/main/packages/charmd/src/wiring.ts"
click node_session "https://github.com/opencharm-labs/opencharm/blob/main/packages/charmd/src/device/session.ts"
click node_pairing "https://github.com/opencharm-labs/opencharm/blob/main/packages/charmd/src/auth/pairing.ts"
click node_state "https://github.com/opencharm-labs/opencharm/blob/main/packages/charmd/src/store/state-store.ts"
click node_turn "https://github.com/opencharm-labs/opencharm/blob/main/packages/charmd/src/turn/turn.ts"
click node_agent "https://github.com/opencharm-labs/opencharm/tree/main/packages/charmd/src/agent"
click node_voice "https://github.com/opencharm-labs/opencharm/tree/main/packages/charmd/src/voice"
click node_protocol "https://github.com/opencharm-labs/opencharm/blob/main/packages/protocol/src/messages.ts"
click node_board "https://github.com/opencharm-labs/opencharm/blob/main/firmware/core/src/app.cpp"
click node_view "https://github.com/opencharm-labs/opencharm/blob/main/firmware/core/src/ui/lvgl_view.cpp"
click node_sim "https://github.com/opencharm-labs/opencharm/blob/main/firmware/sim/src/sim_main.cpp"
click node_desktop "https://github.com/opencharm-labs/opencharm/blob/main/apps/desktop/src-tauri/src/lib.rs"
click node_web "https://github.com/opencharm-labs/opencharm/blob/main/apps/web/src/app/page.tsx"
click node_faces "https://github.com/opencharm-labs/opencharm/blob/main/packages/design/src/charm-face.js"
click node_film "https://github.com/opencharm-labs/opencharm/blob/main/apps/video/src/scenes/notch-timeline.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_cli,node_admin,node_mcp,node_user toneBlue
class node_daemon,node_wiring,node_session,node_pairing,node_state,node_turn,node_agent,node_voice,node_protocol toneAmber
class node_board,node_view,node_sim toneMint
class node_desktop toneRose
class node_web,node_faces,node_film,node_agent_service,node_speech_service toneIndigo
```

## Components

### CLI and Admin

- [OpenCharm CLI](https://github.com/opencharm-labs/opencharm/blob/main/packages/cli/src/main.ts): `packages/cli/src/main.ts`
- [Pair and admin commands](https://github.com/opencharm-labs/opencharm/blob/main/packages/cli/src/commands/admin.ts): `packages/cli/src/commands/admin.ts`
- [Agent charm tools](https://github.com/opencharm-labs/opencharm/blob/main/packages/cli/src/mcp/server.ts): `packages/cli/src/mcp/server.ts`

### Charm Daemon

- [charmd service](https://github.com/opencharm-labs/opencharm/blob/main/packages/charmd/src/daemon.ts): `packages/charmd/src/daemon.ts`
- [Runtime wiring](https://github.com/opencharm-labs/opencharm/blob/main/packages/charmd/src/wiring.ts): `packages/charmd/src/wiring.ts`
- [Device session](https://github.com/opencharm-labs/opencharm/blob/main/packages/charmd/src/device/session.ts): `packages/charmd/src/device/session.ts`
- [Pairing and authentication](https://github.com/opencharm-labs/opencharm/blob/main/packages/charmd/src/auth/pairing.ts): `packages/charmd/src/auth/pairing.ts`
- [Charm state store](https://github.com/opencharm-labs/opencharm/blob/main/packages/charmd/src/store/state-store.ts): `packages/charmd/src/store/state-store.ts`
- [Agent turn](https://github.com/opencharm-labs/opencharm/blob/main/packages/charmd/src/turn/turn.ts): `packages/charmd/src/turn/turn.ts`
- [Agent adapters](https://github.com/opencharm-labs/opencharm/tree/main/packages/charmd/src/agent): `packages/charmd/src/agent`
- [Speech providers](https://github.com/opencharm-labs/opencharm/tree/main/packages/charmd/src/voice): `packages/charmd/src/voice`
- [Device protocol](https://github.com/opencharm-labs/opencharm/blob/main/packages/protocol/src/messages.ts): `packages/protocol/src/messages.ts`

### Device Experience

- [Charm firmware](https://github.com/opencharm-labs/opencharm/blob/main/firmware/core/src/app.cpp): `firmware/core/src/app.cpp`
- [Display rendering](https://github.com/opencharm-labs/opencharm/blob/main/firmware/core/src/ui/lvgl_view.cpp): `firmware/core/src/ui/lvgl_view.cpp`
- [Browser emulator](https://github.com/opencharm-labs/opencharm/blob/main/firmware/sim/src/sim_main.cpp): `firmware/sim/src/sim_main.cpp`

### Desktop Charm

- [Desktop charm](https://github.com/opencharm-labs/opencharm/blob/main/apps/desktop/src-tauri/src/lib.rs): `apps/desktop/src-tauri/src/lib.rs`

### Web and Film

- [Product website](https://github.com/opencharm-labs/opencharm/blob/main/apps/web/src/app/page.tsx): `apps/web/src/app/page.tsx`
- [Face design system](https://github.com/opencharm-labs/opencharm/blob/main/packages/design/src/charm-face.js): `packages/design/src/charm-face.js`
- [Product film](https://github.com/opencharm-labs/opencharm/blob/main/apps/video/src/scenes/notch-timeline.ts): `apps/video/src/scenes/notch-timeline.ts`

### Other components

- **Charm user**
- **Configured AI agent**
- **Speech model**

## Connections

- Charm user → OpenCharm CLI: runs commands (evidence: `README.md`)
- OpenCharm CLI → Pair and admin commands: dispatches commands (evidence: `packages/cli/src/main.ts`)
- OpenCharm CLI → charmd service: starts service (evidence: `README.md`)
- Pair and admin commands → charmd service: sends admin requests (evidence: `packages/cli/src/commands/admin.ts`)
- OpenCharm CLI → Agent charm tools: starts tools (evidence: `packages/cli/src/main.ts`)
- Agent charm tools → charmd service: sends charm commands (evidence: `packages/cli/src/mcp/server.ts`)
- charmd service → Runtime wiring: configures runtime
- Runtime wiring → Device session: connects sessions
- Device session → Pairing and authentication: uses pairing (evidence: `packages/charmd/src/device/session.ts`)
- Device session → Charm state store: reads and writes (evidence: `packages/charmd/src/device/session.ts`)
- Device session → Agent turn: routes turn commands (evidence: `packages/charmd/src/device/session.ts`)
- Agent turn → Agent adapters: invokes agent (evidence: `packages/charmd/src/turn/turn.ts`)
- Agent turn → Speech providers: transcribes and speaks (evidence: `packages/charmd/src/turn/turn.ts`)
- Charm user → Charm firmware: speaks and presses (evidence: `README.md`)
- Charm firmware → charmd service: sends audio and messages (evidence: `firmware/core/src/app.cpp`)
- charmd service → Charm firmware: sends face and speech
- Charm firmware → Display rendering: renders display (evidence: `firmware/core/src/app.cpp`)
- Browser emulator → Charm firmware: runs firmware (evidence: `firmware/sim/src/sim_main.cpp`)
- Charm user → Desktop charm: talks through desktop (evidence: `README.md`)
- Desktop charm → charmd service: connects to service
- Agent adapters → Configured AI agent: adapts requests
- Speech providers → Speech model: uses speech models
- Product website → Face design system: uses face designs
- Product film → Face design system: draws product faces
