Developer Docs
Architecture and Data Flow
How data moves through the API, job runners, database and browser.Runtime pieces
apps/api/src/server.ts starts the Fastify API.
Background work is enqueued through apps/api/src/queue/index.ts:
- Locally, jobs run in-process.
- On Vercel (
VERCEL=1, including preview), jobs are published to Vercel Queues
and handled by consumers in apps/api/api/queues/. QUEUE_BACKEND=local is ignored on Vercel.
Job runners live under apps/api/src/jobs/ (visual runs, crawls, page reruns). Scheduled recrawls are triggered by a Vercel Cron at /internal/cron/recrawl.
Suite discovery
- A suite is created with a
baseUrl. - A crawl job is queued.
SiteCrawlerdiscovers pages from sitemaps and same-origin links.- Discovered pages are stored as
SitePagedocuments. - Users choose which pages are tracked.
Discovery finds candidates. Tracking decides what is tested.
Run execution
RunService.startSuiteRuncreates aTestRun.- A job is enqueued on the visual-tests topic.
- The runner screenshots tracked pages with
ScreenshotService. VisualComparisoncompares current screenshots with baselines.- Results are stored as
PageResultdocuments. RunOutcomeServicefinalises status, review state and GitHub check state.
Logs are stored as TestRunLog documents. The browser polls GET /test-runs/:id/logs while a run is active.
Review and promotion
Single-page approval and approve-all both go through review services.
For manual and branch runs, approval updates baselines immediately and appends a BaselineVersion.
For PR runs, approval marks the result accepted and unblocks the GitHub check. PromotionService promotes approved screenshots when the pull request is merged.
Frontend data flow
The web app uses a typed axios client and TanStack Query hooks. It does not call MongoDB directly and it does not own API types. Shared shapes come from @viz/types.
When adding a new endpoint, update the shared contract first, then the route, mapper and client hook.
Preview deployments
Web and API are separate Vercel projects linked with Related Projects so a preview web deploy talks to the matching preview API. Each preview uses an isolated Mongo database (viz_preview_pr_<n>), seeded on first boot when empty.