# mukeshbhol325/playwright-rag-ai-self-healing architecture

> Architecture diagram of the GitHub repository mukeshbhol325/playwright-rag-ai-self-healing, 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/mukeshbhol325/playwright-rag-ai-self-healing
- Repository: https://github.com/mukeshbhol325/playwright-rag-ai-self-healing

## Overview

This repository combines a Playwright framework for OpenCart flows with a FastAPI locator-healing service. Page objects use keyed selectors; when an interaction fails, HealingPage requests candidates, validates them in the live page, retries, and sends feedback. After test runs, the reporter submits failures for triage. The service combines learned repairs, DOM heuristics, retrieval, and optional LLM reranking. The README documents the cross-service workflow; source excerpts and the SOURCE INDEX support the internal links shown. Other unsampled implementation details are omitted where their relationships are not established.

Main entry points: [`healer-service/app/core/container.py`](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/core/container.py) (Service container), [`tests-ts/src/healing/HealingPage.ts`](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/tests-ts/src/healing/HealingPage.ts) (HealingPage), [`healer-service/app/main.py`](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/main.py) (FastAPI app), [`healer-service/app/services/rag_healer.py`](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/services/rag_healer.py) (RAG healer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_playwright["Playwright Framework"]
  node_page_objects["OpenCart page objects<br/>[BasePage.ts]"]
  node_healing_page["HealingPage<br/>[HealingPage.ts]"]
  node_registry["Locator registry<br/>[LocatorRegistry.ts]"]
  node_validator["Candidate validator"]
  node_dom_snapshot["DOM snapshot<br/>[domSnapshot.ts]"]
  node_healer_client["Healer REST client<br/>[HealerClient.ts]"]
  node_reporter["Healing reporter<br/>[healingReporter.ts]"]
end

subgraph group_service_api["Healer API"]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_heal_api["Heal endpoint<br/>[heal.py]"]
  node_feedback_api["Feedback endpoint<br/>[feedback.py]"]
  node_failures_api["Failure endpoint<br/>[failures.py]"]
  node_health_api["Health endpoint<br/>[health.py]"]
  node_container["Service container<br/>[container.py]"]
end

subgraph group_healing["Healing Engine"]
  node_rag_healer["RAG healer<br/>[rag_healer.py]"]
  node_heuristic["DOM heuristics"]
end

subgraph group_knowledge["Knowledge and Analysis"]
  node_knowledge_base[("Chroma knowledge base<br/>[vector_store.py]")]
  node_failure_analyzer["Failure analyzer"]
  node_prompts["RAG prompts<br/>[prompts.py]"]
end

subgraph group_providers["Model Providers"]
  node_llm_factory["LLM provider factory<br/>[factory.py]"]
end

node_test_actor(("Playwright test run"))
node_site["OpenCart demo"]
node_llm_provider["LLM provider<br/>[base.py]"]

node_test_actor -->|"runs flows"| node_page_objects
node_page_objects -->|"uses interactions"| node_healing_page
node_page_objects -.->|"drives browser"| node_site
node_healing_page -->|"resolves selectors"| node_registry
node_healing_page -->|"captures DOM"| node_dom_snapshot
node_healing_page -->|"validates candidates"| node_validator
node_healing_page -->|"requests healing"| node_healer_client
node_healer_client -->|"REST requests"| node_api_app
node_healing_page -.->|"retries actions"| node_site
node_reporter -->|"reports failures"| node_healer_client
node_api_app -->|"registers route"| node_heal_api
node_api_app -->|"registers route"| node_feedback_api
node_api_app -->|"registers route"| node_failures_api
node_api_app -->|"registers route"| node_health_api
node_heal_api -->|"gets services"| node_container
node_feedback_api -->|"gets services"| node_container
node_failures_api -->|"gets services"| node_container
node_health_api -->|"gets services"| node_container
node_container -->|"builds healer"| node_rag_healer
node_container -->|"builds analyzer"| node_failure_analyzer
node_container -->|"builds knowledge base"| node_knowledge_base
node_container -->|"selects provider"| node_llm_factory
node_rag_healer -->|"looks up repairs"| node_knowledge_base
node_rag_healer -->|"scores DOM"| node_heuristic
node_rag_healer -->|"builds rerank prompt"| node_prompts
node_rag_healer -.->|"reranks candidates"| node_llm_provider
node_failure_analyzer -->|"retrieves cases"| node_knowledge_base
node_failure_analyzer -->|"uses analysis prompt"| node_prompts
node_failure_analyzer -.->|"requests analysis"| node_llm_provider
node_llm_factory -->|"creates provider"| node_llm_provider

click node_page_objects "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/tests-ts/src/pages/BasePage.ts"
click node_healing_page "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/tests-ts/src/healing/HealingPage.ts"
click node_registry "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/tests-ts/src/healing/LocatorRegistry.ts"
click node_validator "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/tests-ts/src/healing/LocatorValidator.ts"
click node_dom_snapshot "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/tests-ts/src/utils/domSnapshot.ts"
click node_healer_client "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/tests-ts/src/api/HealerClient.ts"
click node_reporter "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/tests-ts/src/reporters/healingReporter.ts"
click node_api_app "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/main.py"
click node_heal_api "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/api/heal.py"
click node_feedback_api "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/api/feedback.py"
click node_failures_api "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/api/failures.py"
click node_health_api "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/api/health.py"
click node_container "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/core/container.py"
click node_rag_healer "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/services/rag_healer.py"
click node_heuristic "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/services/heuristic_healer.py"
click node_knowledge_base "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/rag/vector_store.py"
click node_failure_analyzer "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/services/failure_analyzer.py"
click node_prompts "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/rag/prompts.py"
click node_llm_factory "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/llm/factory.py"
click node_llm_provider "https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/llm/base.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_page_objects,node_healing_page,node_registry,node_validator,node_dom_snapshot,node_healer_client,node_reporter toneBlue
class node_api_app,node_heal_api,node_feedback_api,node_failures_api,node_health_api,node_container toneAmber
class node_rag_healer,node_heuristic toneMint
class node_knowledge_base,node_failure_analyzer,node_prompts toneRose
class node_llm_factory,node_test_actor,node_site,node_llm_provider toneIndigo
```

## Components

### Playwright Framework

- [OpenCart page objects](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/tests-ts/src/pages/BasePage.ts): `tests-ts/src/pages/BasePage.ts`
- [HealingPage](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/tests-ts/src/healing/HealingPage.ts): `tests-ts/src/healing/HealingPage.ts`
- [Locator registry](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/tests-ts/src/healing/LocatorRegistry.ts): `tests-ts/src/healing/LocatorRegistry.ts`
- [Candidate validator](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/tests-ts/src/healing/LocatorValidator.ts): `tests-ts/src/healing/LocatorValidator.ts`
- [DOM snapshot](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/tests-ts/src/utils/domSnapshot.ts): `tests-ts/src/utils/domSnapshot.ts`
- [Healer REST client](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/tests-ts/src/api/HealerClient.ts): `tests-ts/src/api/HealerClient.ts`
- [Healing reporter](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/tests-ts/src/reporters/healingReporter.ts): `tests-ts/src/reporters/healingReporter.ts`

### Healer API

- [FastAPI app](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/main.py): `healer-service/app/main.py`
- [Heal endpoint](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/api/heal.py): `healer-service/app/api/heal.py`
- [Feedback endpoint](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/api/feedback.py): `healer-service/app/api/feedback.py`
- [Failure endpoint](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/api/failures.py): `healer-service/app/api/failures.py`
- [Health endpoint](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/api/health.py): `healer-service/app/api/health.py`
- [Service container](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/core/container.py): `healer-service/app/core/container.py`

### Healing Engine

- [RAG healer](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/services/rag_healer.py): `healer-service/app/services/rag_healer.py`
- [DOM heuristics](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/services/heuristic_healer.py): `healer-service/app/services/heuristic_healer.py`

### Knowledge and Analysis

- [Chroma knowledge base](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/rag/vector_store.py): `healer-service/app/rag/vector_store.py`
- [Failure analyzer](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/services/failure_analyzer.py): `healer-service/app/services/failure_analyzer.py`
- [RAG prompts](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/rag/prompts.py): `healer-service/app/rag/prompts.py`

### Model Providers

- [LLM provider factory](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/llm/factory.py): `healer-service/app/llm/factory.py`

### Other components

- **Playwright test run**
- **OpenCart demo**
- [LLM provider](https://github.com/mukeshbhol325/playwright-rag-ai-self-healing/blob/main/healer-service/app/llm/base.py): `healer-service/app/llm/base.py`

## Connections

- Playwright test run → OpenCart page objects: runs flows
- OpenCart page objects → HealingPage: uses interactions (evidence: `tests-ts/src/pages/BasePage.ts`)
- OpenCart page objects → OpenCart demo: drives browser
- HealingPage → Locator registry: resolves selectors (evidence: `tests-ts/src/healing/HealingPage.ts`)
- HealingPage → DOM snapshot: captures DOM (evidence: `tests-ts/src/healing/HealingPage.ts`)
- HealingPage → Candidate validator: validates candidates (evidence: `tests-ts/src/healing/HealingPage.ts`)
- HealingPage → Healer REST client: requests healing (evidence: `tests-ts/src/healing/HealingPage.ts`)
- Healer REST client → FastAPI app: REST requests
- HealingPage → OpenCart demo: retries actions
- Healing reporter → Healer REST client: reports failures (evidence: `tests-ts/src/reporters/healingReporter.ts`)
- FastAPI app → Heal endpoint: registers route (evidence: `healer-service/app/main.py`)
- FastAPI app → Feedback endpoint: registers route (evidence: `healer-service/app/main.py`)
- FastAPI app → Failure endpoint: registers route (evidence: `healer-service/app/main.py`)
- FastAPI app → Health endpoint: registers route (evidence: `healer-service/app/main.py`)
- Heal endpoint → Service container: gets services (evidence: `healer-service/app/api/heal.py`)
- Feedback endpoint → Service container: gets services (evidence: `healer-service/app/api/feedback.py`)
- Failure endpoint → Service container: gets services (evidence: `healer-service/app/api/failures.py`)
- Health endpoint → Service container: gets services (evidence: `healer-service/app/api/health.py`)
- Service container → RAG healer: builds healer (evidence: `healer-service/app/core/container.py`)
- Service container → Failure analyzer: builds analyzer (evidence: `healer-service/app/core/container.py`)
- Service container → Chroma knowledge base: builds knowledge base (evidence: `healer-service/app/core/container.py`)
- Service container → LLM provider factory: selects provider (evidence: `healer-service/app/core/container.py`)
- RAG healer → Chroma knowledge base: looks up repairs (evidence: `healer-service/app/services/rag_healer.py`)
- RAG healer → DOM heuristics: scores DOM (evidence: `healer-service/app/services/rag_healer.py`)
- RAG healer → RAG prompts: builds rerank prompt (evidence: `healer-service/app/services/rag_healer.py`)
- RAG healer → LLM provider: reranks candidates (evidence: `healer-service/app/services/rag_healer.py`)
- Failure analyzer → Chroma knowledge base: retrieves cases (evidence: `healer-service/app/services/failure_analyzer.py`)
- Failure analyzer → RAG prompts: uses analysis prompt (evidence: `healer-service/app/services/failure_analyzer.py`)
- Failure analyzer → LLM provider: requests analysis (evidence: `healer-service/app/services/failure_analyzer.py`)
- LLM provider factory → LLM provider: creates provider (evidence: `healer-service/app/llm/factory.py`)
