# kunchenguid/lavish-axi architecture

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

- Interactive diagram: https://gitdiagram.com/kunchenguid/lavish-axi
- Repository: https://github.com/kunchenguid/lavish-axi

## Overview

#### Purpose and entry points
Lavish AXI is a local-first CLI for reviewing agent-authored HTML artifacts in a browser and returning human feedback to an agent. The executable entry is `bin/lavish-axi.js`, dispatching CLI behavior in `src/cli.js`. Core commands open/resume a review, long-poll feedback, end sessions, export standalone HTML, share externally, and install agent integrations.

#### Local server and session lifecycle
A persistent local HTTP server hosts editor chrome, artifact routes, browser APIs, and long-poll endpoints. `src/server.js` orchestrates serving, security boundaries, watching, and lifecycle; `src/session-store.js` persists sessions keyed by canonical artifact path; `src/paths.js` centralizes state and path policy. The server is normally loopback-only, can expose a Tailscale address, validates hosts/origins, and self-stops when idle.

#### Artifact review boundary
Artifacts remain author-owned HTML loaded in a sandboxed iframe; Lavish injects collaboration behavior without changing the saved artifact design. `src/html-app.js` serves/reconciles artifact documents, `src/html-transform.js` injects and removes runtime code as appropriate, and `src/artifact-sdk.js` provides in-artifact selection, annotation, feedback-control, snapshot, and layout-audit integration. This boundary preserves direct-browser rendering while permitting local relative assets through controlled server routes.

#### Feedback, polling, and attachments
Browser actions are accumulated as prompts, then delivered atomically to an agent’s `poll` request; layout detection itself never wakes the agent. Session state carries queue, presence, replies, and end attribution via `src/session-store.js` and `src/server.js`. Image attachment uploads are content-addressed local files managed by `src/attachment-store.js`, with admission, TTL, reference protection, and disk caps. `src/async-mutex.js` protects concurrent state-changing operations.

#### Review chrome, diagnostics, and whiteboards
The browser chrome owns annotation UX, conversation state, open-time render gating, responsive review layout, and reload preservation. Its primary assets are `src/chrome-client.js` and `src/chrome.css`. `src/layout-warnings.js` detects evidence-backed clipping, overflow, reachability, and occlusion findings and tracks their viewport-specific lifecycle. Mermaid source extraction/conversion and editable Excalidraw-style whiteboards are handled by `src/mermaid-source.js`, `src/mermaid-node.js`, `src/whiteboard-core.js`, `src/whiteboard-store.js`, and `src/whiteboard-frame.js`.

#### Packaging and agent-facing guidance
The published npm package bundles CLI, server/chrome assets, skill content, and plugin metadata. Build orchestration resides in `scripts/build.js`, `scripts/build-plugin.js`, and `scripts/build-skill.js`; plugin declaration is `plugin.json`. Agent guidance is runtime-discoverable through `src/design-reference.js`, `src/playbooks.js`, and `src/skill.js`, sourced from `skills/lavish/SKILL.md`.

#### Export, sharing, and integrations
`src/export-bundle.js` produces portable HTML by safely inlining local assets and removing Lavish runtime injection. `src/html-app.js` and `src/share-password.js` support publishing to the external ht-ml.app API, including private-page credentials and update keys; the API base is configurable for self-hosting. `src/tailscale.js` discovers and binds tailnet access. `src/plugin.js` installs local Agent Plugin registrations, while hooks are configured through CLI setup flows. Telemetry behavior is isolated in `src/telemetry.js`.

Main entry points: [`src/server.js`](https://github.com/kunchenguid/lavish-axi/blob/main/src/server.js) (Local HTTP server), [`src/cli.js`](https://github.com/kunchenguid/lavish-axi/blob/main/src/cli.js) (Command dispatcher), [`src/chrome-client.js`](https://github.com/kunchenguid/lavish-axi/blob/main/src/chrome-client.js) (Review chrome), [`src/html-app.js`](https://github.com/kunchenguid/lavish-axi/blob/main/src/html-app.js) (Artifact document service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI &amp; package"]
  node_entry["lavish-axi executable<br/>CLI entry<br/>[lavish-axi.js]"]
  node_cli_dispatch["Command dispatcher<br/>CLI<br/>[cli.js]"]
  node_build["Package builders<br/>build pipeline<br/>[build.js]"]
  node_plugin_manifest["Plugin declaration<br/>plugin metadata<br/>[plugin.json]"]
end

subgraph group_runtime["Local review runtime"]
  node_server{{"Local HTTP server<br/>server orchestrator<br/>[server.js]"}}
  node_sessions[("Session store<br/>persistent session state<br/>[session-store.js]")]
  node_path_policy["Path policy<br/>state paths<br/>[paths.js]"]
  node_mutex["Async mutex<br/>concurrency guard<br/>[async-mutex.js]"]
  node_attachments[("Attachment store<br/>content-addressed files")]
  node_artifact_app["Artifact document service<br/>artifact route layer<br/>[html-app.js]"]
  node_html_transform["HTML runtime transform<br/>document transform<br/>[html-transform.js]"]
end

subgraph group_browser["Browser review surface"]
  node_chrome["Review chrome<br/>browser client<br/>[chrome-client.js]"]
  node_chrome_style["Chrome styles<br/>browser stylesheet<br/>[chrome.css]"]
  node_artifact_sdk["In-artifact SDK<br/>sandbox runtime<br/>[artifact-sdk.js]"]
  node_layout_warnings["Layout diagnostics<br/>viewport audit<br/>[layout-warnings.js]"]
  node_whiteboards["Diagram &amp; whiteboards<br/>visual collaboration<br/>[whiteboard-core.js]"]
end

subgraph group_delivery["Export &amp; integrations"]
  node_export_bundle["Portable HTML export<br/>exporter<br/>[export-bundle.js]"]
  node_sharing["External sharing<br/>publishing client<br/>[share-password.js]"]
  node_tailscale["Tailnet access<br/>network integration<br/>[tailscale.js]"]
  node_agent_guidance["Agent guidance<br/>runtime-discoverable skill<br/>[skill.js]"]
  node_plugin_install["Agent plugin installer<br/>integration installer<br/>[plugin.js]"]
  node_telemetry["Telemetry<br/>[telemetry.js]"]
end

node_entry -->|"dispatches"| node_cli_dispatch
node_cli_dispatch -->|"starts and controls"| node_server
node_cli_dispatch -->|"exports"| node_export_bundle
node_cli_dispatch -->|"shares"| node_sharing
node_cli_dispatch -->|"installs"| node_plugin_install
node_build -->|"packages"| node_plugin_manifest
node_server -->|"loads and updates sessions"| node_sessions
node_sessions -->|"uses canonical paths"| node_path_policy
node_server -->|"guards mutations with"| node_mutex
node_server -->|"accepts attachment uploads"| node_attachments
node_server -->|"serves artifact routes"| node_artifact_app
node_artifact_app -->|"transforms documents"| node_html_transform
node_html_transform -->|"injects"| node_artifact_sdk
node_server -->|"serves browser APIs and chrome"| node_chrome
node_chrome -->|"renders with"| node_chrome_style
node_chrome -->|"coordinates sandbox review"| node_artifact_sdk
node_chrome -->|"displays diagnostics"| node_layout_warnings
node_chrome -->|"hosts visual boards"| node_whiteboards
node_chrome -->|"queues feedback and long-polls"| node_server
node_server -.->|"optionally exposes via"| node_tailscale
node_artifact_app -->|"publishes reviewed HTML"| node_sharing
node_cli_dispatch -->|"discovers guidance"| node_agent_guidance
node_cli_dispatch -.->|"reports through"| node_telemetry

click node_entry "https://github.com/kunchenguid/lavish-axi/blob/main/bin/lavish-axi.js"
click node_cli_dispatch "https://github.com/kunchenguid/lavish-axi/blob/main/src/cli.js"
click node_build "https://github.com/kunchenguid/lavish-axi/blob/main/scripts/build.js"
click node_plugin_manifest "https://github.com/kunchenguid/lavish-axi/blob/main/plugin.json"
click node_server "https://github.com/kunchenguid/lavish-axi/blob/main/src/server.js"
click node_sessions "https://github.com/kunchenguid/lavish-axi/blob/main/src/session-store.js"
click node_path_policy "https://github.com/kunchenguid/lavish-axi/blob/main/src/paths.js"
click node_mutex "https://github.com/kunchenguid/lavish-axi/blob/main/src/async-mutex.js"
click node_attachments "https://github.com/kunchenguid/lavish-axi/blob/main/src/attachment-store.js"
click node_artifact_app "https://github.com/kunchenguid/lavish-axi/blob/main/src/html-app.js"
click node_html_transform "https://github.com/kunchenguid/lavish-axi/blob/main/src/html-transform.js"
click node_chrome "https://github.com/kunchenguid/lavish-axi/blob/main/src/chrome-client.js"
click node_chrome_style "https://github.com/kunchenguid/lavish-axi/blob/main/src/chrome.css"
click node_artifact_sdk "https://github.com/kunchenguid/lavish-axi/blob/main/src/artifact-sdk.js"
click node_layout_warnings "https://github.com/kunchenguid/lavish-axi/blob/main/src/layout-warnings.js"
click node_whiteboards "https://github.com/kunchenguid/lavish-axi/blob/main/src/whiteboard-core.js"
click node_export_bundle "https://github.com/kunchenguid/lavish-axi/blob/main/src/export-bundle.js"
click node_sharing "https://github.com/kunchenguid/lavish-axi/blob/main/src/share-password.js"
click node_tailscale "https://github.com/kunchenguid/lavish-axi/blob/main/src/tailscale.js"
click node_agent_guidance "https://github.com/kunchenguid/lavish-axi/blob/main/src/skill.js"
click node_plugin_install "https://github.com/kunchenguid/lavish-axi/blob/main/src/plugin.js"
click node_telemetry "https://github.com/kunchenguid/lavish-axi/blob/main/src/telemetry.js"

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_entry,node_cli_dispatch,node_build,node_plugin_manifest toneBlue
class node_server,node_sessions,node_path_policy,node_mutex,node_attachments,node_artifact_app,node_html_transform toneAmber
class node_chrome,node_chrome_style,node_artifact_sdk,node_layout_warnings,node_whiteboards toneMint
class node_export_bundle,node_sharing,node_tailscale,node_agent_guidance,node_plugin_install,node_telemetry toneRose
```

## Components

### CLI & package

- [lavish-axi executable](https://github.com/kunchenguid/lavish-axi/blob/main/bin/lavish-axi.js): CLI entry · `bin/lavish-axi.js`
- [Command dispatcher](https://github.com/kunchenguid/lavish-axi/blob/main/src/cli.js): CLI · Opens, resumes, polls, ends, exports, shares, and installs integrations. · `src/cli.js`
- [Package builders](https://github.com/kunchenguid/lavish-axi/blob/main/scripts/build.js): build pipeline · Bundles the published CLI, assets, plugin, and skill. · `scripts/build.js`
- [Plugin declaration](https://github.com/kunchenguid/lavish-axi/blob/main/plugin.json): plugin metadata · `plugin.json`

### Local review runtime

- [Local HTTP server](https://github.com/kunchenguid/lavish-axi/blob/main/src/server.js): server orchestrator · Owns routes, security checks, file watching, and idle shutdown. · `src/server.js`
- [Session store](https://github.com/kunchenguid/lavish-axi/blob/main/src/session-store.js): persistent session state · Persists sessions by canonical artifact path, including feedback and presence. · `src/session-store.js`
- [Path policy](https://github.com/kunchenguid/lavish-axi/blob/main/src/paths.js): state paths · `src/paths.js`
- [Async mutex](https://github.com/kunchenguid/lavish-axi/blob/main/src/async-mutex.js): concurrency guard · Serializes state-changing operations. · `src/async-mutex.js`
- [Attachment store](https://github.com/kunchenguid/lavish-axi/blob/main/src/attachment-store.js): content-addressed files · Applies upload admission, TTL, references, and disk caps. · `src/attachment-store.js`
- [Artifact document service](https://github.com/kunchenguid/lavish-axi/blob/main/src/html-app.js): artifact route layer · Serves and reconciles author-owned HTML and controlled local assets. · `src/html-app.js`
- [HTML runtime transform](https://github.com/kunchenguid/lavish-axi/blob/main/src/html-transform.js): document transform · Injects review runtime and removes it when required. · `src/html-transform.js`

### Browser review surface

- [Review chrome](https://github.com/kunchenguid/lavish-axi/blob/main/src/chrome-client.js): browser client · Owns annotations, conversation UX, responsive layout, and reload preservation. · `src/chrome-client.js`
- [Chrome styles](https://github.com/kunchenguid/lavish-axi/blob/main/src/chrome.css): browser stylesheet · `src/chrome.css`
- [In-artifact SDK](https://github.com/kunchenguid/lavish-axi/blob/main/src/artifact-sdk.js): sandbox runtime · Enables selection, annotations, feedback controls, snapshots, and audit integration. · `src/artifact-sdk.js`
- [Layout diagnostics](https://github.com/kunchenguid/lavish-axi/blob/main/src/layout-warnings.js): viewport audit · Tracks evidence-backed clipping, overflow, reachability, and occlusion findings. · `src/layout-warnings.js`
- [Diagram & whiteboards](https://github.com/kunchenguid/lavish-axi/blob/main/src/whiteboard-core.js): visual collaboration · Converts Mermaid and supports editable Excalidraw-style boards. · `src/whiteboard-core.js`

### Export & integrations

- [Portable HTML export](https://github.com/kunchenguid/lavish-axi/blob/main/src/export-bundle.js): exporter · Inlines local assets safely and strips Lavish runtime injection. · `src/export-bundle.js`
- [External sharing](https://github.com/kunchenguid/lavish-axi/blob/main/src/share-password.js): publishing client · Publishes to ht-ml.app with private credentials and update keys. · `src/share-password.js`
- [Tailnet access](https://github.com/kunchenguid/lavish-axi/blob/main/src/tailscale.js): network integration · Discovers and binds a Tailscale address. · `src/tailscale.js`
- [Agent guidance](https://github.com/kunchenguid/lavish-axi/blob/main/src/skill.js): runtime-discoverable skill · Exposes design references, playbooks, and the packaged skill. · `src/skill.js`
- [Agent plugin installer](https://github.com/kunchenguid/lavish-axi/blob/main/src/plugin.js): integration installer · `src/plugin.js`
- [Telemetry](https://github.com/kunchenguid/lavish-axi/blob/main/src/telemetry.js): telemetry boundary · `src/telemetry.js`

## Connections

- lavish-axi executable → Command dispatcher: dispatches
- Command dispatcher → Local HTTP server: starts and controls
- Command dispatcher → Portable HTML export: exports
- Command dispatcher → External sharing: shares
- Command dispatcher → Agent plugin installer: installs
- Package builders → Plugin declaration: packages
- Local HTTP server → Session store: loads and updates sessions
- Session store → Path policy: uses canonical paths
- Local HTTP server → Async mutex: guards mutations with
- Local HTTP server → Attachment store: accepts attachment uploads
- Local HTTP server → Artifact document service: serves artifact routes
- Artifact document service → HTML runtime transform: transforms documents
- HTML runtime transform → In-artifact SDK: injects
- Local HTTP server → Review chrome: serves browser APIs and chrome
- Review chrome → Chrome styles: renders with
- Review chrome → In-artifact SDK: coordinates sandbox review
- Review chrome → Layout diagnostics: displays diagnostics
- Review chrome → Diagram & whiteboards: hosts visual boards
- Review chrome → Local HTTP server: queues feedback and long-polls
- Local HTTP server → Tailnet access: optionally exposes via
- Artifact document service → External sharing: publishes reviewed HTML
- Command dispatcher → Agent guidance: discovers guidance
- Command dispatcher → Telemetry: reports through
