# zarmoin/magxr architecture

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

- Interactive diagram: https://gitdiagram.com/zarmoin/magxr
- Repository: https://github.com/zarmoin/magxr

## Overview

MagXR is an AI-assisted XR magnification system: voice commands are captured or received, interpreted into magnification parameters, paused for user confirmation, then dispatched over WebSockets to Unity for view changes or spatial checkpoint actions. The graph preserves those stages and the Unity confirmation UI and controller. The README contains no capability detail beyond the product context; several agent and Unity internals are only partially sampled, so uncertain links are omitted.

Main entry points: [`unity/MagXRWebSocketClient.cs`](https://github.com/zarmoin/magxr/blob/main/unity/MagXRWebSocketClient.cs) (Unity WebSocket Client), [`src/magxr/prompt_parser.py`](https://github.com/zarmoin/magxr/blob/main/src/magxr/prompt_parser.py) (Speech Parsing), [`src/magxr/agent.py`](https://github.com/zarmoin/magxr/blob/main/src/magxr/agent.py) (Agent Orchestrator), [`src/magxr/server.py`](https://github.com/zarmoin/magxr/blob/main/src/magxr/server.py) (WebSocket Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Voice Input"]
  node_mic["Audio Capture<br/>[voiceCommand.py]"]
end

subgraph group_interpret["Command Intelligence"]
  node_speech["Speech Parsing<br/>[prompt_parser.py]"]
end

subgraph group_bridge["Agent and Bridge"]
  node_agent["Agent Orchestrator<br/>[agent.py]"]
  node_tools["Magnification Tools<br/>[agent.py]"]
  node_wsserver["WebSocket Server<br/>[server.py]"]
end

subgraph group_xr["Unity XR Runtime"]
  node_unityclient["Unity WebSocket Client"]
  node_confirm["Confirmation Canvas"]
  node_magnifier["Magnifier Controller"]
end

node_user(("XR User"))
node_gemini{{"Gemini AI"}}
node_vr["XR Scene"]

node_user -->|"speaks"| node_mic
node_mic -->|"audio bytes"| node_speech
node_speech -->|"transcribes and parses"| node_gemini
node_speech -->|"structured prompt"| node_agent
node_agent -->|"dispatches tools"| node_tools
node_agent -->|"returns actions"| node_wsserver
node_unityclient -->|"sends commands"| node_wsserver
node_wsserver -->|"sends confirmation and actions"| node_unityclient
node_unityclient -->|"dispatches messages"| node_confirm
node_confirm -->|"sends confirmation"| node_unityclient
node_unityclient -->|"forwards action payload"| node_magnifier
node_magnifier -.->|"changes view"| node_vr
node_user -.->|"issues text command"| node_unityclient

click node_mic "https://github.com/zarmoin/magxr/blob/main/voiceCommand.py"
click node_speech "https://github.com/zarmoin/magxr/blob/main/src/magxr/prompt_parser.py"
click node_agent "https://github.com/zarmoin/magxr/blob/main/src/magxr/agent.py"
click node_tools "https://github.com/zarmoin/magxr/blob/main/src/magxr/agent.py"
click node_wsserver "https://github.com/zarmoin/magxr/blob/main/src/magxr/server.py"
click node_unityclient "https://github.com/zarmoin/magxr/blob/main/unity/MagXRWebSocketClient.cs"
click node_confirm "https://github.com/zarmoin/magxr/blob/main/unity/WorldSpaceConfirmationCanvas.cs"
click node_magnifier "https://github.com/zarmoin/magxr/blob/main/unity/MagnifierController.cs"

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_mic,node_user toneBlue
class node_speech toneAmber
class node_agent,node_tools,node_wsserver toneMint
class node_unityclient,node_confirm,node_magnifier toneRose
class node_gemini,node_vr toneIndigo
```

## Components

### Voice Input

- [Audio Capture](https://github.com/zarmoin/magxr/blob/main/voiceCommand.py): `voiceCommand.py`

### Command Intelligence

- [Speech Parsing](https://github.com/zarmoin/magxr/blob/main/src/magxr/prompt_parser.py): `src/magxr/prompt_parser.py`

### Agent and Bridge

- [Agent Orchestrator](https://github.com/zarmoin/magxr/blob/main/src/magxr/agent.py): `src/magxr/agent.py`
- [Magnification Tools](https://github.com/zarmoin/magxr/blob/main/src/magxr/agent.py): `src/magxr/agent.py`
- [WebSocket Server](https://github.com/zarmoin/magxr/blob/main/src/magxr/server.py): `src/magxr/server.py`

### Unity XR Runtime

- [Unity WebSocket Client](https://github.com/zarmoin/magxr/blob/main/unity/MagXRWebSocketClient.cs): `unity/MagXRWebSocketClient.cs`
- [Confirmation Canvas](https://github.com/zarmoin/magxr/blob/main/unity/WorldSpaceConfirmationCanvas.cs): `unity/WorldSpaceConfirmationCanvas.cs`
- [Magnifier Controller](https://github.com/zarmoin/magxr/blob/main/unity/MagnifierController.cs): `unity/MagnifierController.cs`

### Other components

- **XR User**
- **Gemini AI**
- **XR Scene**

## Connections

- XR User → Audio Capture: speaks
- Audio Capture → Speech Parsing: audio bytes (evidence: `promptParser.py`)
- Speech Parsing → Gemini AI: transcribes and parses (evidence: `src/magxr/prompt_parser.py`)
- Speech Parsing → Agent Orchestrator: structured prompt (evidence: `src/magxr/agent.py`)
- Agent Orchestrator → Magnification Tools: dispatches tools (evidence: `src/magxr/agent.py`)
- Agent Orchestrator → WebSocket Server: returns actions (evidence: `src/magxr/server.py`)
- Unity WebSocket Client → WebSocket Server: sends commands (evidence: `src/magxr/server.py`)
- WebSocket Server → Unity WebSocket Client: sends confirmation and actions (evidence: `src/magxr/server.py`)
- Unity WebSocket Client → Confirmation Canvas: dispatches messages (evidence: `unity/MagXRWebSocketClient.cs`)
- Confirmation Canvas → Unity WebSocket Client: sends confirmation (evidence: `unity/WorldSpaceConfirmationCanvas.cs`)
- Unity WebSocket Client → Magnifier Controller: forwards action payload (evidence: `unity/MagXRWebSocketClient.cs`)
- Magnifier Controller → XR Scene: changes view
- XR User → Unity WebSocket Client: issues text command
