# armankhan8/ai_browser_agent_end_to_end architecture

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

- Interactive diagram: https://gitdiagram.com/armankhan8/ai_browser_agent_end_to_end
- Repository: https://github.com/armankhan8/ai_browser_agent_end_to_end

## Overview

AI Browser Agent accepts a natural-language task in its Gradio UI, runs an OpenAI Agents SDK agent, and executes one browser tool at a time against a persistent Playwright-controlled Chromium session. Each action returns a fresh, compact page state for the agent to choose its next step, ending in a brief result or blocker. The graph covers the documented workflow and browser capabilities; browser.py was only partially excerpted, so its individual session internals are represented together.

Main entry points: [`browser.py`](https://github.com/armankhan8/ai_browser_agent_end_to_end/blob/main/browser.py) (Browser session), [`agent.py`](https://github.com/armankhan8/ai_browser_agent_end_to_end/blob/main/agent.py) (Agent runner), [`app.py`](https://github.com/armankhan8/ai_browser_agent_end_to_end/blob/main/app.py) (Session lifecycle), [`config.py`](https://github.com/armankhan8/ai_browser_agent_end_to_end/blob/main/config.py) (Settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Task interaction"]
  node_ui["Gradio UI<br/>[app.py]"]
  node_session_lifecycle["Session lifecycle<br/>[app.py]"]
end

subgraph group_agent["Agent orchestration"]
  node_agent_runner["Agent runner<br/>[agent.py]"]
  node_tool_dispatch["Browser tools<br/>[browser_tools.py]"]
  node_openai["OpenAI Agents SDK"]
end

subgraph group_browser["Browser runtime"]
  node_browser_session["Browser session<br/>[browser.py]"]
  node_page_inspector["Page inspector<br/>[browser.py]"]
  node_playwright["Playwright"]
  node_chromium["Chromium"]
end

subgraph group_settings["Runtime settings"]
  node_settings["Settings<br/>[config.py]"]
end

node_user(("User"))
node_website(("Target website"))

node_user -->|"submits task"| node_ui
node_ui -->|"runs task"| node_session_lifecycle
node_session_lifecycle -->|"loads settings"| node_settings
node_session_lifecycle -->|"starts session"| node_browser_session
node_session_lifecycle -->|"starts agent"| node_agent_runner
node_agent_runner -->|"runs agent"| node_openai
node_agent_runner -->|"registers tools"| node_tool_dispatch
node_agent_runner -->|"reads initial state"| node_browser_session
node_tool_dispatch -->|"invokes actions"| node_browser_session
node_browser_session -->|"controls browser"| node_playwright
node_playwright -->|"drives"| node_chromium
node_chromium -->|"browses"| node_website
node_browser_session -->|"extracts page state"| node_page_inspector
node_page_inspector -->|"returns updated state"| node_tool_dispatch
node_settings -->|"configures session"| node_browser_session
node_settings -->|"sets agent limits"| node_agent_runner

click node_ui "https://github.com/armankhan8/ai_browser_agent_end_to_end/blob/main/app.py"
click node_session_lifecycle "https://github.com/armankhan8/ai_browser_agent_end_to_end/blob/main/app.py"
click node_settings "https://github.com/armankhan8/ai_browser_agent_end_to_end/blob/main/config.py"
click node_agent_runner "https://github.com/armankhan8/ai_browser_agent_end_to_end/blob/main/agent.py"
click node_tool_dispatch "https://github.com/armankhan8/ai_browser_agent_end_to_end/blob/main/browser_tools.py"
click node_browser_session "https://github.com/armankhan8/ai_browser_agent_end_to_end/blob/main/browser.py"
click node_page_inspector "https://github.com/armankhan8/ai_browser_agent_end_to_end/blob/main/browser.py"

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_ui,node_session_lifecycle,node_user toneBlue
class node_agent_runner,node_tool_dispatch,node_openai toneAmber
class node_browser_session,node_page_inspector,node_playwright,node_chromium toneMint
class node_settings toneRose
class node_website toneIndigo
```

## Components

### Task interaction

- [Gradio UI](https://github.com/armankhan8/ai_browser_agent_end_to_end/blob/main/app.py): `app.py`
- [Session lifecycle](https://github.com/armankhan8/ai_browser_agent_end_to_end/blob/main/app.py): `app.py`

### Agent orchestration

- [Agent runner](https://github.com/armankhan8/ai_browser_agent_end_to_end/blob/main/agent.py): `agent.py`
- [Browser tools](https://github.com/armankhan8/ai_browser_agent_end_to_end/blob/main/browser_tools.py): `browser_tools.py`
- **OpenAI Agents SDK**

### Browser runtime

- [Browser session](https://github.com/armankhan8/ai_browser_agent_end_to_end/blob/main/browser.py): `browser.py`
- [Page inspector](https://github.com/armankhan8/ai_browser_agent_end_to_end/blob/main/browser.py): `browser.py`
- **Playwright**
- **Chromium**

### Runtime settings

- [Settings](https://github.com/armankhan8/ai_browser_agent_end_to_end/blob/main/config.py): `config.py`

### Other components

- **User**
- **Target website**

## Connections

- User → Gradio UI: submits task (evidence: `app.py`)
- Gradio UI → Session lifecycle: runs task (evidence: `app.py`)
- Session lifecycle → Settings: loads settings (evidence: `app.py`)
- Session lifecycle → Browser session: starts session (evidence: `app.py`)
- Session lifecycle → Agent runner: starts agent (evidence: `app.py`)
- Agent runner → OpenAI Agents SDK: runs agent (evidence: `agent.py`)
- Agent runner → Browser tools: registers tools (evidence: `agent.py`)
- Agent runner → Browser session: reads initial state (evidence: `agent.py`)
- Browser tools → Browser session: invokes actions (evidence: `browser_tools.py`)
- Browser session → Playwright: controls browser (evidence: `browser.py`)
- Playwright → Chromium: drives (evidence: `README.md`)
- Chromium → Target website: browses (evidence: `README.md`)
- Browser session → Page inspector: extracts page state (evidence: `browser.py`)
- Page inspector → Browser tools: returns updated state (evidence: `browser_tools.py`)
- Settings → Browser session: configures session (evidence: `browser.py`)
- Settings → Agent runner: sets agent limits (evidence: `agent.py`)
