Skip to content

Atlas Data Models

All models are defined in packages/db/schema.prisma with MongoDB as the provider. Zod types are auto-generated via zod-prisma-types.

Entity Relationship Overview


User & Auth

User

Core user record managed by Better-Auth.

FieldTypeNotes
idStringMongoDB ObjectId
emailStringUnique
nameString
roleEnumUSER | ADMIN
phoneString?
locationString?
professionString?
onboardingCompletedBooleanDefault: false
bannedBoolean?
twoFactorEnabledBoolean?

Session

Better-Auth session tokens (cookie-based).

FieldType
tokenString (unique)
expiresAtDateTime
userIdString (FK)
ipAddressString?
userAgentString?

Account

OAuth provider accounts linked to a user (Google, Stripe).

FieldType
accountIdString
providerIdString
accessTokenString?
refreshTokenString?
userIdString (FK)

Credits & Billing

Billing

One-to-one per user. Tracks Chargebee subscription state.

FieldTypeNotes
userIdStringUnique
chargebeeCustomerIdString?
chargebeeSubscriptionIdString?
subscriptionStatusEnumactive | cancelled | non_renewing | paused
subscriptionPlanIdString?

Credit

One-to-one per user. Tracks available credits.

FieldTypeNotes
userIdStringUnique
subscriptionCreditsIntResets each billing period
purchasedCreditsIntPermanent (never reset)
creditAvailableIntsubscriptionCredits + purchasedCredits

CreditUsage

Tracks credit consumption per operation type.

FieldType
creditIdString (FK)
creditTypeEnum: SEARCH | SKIPTRACE
creditReservedInt
creditUsedInt

CreditLog

Immutable audit trail of credit changes.

FieldType
creditIdString (FK)
creditTypeEnum
creditBeforeInt
creditAfterInt
changeAmountInt
timestampDateTime

CreditWeight

Configurable credit cost per operation (adjustable by admin).

FieldTypeNotes
creditTypeEnumSEARCH | SKIPTRACE — Unique
weightFloate.g., 1.0 for search, 0.5 for skiptrace

PaymentTransaction

Each Chargebee invoice/transaction is recorded here.

FieldType
userIdString
chargebeeInvoiceIdString?
chargebeeTransactionIdString?
typesubscription | one_time_purchase | credit_adjustment
statussuccess | pending | failed | refunded
amountFloat
creditsAddedInt
planId / planNameString?
billingPeriodString?
transactionDateDateTime

Properties

Cached property records from BatchData.

FieldTypeNotes
propertyIdStringUnique — BatchData ID
addressString
city / county / state / postal_codeString
dataJsonFull BatchData response
googleImagesString[]S3 keys
hasImageSearchedBooleanFlag to avoid re-fetching

PropertyDatasetPermission

Tracks which datasets a user has unlocked for a specific property.

FieldType
userIdString
propertyIdString
datasetsEnum[]

Dataset enum values: BASIC, BATCHRANK, CONTACT, DEED, DEMOGRAPHIC, FORECLOSURE, LISTING, MORTGAGE_LIENS, OWNER, PERMIT, QUICKLIST, VALUATION, DIVORCE_INFO

SavedSearch

A named saved search with filters and associated property results.

FieldType
userIdString
nameString
filtersJson
createdAtDateTime
lastRunAtDateTime?

Many-to-many with Properties.


Leads & Enrichment

Leads (Lead Group)

FieldType
nameString
descriptionString?
totalContactsInt
fileNameString?
tagsString[]
isDeletedBoolean
userIdString (FK)

Contacts

FieldType
firstName / lastNameString?
email / phoneString?
company / linkedinString?
address, city, state, zipString?
isEnrichedBoolean
enrichedAtDateTime?
enrichmentSourceString?
isDivorceLeadBoolean
engagementScoreInt?
leadsIdString (FK)

Enrichment

Tracks the overall enrichment (skip-trace) job for a lead group.

FieldType
leadIdString (FK)
statusprocessing | completed | failed
totalBatchesInt
totalLeadsInt

EnrichmentBatchs

Individual batch within an enrichment job.

FieldType
enrichmentIdString (FK)
batchNumberInt
totalContactsInt
statuspending | completed | failed
enrichedCount / skippedCountInt
uploadIdString?
metadataJson?

Divorce Leads

DivorceLead

FieldType
userIdString
propertyIdString?
leadIdString?
state / city / zip / countyString?
filingDate / scrapedDateDateTime?
owner1Name / owner2NameString?
owner1Phones / owner2PhonesString[]
owner1Emails / owner2EmailsString[]
propertyAddressJson?
enrichmentScoreFloat?
confidenceFloat?
statusnew | viewed | ...
rawDataJson

Other Models

HelpCenterArticle

FieldType
title / contentString
slugString (unique)
categoryEnum (6 categories)
tagsString[]
publishedBoolean
viewsInt
orderInt

FeatureRequest

FieldType
userIdString
requestTypeString
quickSignalsString[]
descriptionString?
statusPENDING | REVIEWED | IN_PROGRESS | COMPLETED | REJECTED
priorityLOW | MEDIUM | HIGH | CRITICAL
adminNotesString?