# karthick-1501/playwright-agent architecture

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

- Interactive diagram: https://gitdiagram.com/karthick-1501/playwright-agent
- Repository: https://github.com/karthick-1501/playwright-agent

## Overview

Playwright AI Test Agent combines browser-test authoring and execution with selector health tracking and repair. Its generation workflow runs from a user request through the CLI and deterministic orchestrator, which resolves Scout/registry context, calls Claude, validates the response, then writes generated artifacts and synchronizes selectors. Runtime tests use page objects and locator builders over Playwright; BasePage records interaction outcomes for registry-based healing. The README also documents CDP discovery and health reporting. Relationships for unsampled tests and Scout internals are included only where README evidence supports them.

Main entry points: [`src/pages`](https://github.com/karthick-1501/playwright-agent/tree/main/src/pages) (Page objects), [`src/agent/orchestrator.js`](https://github.com/karthick-1501/playwright-agent/blob/main/src/agent/orchestrator.js) (Orchestrator), [`src/agent/cli.js`](https://github.com/karthick-1501/playwright-agent/blob/main/src/agent/cli.js) (Agent CLI), [`src/registry/registry-manager.js`](https://github.com/karthick-1501/playwright-agent/blob/main/src/registry/registry-manager.js) (Registry manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["AI Authoring"]
  node_cli["Agent CLI<br/>[cli.js]"]
  node_orchestrator["Orchestrator<br/>[orchestrator.js]"]
  node_scout["DOM Scout<br/>[scout.js]"]
  node_generated["Generated tests"]
  node_elements_sync["Element patching<br/>[orchestrator.js]"]
end

subgraph group_healing["Selector Health"]
  node_registry_store[("Selector registry")]
  node_registry_manager["Registry manager"]
  node_heal_manager["Heal manager<br/>[heal.js]"]
  node_scout_data["Scout summaries"]
end

subgraph group_runtime["Browser Tests"]
  node_tests["Test specs"]
  node_page_objects["Page objects"]
  node_base_page["Action and assert engine<br/>[BasePage.js]"]
  node_home_elements["Home locators"]
  node_login_elements["Login locators"]
end

subgraph group_config["Test Configuration"]
  node_execution_config["Execution config"]
  node_testdata["Test data<br/>[testdata.config.js]"]
end

node_user(("Test author"))
node_claude["Claude API"]
node_playwright["Playwright"]
node_target_site["Hyva demo site"]

node_user -->|"requests generation"| node_cli
node_cli -->|"runs generation"| node_orchestrator
node_orchestrator -.->|"uses discovery"| node_scout
node_orchestrator -->|"sends context"| node_claude
node_claude -.->|"returns envelope"| node_orchestrator
node_orchestrator -->|"writes files"| node_generated
node_orchestrator -->|"patches locators"| node_elements_sync
node_elements_sync -->|"updates selectors"| node_home_elements
node_elements_sync -->|"updates selectors"| node_login_elements
node_cli -->|"creates manager"| node_registry_manager
node_cli -->|"creates healer"| node_heal_manager
node_heal_manager -->|"resolves and updates"| node_registry_manager
node_heal_manager -->|"reads summaries"| node_scout_data
node_registry_manager -->|"loads and saves"| node_registry_store
node_tests -->|"invokes workflows"| node_page_objects
node_page_objects -->|"delegates actions"| node_base_page
node_page_objects -->|"uses locators"| node_home_elements
node_page_objects -->|"uses locators"| node_login_elements
node_base_page -->|"records outcomes"| node_registry_manager
node_base_page -->|"performs browser actions"| node_playwright
node_tests -.->|"reads test inputs"| node_testdata
node_page_objects -->|"reads base URL"| node_execution_config
node_page_objects -.->|"navigates browser"| node_target_site
node_scout -.->|"discovers DOM"| node_target_site

click node_cli "https://github.com/karthick-1501/playwright-agent/blob/main/src/agent/cli.js"
click node_orchestrator "https://github.com/karthick-1501/playwright-agent/blob/main/src/agent/orchestrator.js"
click node_scout "https://github.com/karthick-1501/playwright-agent/blob/main/src/agent/scout.js"
click node_generated "https://github.com/karthick-1501/playwright-agent/tree/main/src/tests"
click node_elements_sync "https://github.com/karthick-1501/playwright-agent/blob/main/src/agent/orchestrator.js"
click node_registry_manager "https://github.com/karthick-1501/playwright-agent/blob/main/src/registry/registry-manager.js"
click node_heal_manager "https://github.com/karthick-1501/playwright-agent/blob/main/src/registry/heal.js"
click node_tests "https://github.com/karthick-1501/playwright-agent/tree/main/src/tests"
click node_page_objects "https://github.com/karthick-1501/playwright-agent/tree/main/src/pages"
click node_base_page "https://github.com/karthick-1501/playwright-agent/blob/main/src/pages/BasePage.js"
click node_home_elements "https://github.com/karthick-1501/playwright-agent/blob/main/src/elements/HyvaHome.elements.js"
click node_login_elements "https://github.com/karthick-1501/playwright-agent/blob/main/src/elements/HyvaLogin.elements.js"
click node_execution_config "https://github.com/karthick-1501/playwright-agent/blob/main/config/execution.config.js"
click node_testdata "https://github.com/karthick-1501/playwright-agent/blob/main/config/testdata.config.js"

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_orchestrator,node_scout,node_generated,node_elements_sync toneBlue
class node_registry_store,node_registry_manager,node_heal_manager,node_scout_data toneAmber
class node_tests,node_page_objects,node_base_page,node_home_elements,node_login_elements,node_claude toneMint
class node_execution_config,node_testdata toneRose
class node_user,node_playwright,node_target_site toneIndigo
```

## Components

### AI Authoring

- [Agent CLI](https://github.com/karthick-1501/playwright-agent/blob/main/src/agent/cli.js): `src/agent/cli.js`
- [Orchestrator](https://github.com/karthick-1501/playwright-agent/blob/main/src/agent/orchestrator.js): `src/agent/orchestrator.js`
- [DOM Scout](https://github.com/karthick-1501/playwright-agent/blob/main/src/agent/scout.js): `src/agent/scout.js`
- [Generated tests](https://github.com/karthick-1501/playwright-agent/tree/main/src/tests): `src/tests`
- [Element patching](https://github.com/karthick-1501/playwright-agent/blob/main/src/agent/orchestrator.js): `src/agent/orchestrator.js`

### Selector Health

- **Selector registry**
- [Registry manager](https://github.com/karthick-1501/playwright-agent/blob/main/src/registry/registry-manager.js): `src/registry/registry-manager.js`
- [Heal manager](https://github.com/karthick-1501/playwright-agent/blob/main/src/registry/heal.js): `src/registry/heal.js`
- **Scout summaries**

### Browser Tests

- [Test specs](https://github.com/karthick-1501/playwright-agent/tree/main/src/tests): `src/tests`
- [Page objects](https://github.com/karthick-1501/playwright-agent/tree/main/src/pages): `src/pages`
- [Action and assert engine](https://github.com/karthick-1501/playwright-agent/blob/main/src/pages/BasePage.js): `src/pages/BasePage.js`
- [Home locators](https://github.com/karthick-1501/playwright-agent/blob/main/src/elements/HyvaHome.elements.js): `src/elements/HyvaHome.elements.js`
- [Login locators](https://github.com/karthick-1501/playwright-agent/blob/main/src/elements/HyvaLogin.elements.js): `src/elements/HyvaLogin.elements.js`

### Test Configuration

- [Execution config](https://github.com/karthick-1501/playwright-agent/blob/main/config/execution.config.js): `config/execution.config.js`
- [Test data](https://github.com/karthick-1501/playwright-agent/blob/main/config/testdata.config.js): `config/testdata.config.js`

### Other components

- **Test author**
- **Claude API**
- **Playwright**
- **Hyva demo site**

## Connections

- Test author → Agent CLI: requests generation (evidence: `README.md`)
- Agent CLI → Orchestrator: runs generation (evidence: `src/agent/cli.js`)
- Orchestrator → DOM Scout: uses discovery (evidence: `README.md`)
- Orchestrator → Claude API: sends context (evidence: `README.md`)
- Claude API → Orchestrator: returns envelope (evidence: `README.md`)
- Orchestrator → Generated tests: writes files (evidence: `README.md`)
- Orchestrator → Element patching: patches locators (evidence: `src/agent/orchestrator.js`)
- Element patching → Home locators: updates selectors (evidence: `README.md`)
- Element patching → Login locators: updates selectors (evidence: `README.md`)
- Agent CLI → Registry manager: creates manager (evidence: `src/agent/cli.js`)
- Agent CLI → Heal manager: creates healer (evidence: `src/agent/cli.js`)
- Heal manager → Registry manager: resolves and updates (evidence: `src/registry/heal.js`)
- Heal manager → Scout summaries: reads summaries (evidence: `src/registry/heal.js`)
- Registry manager → Selector registry: loads and saves (evidence: `src/registry/registry-manager.js`)
- Test specs → Page objects: invokes workflows (evidence: `README.md`)
- Page objects → Action and assert engine: delegates actions (evidence: `src/pages/HyvaLogin.page.js`)
- Page objects → Home locators: uses locators (evidence: `src/pages/HyvaHome.page.js`)
- Page objects → Login locators: uses locators (evidence: `src/pages/HyvaLogin.page.js`)
- Action and assert engine → Registry manager: records outcomes (evidence: `src/pages/BasePage.js`)
- Action and assert engine → Playwright: performs browser actions (evidence: `src/pages/BasePage.js`)
- Test specs → Test data: reads test inputs (evidence: `README.md`)
- Page objects → Execution config: reads base URL (evidence: `src/pages/HyvaLogin.page.js`)
- Page objects → Hyva demo site: navigates browser (evidence: `README.md`)
- DOM Scout → Hyva demo site: discovers DOM (evidence: `README.md`)
