# wendellhua/sighttest architecture

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

- Interactive diagram: https://gitdiagram.com/wendellhua/sighttest
- Repository: https://github.com/wendellhua/sighttest

## Overview

#### Purpose and deployment shape
SightTest is a local web-based automated testing platform: a user submits a target URL, and the system explores it with a real Chromium browser, designs tests from observed behavior, runs multidimensional checks, and produces reports. It is served by a Python FastAPI process; static frontend assets are included in the same repository. Primary launch point: `backend/main.py`; browser entry/UI shell: `index.html`.

#### Frontend application and fallback
The frontend is an unbundled ES-module SPA. `js/main.js` owns routing, event binding, and render dispatch; views render task, experience, case, and report workflows under `js/views/`. `js/api.js` calls FastAPI and probes backend availability, while `js/store.js` holds task state, persistence, and SSE subscriptions. If the backend is unavailable, `js/engine.js` supplies local simulated data rather than blocking UI use.

#### API and task lifecycle boundary
`backend/main.py` is the HTTP/SSE boundary: it exposes task, experience, report, and LLM configuration APIs; serves/redirects to frontend assets; and initiates asynchronous work. Tasks move through pending, exploration, case design, testing, reporting, and completion states. SSE task streams carry status and logs to the frontend, separating long-running automation from request/response UI interactions.

#### Orchestration pipeline
`backend/orchestrator.py` is the principal workflow coordinator. It starts browser-backed execution, transitions task state, collects stage outputs, handles cancellation/failure recovery, and invokes reporting. The main pipeline is:
1. Explore the target and produce product understanding.
2. Generate tailored cases from that understanding when LLM support exists.
3. Execute enabled test suites and collect evidence/results.
4. Aggregate findings into a report.
Core pipeline modules are `backend/explorer.py`, `backend/casegen.py`, `backend/case_runner.py`, and `backend/reporter.py`.

#### Browser exploration and network evidence
`backend/browser.py` encapsulates Playwright/Chromium lifecycle and is the boundary for real page interaction. `backend/explorer.py` uses that runtime to navigate and inspect the target product, producing the experience artifact used as the basis for case design. `backend/whistle.py` optionally manages the Node.js whistle proxy to capture request parameters and response payloads; without it, API evidence degrades to browser-level network observation.

#### Test execution domains
Execution is partitioned into independently archived suites: functional/page behavior (`backend/suite_func.py`), API/contract validation (`backend/suite_api.py`, `backend/suite_api_core.py`, `backend/suite_api_ext.py`), security probing (`backend/suite_security.py`), performance checks (`backend/suite_perf.py`), and optional AI-driven testing (`backend/suite_ai.py`). `backend/case_runner.py` provides the common case-execution layer, while `backend/models.py` defines shared models and cross-stage data contracts.

#### AI integration, reporting, and persistence
`backend/llm.py` manages configuration and calls any OpenAI-compatible provider; absent credentials disable AI case generation/report features without disabling browser-based suites. `backend/reporter.py` consolidates suite outcomes, defects, evidence, and risk assessment into conclusion-first reports. Runtime task/report data and local LLM settings reside under `backend/data/`, intentionally outside source control. Required runtimes are Python 3.10+, FastAPI/Uvicorn, Playwright Chromium, and optionally Node.js plus whistle.

Main entry points: [`backend/case_runner.py`](https://github.com/wendellhua/sighttest/blob/main/backend/case_runner.py) (Case execution layer), [`backend/orchestrator.py`](https://github.com/wendellhua/sighttest/blob/main/backend/orchestrator.py) (Task orchestrator), [`backend/main.py`](https://github.com/wendellhua/sighttest/blob/main/backend/main.py) (FastAPI / SSE boundary), [`backend/explorer.py`](https://github.com/wendellhua/sighttest/blob/main/backend/explorer.py) (Product explorer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend SPA"]
  node_ui_shell["UI shell<br/>static HTML<br/>[index.html]"]
  node_ui_app["SPA router &amp; views<br/>ES modules<br/>[main.js]"]
  node_frontend_api["API client<br/>HTTP client<br/>[api.js]"]
  node_task_store["Task store &amp; SSE<br/>client state<br/>[store.js]"]
  node_local_engine["Offline simulator<br/>fallback engine<br/>[engine.js]"]
end

subgraph group_api["API &amp; Workflow"]
  node_fastapi{{"FastAPI / SSE boundary<br/>Python service<br/>[main.py]"}}
  node_orchestrator["Task orchestrator<br/>workflow coordinator<br/>[orchestrator.py]"]
  node_models["Shared contracts<br/>data models<br/>[models.py]"]
  node_reporter["Report aggregator<br/>pipeline stage<br/>[reporter.py]"]
  node_runtime_data[("Task, report &amp; LLM data<br/>local persistence")]
end

subgraph group_automation["Browser &amp; Test Execution"]
  node_explorer["Product explorer<br/>pipeline stage<br/>[explorer.py]"]
  node_casegen["Case generator<br/>pipeline stage<br/>[casegen.py]"]
  node_case_runner["Case execution layer<br/>pipeline stage<br/>[case_runner.py]"]
  node_functional_suite["Functional suite<br/>test suite<br/>[suite_func.py]"]
  node_api_suite["API contract suite<br/>test suite<br/>[suite_api.py]"]
  node_security_suite["Security suite<br/>test suite<br/>[suite_security.py]"]
  node_performance_suite["Performance suite<br/>test suite<br/>[suite_perf.py]"]
  node_ai_suite["AI-driven suite<br/>optional test suite<br/>[suite_ai.py]"]
end

subgraph group_external["External Runtimes"]
  node_browser(("Playwright Chromium<br/>browser runtime<br/>[browser.py]"))
  node_whistle["Whistle proxy<br/>optional Node proxy<br/>[whistle.py]"]
  node_llm(("OpenAI-compatible LLM<br/>optional provider<br/>[llm.py]"))
end

node_ui_shell -->|"loads"| node_ui_app
node_ui_app -->|"uses"| node_frontend_api
node_ui_app -->|"renders state"| node_task_store
node_frontend_api -->|"HTTP APIs"| node_fastapi
node_task_store -->|"SSE task stream"| node_fastapi
node_frontend_api -.->|"fallback when unavailable"| node_local_engine
node_fastapi -->|"starts async task"| node_orchestrator
node_fastapi -->|"reads/writes"| node_runtime_data
node_orchestrator -->|"explore"| node_explorer
node_explorer -->|"navigates and inspects"| node_browser
node_browser -.->|"optional network capture"| node_whistle
node_orchestrator -->|"design cases"| node_casegen
node_explorer -->|"experience artifact"| node_casegen
node_casegen -.->|"optional generation"| node_llm
node_orchestrator -->|"execute cases"| node_case_runner
node_case_runner -->|"runs"| node_functional_suite
node_case_runner -->|"runs"| node_api_suite
node_case_runner -->|"runs"| node_security_suite
node_case_runner -->|"runs"| node_performance_suite
node_case_runner -.->|"optionally runs"| node_ai_suite
node_orchestrator -->|"aggregate outcomes"| node_reporter
node_reporter -.->|"optional AI reporting"| node_llm
node_reporter -->|"stores reports"| node_runtime_data
node_models -.->|"contracts"| node_explorer
node_models -.->|"contracts"| node_case_runner

click node_ui_shell "https://github.com/wendellhua/sighttest/blob/main/index.html"
click node_ui_app "https://github.com/wendellhua/sighttest/blob/main/js/main.js"
click node_frontend_api "https://github.com/wendellhua/sighttest/blob/main/js/api.js"
click node_task_store "https://github.com/wendellhua/sighttest/blob/main/js/store.js"
click node_local_engine "https://github.com/wendellhua/sighttest/blob/main/js/engine.js"
click node_fastapi "https://github.com/wendellhua/sighttest/blob/main/backend/main.py"
click node_orchestrator "https://github.com/wendellhua/sighttest/blob/main/backend/orchestrator.py"
click node_models "https://github.com/wendellhua/sighttest/blob/main/backend/models.py"
click node_explorer "https://github.com/wendellhua/sighttest/blob/main/backend/explorer.py"
click node_casegen "https://github.com/wendellhua/sighttest/blob/main/backend/casegen.py"
click node_case_runner "https://github.com/wendellhua/sighttest/blob/main/backend/case_runner.py"
click node_functional_suite "https://github.com/wendellhua/sighttest/blob/main/backend/suite_func.py"
click node_api_suite "https://github.com/wendellhua/sighttest/blob/main/backend/suite_api.py"
click node_security_suite "https://github.com/wendellhua/sighttest/blob/main/backend/suite_security.py"
click node_performance_suite "https://github.com/wendellhua/sighttest/blob/main/backend/suite_perf.py"
click node_ai_suite "https://github.com/wendellhua/sighttest/blob/main/backend/suite_ai.py"
click node_reporter "https://github.com/wendellhua/sighttest/blob/main/backend/reporter.py"
click node_browser "https://github.com/wendellhua/sighttest/blob/main/backend/browser.py"
click node_whistle "https://github.com/wendellhua/sighttest/blob/main/backend/whistle.py"
click node_llm "https://github.com/wendellhua/sighttest/blob/main/backend/llm.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_shell,node_ui_app,node_frontend_api,node_task_store,node_local_engine toneBlue
class node_fastapi,node_orchestrator,node_models,node_reporter,node_runtime_data toneAmber
class node_explorer,node_casegen,node_case_runner,node_functional_suite,node_api_suite,node_security_suite,node_performance_suite,node_ai_suite toneMint
class node_browser,node_whistle,node_llm toneRose
```

## Components

### Frontend SPA

- [UI shell](https://github.com/wendellhua/sighttest/blob/main/index.html): static HTML · `index.html`
- [SPA router & views](https://github.com/wendellhua/sighttest/blob/main/js/main.js): ES modules · `js/main.js`
- [API client](https://github.com/wendellhua/sighttest/blob/main/js/api.js): HTTP client · `js/api.js`
- [Task store & SSE](https://github.com/wendellhua/sighttest/blob/main/js/store.js): client state · Persists task state and receives task streams. · `js/store.js`
- [Offline simulator](https://github.com/wendellhua/sighttest/blob/main/js/engine.js): fallback engine · Supplies simulated data when the backend is unavailable. · `js/engine.js`

### API & Workflow

- [FastAPI / SSE boundary](https://github.com/wendellhua/sighttest/blob/main/backend/main.py): Python service · Serves assets and exposes task, experience, report, and LLM APIs. · `backend/main.py`
- [Task orchestrator](https://github.com/wendellhua/sighttest/blob/main/backend/orchestrator.py): workflow coordinator · Advances asynchronous tasks through exploration, design, testing, and reporting. · `backend/orchestrator.py`
- [Shared contracts](https://github.com/wendellhua/sighttest/blob/main/backend/models.py): data models · `backend/models.py`
- [Report aggregator](https://github.com/wendellhua/sighttest/blob/main/backend/reporter.py): pipeline stage · Produces conclusion-first reports from findings, evidence, and risks. · `backend/reporter.py`
- **Task, report & LLM data**: local persistence · Runtime data intentionally remains outside source control.

### Browser & Test Execution

- [Product explorer](https://github.com/wendellhua/sighttest/blob/main/backend/explorer.py): pipeline stage · Creates the experience artifact from a target product. · `backend/explorer.py`
- [Case generator](https://github.com/wendellhua/sighttest/blob/main/backend/casegen.py): pipeline stage · Builds tailored cases from product understanding when AI is enabled. · `backend/casegen.py`
- [Case execution layer](https://github.com/wendellhua/sighttest/blob/main/backend/case_runner.py): pipeline stage · Runs enabled suites and collects evidence and results. · `backend/case_runner.py`
- [Functional suite](https://github.com/wendellhua/sighttest/blob/main/backend/suite_func.py): test suite · `backend/suite_func.py`
- [API contract suite](https://github.com/wendellhua/sighttest/blob/main/backend/suite_api.py): test suite · Contract validation spans core and extended API checks. · `backend/suite_api.py`
- [Security suite](https://github.com/wendellhua/sighttest/blob/main/backend/suite_security.py): test suite · `backend/suite_security.py`
- [Performance suite](https://github.com/wendellhua/sighttest/blob/main/backend/suite_perf.py): test suite · `backend/suite_perf.py`
- [AI-driven suite](https://github.com/wendellhua/sighttest/blob/main/backend/suite_ai.py): optional test suite · `backend/suite_ai.py`

### External Runtimes

- [Playwright Chromium](https://github.com/wendellhua/sighttest/blob/main/backend/browser.py): browser runtime · Owns real-page interaction and browser-level network observation. · `backend/browser.py`
- [Whistle proxy](https://github.com/wendellhua/sighttest/blob/main/backend/whistle.py): optional Node proxy · Captures request parameters and response payloads when available. · `backend/whistle.py`
- [OpenAI-compatible LLM](https://github.com/wendellhua/sighttest/blob/main/backend/llm.py): optional provider · Enables AI case generation and report features when configured. · `backend/llm.py`

## Connections

- UI shell → SPA router & views: loads
- SPA router & views → API client: uses
- SPA router & views → Task store & SSE: renders state
- API client → FastAPI / SSE boundary: HTTP APIs
- Task store & SSE → FastAPI / SSE boundary: SSE task stream
- API client → Offline simulator: fallback when unavailable
- FastAPI / SSE boundary → Task orchestrator: starts async task
- FastAPI / SSE boundary → Task, report & LLM data: reads/writes
- Task orchestrator → Product explorer: explore
- Product explorer → Playwright Chromium: navigates and inspects
- Playwright Chromium → Whistle proxy: optional network capture
- Task orchestrator → Case generator: design cases
- Product explorer → Case generator: experience artifact
- Case generator → OpenAI-compatible LLM: optional generation
- Task orchestrator → Case execution layer: execute cases
- Case execution layer → Functional suite: runs
- Case execution layer → API contract suite: runs
- Case execution layer → Security suite: runs
- Case execution layer → Performance suite: runs
- Case execution layer → AI-driven suite: optionally runs
- Task orchestrator → Report aggregator: aggregate outcomes
- Report aggregator → OpenAI-compatible LLM: optional AI reporting
- Report aggregator → Task, report & LLM data: stores reports
- Shared contracts → Product explorer: contracts
- Shared contracts → Case execution layer: contracts
