# tutingjun/browser-use-acp architecture

> Architecture diagram of the GitHub repository tutingjun/browser-use-acp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tutingjun/browser-use-acp
- Repository: https://github.com/tutingjun/browser-use-acp

## Overview

##### Main Components
- Agent Module: Located in the “browser_use/agent” directory, this part encapsulates logic for interacting with LLMs and orchestrating browser actions. It includes submodules like the message manager (with service, tests, utils, and views), prompts, and system prompt files.
- Browser Module: Found in “browser_use/browser”, it is responsible for low-level browser control using tools like Playwright. It includes core functionality (e.g., browser.py and context.py) and its own test suite.
- Controller Module: In “browser_use/controller”, this module seems to offer a higher-level registry and additional control logic for coordinating between the agent and browser components.
- DOM Extraction/Processing: The “browser_use/dom” directory provides the logic for extracting and processing DOM information – including building a DOM tree, handling history, and exposing services and views.
- Telemetry & Logging: The “browser_use/telemetry” and “browser_use/logging_config.py” components track usage and provide essential logging support.
- Utilities: The “browser_use/utils.py” file hosts shared functionality across various modules.
- Documentation & Examples: Folders such as “docs” and “examples” illustrate deployment, UI integrations (e.g., with gradio and streamlit), and usage of features, clarifying how components interconnect.

##### Out Relationships and Interactions
- The Agent serves as the orchestrator that interprets tasks (using LLM integration like ChatOpenAI) and makes decisions on what browser actions to perform.
- Browser Module acts on those decisions by executing interactions modeled after UI behaviors (clicks, navigation, etc.). It is invoked by the Agent either directly or via a controller.
- The Controller provides an abstraction layer that can register components (actions) and manage their lifecycle and expose registry views for enhanced configurability.
- The DOM Module is used by both the Agent and Browser: it extracts information from the live browser DOM, processes page structures, and provides intermediate representations, which may then be used for decision making.
- Logging and Telemetry capture events from the above modules, ensuring observability and debugging support.
- External services such as Playwright (for browser automation) and third-party LLM APIs (e.g., OpenAI) are integrated into these modules.
- Tests and examples act as validation points and usage demonstrations for each module, ensuring that the overall system functions cohesively.

##### Architectural Patterns and Important Design Principles
- Modularity: The project is broken into clear modules (agent, browser, controller, DOM, telemetry) that encapsulate discrete responsibilities.
- Layered Interaction: The Agent layer abstracts high-level tasks while interfacing with lower-level browser control and DOM processing components.
- Testability: Each module includes dedicated testing suites (e.g., “tests/”, “agent/tests.py”, “dom/tests/”), reflecting a design that prioritizes robustness and maintainability.
- Extensibility: Examples and integration subdirectories (including custom functions and integrations with Discord and Slack) highlight that the system was designed with extensibility and plug-and-play enhancements in mind.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Orchestration Layer
    subgraph "Orchestration Layer"
        A("Agent Module"):::orchestration
        C("Controller Module"):::orchestration
    end

    %% Operational Layer
    subgraph "Operational Layer"
        B("Browser Module"):::operational
        D("DOM Extraction/Processing"):::operational
    end

    %% Support Layer
    subgraph "Support Layer"
        T("Telemetry & Logging"):::support
        U("Utilities"):::support
    end

    %% Documentation & Examples
    subgraph "Documentation & Examples"
        DOC("Documentation"):::documentation
        EX("Examples"):::documentation
    end

    %% External Integrations
    LLM("LLM API (e.g., ChatOpenAI)"):::external
    PW("Playwright Automation"):::external

    %% Data & Control Flows
    A -->|"invokes"| B
    A -->|"queries DOM"| D
    A -->|"sends events"| T
    C -->|"orchestrates"| A
    C -->|"mediates"| B
    B -->|"extracts DOM info"| D
    D -->|"returns DOM data"| A
    T -->|"feedback"| A
    A --- U
    B --- U
    D --- U
    C --- U

    %% External integrations for browser automation and LLM decision making
    A --- LLM
    B --- PW

    %% Click Events
    click A "https://github.com/tutingjun/browser-use-acp/tree/main/browser_use/agent"
    click B "https://github.com/tutingjun/browser-use-acp/tree/main/browser_use/browser"
    click C "https://github.com/tutingjun/browser-use-acp/tree/main/browser_use/controller"
    click D "https://github.com/tutingjun/browser-use-acp/tree/main/browser_use/dom"
    click T "https://github.com/tutingjun/browser-use-acp/tree/main/browser_use/telemetry"
    click U "https://github.com/tutingjun/browser-use-acp/blob/main/browser_use/utils.py"
    click DOC "https://github.com/tutingjun/browser-use-acp/tree/main/docs"
    click EX "https://github.com/tutingjun/browser-use-acp/tree/main/examples"

    %% Styles
    classDef orchestration fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef operational fill:#A9DFBF,stroke:#145A32,stroke-width:2px;
    classDef support fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef documentation fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
```
