# garris/backstopjs architecture

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

## Overview

BackstopJS is a visual-regression testing tool: users configure scenarios and viewports, capture test screenshots, compare them with reference images, inspect reports, and approve accepted changes. The CLI and optional remote service enter the command runner; comparison and reporting produce the reviewable result, while the browser UI supports inspection and approval. Capture engines, config processing, comparison, reporting, and the report UI are shown as distinct subsystems. Some core files and integrations were not sampled, so links to those are omitted where their callers are not evidenced.

Main entry points: [`core/command/index.js`](https://github.com/garris/backstopjs/blob/master/core/command/index.js) (Command dispatcher), [`compare/src/components/App.js`](https://github.com/garris/backstopjs/blob/master/compare/src/components/App.js) (Report application), [`core/runner.js`](https://github.com/garris/backstopjs/blob/master/core/runner.js) (Command runner), [`core/util/compare/index.js`](https://github.com/garris/backstopjs/blob/master/core/util/compare/index.js) (Image comparison)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_cli["CLI<br/>[index.js]"]
  node_remote["Remote service<br/>[index.js]"]
  node_runner["Command runner<br/>[runner.js]"]
  node_dispatcher["Command dispatcher<br/>[index.js]"]
end

subgraph group_workflow["Test workflow"]
  node_config["Config assembly<br/>[makeConfig.js]"]
  node_testcmd["Test command"]
  node_reference["Reference command<br/>[reference.js]"]
  node_approve["Approve command<br/>[approve.js]"]
  node_references[("Reference images")]
  node_testimages[("Test images")]
end

subgraph group_capture["Capture engines"]
  node_bitmap["Screenshot capture<br/>[createBitmaps.js]"]
  node_playwright["Playwright engine<br/>[runPlaywright.js]"]
  node_puppeteer["Puppeteer engine<br/>[runPuppet.js]"]
  node_hooks["Capture hooks"]
end

subgraph group_reporting["Comparison and reports"]
  node_comparison["Image comparison<br/>[index.js]"]
  node_diffworker["Diff worker<br/>[compare.js]"]
  node_reportcmd["Report generation<br/>[report.js]"]
  node_reportdata["Report data"]
  node_browserreport["Browser report<br/>[index_bundle.js]"]
end

subgraph group_ui["Report interface"]
  node_app["Report application<br/>[App.js]"]
  node_list["Test results list<br/>[List.js]"]
  node_testcard["Scenario details<br/>[TestCard.js]"]
  node_scrubber["Image scrubber<br/>[ImageScrubber.js]"]
  node_store["UI state store<br/>[store.js]"]
  node_actions["UI actions<br/>[index.js]"]
end

node_user(("User"))

node_user -->|"runs command"| node_cli
node_cli -->|"invokes"| node_runner
node_remote -->|"invokes"| node_runner
node_runner -->|"builds config"| node_config
node_runner -->|"dispatches command"| node_dispatcher
node_dispatcher -->|"executes"| node_testcmd
node_dispatcher -->|"executes"| node_reference
node_dispatcher -->|"executes"| node_approve
node_user -->|"creates baseline"| node_reference
node_reference -->|"writes images"| node_references
node_user -->|"runs tests"| node_testcmd
node_testcmd -.->|"captures screenshots"| node_bitmap
node_bitmap -.->|"writes images"| node_testimages
node_testimages -->|"compares against"| node_comparison
node_references -->|"compares against"| node_comparison
node_comparison -->|"dispatches image pair"| node_diffworker
node_comparison -->|"returns results"| node_reportcmd
node_reportcmd -->|"writes report data"| node_reportdata
node_reportcmd -->|"copies report UI"| node_browserreport
node_browserreport -.->|"provides interface"| node_app
node_app -->|"renders"| node_list
node_list -->|"renders"| node_testcard
node_app -->|"renders modal"| node_scrubber
node_app -.->|"uses state"| node_store
node_store -.->|"manages actions"| node_actions
node_user -->|"approves changes"| node_approve
node_approve -->|"promotes test images"| node_references
node_playwright -.->|"loads scripts"| node_hooks
node_puppeteer -.->|"loads scripts"| node_hooks

click node_cli "https://github.com/garris/backstopjs/blob/master/cli/index.js"
click node_remote "https://github.com/garris/backstopjs/blob/master/remote/index.js"
click node_runner "https://github.com/garris/backstopjs/blob/master/core/runner.js"
click node_dispatcher "https://github.com/garris/backstopjs/blob/master/core/command/index.js"
click node_config "https://github.com/garris/backstopjs/blob/master/core/util/makeConfig.js"
click node_testcmd "https://github.com/garris/backstopjs/tree/master/core/command"
click node_reference "https://github.com/garris/backstopjs/blob/master/core/command/reference.js"
click node_approve "https://github.com/garris/backstopjs/blob/master/core/command/approve.js"
click node_bitmap "https://github.com/garris/backstopjs/blob/master/core/util/createBitmaps.js"
click node_playwright "https://github.com/garris/backstopjs/blob/master/core/util/runPlaywright.js"
click node_puppeteer "https://github.com/garris/backstopjs/blob/master/core/util/runPuppet.js"
click node_hooks "https://github.com/garris/backstopjs/tree/master/capture/engine_scripts"
click node_comparison "https://github.com/garris/backstopjs/blob/master/core/util/compare/index.js"
click node_diffworker "https://github.com/garris/backstopjs/blob/master/core/util/compare/compare.js"
click node_reportcmd "https://github.com/garris/backstopjs/blob/master/core/command/report.js"
click node_browserreport "https://github.com/garris/backstopjs/blob/master/compare/output/index_bundle.js"
click node_app "https://github.com/garris/backstopjs/blob/master/compare/src/components/App.js"
click node_list "https://github.com/garris/backstopjs/blob/master/compare/src/components/ecosystems/List.js"
click node_testcard "https://github.com/garris/backstopjs/blob/master/compare/src/components/organisms/TestCard.js"
click node_scrubber "https://github.com/garris/backstopjs/blob/master/compare/src/components/atoms/ImageScrubber.js"
click node_store "https://github.com/garris/backstopjs/blob/master/compare/src/store.js"
click node_actions "https://github.com/garris/backstopjs/blob/master/compare/src/actions/index.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_remote,node_runner,node_dispatcher,node_user toneBlue
class node_config,node_testcmd,node_reference,node_approve,node_references,node_testimages toneAmber
class node_bitmap,node_playwright,node_puppeteer,node_hooks toneMint
class node_comparison,node_diffworker,node_reportcmd,node_reportdata,node_browserreport toneRose
class node_app,node_list,node_testcard,node_scrubber,node_store,node_actions toneIndigo
```

## Components

### Entry points

- [CLI](https://github.com/garris/backstopjs/blob/master/cli/index.js): `cli/index.js`
- [Remote service](https://github.com/garris/backstopjs/blob/master/remote/index.js): `remote/index.js`
- [Command runner](https://github.com/garris/backstopjs/blob/master/core/runner.js): `core/runner.js`
- [Command dispatcher](https://github.com/garris/backstopjs/blob/master/core/command/index.js): `core/command/index.js`

### Test workflow

- [Config assembly](https://github.com/garris/backstopjs/blob/master/core/util/makeConfig.js): `core/util/makeConfig.js`
- [Test command](https://github.com/garris/backstopjs/tree/master/core/command): `core/command`
- [Reference command](https://github.com/garris/backstopjs/blob/master/core/command/reference.js): `core/command/reference.js`
- [Approve command](https://github.com/garris/backstopjs/blob/master/core/command/approve.js): `core/command/approve.js`
- **Reference images**
- **Test images**

### Capture engines

- [Screenshot capture](https://github.com/garris/backstopjs/blob/master/core/util/createBitmaps.js): `core/util/createBitmaps.js`
- [Playwright engine](https://github.com/garris/backstopjs/blob/master/core/util/runPlaywright.js): `core/util/runPlaywright.js`
- [Puppeteer engine](https://github.com/garris/backstopjs/blob/master/core/util/runPuppet.js): `core/util/runPuppet.js`
- [Capture hooks](https://github.com/garris/backstopjs/tree/master/capture/engine_scripts): `capture/engine_scripts`

### Comparison and reports

- [Image comparison](https://github.com/garris/backstopjs/blob/master/core/util/compare/index.js): `core/util/compare/index.js`
- [Diff worker](https://github.com/garris/backstopjs/blob/master/core/util/compare/compare.js): `core/util/compare/compare.js`
- [Report generation](https://github.com/garris/backstopjs/blob/master/core/command/report.js): `core/command/report.js`
- **Report data**
- [Browser report](https://github.com/garris/backstopjs/blob/master/compare/output/index_bundle.js): `compare/output/index_bundle.js`

### Report interface

- [Report application](https://github.com/garris/backstopjs/blob/master/compare/src/components/App.js): `compare/src/components/App.js`
- [Test results list](https://github.com/garris/backstopjs/blob/master/compare/src/components/ecosystems/List.js): `compare/src/components/ecosystems/List.js`
- [Scenario details](https://github.com/garris/backstopjs/blob/master/compare/src/components/organisms/TestCard.js): `compare/src/components/organisms/TestCard.js`
- [Image scrubber](https://github.com/garris/backstopjs/blob/master/compare/src/components/atoms/ImageScrubber.js): `compare/src/components/atoms/ImageScrubber.js`
- [UI state store](https://github.com/garris/backstopjs/blob/master/compare/src/store.js): `compare/src/store.js`
- [UI actions](https://github.com/garris/backstopjs/blob/master/compare/src/actions/index.js): `compare/src/actions/index.js`

### Other components

- **User**

## Connections

- User → CLI: runs command
- CLI → Command runner: invokes (evidence: `cli/index.js`)
- Remote service → Command runner: invokes (evidence: `remote/index.js`)
- Command runner → Config assembly: builds config (evidence: `core/runner.js`)
- Command runner → Command dispatcher: dispatches command (evidence: `core/runner.js`)
- Command dispatcher → Test command: executes (evidence: `core/command/index.js`)
- Command dispatcher → Reference command: executes (evidence: `core/command/index.js`)
- Command dispatcher → Approve command: executes (evidence: `core/command/index.js`)
- User → Reference command: creates baseline
- Reference command → Reference images: writes images
- User → Test command: runs tests
- Test command → Screenshot capture: captures screenshots
- Screenshot capture → Test images: writes images
- Test images → Image comparison: compares against
- Reference images → Image comparison: compares against
- Image comparison → Diff worker: dispatches image pair (evidence: `core/util/compare/index.js`)
- Image comparison → Report generation: returns results (evidence: `core/command/report.js`)
- Report generation → Report data: writes report data (evidence: `core/command/report.js`)
- Report generation → Browser report: copies report UI (evidence: `core/command/report.js`)
- Browser report → Report application: provides interface
- Report application → Test results list: renders (evidence: `compare/src/components/App.js`)
- Test results list → Scenario details: renders (evidence: `compare/src/components/ecosystems/List.js`)
- Report application → Image scrubber: renders modal (evidence: `compare/src/components/App.js`)
- Report application → UI state store: uses state
- UI state store → UI actions: manages actions
- User → Approve command: approves changes
- Approve command → Reference images: promotes test images
- Playwright engine → Capture hooks: loads scripts
- Puppeteer engine → Capture hooks: loads scripts
