# jj-sleeps/jj1 architecture

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

- Interactive diagram: https://gitdiagram.com/jj-sleeps/jj1
- Repository: https://github.com/jj-sleeps/jj1

## Overview

JJ1 fetches web pages for agents and presents a compact, safer representation: readable Markdown, numbered controls, and action results. The main workflow is URL access through the CLI or MCP tools, guarded networking, HTML distillation, then snapshots, lookup, citations, and confirmed actions. A second product surface is the human-facing WebView browser with Agent view and Deuri. The graph preserves documented audit, sign-in, model setup, DevTools, and extensions; links among unsampled subsystems are omitted or marked unverified.

Main entry points: [`crates/jj1-core/src/lib.rs`](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-core/src/lib.rs) (Tabs and sessions), [`crates/jj1-engine-view/src/bin/browser.rs`](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-engine-view/src/bin/browser.rs) (Windowed browser), [`crates/jj1-distill/src/lib.rs`](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-distill/src/lib.rs) (HTML distiller), [`crates/jj1-net/src/lib.rs`](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-net/src/lib.rs) (HTTP and redirects)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_agent_access["Agent access"]
  node_cli["JJ1 CLI<br/>[main.rs]"]
  node_mcp["MCP tools<br/>[lib.rs]"]
end

subgraph group_page_processing["Page processing"]
  node_distiller["HTML distiller<br/>[lib.rs]"]
  node_markdown["Markdown extraction<br/>[markdown.rs]"]
  node_action_map["Controls and forms<br/>[actions.rs]"]
  node_dom["Visible DOM helpers<br/>[dom.rs]"]
  node_injection_scan["Injection scan<br/>[scan.rs]"]
  node_page_audit["Readiness audit<br/>[audit.rs]"]
  node_citations["Quote citations<br/>[cite.rs]"]
end

subgraph group_safety_network["Safety and network"]
  node_policy["Policy gate<br/>[guard.rs]"]
  node_configuration["Policy configuration<br/>[config.rs]"]
  node_credential_vault[("Saved sign-ins<br/>[vault.rs]")]
  node_network["HTTP and redirects<br/>[lib.rs]"]
  node_bot_auth["Signed requests<br/>[botauth.rs]"]
  node_robots["Robots rules<br/>[robots.rs]"]
end

subgraph group_browser_assistant["Browser and assistant"]
  node_browser["Windowed browser<br/>[browser.rs]"]
  node_agent_view["Browser Agent view<br/>[browserdata.rs]"]
  node_live_view["Live WebView tier<br/>[view.rs]"]
  node_deuri["Deuri assistant<br/>[deuri.rs]"]
  node_model_fit["Hardware model fit<br/>[modelfit.rs]"]
  node_devtools["Docked DevTools<br/>[devtools.rs]"]
  node_extensions["Browser extensions<br/>[extensions.rs]"]
end

subgraph group_shared_runtime["Shared runtime"]
  node_session["Tabs and sessions<br/>[lib.rs]"]
  node_actions_runtime["Action and diffs<br/>[lib.rs]"]
end

node_user(("User or agent"))
node_lm_studio["LM Studio"]
node_web["Web pages"]

node_user -->|"uses"| node_cli
node_user -->|"uses"| node_mcp
node_user -->|"uses"| node_browser
node_cli -.->|"dispatches"| node_session
node_mcp -.->|"dispatches"| node_session
node_session -->|"fetches through"| node_network
node_session -->|"checks URLs"| node_policy
node_session -.->|"distills pages"| node_distiller
node_session -.->|"uses sign-ins"| node_credential_vault
node_session -->|"serves actions"| node_actions_runtime
node_distiller -->|"extracts text"| node_markdown
node_distiller -->|"extracts controls"| node_action_map
node_distiller -->|"scans content"| node_injection_scan
node_markdown -->|"uses helpers"| node_dom
node_action_map -->|"uses helpers"| node_dom
node_page_audit -->|"uses helpers"| node_dom
node_session -.->|"provides citations"| node_citations
node_configuration -.->|"configures"| node_policy
node_network -->|"checks rules"| node_robots
node_network -->|"signs requests"| node_bot_auth
node_network -->|"requests pages"| node_web
node_browser -.->|"shows"| node_agent_view
node_browser -.->|"hosts"| node_deuri
node_browser -.->|"opens pages"| node_live_view
node_browser -.->|"hosts"| node_devtools
node_browser -.->|"loads"| node_extensions
node_deuri -->|"calls API"| node_lm_studio
node_model_fit -.->|"supports setup"| node_browser

click node_cli "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-cli/src/main.rs"
click node_mcp "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-mcp/src/lib.rs"
click node_session "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-core/src/lib.rs"
click node_actions_runtime "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-core/src/lib.rs"
click node_distiller "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-distill/src/lib.rs"
click node_markdown "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-distill/src/markdown.rs"
click node_action_map "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-distill/src/actions.rs"
click node_dom "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-distill/src/dom.rs"
click node_injection_scan "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-distill/src/scan.rs"
click node_page_audit "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-distill/src/audit.rs"
click node_citations "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-distill/src/cite.rs"
click node_policy "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-core/src/guard.rs"
click node_configuration "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-core/src/config.rs"
click node_credential_vault "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-core/src/vault.rs"
click node_network "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-net/src/lib.rs"
click node_bot_auth "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-net/src/botauth.rs"
click node_robots "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-net/src/robots.rs"
click node_browser "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-engine-view/src/bin/browser.rs"
click node_agent_view "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-engine-view/src/browserdata.rs"
click node_live_view "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-engine-view/src/bin/view.rs"
click node_deuri "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-engine-view/src/deuri.rs"
click node_model_fit "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-engine-view/src/modelfit.rs"
click node_devtools "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-engine-view/src/devtools.rs"
click node_extensions "https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-engine-view/src/extensions.rs"

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_mcp,node_user toneBlue
class node_distiller,node_markdown,node_action_map,node_dom,node_injection_scan,node_page_audit,node_citations toneAmber
class node_policy,node_configuration,node_credential_vault,node_network,node_bot_auth,node_robots toneMint
class node_browser,node_agent_view,node_live_view,node_deuri,node_model_fit,node_devtools,node_extensions toneRose
class node_session,node_actions_runtime,node_lm_studio,node_web toneIndigo
```

## Components

### Agent access

- [JJ1 CLI](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-cli/src/main.rs): `crates/jj1-cli/src/main.rs`
- [MCP tools](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-mcp/src/lib.rs): `crates/jj1-mcp/src/lib.rs`

### Page processing

- [HTML distiller](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-distill/src/lib.rs): `crates/jj1-distill/src/lib.rs`
- [Markdown extraction](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-distill/src/markdown.rs): `crates/jj1-distill/src/markdown.rs`
- [Controls and forms](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-distill/src/actions.rs): `crates/jj1-distill/src/actions.rs`
- [Visible DOM helpers](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-distill/src/dom.rs): `crates/jj1-distill/src/dom.rs`
- [Injection scan](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-distill/src/scan.rs): `crates/jj1-distill/src/scan.rs`
- [Readiness audit](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-distill/src/audit.rs): `crates/jj1-distill/src/audit.rs`
- [Quote citations](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-distill/src/cite.rs): `crates/jj1-distill/src/cite.rs`

### Safety and network

- [Policy gate](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-core/src/guard.rs): `crates/jj1-core/src/guard.rs`
- [Policy configuration](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-core/src/config.rs): `crates/jj1-core/src/config.rs`
- [Saved sign-ins](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-core/src/vault.rs): `crates/jj1-core/src/vault.rs`
- [HTTP and redirects](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-net/src/lib.rs): `crates/jj1-net/src/lib.rs`
- [Signed requests](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-net/src/botauth.rs): `crates/jj1-net/src/botauth.rs`
- [Robots rules](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-net/src/robots.rs): `crates/jj1-net/src/robots.rs`

### Browser and assistant

- [Windowed browser](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-engine-view/src/bin/browser.rs): `crates/jj1-engine-view/src/bin/browser.rs`
- [Browser Agent view](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-engine-view/src/browserdata.rs): `crates/jj1-engine-view/src/browserdata.rs`
- [Live WebView tier](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-engine-view/src/bin/view.rs): `crates/jj1-engine-view/src/bin/view.rs`
- [Deuri assistant](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-engine-view/src/deuri.rs): `crates/jj1-engine-view/src/deuri.rs`
- [Hardware model fit](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-engine-view/src/modelfit.rs): `crates/jj1-engine-view/src/modelfit.rs`
- [Docked DevTools](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-engine-view/src/devtools.rs): `crates/jj1-engine-view/src/devtools.rs`
- [Browser extensions](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-engine-view/src/extensions.rs): `crates/jj1-engine-view/src/extensions.rs`

### Shared runtime

- [Tabs and sessions](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-core/src/lib.rs): `crates/jj1-core/src/lib.rs`
- [Action and diffs](https://github.com/jj-sleeps/jj1/blob/main/crates/jj1-core/src/lib.rs): `crates/jj1-core/src/lib.rs`

### Other components

- **User or agent**
- **LM Studio**
- **Web pages**

## Connections

- User or agent → JJ1 CLI: uses (evidence: `README.md`)
- User or agent → MCP tools: uses (evidence: `README.md`)
- User or agent → Windowed browser: uses (evidence: `README.md`)
- JJ1 CLI → Tabs and sessions: dispatches
- MCP tools → Tabs and sessions: dispatches
- Tabs and sessions → HTTP and redirects: fetches through (evidence: `crates/jj1-core/src/lib.rs`)
- Tabs and sessions → Policy gate: checks URLs (evidence: `crates/jj1-core/src/lib.rs`)
- Tabs and sessions → HTML distiller: distills pages
- Tabs and sessions → Saved sign-ins: uses sign-ins (evidence: `crates/jj1-core/src/lib.rs`)
- Tabs and sessions → Action and diffs: serves actions (evidence: `crates/jj1-core/src/lib.rs`)
- HTML distiller → Markdown extraction: extracts text (evidence: `crates/jj1-distill/src/lib.rs`)
- HTML distiller → Controls and forms: extracts controls (evidence: `crates/jj1-distill/src/lib.rs`)
- HTML distiller → Injection scan: scans content (evidence: `crates/jj1-distill/src/lib.rs`)
- Markdown extraction → Visible DOM helpers: uses helpers (evidence: `crates/jj1-distill/src/markdown.rs`)
- Controls and forms → Visible DOM helpers: uses helpers (evidence: `crates/jj1-distill/src/actions.rs`)
- Readiness audit → Visible DOM helpers: uses helpers (evidence: `crates/jj1-distill/src/audit.rs`)
- Tabs and sessions → Quote citations: provides citations
- Policy configuration → Policy gate: configures
- HTTP and redirects → Robots rules: checks rules (evidence: `crates/jj1-net/src/lib.rs`)
- HTTP and redirects → Signed requests: signs requests (evidence: `crates/jj1-net/src/lib.rs`)
- HTTP and redirects → Web pages: requests pages (evidence: `crates/jj1-net/src/lib.rs`)
- Windowed browser → Browser Agent view: shows
- Windowed browser → Deuri assistant: hosts
- Windowed browser → Live WebView tier: opens pages
- Windowed browser → Docked DevTools: hosts
- Windowed browser → Browser extensions: loads
- Deuri assistant → LM Studio: calls API (evidence: `crates/jj1-engine-view/src/deuri.rs`)
- Hardware model fit → Windowed browser: supports setup
