# chengmatt416/lhic architecture

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

- Interactive diagram: https://gitdiagram.com/chengmatt416/lhic
- Repository: https://github.com/chengmatt416/lhic

## Overview

LHIC is a local-first browser and desktop automation runtime. A user submits an intent through the CLI or Desktop Control Center; the controller routes it through local Fast Path execution or optional Slow Path planning, applies risk and approval gates, executes actions, and requires verification evidence. Traces and durable workflow state support audit and recovery. The README documents additional game-training, shared-skill, MCP, and observability capabilities; source excerpts are partial, so uncertain internal wiring is omitted.

Main entry points: [`packages/controller/src/multi-path-task-controller.ts`](https://github.com/chengmatt416/lhic/blob/main/packages/controller/src/multi-path-task-controller.ts) (Intent routing), [`apps/desktop/src/main/controller.ts`](https://github.com/chengmatt416/lhic/blob/main/apps/desktop/src/main/controller.ts) (Desktop controller), [`packages/trace/src/event-log.ts`](https://github.com/chengmatt416/lhic/blob/main/packages/trace/src/event-log.ts) (Trace and export), [`packages/verifier/src/verifier-engine.ts`](https://github.com/chengmatt416/lhic/blob/main/packages/verifier/src/verifier-engine.ts) (Action verification)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_cli["CLI<br/>[main.ts]"]
  node_desktop["Desktop Control Center<br/>[app.tsx]"]
  node_desktopmain["Desktop main process<br/>[main.ts]"]
  node_controller["Desktop controller<br/>[controller.ts]"]
end

subgraph group_control["Intent Control"]
  node_intent["Intent routing"]
  node_context["Task context<br/>[context-engine.ts]"]
  node_fastpath["Fast Path router"]
  node_slowpath["Slow Path planner<br/>[slow-path.ts]"]
  node_provider["Model providers<br/>[openai-provider.ts]"]
end

subgraph group_execution["Action Execution"]
  node_skills["Browser skills<br/>[index.ts]"]
  node_browser["Playwright browser runtime<br/>[index.ts]"]
  node_desktopactions["Global desktop actions<br/>[os-bridge.ts]"]
end

subgraph group_assurance["Security and Evidence"]
  node_verifier["Action verification<br/>[verifier-engine.ts]"]
  node_policy["Risk and approval policy<br/>[risk-policy.ts]"]
  node_redaction["Trace redaction<br/>[redact.ts]"]
  node_trace["Trace and export<br/>[event-log.ts]"]
  node_workflow[("Workflow state<br/>[workflow-state.ts]")]
end

subgraph group_extensions["Training and Integrations"]
  node_game["Game training runtime<br/>[index.ts]"]
  node_trainer["Local policy trainer<br/>[worker.py]"]
  node_shared["Shared skills sync<br/>[sync-service.ts]"]
  node_registry["Appwrite registry<br/>[main.js]"]
  node_mcp["MCP server<br/>[index.ts]"]
  node_controlplane["Control plane<br/>[control-plane.ts]"]
end

node_user(("Human user"))
node_otlp(("OTLP collector"))

node_user -->|"submits intent"| node_cli
node_user -->|"submits intent"| node_desktop
node_desktop -->|"IPC requests"| node_desktopmain
node_desktopmain -->|"dispatches"| node_controller
node_cli -->|"starts runtime"| node_intent
node_controller -->|"routes task"| node_intent
node_intent -->|"updates context"| node_context
node_intent -->|"routes locally"| node_fastpath
node_intent -.->|"plans ambiguous tasks"| node_slowpath
node_slowpath -.->|"requests proposal"| node_provider
node_intent -->|"checks risk"| node_policy
node_intent -->|"dispatches browser actions"| node_skills
node_skills -->|"executes actions"| node_browser
node_intent -->|"dispatches approved actions"| node_desktopactions
node_desktopactions -->|"requires verification"| node_verifier
node_browser -->|"provides evidence"| node_verifier
node_intent -->|"requires result verification"| node_verifier
node_intent -->|"records route events"| node_trace
node_trace -->|"redacts data"| node_redaction
node_intent -->|"recovers task state"| node_workflow
node_game -->|"trains policy"| node_trainer
node_controller -->|"manages training"| node_game
node_shared -->|"syncs skills"| node_registry
node_mcp -->|"serves API"| node_controlplane
node_trace -.->|"exports traces"| node_otlp

click node_cli "https://github.com/chengmatt416/lhic/blob/main/apps/cli/src/main.ts"
click node_desktop "https://github.com/chengmatt416/lhic/blob/main/apps/desktop/src/renderer/app.tsx"
click node_desktopmain "https://github.com/chengmatt416/lhic/blob/main/apps/desktop/src/main/main.ts"
click node_controller "https://github.com/chengmatt416/lhic/blob/main/apps/desktop/src/main/controller.ts"
click node_intent "https://github.com/chengmatt416/lhic/blob/main/packages/controller/src/multi-path-task-controller.ts"
click node_context "https://github.com/chengmatt416/lhic/blob/main/packages/controller/src/context-engine.ts"
click node_fastpath "https://github.com/chengmatt416/lhic/blob/main/packages/controller/src/fast-path-router.ts"
click node_slowpath "https://github.com/chengmatt416/lhic/blob/main/packages/controller/src/slow-path.ts"
click node_provider "https://github.com/chengmatt416/lhic/blob/main/packages/controller/src/openai-provider.ts"
click node_skills "https://github.com/chengmatt416/lhic/blob/main/packages/skills/src/index.ts"
click node_browser "https://github.com/chengmatt416/lhic/blob/main/packages/browser/src/index.ts"
click node_desktopactions "https://github.com/chengmatt416/lhic/blob/main/packages/skills/src/os-bridge.ts"
click node_verifier "https://github.com/chengmatt416/lhic/blob/main/packages/verifier/src/verifier-engine.ts"
click node_policy "https://github.com/chengmatt416/lhic/blob/main/packages/security/src/risk-policy.ts"
click node_redaction "https://github.com/chengmatt416/lhic/blob/main/packages/trace/src/redact.ts"
click node_trace "https://github.com/chengmatt416/lhic/blob/main/packages/trace/src/event-log.ts"
click node_workflow "https://github.com/chengmatt416/lhic/blob/main/packages/memory/src/workflow-state.ts"
click node_game "https://github.com/chengmatt416/lhic/blob/main/packages/game-training/src/index.ts"
click node_trainer "https://github.com/chengmatt416/lhic/blob/main/packages/game-training/python/worker.py"
click node_shared "https://github.com/chengmatt416/lhic/blob/main/packages/shared-skills/src/sync-service.ts"
click node_registry "https://github.com/chengmatt416/lhic/blob/main/services/appwrite-shared-skills/src/main.js"
click node_mcp "https://github.com/chengmatt416/lhic/blob/main/apps/mcp-server/src/index.ts"
click node_controlplane "https://github.com/chengmatt416/lhic/blob/main/apps/mcp-server/src/control-plane.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_desktop,node_desktopmain,node_controller,node_user toneBlue
class node_intent,node_context,node_fastpath,node_slowpath,node_provider toneAmber
class node_skills,node_browser,node_desktopactions toneMint
class node_verifier,node_policy,node_redaction,node_trace,node_workflow toneRose
class node_game,node_trainer,node_shared,node_registry,node_mcp,node_controlplane,node_otlp toneIndigo
```

## Components

### User Interfaces

- [CLI](https://github.com/chengmatt416/lhic/blob/main/apps/cli/src/main.ts): `apps/cli/src/main.ts`
- [Desktop Control Center](https://github.com/chengmatt416/lhic/blob/main/apps/desktop/src/renderer/app.tsx): `apps/desktop/src/renderer/app.tsx`
- [Desktop main process](https://github.com/chengmatt416/lhic/blob/main/apps/desktop/src/main/main.ts): `apps/desktop/src/main/main.ts`
- [Desktop controller](https://github.com/chengmatt416/lhic/blob/main/apps/desktop/src/main/controller.ts): `apps/desktop/src/main/controller.ts`

### Intent Control

- [Intent routing](https://github.com/chengmatt416/lhic/blob/main/packages/controller/src/multi-path-task-controller.ts): `packages/controller/src/multi-path-task-controller.ts`
- [Task context](https://github.com/chengmatt416/lhic/blob/main/packages/controller/src/context-engine.ts): `packages/controller/src/context-engine.ts`
- [Fast Path router](https://github.com/chengmatt416/lhic/blob/main/packages/controller/src/fast-path-router.ts): `packages/controller/src/fast-path-router.ts`
- [Slow Path planner](https://github.com/chengmatt416/lhic/blob/main/packages/controller/src/slow-path.ts): `packages/controller/src/slow-path.ts`
- [Model providers](https://github.com/chengmatt416/lhic/blob/main/packages/controller/src/openai-provider.ts): `packages/controller/src/openai-provider.ts`

### Action Execution

- [Browser skills](https://github.com/chengmatt416/lhic/blob/main/packages/skills/src/index.ts): `packages/skills/src/index.ts`
- [Playwright browser runtime](https://github.com/chengmatt416/lhic/blob/main/packages/browser/src/index.ts): `packages/browser/src/index.ts`
- [Global desktop actions](https://github.com/chengmatt416/lhic/blob/main/packages/skills/src/os-bridge.ts): `packages/skills/src/os-bridge.ts`

### Security and Evidence

- [Action verification](https://github.com/chengmatt416/lhic/blob/main/packages/verifier/src/verifier-engine.ts): `packages/verifier/src/verifier-engine.ts`
- [Risk and approval policy](https://github.com/chengmatt416/lhic/blob/main/packages/security/src/risk-policy.ts): `packages/security/src/risk-policy.ts`
- [Trace redaction](https://github.com/chengmatt416/lhic/blob/main/packages/trace/src/redact.ts): `packages/trace/src/redact.ts`
- [Trace and export](https://github.com/chengmatt416/lhic/blob/main/packages/trace/src/event-log.ts): `packages/trace/src/event-log.ts`
- [Workflow state](https://github.com/chengmatt416/lhic/blob/main/packages/memory/src/workflow-state.ts): `packages/memory/src/workflow-state.ts`

### Training and Integrations

- [Game training runtime](https://github.com/chengmatt416/lhic/blob/main/packages/game-training/src/index.ts): `packages/game-training/src/index.ts`
- [Local policy trainer](https://github.com/chengmatt416/lhic/blob/main/packages/game-training/python/worker.py): `packages/game-training/python/worker.py`
- [Shared skills sync](https://github.com/chengmatt416/lhic/blob/main/packages/shared-skills/src/sync-service.ts): `packages/shared-skills/src/sync-service.ts`
- [Appwrite registry](https://github.com/chengmatt416/lhic/blob/main/services/appwrite-shared-skills/src/main.js): `services/appwrite-shared-skills/src/main.js`
- [MCP server](https://github.com/chengmatt416/lhic/blob/main/apps/mcp-server/src/index.ts): `apps/mcp-server/src/index.ts`
- [Control plane](https://github.com/chengmatt416/lhic/blob/main/apps/mcp-server/src/control-plane.ts): `apps/mcp-server/src/control-plane.ts`

### Other components

- **Human user**
- **OTLP collector**

## Connections

- Human user → CLI: submits intent
- Human user → Desktop Control Center: submits intent
- Desktop Control Center → Desktop main process: IPC requests
- Desktop main process → Desktop controller: dispatches
- CLI → Intent routing: starts runtime
- Desktop controller → Intent routing: routes task
- Intent routing → Task context: updates context
- Intent routing → Fast Path router: routes locally
- Intent routing → Slow Path planner: plans ambiguous tasks
- Slow Path planner → Model providers: requests proposal
- Intent routing → Risk and approval policy: checks risk
- Intent routing → Browser skills: dispatches browser actions
- Browser skills → Playwright browser runtime: executes actions
- Intent routing → Global desktop actions: dispatches approved actions
- Global desktop actions → Action verification: requires verification
- Playwright browser runtime → Action verification: provides evidence
- Intent routing → Action verification: requires result verification
- Intent routing → Trace and export: records route events
- Trace and export → Trace redaction: redacts data
- Intent routing → Workflow state: recovers task state
- Game training runtime → Local policy trainer: trains policy
- Desktop controller → Game training runtime: manages training
- Shared skills sync → Appwrite registry: syncs skills
- MCP server → Control plane: serves API
- Trace and export → OTLP collector: exports traces
