# risenhealthinsurance-dev/reignbrowser architecture

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

- Interactive diagram: https://gitdiagram.com/risenhealthinsurance-dev/reignbrowser
- Repository: https://github.com/risenhealthinsurance-dev/reignbrowser

## Overview

#### Purpose and Entry Points
Browser Use is a Python 3.11+ browser-automation framework where an LLM plans and executes web tasks through a local, remote, or cloud browser. The main library API exports agent and model abstractions from `browser_use/__init__.py`; runtime orchestration is centered in `browser_use/agent/service.py`. User-facing entry points include the Python API, CLI in `browser_use/cli.py`, install/bootstrap command in `browser_use/init_cmd.py`, and MCP server in `browser_use/mcp/server.py`.

#### Agent Orchestration Loop
`Agent` turns a natural-language task into iterative model decisions, browser/tool actions, observations, and history until completion or a stop condition. Prompt variants live in `browser_use/agent/system_prompts/`; conversation state, compaction, and model context boundaries are managed by `browser_use/agent/message_manager/service.py`. Agent-facing state/result schemas are in `browser_use/agent/views.py`, separating orchestration from browser and provider implementations.

#### Browser Session and Execution Boundary
The browser layer owns Chrome/CDP lifecycle, profiles, tabs, navigation, events, recording, and remote/cloud connections. `browser_use/browser/session.py` and `browser_use/browser/session_manager.py` form the session boundary used by the agent; `browser_use/browser/chrome.py` handles browser startup/connection. Watchdogs under `browser_use/browser/watchdogs/` enforce runtime policy and collect artifacts for events such as downloads, popups, permissions, captchas, screenshots, HAR, and crashes.

#### Web State Perception and Interaction
The DOM subsystem converts live pages into agent-readable structured state: snapshotting, visibility/clickability analysis, serialization, and markdown extraction. Its primary boundary is `browser_use/dom/service.py`, with serialized element representations in `browser_use/dom/serializer/serializer.py` and enhanced page state in `browser_use/dom/enhanced_snapshot.py`. Low-level interaction abstractions in `browser_use/actor/page.py` and `browser_use/actor/mouse.py` execute page and coordinate-level actions selected by the agent.

#### Tools, Actions, and Local Resources
The tools layer provides the action registry and typed action contracts that connect LLM tool calls to browser operations, extraction, and custom user actions. Core registry behavior is in `browser_use/tools/registry/service.py`; aggregate tool setup is in `browser_use/tools/service.py`. File operations are isolated behind `browser_use/filesystem/file_system.py`, while `browser_use/sandbox/sandbox.py` provides a controlled execution boundary for sandboxed workflows. This enables custom actions without coupling them to agent planning.

#### LLM Provider Abstraction
A shared chat/model interface normalizes messages, structured output, serialization, retries, and provider-specific APIs. Core contracts are in `browser_use/llm/base.py`, `browser_use/llm/messages.py`, and `browser_use/llm/models.py`. Provider adapters support Browser Use hosted models plus OpenAI, Anthropic, Google, AWS Bedrock, Azure, Ollama, OpenRouter, and others under `browser_use/llm/`. Provider credentials and API behavior remain outside agent/browser control logic.

#### External Services and Deployment Modes
The package can call Browser Use Cloud for hosted agents and remote browsers through `browser_use/browser/cloud/cloud.py`, and exposes cloud-specific event handling in `browser_use/agent/cloud_events.py`. It also integrates with Gmail via `browser_use/integrations/gmail/service.py`, supports MCP clients/servers through `browser_use/mcp/client.py` and `browser_use/mcp/server.py`, and emits telemetry via `browser_use/telemetry/service.py`. Docker packaging (`Dockerfile`, `docker/base-images/chromium/Dockerfile`) supplies a reproducible Python/Chromium runtime for containerized execution.

Main entry points: [`browser_use/agent/service.py`](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/agent/service.py) (Agent orchestration), [`browser_use/browser/session.py`](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/browser/session.py) (Browser session), [`browser_use/tools/registry/service.py`](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/tools/registry/service.py) (Action registry), [`browser_use/agent/message_manager/service.py`](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/agent/message_manager/service.py) (Message manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_python_api["Python API<br/>library export<br/>[__init__.py]"]
  node_cli["CLI<br/>command entry<br/>[cli.py]"]
  node_bootstrap["Install bootstrap<br/>command entry<br/>[init_cmd.py]"]
  node_mcp_server{{"MCP server<br/>MCP entry<br/>[server.py]"}}
end

subgraph group_agent["Agent runtime"]
  node_agent_service["Agent orchestration<br/>iteration loop<br/>[service.py]"]
  node_prompts["System prompts<br/>prompt variants"]
  node_message_manager["Message manager<br/>context manager<br/>[service.py]"]
  node_agent_views["Agent schemas<br/>state contracts<br/>[views.py]"]
  node_tool_service["Tool setup<br/>tool aggregation<br/>[service.py]"]
  node_tool_registry["Action registry<br/>typed tool contracts<br/>[service.py]"]
end

subgraph group_browser["Browser execution"]
  node_browser_session["Browser session<br/>session boundary<br/>[session.py]"]
  node_session_manager["Session manager<br/>lifecycle manager<br/>[session_manager.py]"]
  node_chrome["Chrome / CDP<br/>browser transport<br/>[chrome.py]"]
  node_watchdogs["Runtime watchdogs<br/>policy &amp; artifacts"]
  node_dom_service["DOM perception<br/>page-state service<br/>[service.py]"]
  node_actor["Page interaction<br/>action executor<br/>[page.py]"]
end

subgraph group_ext["Providers &amp; integrations"]
  node_llm_base["LLM abstraction<br/>model contracts<br/>[base.py]"]
  node_cloud{{"Cloud browser<br/>hosted remote service<br/>[cloud.py]"}}
  node_filesystem["File system<br/>local resource boundary<br/>[file_system.py]"]
  node_sandbox["Sandbox<br/>controlled execution<br/>[sandbox.py]"]
  node_telemetry["Telemetry<br/>event reporting<br/>[service.py]"]
  node_container["Container runtime<br/>Python/Chromium image"]
end

node_python_api -->|"creates agent"| node_agent_service
node_cli -->|"runs tasks"| node_agent_service
node_mcp_server -->|"serves agent tools"| node_agent_service
node_bootstrap -.->|"supports setup"| node_container
node_agent_service -->|"selects prompt"| node_prompts
node_agent_service -->|"manages context"| node_message_manager
node_message_manager -->|"model requests"| node_llm_base
node_llm_base -->|"decisions"| node_agent_service
node_agent_service -->|"reads/writes state"| node_agent_views
node_agent_service -->|"executes decisions"| node_tool_service
node_tool_service -->|"registers actions"| node_tool_registry
node_tool_registry -->|"browser actions"| node_browser_session
node_tool_registry -->|"file actions"| node_filesystem
node_tool_registry -->|"sandboxed workflows"| node_sandbox
node_browser_session -->|"lifecycle"| node_session_manager
node_session_manager -->|"starts/connects"| node_chrome
node_browser_session -->|"runtime events"| node_watchdogs
node_browser_session -->|"live page state"| node_dom_service
node_dom_service -->|"observations"| node_agent_service
node_tool_registry -->|"interaction actions"| node_actor
node_actor -->|"page commands"| node_browser_session
node_browser_session -.->|"remote/cloud mode"| node_cloud
node_agent_service -.->|"emits events"| node_telemetry
node_container -.->|"bundles Chromium"| node_chrome

click node_python_api "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/__init__.py"
click node_cli "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/cli.py"
click node_bootstrap "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/init_cmd.py"
click node_mcp_server "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/mcp/server.py"
click node_agent_service "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/agent/service.py"
click node_message_manager "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/agent/message_manager/service.py"
click node_agent_views "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/agent/views.py"
click node_tool_service "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/tools/service.py"
click node_tool_registry "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/tools/registry/service.py"
click node_browser_session "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/browser/session.py"
click node_session_manager "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/browser/session_manager.py"
click node_chrome "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/browser/chrome.py"
click node_dom_service "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/dom/service.py"
click node_actor "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/actor/page.py"
click node_llm_base "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/llm/base.py"
click node_cloud "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/browser/cloud/cloud.py"
click node_filesystem "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/filesystem/file_system.py"
click node_sandbox "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/sandbox/sandbox.py"
click node_telemetry "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/telemetry/service.py"
click node_container "https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/Dockerfile"

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_python_api,node_cli,node_bootstrap,node_mcp_server toneBlue
class node_agent_service,node_prompts,node_message_manager,node_agent_views,node_tool_service,node_tool_registry toneAmber
class node_browser_session,node_session_manager,node_chrome,node_watchdogs,node_dom_service,node_actor toneMint
class node_llm_base,node_cloud,node_filesystem,node_sandbox,node_telemetry,node_container toneRose
```

## Components

### Entry points

- [Python API](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/__init__.py): library export · `browser_use/__init__.py`
- [CLI](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/cli.py): command entry · `browser_use/cli.py`
- [Install bootstrap](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/init_cmd.py): command entry · `browser_use/init_cmd.py`
- [MCP server](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/mcp/server.py): MCP entry · `browser_use/mcp/server.py`

### Agent runtime

- [Agent orchestration](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/agent/service.py): iteration loop · Plans, executes actions, observes results, and stops on completion. · `browser_use/agent/service.py`
- **System prompts**: prompt variants
- [Message manager](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/agent/message_manager/service.py): context manager · Maintains conversation state and compacts model context. · `browser_use/agent/message_manager/service.py`
- [Agent schemas](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/agent/views.py): state contracts · `browser_use/agent/views.py`
- [Tool setup](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/tools/service.py): tool aggregation · `browser_use/tools/service.py`
- [Action registry](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/tools/registry/service.py): typed tool contracts · Dispatches model tool calls to browser, extraction, and custom actions. · `browser_use/tools/registry/service.py`

### Browser execution

- [Browser session](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/browser/session.py): session boundary · Owns tabs, navigation, profiles, events, and remote connections. · `browser_use/browser/session.py`
- [Session manager](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/browser/session_manager.py): lifecycle manager · `browser_use/browser/session_manager.py`
- [Chrome / CDP](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/browser/chrome.py): browser transport · `browser_use/browser/chrome.py`
- **Runtime watchdogs**: policy & artifacts · Handles downloads, popups, permissions, captures, HAR, and crashes.
- [DOM perception](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/dom/service.py): page-state service · Builds agent-readable page snapshots and extracted content. · `browser_use/dom/service.py`
- [Page interaction](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/actor/page.py): action executor · `browser_use/actor/page.py`

### Providers & integrations

- [LLM abstraction](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/llm/base.py): model contracts · Normalizes chat, structured output, retries, and provider APIs. · `browser_use/llm/base.py`
- [Cloud browser](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/browser/cloud/cloud.py): hosted remote service · `browser_use/browser/cloud/cloud.py`
- [File system](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/filesystem/file_system.py): local resource boundary · `browser_use/filesystem/file_system.py`
- [Sandbox](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/sandbox/sandbox.py): controlled execution · `browser_use/sandbox/sandbox.py`
- [Telemetry](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/browser_use/telemetry/service.py): event reporting · `browser_use/telemetry/service.py`
- [Container runtime](https://github.com/risenhealthinsurance-dev/reignbrowser/blob/main/Dockerfile): Python/Chromium image · `Dockerfile`

## Connections

- Python API → Agent orchestration: creates agent
- CLI → Agent orchestration: runs tasks
- MCP server → Agent orchestration: serves agent tools
- Install bootstrap → Container runtime: supports setup
- Agent orchestration → System prompts: selects prompt
- Agent orchestration → Message manager: manages context
- Message manager → LLM abstraction: model requests
- LLM abstraction → Agent orchestration: decisions
- Agent orchestration → Agent schemas: reads/writes state
- Agent orchestration → Tool setup: executes decisions
- Tool setup → Action registry: registers actions
- Action registry → Browser session: browser actions
- Action registry → File system: file actions
- Action registry → Sandbox: sandboxed workflows
- Browser session → Session manager: lifecycle
- Session manager → Chrome / CDP: starts/connects
- Browser session → Runtime watchdogs: runtime events
- Browser session → DOM perception: live page state
- DOM perception → Agent orchestration: observations
- Action registry → Page interaction: interaction actions
- Page interaction → Browser session: page commands
- Browser session → Cloud browser: remote/cloud mode
- Agent orchestration → Telemetry: emits events
- Container runtime → Chrome / CDP: bundles Chromium
