# hal-ucsb/xarp architecture

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

- Interactive diagram: https://gitdiagram.com/hal-ucsb/xarp
- Repository: https://github.com/hal-ucsb/xarp
- Video tour (about a minute): https://gitdiagram.com/hal-ucsb/xarp/video

## Overview

XARP is a Python toolkit for building XR applications and exposing XR capabilities to AI agents. Its main workflow is: a developer supplies an application, the server opens a client session, and the application uses the XR facade to request sensing or device information and update the virtual scene. A WebSocket transport carries command bundles and responses to the XR client. Separate capabilities include agent/MCP integration, gesture support, and spatial data models. Edges are limited to relationships visible in excerpts, the source index, or the README; unsampled implementations are not inferred.

Main entry points: [`src/xarp/express.py`](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/express.py) (XR application facade), [`src/xarp/remote.py`](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/remote.py) (WebSocket transport), [`src/xarp/server.py`](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/server.py) (Session server), [`src/xarp/spatial.py`](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/spatial.py) (Spatial math)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application runtime"]
  node_server["Session server<br/>[server.py]"]
  node_facade["XR application facade<br/>[express.py]"]
  node_settings["Runtime settings<br/>[settings.py]"]
end

subgraph group_protocol["Client protocol"]
  node_transport["WebSocket transport<br/>[remote.py]"]
  node_commands["Command protocol<br/>[__init__.py]"]
  node_entitycmds["Scene commands<br/>[entities.py]"]
  node_infocmd["Device info command<br/>[info.py]"]
  node_sensingcmds["Sensing commands<br/>[sensing.py]"]
  node_uicmds["UI commands<br/>[ui.py]"]
  node_time["Timestamp utility<br/>[time.py]"]
end

subgraph group_scene["XR scene and spatial data"]
  node_models["Device and hand models<br/>[data_models.py]"]
  node_entities["Assets and elements<br/>[entities.py]"]
  node_gestures["Gesture support<br/>[gestures.py]"]
  node_spatial["Spatial math<br/>[spatial.py]"]
  node_icons["Icon assets<br/>[icons.py]"]
end

subgraph group_agents["Agent capabilities"]
  node_agents["Agent tools and MCP<br/>[agents.py]"]
end

node_developer(("XR application developer"))
node_xrclient(("XR client"))

node_developer -->|"starts app"| node_server
node_server -->|"loads settings"| node_settings
node_server -->|"opens session"| node_transport
node_server -->|"provides facade"| node_facade
node_facade -->|"executes bundles"| node_transport
node_facade -->|"issues scene commands"| node_entitycmds
node_facade -->|"requests device info"| node_infocmd
node_facade -->|"requests sensing"| node_sensingcmds
node_facade -->|"issues UI commands"| node_uicmds
node_transport -->|"exchanges messages"| node_xrclient
node_transport -->|"parses protocol"| node_commands
node_transport -->|"timestamps messages"| node_time
node_transport -->|"reads settings"| node_settings
node_entitycmds -->|"serializes scene data"| node_entities
node_infocmd -->|"validates info"| node_models
node_sensingcmds -->|"validates hand data"| node_models
node_sensingcmds -->|"builds image assets"| node_entities
node_sensingcmds -->|"validates poses"| node_spatial
node_models -->|"uses spatial types"| node_spatial
node_entities -->|"uses transforms"| node_spatial
node_gestures -->|"uses hand models"| node_models
node_gestures -->|"uses spatial types"| node_spatial
node_icons -->|"creates assets"| node_entities
node_icons -->|"uses spatial types"| node_spatial
node_agents -->|"exposes XR tools"| node_facade
node_agents -->|"integrates runtime"| node_server
node_agents -->|"uses client transport"| node_transport

click node_server "https://github.com/hal-ucsb/xarp/blob/main/src/xarp/server.py"
click node_facade "https://github.com/hal-ucsb/xarp/blob/main/src/xarp/express.py"
click node_settings "https://github.com/hal-ucsb/xarp/blob/main/src/xarp/settings.py"
click node_agents "https://github.com/hal-ucsb/xarp/blob/main/src/xarp/agents.py"
click node_transport "https://github.com/hal-ucsb/xarp/blob/main/src/xarp/remote.py"
click node_commands "https://github.com/hal-ucsb/xarp/blob/main/src/xarp/commands/__init__.py"
click node_entitycmds "https://github.com/hal-ucsb/xarp/blob/main/src/xarp/commands/entities.py"
click node_infocmd "https://github.com/hal-ucsb/xarp/blob/main/src/xarp/commands/info.py"
click node_sensingcmds "https://github.com/hal-ucsb/xarp/blob/main/src/xarp/commands/sensing.py"
click node_uicmds "https://github.com/hal-ucsb/xarp/blob/main/src/xarp/commands/ui.py"
click node_models "https://github.com/hal-ucsb/xarp/blob/main/src/xarp/data_models.py"
click node_entities "https://github.com/hal-ucsb/xarp/blob/main/src/xarp/entities.py"
click node_gestures "https://github.com/hal-ucsb/xarp/blob/main/src/xarp/gestures.py"
click node_spatial "https://github.com/hal-ucsb/xarp/blob/main/src/xarp/spatial.py"
click node_icons "https://github.com/hal-ucsb/xarp/blob/main/src/xarp/icons.py"
click node_time "https://github.com/hal-ucsb/xarp/blob/main/src/xarp/time.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_server,node_facade,node_settings,node_xrclient toneBlue
class node_transport,node_commands,node_entitycmds,node_infocmd,node_sensingcmds,node_uicmds,node_time toneAmber
class node_models,node_entities,node_gestures,node_spatial,node_icons toneMint
class node_agents toneRose
class node_developer toneIndigo
```

## Components

### Application runtime

- [Session server](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/server.py): `src/xarp/server.py`
- [XR application facade](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/express.py): `src/xarp/express.py`
- [Runtime settings](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/settings.py): `src/xarp/settings.py`

### Client protocol

- [WebSocket transport](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/remote.py): `src/xarp/remote.py`
- [Command protocol](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/commands/__init__.py): `src/xarp/commands/__init__.py`
- [Scene commands](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/commands/entities.py): `src/xarp/commands/entities.py`
- [Device info command](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/commands/info.py): `src/xarp/commands/info.py`
- [Sensing commands](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/commands/sensing.py): `src/xarp/commands/sensing.py`
- [UI commands](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/commands/ui.py): `src/xarp/commands/ui.py`
- [Timestamp utility](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/time.py): `src/xarp/time.py`

### XR scene and spatial data

- [Device and hand models](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/data_models.py): `src/xarp/data_models.py`
- [Assets and elements](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/entities.py): `src/xarp/entities.py`
- [Gesture support](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/gestures.py): `src/xarp/gestures.py`
- [Spatial math](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/spatial.py): `src/xarp/spatial.py`
- [Icon assets](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/icons.py): `src/xarp/icons.py`

### Agent capabilities

- [Agent tools and MCP](https://github.com/hal-ucsb/xarp/blob/main/src/xarp/agents.py): `src/xarp/agents.py`

### Other components

- **XR application developer**
- **XR client**

## Connections

- XR application developer → Session server: starts app (evidence: `README.md`)
- Session server → Runtime settings: loads settings (evidence: `src/xarp/server.py`)
- Session server → WebSocket transport: opens session (evidence: `src/xarp/server.py`)
- Session server → XR application facade: provides facade (evidence: `src/xarp/server.py`)
- XR application facade → WebSocket transport: executes bundles (evidence: `src/xarp/express.py`)
- XR application facade → Scene commands: issues scene commands (evidence: `src/xarp/express.py`)
- XR application facade → Device info command: requests device info (evidence: `src/xarp/express.py`)
- XR application facade → Sensing commands: requests sensing (evidence: `src/xarp/express.py`)
- XR application facade → UI commands: issues UI commands (evidence: `src/xarp/express.py`)
- WebSocket transport → XR client: exchanges messages (evidence: `src/xarp/remote.py`)
- WebSocket transport → Command protocol: parses protocol (evidence: `src/xarp/remote.py`)
- WebSocket transport → Timestamp utility: timestamps messages (evidence: `src/xarp/remote.py`)
- WebSocket transport → Runtime settings: reads settings (evidence: `src/xarp/server.py`)
- Scene commands → Assets and elements: serializes scene data (evidence: `src/xarp/commands/entities.py`)
- Device info command → Device and hand models: validates info (evidence: `src/xarp/commands/info.py`)
- Sensing commands → Device and hand models: validates hand data (evidence: `src/xarp/commands/sensing.py`)
- Sensing commands → Assets and elements: builds image assets (evidence: `src/xarp/commands/sensing.py`)
- Sensing commands → Spatial math: validates poses (evidence: `src/xarp/commands/sensing.py`)
- Device and hand models → Spatial math: uses spatial types (evidence: `src/xarp/data_models.py`)
- Assets and elements → Spatial math: uses transforms (evidence: `src/xarp/entities.py`)
- Gesture support → Device and hand models: uses hand models (evidence: `src/xarp/gestures.py`)
- Gesture support → Spatial math: uses spatial types (evidence: `src/xarp/gestures.py`)
- Icon assets → Assets and elements: creates assets (evidence: `src/xarp/icons.py`)
- Icon assets → Spatial math: uses spatial types (evidence: `src/xarp/icons.py`)
- Agent tools and MCP → XR application facade: exposes XR tools (evidence: `README.md`)
- Agent tools and MCP → Session server: integrates runtime (evidence: `src/xarp/agents.py`)
- Agent tools and MCP → WebSocket transport: uses client transport (evidence: `src/xarp/agents.py`)
