# jaredrhod/barehands architecture

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

- Interactive diagram: https://gitdiagram.com/jaredrhod/barehands
- Repository: https://github.com/jaredrhod/barehands

## Overview

#### Purpose and Entry Points
barehands is a local, webcam-driven spatial board: hand gestures manipulate rendered markdown cards, images, and 3D media. It is also a controlled visual interface for an AI or other local automation.

Primary startup is `server.py`, then Chrome loads `stage.html` at `http://127.0.0.1:8794/stage.html`. `stage.html?role=render` is the transparent render-only mirror for OBS. Installation/configuration guidance for AI agents lives in `barehands.md`; user config begins from `barehands.json.example`.

#### Local Server and Trust Boundary
`server.py` is the stdlib-Python local HTTP/API server. It serves the stage and likely mediates filesystem and board-action access rather than exposing arbitrary local filesystem control.

Two explicit safety boundaries define the integration:
- Configured notes directories are readable as markdown vault sources.
- Board media is constrained to `media/`; the server enforces this media jail and an action allowlist for agent-issued commands.

Relevant paths: `server.py`, `barehands.json.example`, `media/`.

#### Browser Spatial Runtime
The browser application in `stage.html` owns webcam interaction, gesture interpretation, scene state, and visual rendering. It loads Google MediaPipe hand tracking and three.js from public CDNs, avoiding a bundled frontend dependency/runtime.

The tracker recognizes pinch/tap, drag, rotate, scale, throw, clap clear, claw force-pull, and exploded-view scrubbing. Query parameters select rendering role, cursor visibility, resolution/scaling, and portrait orientation. The render role mirrors the same scene without camera ownership for capture workflows.

Relevant path: `stage.html`.

#### Content Ingestion: Notes and Media
Orbs configured in `barehands.json` expose either markdown folders (`kind: "notes"`) or media (`kind: "media"`). Markdown is treated as a vault hierarchy and displayed as glass cards; an Obsidian vault is compatible without conversion.

Media is categorized by directory: ordinary images/props, transparent effects, conventional models, and holographic-model rendering. This provides a narrow, predictable asset pipeline rather than arbitrary file display.

Relevant paths: `barehands.json.example`, `sample-notes/`, `media/fx/`, `media/holo/`, `media/models/`, `media/misc/`.

#### AI / Automation Control Plane
An external brain does not run inside barehands. Any program capable of writing files or calling localhost can control it through two protocols:
- Presence state: write `idle`, `thinking`, `listening`, or `speaking` to a state file; the on-screen ring reflects it.
- Board commands: send JSON actions through the board script/API to present or compose cards, images, hand cues, explosions, yanks, and hover behavior.

The reverse path is board inspection: an agent calls the state script before deciding what to present. This makes AI integration a bounded local command interface, not browser automation.

Relevant paths: `state/README.md`, `bin/board.sh`, `bin/board-state.sh`, `barehands.md`.

#### State and Operating Model
Runtime presence data is filesystem-based under `state/`, allowing simple integration with Claude Code hooks, local LLMs, cron jobs, or hardware buttons. Board commands cross into the localhost server, which validates them before they affect the browser scene.

The application is intentionally local-first: Python stdlib server, Chrome webcam permissions, CDN-delivered MediaPipe/three.js, optional OBS as an external render consumer, and no required hosted backend.

Relevant paths: `state/`, `server.py`, `stage.html`.

#### Onboarding and Maintenance
Embedded sample notes teach interaction from within the product and are suitable as the initial notes orb. Troubleshooting focuses on gesture calibration/debugging. Update scripts pull product changes while intended user-owned config, notes, and media can remain outside tracked files.

Relevant paths: `sample-notes/Getting Started/`, `TROUBLESHOOTING.md`, `update.sh`, `update.bat`.

Main entry points: [`server.py`](https://github.com/jaredrhod/barehands/blob/main/server.py) (Local HTTP/API server), [`stage.html`](https://github.com/jaredrhod/barehands/blob/main/stage.html) (Spatial board), [`barehands.json.example`](https://github.com/jaredrhod/barehands/blob/main/barehands.json.example) (Orb configuration), [`bin/board.sh`](https://github.com/jaredrhod/barehands/blob/main/bin/board.sh) (Board command API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Local Control Plane"]
  node_startup["Local startup<br/>launcher<br/>[server.py]"]
  node_server{{"Local HTTP/API server<br/>Python stdlib server<br/>[server.py]"}}
  node_board_api["Board command API<br/>validated actions<br/>[board.sh]"]
  node_board_inspection["Board inspection<br/>state query<br/>[board-state.sh]"]
  node_presence_state["Presence state files<br/>filesystem state"]
  node_state_protocol["State protocol<br/>integration guide<br/>[README.md]"]
end

subgraph group_browser["Browser Spatial Runtime"]
  node_stage{{"Spatial board<br/>browser application<br/>[stage.html]"}}
  node_webcam(("Webcam input<br/>browser device API"))
  node_gesture_tracking["Hand gesture tracking<br/>MediaPipe integration<br/>[stage.html]"]
  node_scene_renderer["3D scene renderer<br/>three.js integration<br/>[stage.html]"]
  node_obs_mirror["OBS render mirror<br/>render-only stage role<br/>[stage.html]"]
end

subgraph group_content["Content Sources"]
  node_user_config["Orb configuration<br/>JSON config template"]
  node_notes_vault["Markdown notes vault<br/>configured directory"]
  node_media_jail[("Board media jail<br/>restricted asset root")]
  node_effects["Transparent effects<br/>media category"]
  node_holographic_models["Holographic models<br/>media category"]
  node_models["3D models<br/>media category"]
  node_props_images["Images and props<br/>media category"]
end

subgraph group_operations["Operations"]
  node_agent_guide["AI integration guide<br/>operating guide<br/>[barehands.md]"]
  node_onboarding_notes["Embedded onboarding<br/>sample notes"]
  node_troubleshooting["Gesture troubleshooting<br/>maintenance guide<br/>[TROUBLESHOOTING.md]"]
  node_updates["Update scripts<br/>maintenance automation<br/>[update.sh]"]
end

node_startup -->|"starts"| node_server
node_server -->|"serves"| node_stage
node_webcam -->|"hand frames"| node_gesture_tracking
node_gesture_tracking -->|"scene gestures"| node_stage
node_stage -->|"renders through"| node_scene_renderer
node_stage -.->|"shared scene role"| node_obs_mirror
node_presence_state -->|"presence input"| node_server
node_server -->|"presence and actions"| node_stage
node_board_api -->|"JSON board commands"| node_server
node_board_inspection -->|"queries state"| node_server
node_state_protocol -.->|"defines writes"| node_presence_state
node_user_config -->|"configures notes orb"| node_notes_vault
node_user_config -->|"configures media orb"| node_media_jail
node_notes_vault -->|"readable markdown source"| node_server
node_media_jail -->|"jail-enforced assets"| node_server
node_effects -.->|"contained in"| node_media_jail
node_holographic_models -.->|"contained in"| node_media_jail
node_models -.->|"contained in"| node_media_jail
node_props_images -.->|"contained in"| node_media_jail
node_server -->|"content delivery"| node_stage
node_agent_guide -.->|"documents control"| node_board_api
node_onboarding_notes -.->|"initial content"| node_notes_vault
node_troubleshooting -.->|"calibration guidance"| node_gesture_tracking
node_updates -.->|"updates product"| node_server

click node_startup "https://github.com/jaredrhod/barehands/blob/main/server.py"
click node_server "https://github.com/jaredrhod/barehands/blob/main/server.py"
click node_board_api "https://github.com/jaredrhod/barehands/blob/main/bin/board.sh"
click node_board_inspection "https://github.com/jaredrhod/barehands/blob/main/bin/board-state.sh"
click node_state_protocol "https://github.com/jaredrhod/barehands/blob/main/state/README.md"
click node_stage "https://github.com/jaredrhod/barehands/blob/main/stage.html"
click node_gesture_tracking "https://github.com/jaredrhod/barehands/blob/main/stage.html"
click node_scene_renderer "https://github.com/jaredrhod/barehands/blob/main/stage.html"
click node_obs_mirror "https://github.com/jaredrhod/barehands/blob/main/stage.html"
click node_user_config "https://github.com/jaredrhod/barehands/blob/main/barehands.json.example"
click node_agent_guide "https://github.com/jaredrhod/barehands/blob/main/barehands.md"
click node_troubleshooting "https://github.com/jaredrhod/barehands/blob/main/TROUBLESHOOTING.md"
click node_updates "https://github.com/jaredrhod/barehands/blob/main/update.sh"

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_startup,node_server,node_board_api,node_board_inspection,node_presence_state,node_state_protocol toneBlue
class node_stage,node_webcam,node_gesture_tracking,node_scene_renderer,node_obs_mirror toneAmber
class node_user_config,node_notes_vault,node_media_jail,node_effects,node_holographic_models,node_models,node_props_images toneMint
class node_agent_guide,node_onboarding_notes,node_troubleshooting,node_updates toneRose
```

## Components

### Local Control Plane

- [Local startup](https://github.com/jaredrhod/barehands/blob/main/server.py): launcher · Starts the local server and opens Chrome. · `server.py`
- [Local HTTP/API server](https://github.com/jaredrhod/barehands/blob/main/server.py): Python stdlib server · Serves the stage and validates local board operations. · `server.py`
- [Board command API](https://github.com/jaredrhod/barehands/blob/main/bin/board.sh): validated actions · Applies an allowlisted command set. · `bin/board.sh`
- [Board inspection](https://github.com/jaredrhod/barehands/blob/main/bin/board-state.sh): state query · Lets an external controller inspect board state. · `bin/board-state.sh`
- **Presence state files**: filesystem state · Stores idle, thinking, listening, or speaking presence.
- [State protocol](https://github.com/jaredrhod/barehands/blob/main/state/README.md): integration guide · `state/README.md`

### Browser Spatial Runtime

- [Spatial board](https://github.com/jaredrhod/barehands/blob/main/stage.html): browser application · Owns scene state, interaction, and rendering. · `stage.html`
- **Webcam input**: browser device API
- [Hand gesture tracking](https://github.com/jaredrhod/barehands/blob/main/stage.html): MediaPipe integration · Interprets pinch, drag, rotate, scale, throw, clap, claw, and scrub gestures. · `stage.html`
- [3D scene renderer](https://github.com/jaredrhod/barehands/blob/main/stage.html): three.js integration · Renders cards, images, media, and presence cues. · `stage.html`
- [OBS render mirror](https://github.com/jaredrhod/barehands/blob/main/stage.html): render-only stage role · Uses stage.html?role=render without camera ownership. · `stage.html`

### Content Sources

- [Orb configuration](https://github.com/jaredrhod/barehands/blob/main/barehands.json.example): JSON config template · Configures notes and media sources. · `barehands.json.example`
- **Markdown notes vault**: configured directory · Markdown hierarchy becomes glass cards; Obsidian-compatible.
- **Board media jail**: restricted asset root · Server constrains board media to this directory.
- **Transparent effects**: media category
- **Holographic models**: media category
- **3D models**: media category
- **Images and props**: media category

### Operations

- [AI integration guide](https://github.com/jaredrhod/barehands/blob/main/barehands.md): operating guide · `barehands.md`
- **Embedded onboarding**: sample notes · Teaches interaction from the initial notes orb.
- [Gesture troubleshooting](https://github.com/jaredrhod/barehands/blob/main/TROUBLESHOOTING.md): maintenance guide · `TROUBLESHOOTING.md`
- [Update scripts](https://github.com/jaredrhod/barehands/blob/main/update.sh): maintenance automation · Updates product files while user-owned content can remain external. · `update.sh`

## Connections

- Local startup → Local HTTP/API server: starts
- Local HTTP/API server → Spatial board: serves
- Webcam input → Hand gesture tracking: hand frames
- Hand gesture tracking → Spatial board: scene gestures
- Spatial board → 3D scene renderer: renders through
- Spatial board → OBS render mirror: shared scene role
- Presence state files → Local HTTP/API server: presence input
- Local HTTP/API server → Spatial board: presence and actions
- Board command API → Local HTTP/API server: JSON board commands
- Board inspection → Local HTTP/API server: queries state
- State protocol → Presence state files: defines writes
- Orb configuration → Markdown notes vault: configures notes orb
- Orb configuration → Board media jail: configures media orb
- Markdown notes vault → Local HTTP/API server: readable markdown source
- Board media jail → Local HTTP/API server: jail-enforced assets
- Transparent effects → Board media jail: contained in
- Holographic models → Board media jail: contained in
- 3D models → Board media jail: contained in
- Images and props → Board media jail: contained in
- Local HTTP/API server → Spatial board: content delivery
- AI integration guide → Board command API: documents control
- Embedded onboarding → Markdown notes vault: initial content
- Gesture troubleshooting → Hand gesture tracking: calibration guidance
- Update scripts → Local HTTP/API server: updates product
