# migoxlab/webqa-agent architecture

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

- Interactive diagram: https://gitdiagram.com/migoxlab/webqa-agent
- Repository: https://github.com/migoxlab/webqa-agent

## Overview

1. **Overall shape**
   - The repo has two main planes:
     - **`webqa_agent/`**: the core autonomous testing engine and CLI.
     - **`backend/` + `frontend/`**: a web dashboard and management API for persistent test management, history, and scheduling.
   - Around them are **deployment manifests** and **tests** that validate the agent behavior end-to-end.

2. **Primary user entry points**
   - The agent is used in two modes: **Generate** and **Run**.
   - Entry points are:
     - **CLI** via `webqa_agent/cli.py`
     - **Backend API** via `backend/app/main.py`
     - **Web UI** via `frontend/src/App.tsx`
   - The CLI is the direct path for developers; the backend/frontend path is the operational dashboard path.

3. **Core agent pipeline**
   - The central flow in `webqa_agent` is:
     - load configuration
     - create browser session
     - crawl/extract page structure and signals
     - consult LLM prompts
     - produce actions or test cases
     - execute them through browser/tool adapters
     - aggregate results into reports
   - This is split into clear subsystems: **browser**, **crawler**, **executor**, **tools**, **LLM**, and **reporting/utils**.

4. **Generate mode architecture**
   - Generate mode is the autonomous discovery path.
   - It combines:
     - **crawler** components for DOM/page feature extraction
     - **LLM prompts** for planning and step generation
     - **dynamic step generation** and **status determination** under `webqa_agent/executor/gen/agents`
     - helpers like **case recorder**, **case synchronizer**, **error classifier**, and **summary utilities**
   - Output is a structured test case set plus execution artifacts/reporting.

5. **Run mode architecture**
   - Run mode is the deterministic execution path for prewritten cases.
   - It reads YAML-defined cases from config, then drives:
     - **action handlers/executor** for browser actions
     - **verification tools** for assertions
     - **network/console monitoring** for runtime validation
   - This mode is designed for repeatable regression tests rather than discovery.

6. **Browser automation boundary**
   - `webqa_agent/browser/` isolates all browser/session lifecycle concerns:
     - session creation
     - context management
     - event collection
     - browser configuration
   - `webqa_agent/crawler/js/` shows that some page inspection is injected into the browser runtime with JavaScript helpers.
   - This forms the boundary between the agent logic and the external browser/page environment.

7. **Tooling layer**
   - Tools are treated as pluggable capability modules.
   - Default capabilities cover:
     - **UI actions**
     - **UI assertions**
     - **UX checks**
   - Optional/custom tools extend the engine with:
     - **Lighthouse** for performance
     - **Nuclei** for security scanning
     - **link/button checks**
   - The registry and `tools/core` vs `tools/custom` split indicate a capability-based architecture rather than hardcoded test logic.

8. **LLM integration**
   - `webqa_agent/llm/llm_api.py`, `prompts/`, and `config_models/` form a provider-agnostic LLM integration layer.
   - The README indicates support for OpenAI-compatible APIs and multiple model providers.
   - The LLM is used for planning, filtering, step generation, and reasoning, but browser execution remains local and deterministic.

9. **Data and artifact flow**
   - Test execution produces structured runtime data under `webqa_agent/data/` and human-readable reports through utilities in `webqa_agent/utils/`.
   - The README indicates HTML reports are written to a `reports/` directory.
   - This makes the agent a producer of both machine-usable case structures and operator-facing execution reports.

10. **Backend service boundaries**
   - The backend is a separate API service with a conventional layered structure:
     - **API routes** in `backend/app/api/`
     - **domain models** in `backend/app/models/`
     - **schemas** in `backend/app/schemas/`
     - **services** in `backend/app/services/`
     - **providers** for auth, storage, and notifications
   - Key resources exposed by the API are businesses, environments, test cases, executions, files, and scheduled tasks.

11. **Backend state and infrastructure**
   - `backend/alembic/` and `backend/app/database.py` show a relational database with schema migrations.
   - The deployment manifests include **PostgreSQL** and **Redis**, so the backend likely uses:
     - Postgres for persisted business/test/execution records
     - Redis for ephemeral state, progress cache, or scheduling support
   - Scheduled task handling and job monitoring are first-class backend concerns.

12. **Frontend dashboard**
   - `frontend/` is a React/Vite application that consumes the backend API through `frontend/src/api/client.ts`.
   - The main screens map directly to backend resources:
     - business management
     - test case editor
     - execution history/detail
     - scheduled task manager
     - file/config management
     - debug/gen pages
   - The frontend is a presentation and control layer; it does not contain the agent logic.

13. **Deployment model**
   - The repo supports:
     - **local development**
     - **Docker Compose**
     - **Kubernetes**
   - K8s manifests define backend, frontend, Postgres, Redis, ingress, RBAC, secrets, configmaps, and storage.
   - This means the agent runtime can be used standalone via CLI or as part of a persistent multi-service platform.

14. **Testing and validation**
   - `tests/` covers crawler behavior, action execution, URL validation, error classification, status determination, and report generation.
   - That test split mirrors the architecture: browser automation, data extraction, execution semantics, and result classification are all independently validated.

15. **Architectural takeaway**
   - The repo is best understood as a **browser-native AI testing engine** with two operating surfaces:
     - a **local/CLI autonomous agent**
     - a **managed web platform** for teams
   - The stable boundaries are: **config → browser/crawler → LLM/planning → tool-backed execution → result/reporting**, with the backend/frontend stack layered on top for persistence, scheduling, and human workflow management.

Main entry points: [`webqa_agent/executor/gen`](https://github.com/migoxlab/webqa-agent/tree/main/webqa_agent/executor/gen) (Generate Flow), [`webqa_agent/executor/run`](https://github.com/migoxlab/webqa-agent/tree/main/webqa_agent/executor/run) (Run Flow), [`webqa_agent/cli.py`](https://github.com/migoxlab/webqa-agent/blob/main/webqa_agent/cli.py) (CLI), [`tests`](https://github.com/migoxlab/webqa-agent/tree/main/tests) (Tests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_agent["WebQA Agent"]
  node_cli(("CLI<br/>entrypoint<br/>[cli.py]"))
  node_agent_config["Config"]
  node_browser[("Browser<br/>session boundary")]
  node_crawler["Crawler<br/>page extraction"]
  node_llm["LLM Layer<br/>planning<br/>[llm_api.py]"]
  node_generate_exec["Generate Flow<br/>autonomous execution"]
  node_run_exec["Run Flow<br/>deterministic execution"]
  node_actions["Actions"]
  node_tools["Tools<br/>capabilities"]
  node_reporting["Reports<br/>artifact output<br/>[reporting_utils.py]"]
  node_data["Data Models<br/>runtime structures"]
end

subgraph group_platform["Managed Platform"]
  node_backend_api(("Backend API<br/>service entrypoint<br/>[main.py]"))
  node_backend_domain["Domain Layer<br/>api domain"]
  node_scheduler["Scheduler<br/>job orchestration"]
  node_frontend_app(("Frontend App<br/>ui entrypoint<br/>[App.tsx]"))
  node_frontend_views["Dashboard Views<br/>ui pages"]
  node_backend_db[("Database<br/>persistence<br/>[database.py]")]
end

subgraph group_infra["Deployment"]
  node_deployments["Deploy Manifests<br/>deployment assets"]
end

subgraph group_validation["Validation"]
  node_tests["Tests<br/>validation suite"]
end

node_cli -->|"loads"| node_agent_config
node_cli -->|"opens"| node_browser
node_cli -->|"generate mode"| node_generate_exec
node_cli -->|"run mode"| node_run_exec
node_generate_exec -->|"extracts"| node_crawler
node_generate_exec -->|"plans"| node_llm
node_generate_exec -->|"executes"| node_actions
node_generate_exec -->|"produces"| node_data
node_generate_exec -->|"summarizes"| node_reporting
node_run_exec -->|"drives"| node_actions
node_run_exec -->|"verifies"| node_tools
node_run_exec -->|"records"| node_data
node_run_exec -->|"summarizes"| node_reporting
node_actions -->|"controls"| node_browser
node_crawler -->|"inspects"| node_browser
node_crawler -.->|"feeds context"| node_llm
node_tools -->|"checks"| node_browser
node_backend_api -->|"serves"| node_backend_domain
node_backend_domain -->|"persists"| node_backend_db
node_scheduler -->|"tracks"| node_backend_db
node_backend_api -->|"orchestrates"| node_scheduler
node_frontend_app -->|"consumes"| node_backend_api
node_frontend_app -->|"renders"| node_frontend_views
node_backend_api -.->|"deploys with"| node_deployments
node_frontend_app -.->|"deploys with"| node_deployments
node_tests -->|"validates"| node_crawler
node_tests -->|"validates"| node_actions
node_tests -->|"validates"| node_generate_exec
node_tests -->|"validates"| node_reporting

click node_cli "https://github.com/migoxlab/webqa-agent/blob/main/webqa_agent/cli.py"
click node_agent_config "https://github.com/migoxlab/webqa-agent/tree/main/webqa_agent/config_models"
click node_browser "https://github.com/migoxlab/webqa-agent/tree/main/webqa_agent/browser"
click node_crawler "https://github.com/migoxlab/webqa-agent/tree/main/webqa_agent/crawler"
click node_llm "https://github.com/migoxlab/webqa-agent/blob/main/webqa_agent/llm/llm_api.py"
click node_generate_exec "https://github.com/migoxlab/webqa-agent/tree/main/webqa_agent/executor/gen"
click node_run_exec "https://github.com/migoxlab/webqa-agent/tree/main/webqa_agent/executor/run"
click node_actions "https://github.com/migoxlab/webqa-agent/tree/main/webqa_agent/actions"
click node_tools "https://github.com/migoxlab/webqa-agent/tree/main/webqa_agent/tools"
click node_reporting "https://github.com/migoxlab/webqa-agent/blob/main/webqa_agent/utils/reporting_utils.py"
click node_data "https://github.com/migoxlab/webqa-agent/tree/main/webqa_agent/data"
click node_backend_api "https://github.com/migoxlab/webqa-agent/blob/main/backend/app/main.py"
click node_backend_domain "https://github.com/migoxlab/webqa-agent/tree/main/backend/app"
click node_scheduler "https://github.com/migoxlab/webqa-agent/tree/main/backend/app/services"
click node_frontend_app "https://github.com/migoxlab/webqa-agent/blob/main/frontend/src/App.tsx"
click node_frontend_views "https://github.com/migoxlab/webqa-agent/tree/main/frontend/src/components"
click node_backend_db "https://github.com/migoxlab/webqa-agent/blob/main/backend/app/database.py"
click node_deployments "https://github.com/migoxlab/webqa-agent/tree/main/deploy"
click node_tests "https://github.com/migoxlab/webqa-agent/tree/main/tests"

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_agent_config,node_browser,node_crawler,node_llm,node_generate_exec,node_run_exec,node_actions,node_tools,node_reporting,node_data toneBlue
class node_backend_api,node_backend_domain,node_scheduler,node_frontend_app,node_frontend_views,node_backend_db toneAmber
class node_deployments toneMint
class node_tests toneRose
```

## Components

### WebQA Agent

Autonomous browser testing engine and CLI.

- [CLI](https://github.com/migoxlab/webqa-agent/blob/main/webqa_agent/cli.py): entrypoint · Developer entrypoint for generate and run modes. · `webqa_agent/cli.py`
- [Config](https://github.com/migoxlab/webqa-agent/tree/main/webqa_agent/config_models): config · Loads run and generate configuration models. · `webqa_agent/config_models`
- [Browser](https://github.com/migoxlab/webqa-agent/tree/main/webqa_agent/browser): session boundary · Browser lifecycle, context, config, and event capture. · `webqa_agent/browser`
- [Crawler](https://github.com/migoxlab/webqa-agent/tree/main/webqa_agent/crawler): page extraction · DOM crawling, feature detection, and JS page inspection. · `webqa_agent/crawler`
- [LLM Layer](https://github.com/migoxlab/webqa-agent/blob/main/webqa_agent/llm/llm_api.py): planning · Provider-agnostic prompt and API integration for planning and reasoning. · `webqa_agent/llm/llm_api.py`
- [Generate Flow](https://github.com/migoxlab/webqa-agent/tree/main/webqa_agent/executor/gen): autonomous execution · Discovery pipeline that creates and refines test cases. · `webqa_agent/executor/gen`
- [Run Flow](https://github.com/migoxlab/webqa-agent/tree/main/webqa_agent/executor/run): deterministic execution · Repeatable execution of predefined YAML test cases. · `webqa_agent/executor/run`
- [Actions](https://github.com/migoxlab/webqa-agent/tree/main/webqa_agent/actions): browser actions · Action handlers and executors for clicks and scripted UI operations. · `webqa_agent/actions`
- [Tools](https://github.com/migoxlab/webqa-agent/tree/main/webqa_agent/tools): capabilities · Pluggable UI checks, assertions, and external scan capabilities. · `webqa_agent/tools`
- [Reports](https://github.com/migoxlab/webqa-agent/blob/main/webqa_agent/utils/reporting_utils.py): artifact output · Aggregates execution results and produces human-readable reports. · `webqa_agent/utils/reporting_utils.py`
- [Data Models](https://github.com/migoxlab/webqa-agent/tree/main/webqa_agent/data): runtime structures · Structured runtime objects for generate and run workflows. · `webqa_agent/data`

### Managed Platform

Backend API and frontend dashboard for persistent test management.

- [Backend API](https://github.com/migoxlab/webqa-agent/blob/main/backend/app/main.py): service entrypoint · API service for persisted cases, executions, files, and scheduling. · `backend/app/main.py`
- [Domain Layer](https://github.com/migoxlab/webqa-agent/tree/main/backend/app): api domain · Routes, schemas, models, and services for business workflows. · `backend/app`
- [Scheduler](https://github.com/migoxlab/webqa-agent/tree/main/backend/app/services): job orchestration · Task scheduling, progress cache, and job monitoring. · `backend/app/services`
- [Frontend App](https://github.com/migoxlab/webqa-agent/blob/main/frontend/src/App.tsx): ui entrypoint · React dashboard entrypoint and API client surface. · `frontend/src/App.tsx`
- [Dashboard Views](https://github.com/migoxlab/webqa-agent/tree/main/frontend/src/components): ui pages · Business, case, execution, file, scheduled task, and debug screens. · `frontend/src/components`
- [Database](https://github.com/migoxlab/webqa-agent/blob/main/backend/app/database.py): persistence · Relational persistence with migrations for managed platform state. · `backend/app/database.py`

### Deployment

Container and Kubernetes deployment assets.

- [Deploy Manifests](https://github.com/migoxlab/webqa-agent/tree/main/deploy): deployment assets · Docker Compose and Kubernetes manifests for local and cluster deployment. · `deploy`

### Validation

Test suite and architectural checks.

- [Tests](https://github.com/migoxlab/webqa-agent/tree/main/tests): validation suite · Behavioral tests for crawler, execution, classification, and reporting. · `tests`

## Connections

- CLI → Config: loads · CLI selects generate or run configuration.
- CLI → Browser: opens · CLI starts browser sessions for automation.
- CLI → Generate Flow: generate mode · Autonomous discovery workflow.
- CLI → Run Flow: run mode · Deterministic test execution workflow.
- Generate Flow → Crawler: extracts · Generate flow inspects pages and DOM signals.
- Generate Flow → LLM Layer: plans · LLM creates and refines steps and cases.
- Generate Flow → Actions: executes · Generated steps are carried out in browser.
- Generate Flow → Data Models: produces · Writes structured generation artifacts.
- Generate Flow → Reports: summarizes · Builds execution summaries and reports.
- Run Flow → Actions: drives · Run flow applies deterministic browser actions.
- Run Flow → Tools: verifies · Assertions and checks validate outcomes.
- Run Flow → Data Models: records · Stores run structures and results.
- Run Flow → Reports: summarizes · Produces run reports and artifacts.
- Actions → Browser: controls · Actions operate through browser/session boundary.
- Crawler → Browser: inspects · Crawler reads page state through browser context.
- Crawler → LLM Layer: feeds context · Extracted structure informs planning prompts.
- Tools → Browser: checks · Tools may query UI and runtime state.
- Backend API → Domain Layer: serves · API routes are backed by domain models and services.
- Domain Layer → Database: persists · Managed entities are stored in the database.
- Scheduler → Database: tracks · Jobs and execution state are persisted.
- Backend API → Scheduler: orchestrates · API exposes scheduled task and monitoring flows.
- Frontend App → Backend API: consumes · Dashboard uses the backend API client.
- Frontend App → Dashboard Views: renders · Main app composes dashboard screens.
- Backend API → Deploy Manifests: deploys with · Service is packaged with local and cluster manifests.
- Frontend App → Deploy Manifests: deploys with · UI is packaged for container and cluster deployment.
- Tests → Crawler: validates · Crawling and DOM extraction behavior is tested.
- Tests → Actions: validates · Action execution semantics are tested.
- Tests → Generate Flow: validates · Generate-specific classifiers and synchronizers are tested.
- Tests → Reports: validates · Report generation utilities are tested.
