# suryadev41/selfheal architecture

> Architecture diagram of the GitHub repository suryadev41/selfheal, 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/suryadev41/selfheal
- Repository: https://github.com/suryadev41/selfheal

## Overview

Selfheal turns spreadsheet cases into Playwright browser checks, repairing selectors through configured/semantic locators, verified SQLite entries and (when enabled) OpenAI suggestions. Runs produce per-case results, screenshots and workbook history; an operations dashboard launches runs and presents results, cache activity and traces. Groups distinguish input/control, browser execution, healing, and observability. Relationships follow README statements and indexed imports; unsampled modules are represented only where their paths and subsystem are documented.

Main entry points: [`src/selfheal/runner.py`](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/runner.py) (Suite runner), [`src/selfheal/healing/locator.py`](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/healing/locator.py) (Locator resolver), [`src/selfheal/telemetry/langsmith.py`](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/telemetry/langsmith.py) (LangSmith tracker), [`src/selfheal/cli.py`](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/cli.py) (CLI commands)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Suite and configuration"]
  node_sheets["Test workbooks"]
  node_cli["CLI commands<br/>[cli.py]"]
  node_config["App configuration<br/>[config.py]"]
  node_loader["Suite parser<br/>[suite_loader.py]"]
end

subgraph group_execution["Browser execution"]
  node_runner["Suite runner<br/>[runner.py]"]
  node_browserexec["Browser step executor<br/>[browser.py]"]
  node_genericexec["Generic step executor<br/>[generic.py]"]
end

subgraph group_healing["Locator recovery"]
  node_healer["Locator resolver<br/>[locator.py]"]
  node_cache[("Verified locator cache<br/>[cache.py]")]
  node_ai["OpenAI locator client<br/>[openai_client.py]"]
  node_pricing["Token cost estimator<br/>[openai_pricing.py]"]
end

subgraph group_observability["Run observability"]
  node_events["Healing event log<br/>[healing_log.py]"]
  node_tracing["LangSmith tracker<br/>[langsmith.py]"]
  node_localstore["Local telemetry store<br/>[local_store.py]"]
  node_history["Run history workbook<br/>[run_history.py]"]
end

subgraph group_dashboard["Operations dashboard"]
  node_dashboard["Dashboard UI<br/>[app.py]"]
  node_dashdata["Dashboard data access<br/>[data.py]"]
  node_dashhistory["Dashboard history views<br/>[history.py]"]
end

node_operator(("Operator"))
node_site["Tested website"]
node_langsmith_service["LangSmith service"]
node_openai_service["OpenAI service"]

node_operator -->|"runs commands"| node_cli
node_operator -->|"operates"| node_dashboard
node_sheets -->|"provides cases"| node_loader
node_cli -->|"loads settings"| node_config
node_cli -->|"parses suites"| node_loader
node_cli -->|"starts run"| node_runner
node_runner -->|"loads settings"| node_config
node_runner -->|"executes cases"| node_browserexec
node_browserexec -->|"drives browser"| node_site
node_browserexec -->|"uses step helpers"| node_genericexec
node_browserexec -->|"resolves targets"| node_healer
node_healer -->|"reads and writes"| node_cache
node_healer -->|"requests suggestions"| node_ai
node_ai -->|"requests completion"| node_openai_service
node_ai -->|"estimates cost"| node_pricing
node_healer -->|"records events"| node_events
node_healer -->|"configures tracking"| node_tracing
node_ai -->|"wraps client"| node_tracing
node_tracing -.->|"uploads traces"| node_langsmith_service
node_runner -->|"tracks cases"| node_tracing
node_runner -->|"records run summary"| node_history
node_runner -.->|"persists telemetry"| node_localstore
node_dashboard -->|"loads dashboard data"| node_dashdata
node_dashboard -->|"uses history views"| node_dashhistory
node_dashboard -->|"reads suite details"| node_loader
node_dashdata -->|"discovers profiles"| node_config
node_dashdata -->|"loads trace records"| node_tracing
node_dashdata -.->|"reads cache entries"| node_cache
node_dashhistory -.->|"formats run history"| node_history

click node_sheets "https://github.com/suryadev41/selfheal/tree/main/suites"
click node_cli "https://github.com/suryadev41/selfheal/blob/main/src/selfheal/cli.py"
click node_config "https://github.com/suryadev41/selfheal/blob/main/src/selfheal/config.py"
click node_loader "https://github.com/suryadev41/selfheal/blob/main/src/selfheal/suite_loader.py"
click node_runner "https://github.com/suryadev41/selfheal/blob/main/src/selfheal/runner.py"
click node_browserexec "https://github.com/suryadev41/selfheal/blob/main/src/selfheal/executor/browser.py"
click node_genericexec "https://github.com/suryadev41/selfheal/blob/main/src/selfheal/executor/generic.py"
click node_healer "https://github.com/suryadev41/selfheal/blob/main/src/selfheal/healing/locator.py"
click node_cache "https://github.com/suryadev41/selfheal/blob/main/src/selfheal/healing/cache.py"
click node_ai "https://github.com/suryadev41/selfheal/blob/main/src/selfheal/llm/openai_client.py"
click node_pricing "https://github.com/suryadev41/selfheal/blob/main/src/selfheal/llm/openai_pricing.py"
click node_events "https://github.com/suryadev41/selfheal/blob/main/src/selfheal/telemetry/healing_log.py"
click node_tracing "https://github.com/suryadev41/selfheal/blob/main/src/selfheal/telemetry/langsmith.py"
click node_localstore "https://github.com/suryadev41/selfheal/blob/main/src/selfheal/telemetry/local_store.py"
click node_history "https://github.com/suryadev41/selfheal/blob/main/src/selfheal/telemetry/run_history.py"
click node_dashboard "https://github.com/suryadev41/selfheal/blob/main/src/selfheal/dashboard/app.py"
click node_dashdata "https://github.com/suryadev41/selfheal/blob/main/src/selfheal/dashboard/data.py"
click node_dashhistory "https://github.com/suryadev41/selfheal/blob/main/src/selfheal/dashboard/history.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_sheets,node_cli,node_config,node_loader toneBlue
class node_runner,node_browserexec,node_genericexec toneAmber
class node_healer,node_cache,node_ai,node_pricing toneMint
class node_events,node_tracing,node_localstore,node_history toneRose
class node_dashboard,node_dashdata,node_dashhistory,node_operator,node_site,node_langsmith_service,node_openai_service toneIndigo
```

## Components

### Suite and configuration

- [Test workbooks](https://github.com/suryadev41/selfheal/tree/main/suites): `suites`
- [CLI commands](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/cli.py): `src/selfheal/cli.py`
- [App configuration](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/config.py): `src/selfheal/config.py`
- [Suite parser](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/suite_loader.py): `src/selfheal/suite_loader.py`

### Browser execution

- [Suite runner](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/runner.py): `src/selfheal/runner.py`
- [Browser step executor](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/executor/browser.py): `src/selfheal/executor/browser.py`
- [Generic step executor](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/executor/generic.py): `src/selfheal/executor/generic.py`

### Locator recovery

- [Locator resolver](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/healing/locator.py): `src/selfheal/healing/locator.py`
- [Verified locator cache](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/healing/cache.py): `src/selfheal/healing/cache.py`
- [OpenAI locator client](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/llm/openai_client.py): `src/selfheal/llm/openai_client.py`
- [Token cost estimator](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/llm/openai_pricing.py): `src/selfheal/llm/openai_pricing.py`

### Run observability

- [Healing event log](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/telemetry/healing_log.py): `src/selfheal/telemetry/healing_log.py`
- [LangSmith tracker](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/telemetry/langsmith.py): `src/selfheal/telemetry/langsmith.py`
- [Local telemetry store](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/telemetry/local_store.py): `src/selfheal/telemetry/local_store.py`
- [Run history workbook](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/telemetry/run_history.py): `src/selfheal/telemetry/run_history.py`

### Operations dashboard

- [Dashboard UI](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/dashboard/app.py): `src/selfheal/dashboard/app.py`
- [Dashboard data access](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/dashboard/data.py): `src/selfheal/dashboard/data.py`
- [Dashboard history views](https://github.com/suryadev41/selfheal/blob/main/src/selfheal/dashboard/history.py): `src/selfheal/dashboard/history.py`

### Other components

- **Operator**
- **Tested website**
- **LangSmith service**
- **OpenAI service**

## Connections

- Operator → CLI commands: runs commands (evidence: `README.md`)
- Operator → Dashboard UI: operates (evidence: `README.md`)
- Test workbooks → Suite parser: provides cases (evidence: `README.md`)
- CLI commands → App configuration: loads settings (evidence: `src/selfheal/cli.py`)
- CLI commands → Suite parser: parses suites (evidence: `src/selfheal/cli.py`)
- CLI commands → Suite runner: starts run (evidence: `src/selfheal/cli.py`)
- Suite runner → App configuration: loads settings (evidence: `src/selfheal/runner.py`)
- Suite runner → Browser step executor: executes cases (evidence: `src/selfheal/runner.py`)
- Browser step executor → Tested website: drives browser (evidence: `README.md`)
- Browser step executor → Generic step executor: uses step helpers (evidence: `src/selfheal/executor/browser.py`)
- Browser step executor → Locator resolver: resolves targets (evidence: `src/selfheal/executor/browser.py`)
- Locator resolver → Verified locator cache: reads and writes (evidence: `src/selfheal/healing/locator.py`)
- Locator resolver → OpenAI locator client: requests suggestions (evidence: `src/selfheal/healing/locator.py`)
- OpenAI locator client → OpenAI service: requests completion (evidence: `src/selfheal/llm/openai_client.py`)
- OpenAI locator client → Token cost estimator: estimates cost (evidence: `src/selfheal/llm/openai_client.py`)
- Locator resolver → Healing event log: records events (evidence: `src/selfheal/healing/locator.py`)
- Locator resolver → LangSmith tracker: configures tracking (evidence: `src/selfheal/healing/locator.py`)
- OpenAI locator client → LangSmith tracker: wraps client (evidence: `src/selfheal/llm/openai_client.py`)
- LangSmith tracker → LangSmith service: uploads traces (evidence: `src/selfheal/telemetry/langsmith.py`)
- Suite runner → LangSmith tracker: tracks cases (evidence: `src/selfheal/runner.py`)
- Suite runner → Run history workbook: records run summary (evidence: `src/selfheal/runner.py`)
- Suite runner → Local telemetry store: persists telemetry
- Dashboard UI → Dashboard data access: loads dashboard data (evidence: `src/selfheal/dashboard/app.py`)
- Dashboard UI → Dashboard history views: uses history views (evidence: `src/selfheal/dashboard/app.py`)
- Dashboard UI → Suite parser: reads suite details (evidence: `src/selfheal/dashboard/app.py`)
- Dashboard data access → App configuration: discovers profiles (evidence: `src/selfheal/dashboard/data.py`)
- Dashboard data access → LangSmith tracker: loads trace records (evidence: `src/selfheal/dashboard/data.py`)
- Dashboard data access → Verified locator cache: reads cache entries
- Dashboard history views → Run history workbook: formats run history
