# abblot229/light-panda-browser architecture

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

- Interactive diagram: https://gitdiagram.com/abblot229/light-panda-browser
- Repository: https://github.com/abblot229/light-panda-browser

## Overview

Lightpanda is a headless browser for automation and AI agents. Its principal workflow accepts a URL or browser-control request, loads and parses a page, executes scripts and browser behaviors, then exposes page state or emits a dump; clients can use CDP or WebDriver BiDi, while the native agent can control the same browser and save replayable scripts. The README documents these product capabilities, and the tree identifies their likely modules. Source excerpts confirm the Rust HTML parser and renderer boundaries; several implementation links below are therefore dashed where their callers were not shown.

Main entry points: [`src/browser/Browser.zig`](https://github.com/abblot229/light-panda-browser/blob/main/src/browser/Browser.zig) (Browser engine), [`src/browser/frame`](https://github.com/abblot229/light-panda-browser/tree/main/src/browser/frame) (Frames and loading), [`src/browser/Page.zig`](https://github.com/abblot229/light-panda-browser/blob/main/src/browser/Page.zig) (Page lifecycle), [`src/rust/html5ever/lib.rs`](https://github.com/abblot229/light-panda-browser/blob/main/src/rust/html5ever/lib.rs) (HTML parsing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Interfaces and control"]
  node_app["Command interface<br/>[App.zig]"]
  node_server["Protocol servers"]
end

subgraph group_browser["Browser runtime"]
  node_browser_core["Browser engine<br/>[Browser.zig]"]
  node_session["Browser sessions<br/>[Session.zig]"]
  node_page_runtime["Page lifecycle<br/>[Page.zig]"]
  node_frame["Frames and loading"]
  node_network["Network requests"]
end

subgraph group_page["Page processing"]
  node_html_parser["HTML parsing<br/>[lib.rs]"]
  node_dom_sink["DOM tree callbacks<br/>[sink.rs]"]
  node_prescan["Resource prescan<br/>[prescan.rs]"]
  node_script_runtime["JavaScript runtime"]
  node_style["CSS and styles<br/>[StyleManager.zig]"]
  node_render["Text rendering<br/>[lib.rs]"]
  node_outputs["Page exports<br/>[dump.zig]"]
end

subgraph group_agent["Agent experience"]
  node_agent_runtime["Native agent<br/>[Agent.zig]"]
  node_conversation["Agent conversation<br/>[Conversation.zig]"]
  node_model_call["Model providers<br/>[ModelCall.zig]"]
  node_script_run["PandaScript runner<br/>[Runner.zig]"]
end

subgraph group_support["Native support"]
  node_storage[("Browser storage")]
  node_telemetry["Telemetry"]
  node_rust_ffi["Rust FFI archive<br/>[lib.rs]"]
  node_url["URL processing<br/>[url.rs]"]
end

node_automation(("Automation client"))
node_user(("Agent user"))

node_automation -->|"connects via"| node_server
node_server -.->|"controls"| node_browser_core
node_user -->|"starts task"| node_app
node_app -.->|"starts agent"| node_agent_runtime
node_app -.->|"fetches URL"| node_page_runtime
node_browser_core -.->|"manages sessions"| node_session
node_session -.->|"creates pages"| node_page_runtime
node_page_runtime -.->|"loads frames"| node_frame
node_frame -.->|"requests resources"| node_network
node_frame -.->|"scans resources"| node_prescan
node_frame -.->|"parses markup"| node_html_parser
node_html_parser -->|"builds DOM via"| node_dom_sink
node_html_parser -->|"uses tokenizer"| node_prescan
node_rust_ffi -->|"links crate"| node_html_parser
node_frame -.->|"runs scripts"| node_script_runtime
node_page_runtime -.->|"applies styles"| node_style
node_page_runtime -.->|"exports page"| node_outputs
node_outputs -.->|"renders output"| node_render
node_agent_runtime -->|"drives browser"| node_browser_core
node_agent_runtime -.->|"manages conversation"| node_conversation
node_conversation -.->|"requests completions"| node_model_call
node_model_call -.->|"uses provider APIs"| node_automation
node_agent_runtime -->|"saves replay script"| node_script_run
node_script_run -.->|"replays actions"| node_browser_core
node_browser_core -.->|"uses storage"| node_storage
node_browser_core -.->|"reports metrics"| node_telemetry
node_html_parser -.->|"uses URL parsing"| node_url

click node_app "https://github.com/abblot229/light-panda-browser/blob/main/src/App.zig"
click node_server "https://github.com/abblot229/light-panda-browser/tree/main/src/server"
click node_browser_core "https://github.com/abblot229/light-panda-browser/blob/main/src/browser/Browser.zig"
click node_session "https://github.com/abblot229/light-panda-browser/blob/main/src/browser/Session.zig"
click node_page_runtime "https://github.com/abblot229/light-panda-browser/blob/main/src/browser/Page.zig"
click node_frame "https://github.com/abblot229/light-panda-browser/tree/main/src/browser/frame"
click node_network "https://github.com/abblot229/light-panda-browser/tree/main/src/network"
click node_html_parser "https://github.com/abblot229/light-panda-browser/blob/main/src/rust/html5ever/lib.rs"
click node_dom_sink "https://github.com/abblot229/light-panda-browser/blob/main/src/rust/html5ever/sink.rs"
click node_prescan "https://github.com/abblot229/light-panda-browser/blob/main/src/rust/html5ever/prescan.rs"
click node_script_runtime "https://github.com/abblot229/light-panda-browser/tree/main/src/browser/js"
click node_style "https://github.com/abblot229/light-panda-browser/blob/main/src/browser/StyleManager.zig"
click node_render "https://github.com/abblot229/light-panda-browser/blob/main/src/rust/render/lib.rs"
click node_outputs "https://github.com/abblot229/light-panda-browser/blob/main/src/browser/dump.zig"
click node_agent_runtime "https://github.com/abblot229/light-panda-browser/blob/main/src/agent/Agent.zig"
click node_conversation "https://github.com/abblot229/light-panda-browser/blob/main/src/agent/Conversation.zig"
click node_model_call "https://github.com/abblot229/light-panda-browser/blob/main/src/agent/ModelCall.zig"
click node_script_run "https://github.com/abblot229/light-panda-browser/blob/main/src/browser/Runner.zig"
click node_storage "https://github.com/abblot229/light-panda-browser/tree/main/src/storage"
click node_telemetry "https://github.com/abblot229/light-panda-browser/tree/main/src/telemetry"
click node_rust_ffi "https://github.com/abblot229/light-panda-browser/blob/main/src/rust/ffi/lib.rs"
click node_url "https://github.com/abblot229/light-panda-browser/blob/main/src/rust/html5ever/url.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_app,node_server,node_automation,node_user toneBlue
class node_browser_core,node_session,node_page_runtime,node_frame,node_network toneAmber
class node_html_parser,node_dom_sink,node_prescan,node_script_runtime,node_style,node_render,node_outputs toneMint
class node_agent_runtime,node_conversation,node_model_call,node_script_run toneRose
class node_storage,node_telemetry,node_rust_ffi,node_url toneIndigo
```

## Components

### Interfaces and control

- [Command interface](https://github.com/abblot229/light-panda-browser/blob/main/src/App.zig): `src/App.zig`
- [Protocol servers](https://github.com/abblot229/light-panda-browser/tree/main/src/server): `src/server`

### Browser runtime

- [Browser engine](https://github.com/abblot229/light-panda-browser/blob/main/src/browser/Browser.zig): `src/browser/Browser.zig`
- [Browser sessions](https://github.com/abblot229/light-panda-browser/blob/main/src/browser/Session.zig): `src/browser/Session.zig`
- [Page lifecycle](https://github.com/abblot229/light-panda-browser/blob/main/src/browser/Page.zig): `src/browser/Page.zig`
- [Frames and loading](https://github.com/abblot229/light-panda-browser/tree/main/src/browser/frame): `src/browser/frame`
- [Network requests](https://github.com/abblot229/light-panda-browser/tree/main/src/network): `src/network`

### Page processing

- [HTML parsing](https://github.com/abblot229/light-panda-browser/blob/main/src/rust/html5ever/lib.rs): `src/rust/html5ever/lib.rs`
- [DOM tree callbacks](https://github.com/abblot229/light-panda-browser/blob/main/src/rust/html5ever/sink.rs): `src/rust/html5ever/sink.rs`
- [Resource prescan](https://github.com/abblot229/light-panda-browser/blob/main/src/rust/html5ever/prescan.rs): `src/rust/html5ever/prescan.rs`
- [JavaScript runtime](https://github.com/abblot229/light-panda-browser/tree/main/src/browser/js): `src/browser/js`
- [CSS and styles](https://github.com/abblot229/light-panda-browser/blob/main/src/browser/StyleManager.zig): `src/browser/StyleManager.zig`
- [Text rendering](https://github.com/abblot229/light-panda-browser/blob/main/src/rust/render/lib.rs): `src/rust/render/lib.rs`
- [Page exports](https://github.com/abblot229/light-panda-browser/blob/main/src/browser/dump.zig): `src/browser/dump.zig`

### Agent experience

- [Native agent](https://github.com/abblot229/light-panda-browser/blob/main/src/agent/Agent.zig): `src/agent/Agent.zig`
- [Agent conversation](https://github.com/abblot229/light-panda-browser/blob/main/src/agent/Conversation.zig): `src/agent/Conversation.zig`
- [Model providers](https://github.com/abblot229/light-panda-browser/blob/main/src/agent/ModelCall.zig): `src/agent/ModelCall.zig`
- [PandaScript runner](https://github.com/abblot229/light-panda-browser/blob/main/src/browser/Runner.zig): `src/browser/Runner.zig`

### Native support

- [Browser storage](https://github.com/abblot229/light-panda-browser/tree/main/src/storage): `src/storage`
- [Telemetry](https://github.com/abblot229/light-panda-browser/tree/main/src/telemetry): `src/telemetry`
- [Rust FFI archive](https://github.com/abblot229/light-panda-browser/blob/main/src/rust/ffi/lib.rs): `src/rust/ffi/lib.rs`
- [URL processing](https://github.com/abblot229/light-panda-browser/blob/main/src/rust/html5ever/url.rs): `src/rust/html5ever/url.rs`

### Other components

- **Automation client**
- **Agent user**

## Connections

- Automation client → Protocol servers: connects via (evidence: `README.md`)
- Protocol servers → Browser engine: controls
- Agent user → Command interface: starts task (evidence: `README.md`)
- Command interface → Native agent: starts agent
- Command interface → Page lifecycle: fetches URL
- Browser engine → Browser sessions: manages sessions
- Browser sessions → Page lifecycle: creates pages
- Page lifecycle → Frames and loading: loads frames
- Frames and loading → Network requests: requests resources
- Frames and loading → Resource prescan: scans resources
- Frames and loading → HTML parsing: parses markup
- HTML parsing → DOM tree callbacks: builds DOM via (evidence: `src/rust/html5ever/lib.rs`)
- HTML parsing → Resource prescan: uses tokenizer (evidence: `src/rust/html5ever/lib.rs`)
- Rust FFI archive → HTML parsing: links crate (evidence: `src/rust/ffi/lib.rs`)
- Frames and loading → JavaScript runtime: runs scripts
- Page lifecycle → CSS and styles: applies styles
- Page lifecycle → Page exports: exports page
- Page exports → Text rendering: renders output
- Native agent → Browser engine: drives browser (evidence: `README.md`)
- Native agent → Agent conversation: manages conversation
- Agent conversation → Model providers: requests completions
- Model providers → Automation client: uses provider APIs
- Native agent → PandaScript runner: saves replay script (evidence: `README.md`)
- PandaScript runner → Browser engine: replays actions
- Browser engine → Browser storage: uses storage
- Browser engine → Telemetry: reports metrics
- HTML parsing → URL processing: uses URL parsing (evidence: `src/rust/html5ever/lib.rs`)
