Developer Docs

Models

Generated from the Mongoose schemas in apps/api/src/models.
Generated from Mongoose schemas in apps/api/src/models. Field notes come from comments inside the schema where they exist.

Mongoose models

model

Account

Collection
accounts
Timestamps
true
FieldTypeRulesNotes
userIdSchema.Types.ObjectIdrequired: true, ref: 'User'
typeStringrequired: true
providerStringrequired: true
providerAccountIdStringrequired: true
refresh_tokenString
access_tokenString
expires_atNumber
token_typeString
scopeString
id_tokenString
session_stateString
Indexes{ provider: 1, providerAccountId: 1 }, { unique: true }{ userId: 1 }
apps/api/src/models/Account.ts:3
model

Baseline

Collection
baselines
Timestamps
true
FieldTypeRulesNotes
urlStringrequired: true
pathStringURL pathname (host-independent). Used to match baselines against a PR's Vercel preview, which lives on a different host than the suite baseUrl. Backfilled lazily — older baselines may only have `url`.
viewportStringrequired: true
filePathStringrequired: true
isApprovedBooleandefault: false
currentVersionNumberdefault: nullDenormalised pointer to the latest BaselineVersion for this (testSuiteId, path, viewport). Additive — lets the run processor read the "current" baseline without a version lookup. Backfilled on each promote.
currentVersionIdSchema.Types.ObjectIddefault: null, ref: 'BaselineVersion'
testSuiteIdSchema.Types.ObjectIdrequired: true, ref: 'TestSuite'
Indexes{ testSuiteId: 1, url: 1, viewport: 1 }, { unique: true }{ testSuiteId: 1, path: 1, viewport: 1 }
apps/api/src/models/Baseline.ts:3
model

BaselineVersion

Collection
baseline_versions
Timestamps
true
FieldTypeRulesNotes
testSuiteIdSchema.Types.ObjectIdrequired: true, ref: 'TestSuite'
pathStringrequired: true, trim: trueHost-independent path — canonical page identity (matches SitePage.path).
urlStringrequired: trueCanonical URL on the suite origin at approval time.
viewportStringrequired: true
versionNumberrequired: trueMonotonic per (testSuiteId, path, viewport), starting at 1.
filePathStringrequired: trueS3/CloudFront URL of the approved screenshot.
sourceStringrequired: true, enum: Object.values(BaselineSource)
approvedBySchema.Types.ObjectIddefault: null, ref: 'User'Reviewer who approved this version; null for auto-seeded/legacy entries.
approvedAtDaterequired: true, default: Date.now
testRunIdSchema.Types.ObjectIddefault: null, ref: 'TestRun'Run the screenshot came from, when applicable.
pageResultIdSchema.Types.ObjectIddefault: null, ref: 'PageResult'The specific page result promoted, when applicable.
diffScoreNumberdefault: nullDiff % versus the version it replaced (null for the first version).
prNumberNumberdefault: nullSet when source === PR_MERGE.
noteStringdefault: nullOptional reviewer note.
Indexes{ testSuiteId: 1, path: 1, viewport: 1, version: -1 }, { unique: true }{ testSuiteId: 1, path: 1, approvedAt: -1 }
apps/api/src/models/BaselineVersion.ts:16
model

GitHubInstallation

Collection
github_installations
Timestamps
true
FieldTypeRulesNotes
installationIdNumberrequired: true, unique: true
accountLoginStringrequired: true
accountTypeString
repos[String]default: []Full names ("owner/repo") this installation can access, when known.
apps/api/src/models/GitHubInstallation.ts:8
model

PageResult

Collection
page_results
Timestamps
true
FieldTypeRulesNotes
urlStringrequired: true
pathStringURL pathname, used to promote PR images to baselines by path.
viewportStringrequired: true
statusStringrequired: true, default: ResultStatus.PENDING, enum: Object.values(ResultStatus)
approvedBooleandefault: falseSet true when a reviewer approves this result's image (PR runs).
approvedBySchema.Types.ObjectIddefault: null, ref: 'User'Reviewer who approved this result in-app. Recorded at approve time so PR runs can attribute the baseline version when the PR later merges (the merge happens in a webhook with no user session).
approvedAtDatedefault: null
isNewBooleandefault: falseTrue when no baseline existed for this path/viewport at run time.
diffScoreNumber
baselineFileString
currentFileString
diffFileString
errorStringDetailed error message when status is ERROR.
testRunIdSchema.Types.ObjectIdrequired: true, ref: 'TestRun'
Indexes{ testRunId: 1 }{ status: 1 }
apps/api/src/models/PageResult.ts:6
model

PasswordResetToken

Collection
password_reset_tokens
Timestamps
{ createdAt: true, updatedAt: false }
FieldTypeRulesNotes
userIdSchema.Types.ObjectIdrequired: true, ref: 'User'
tokenStringrequired: true, unique: true
expiresDaterequired: true
Indexes{ expires: 1 }, { expireAfterSeconds: 0 }{ userId: 1 }
apps/api/src/models/PasswordResetToken.ts:3
model

SitePage

Collection
site_pages
Timestamps
true
FieldTypeRulesNotes
testSuiteIdSchema.Types.ObjectIdrequired: true, ref: 'TestSuite'
urlStringrequired: true, trim: trueFull URL on the suite's own host.
pathStringrequired: true, trim: trueHost-independent pathname + search — canonical page identity.
titleStringdefault: null, trim: true<title> captured during discovery, when available.
statusStringdefault: PageStatus.ACTIVE, enum: Object.values(PageStatus)
trackedBooleandefault: falseSelected for visual diffing.
firstSeenAtDaterequired: true, default: Date.now
lastSeenAtDaterequired: true, default: Date.now
removedAtDatedefault: nullSet when the page goes missing from a crawl (status === REMOVED).
Indexes{ testSuiteId: 1, path: 1 }, { unique: true }{ testSuiteId: 1, tracked: 1 }{ testSuiteId: 1, status: 1 }
apps/api/src/models/SitePage.ts:13
model

TestRun

Collection
test_runs
Timestamps
true
FieldTypeRulesNotes
statusStringrequired: true, default: RunStatus.PENDING, enum: Object.values(RunStatus)
runTypeStringrequired: true, default: RunType.MANUAL, enum: Object.values(RunType)What triggered this run.
gitSchema.Types.Mixeddefault: nullGit/PR context for PR and BRANCH runs. Shape: { prNumber?, headSha?, branch?, baseBranch?, previewUrl?, checkRunId?, installationId? } — see TestRunGitContext in @viz/types.
reviewStateStringrequired: true, default: VisualReviewState.NOT_REQUIRED, enum: Object.values(VisualReviewState)Visual review gate state (drives the GitHub check for PR runs).
startedAtDatedefault: Date.now
endedAtDate
metadataSchema.Types.Mixed
testSuiteIdSchema.Types.ObjectIdrequired: true, ref: 'TestSuite'
Indexes{ testSuiteId: 1, createdAt: -1 }{ status: 1 }{ testSuiteId: 1, 'git.prNumber': 1 }{ 'git.headSha': 1 }
apps/api/src/models/TestRun.ts:6
model

TestRunLog

Collection
test_run_logs
Timestamps
true
FieldTypeRulesNotes
typeStringrequired: true, enum: Object.values(LogType)
messageStringrequired: true
metadataSchema.Types.Mixed
timestampDaterequired: true
testRunIdSchema.Types.ObjectIdrequired: true, ref: 'TestRun'
Indexes{ testRunId: 1, timestamp: 1 }{ type: 1 }
apps/api/src/models/TestRunLog.ts:6
model

TestSuite

Collection
test_suites
Timestamps
true
FieldTypeRulesNotes
nameStringrequired: true, trim: true
baseUrlStringrequired: true, trim: true
descriptionStringtrim: true
kindStringrequired: true, default: TestSuiteKind.SUITE, enum: Object.values(TestSuiteKind)SUITE (default) for crawl-based suites; MANUAL for lightweight single-URL quick-test buckets that skip discovery. See TestSuiteKind in @viz/types.
configSchema.Types.Mixedrequired: true
isActiveBooleandefault: true
githubSchema.Types.Mixeddefault: nullLinked GitHub repo enabling PR visual-regression checks. Shape: { owner, repo, installationId, checkContext? } — see TestSuiteGitHubLink in @viz/types. Stored as Mixed so it can be null.
crawlSchema.Types.Mixeddefault: () => ({ status: 'IDLE' })Site-discovery crawl state — see SuiteCrawlState in @viz/types. Shape: { status, lastCrawledAt?, lastStats?: { pagesFound, pagesAdded, pagesRemoved }, error? }. Stored as Mixed for flexibility.
userIdSchema.Types.ObjectIdrequired: true, ref: 'User'
Indexes{ userId: 1, isActive: 1 }{ createdAt: -1 }{ kind: 1, createdAt: -1 }{ 'github.owner': 1, 'github.repo': 1 }
apps/api/src/models/TestSuite.ts:6
model

User

Collection
users
Timestamps
true
FieldTypeRulesNotes
emailStringunique: true, trim: true
emailVerifiedDatedefault: null
passwordString
nameStringtrim: true
imageString
apps/api/src/models/User.ts:3