Skip to main content

Data Dictionary

Catalog of Mongoose models and schemas in src/data/. Updated when models or schema fields change. Admin panel groups these into four sidebar sections (Users & Identity, Commerce, Configuration, Monitoring). Theme and display-name settings are stored in UserSettings / UserTheme models. System themes define overrides (sidebar, container, sectionBg, text, colors) for universal layout and are seeded/updated on deploy via seedSystemThemes. The User Settings page (user-settings-page) and LoggedIn override use explicit theme-aware color tokens (grey100/grey80) plus a global CSS override (ThemeAwareGlobals) to ensure readable text on all theme backgrounds.

Trigger: Changes to src/data/** or *.model.ts
Regenerate: Use generate-reference-docs skill or run pre-commit with affected model files staged.

Note: src/data/discord-commands/ is a service layer (command router, notify service) with no database model. The router exposes execute, executeComponent, and executeModal. See Discord Commands.


Address

Model: Address | File: src/data/address/address.model.ts

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
nameStringYesRecipient name
line1StringYesStreet address
line2StringNoApt/suite
cityStringYesCity
stateStringYesState/province
postalCodeStringYesZIP/postal code
countryStringYesCountry code
phoneStringNoPhone number

Alert

Model: Alert | File: src/data/alert/alert.model.ts

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
typeenumYesLOW_INVENTORY, NEW_ORDER, PAYMENT_FAILED, FULFILLMENT_FAILED
severityenumYesINFO, WARN, ERROR
messageStringYesAlert message
entityTypeStringNoRelated entity type
entityIdStringNoRelated entity ID
isReadBooleanYesRead status

AuditLog

Model: AuditLog | File: src/data/audit-log/audit-log.model.ts

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
actorIdStringYesUser who performed action
actionStringYesAction name
entityTypeStringYesEntity type affected
entityIdStringYesEntity ID affected
metaMixedYesAdditional metadata

BotConfig

Model: BotConfig | File: src/data/bot-config/bot-config.model.ts

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
guildIdStringYesDiscord guild ID
defaultOrderChannelIdStringNoDefault order channel
announcementChannelIdStringNoAnnouncement channel
adminRoleIds[String]YesAdmin role IDs
staffRoleIds[String]YesStaff role IDs
responseModeenumYesEPHEMERAL, DM
lowInventoryThresholdNumberYesLow stock threshold
enabledPaymentMethods[String]YesPayment methods
paymentInstructionsStringYesPayment instructions text
paymentInstructionsByMethodMixedYesPer-method instructions
registeredDiscordUserIds[String]YesRegistered user IDs
defaultQtyVisibilityenumYespublic or private — tenant-wide default for product stock count display
defaultProductImageUrlStringNoFallback image URL when a product has none
shippingTypesMixedYesArray of { code, label, costCents, estimatedDays } — default []
FieldTypeRequiredDescription
------------------------------------------------------------------------------------------------------------------------------
tenantIdStringYesTenant identifier
guildIdStringYesDiscord guild ID
defaultOrderChannelIdStringNoDefault order channel
announcementChannelIdStringNoAnnouncement / admin channel (takes precedence over adminChannelId)
adminChannelIdStringNoFallback admin channel for notifications (used when announcementChannelId is blank)
adminRoleIds[String]YesAdmin role IDs
staffRoleIds[String]YesStaff role IDs
responseModeenumYesEPHEMERAL, DM
lowInventoryThresholdNumberYesLow stock threshold
enabledPaymentMethods[String]YesPayment methods
paymentInstructionsStringYesPayment instructions text
paymentInstructionsByMethodMixedYesPer-method instructions
registeredDiscordUserIds[String]YesRegistered user IDs
defaultQtyVisibilityenumYespublic or private — tenant-wide default for product stock count display
defaultProductImageUrlStringNoFallback image URL when a product has none
adminNotifyEmailStringNoOptional email address for admin notifications (e.g. payment-rejected alerts). Not exposed in AdminJS — set via seed or direct DB update. Requires EMAIL_PROVIDER=sendgrid.

Customer

Model: Customer | File: src/data/customer/customer.model.ts

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
userIdStringNoLinked platform user
discordIdStringYesDiscord user ID
discordUsernameStringYesDiscord username
discordDisplayNameStringYesDisplay name
sourceenumYesDISCORD, EMAIL, MANUAL
emailStringNoEmail address
phoneStringNoPhone
addresses[addressWithId]YesShipping addresses
defaultAddressIdStringNoDefault address
notesStringNoNotes
isActiveBooleanYesActive flag
dmOptOutBooleanYesWhen true, customer DMs are skipped (default false)
dmPreferencesObjectYesPer-event DM toggles: orderReceived, paymentConfirmed, orderShipped, refunds (all default true)
emailPreferencesObjectYesPer-event email toggles: orderReceived, paymentConfirmed, orderShipped, refunds (all default true)

Discount

Model: Discount | File: src/data/discount/discount.model.ts

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
codeStringNoDiscount code
typeenumYesPERCENT, AMOUNT
percentNumberNoPercent off
amountCentsNumberNoFixed amount off
appliesToAllBooleanYesApplies to all products
productIds[String]YesEligible product IDs
roleIds[String]YesEligible role IDs
customerIds[String]YesEligible customer IDs
isActiveBooleanYesActive flag
startsAtDateNoStart time
endsAtDateNoEnd time
usageLimitNumberNoMax uses
usageCountNumberYesCurrent uses
consumedOrderIds[String]YesOrders that used discount

DiscountAssignment

Model: DiscountAssignment | File: src/data/discount/discount-assignment.model.ts

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
discountIdStringYesThe discount this assignment is for
customerIdStringYesCustomer who holds the assignment
ruleenumYesone_time, next_n, forever
totalAllowedNumberNoMax uses (null for forever)
usedCountNumberYesHow many times the customer has used it
expiresAtDateNoAssignment expiration (soft-revoke sets this)

Entitlement

Model: Entitlement | File: src/data/entitlement/entitlement.model.ts

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
userIdStringYesDiscord user ID who received entitlement
orderIdStringYesOrder that triggered the entitlement
productIdStringYesProduct that carries the role grant
typeenumYesDISCORD_ROLE, DIGITAL_ITEM
roleIdStringNoDiscord role ID (type=DISCORD_ROLE)
statusenumYesPENDING, GRANTED, REVOKED, FAILED
metadataMixedYesAdditional data
grantedAtDateNoWhen Discord grant succeeded
revokedAtDateNoWhen Discord role removal ran (refund)
failedReasonStringNoError message when status is FAILED
FieldTypeRequiredDescription
-------------------------------------------------------------
tenantIdStringYesTenant identifier
userIdStringYesUser who received entitlement
orderIdStringYesOrder that granted it
productIdStringYesProduct granted
typeenumYesDISCORD_ROLE, DIGITAL_ITEM
roleIdStringNoDiscord role (if type=DISCORD_ROLE)
statusenumYesPENDING, GRANTED, REVOKED, FAILED
metadataMixedYesAdditional data
grantedAtDateNoWhen granted
revokedAtDateNoWhen revoked
failedReasonStringNoError message when status=FAILED

FeatureFlag

Model: FeatureFlag | File: src/data/feature-flag/feature-flag.model.ts

FieldTypeRequiredDescription
keyStringYesFlag key
scopeenumYessystem, tenant
tenantIdStringNoTenant (if scope=tenant)
enabledBooleanYesEnabled flag
payloadMixedYesFlag payload

Identity

Model: Identity | File: src/data/identity/identity.model.ts

FieldTypeRequiredDescription
userIdStringYesPlatform user ID
tenantIdStringNoTenant
providerStringYesAuth provider (discord, local)
providerUserIdStringYesProvider user ID
profileMixedYesProfile data
secretsMixedNoOpaque secrets

InventorySnapshot / InventoryTransaction

Models: InventorySnapshot, InventoryTransaction | File: src/data/inventory/inventory.model.ts

InventorySnapshot:

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
productIdStringYesProduct ID
quantityAvailableNumberYesAvailable quantity
quantityReservedNumberYesReserved quantity

InventoryTransaction:

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
productIdStringYesProduct ID
orderIdStringNoRelated order
typeenumYesADJUSTMENT, RESERVE, RELEASE, SALE, RESTOCK, REFUND
quantityDeltaNumberYesQuantity change
reasonStringNoReason text

Order

Model: Order | File: src/data/order/order.model.ts

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
orderNumberStringYesUnique order number
statusenumYesPENDING_PAYMENT, PAID, FULFILLING, SHIPPED, COMPLETE, CANCELLED, REFUNDED
items[orderItem]YesLine items
subtotalCentsNumberYesSubtotal
totalCentsNumberYesTotal
discountIdStringNoApplied discount
discountCodeStringNoDiscount code used
discountAmountCentsNumberYesDiscount amount
taxAmountCentsNumberNoSales tax collected (cents); defaults to 0 for pre-TaxJar orders
currencyStringYesCurrency code
customerorderCustomerYesCustomer snapshot
customerIdStringNoCustomer record ID
customerRoleIds[String]YesCustomer roles at order time
shippingAddressaddressNoShipping address
shippingStatusenumYesPENDING, LABEL_CREATED, SHIPPED, DELIVERED, FAILED
shipmentIdStringNoShipment record
trackingNumberStringNoTracking number
notesStringNoOrder notes

OrderInvoiceLinkToken (virtual — not persisted)

Invoice link tokens are not stored in the database. They are HMAC-signed payloads issued by OrderInvoiceLinkService.generateLink and verified by verifyLinkToken.

FieldTypeDescription
orderIdstringID of the order this token authorises access to
tenantIdstringTenant that owns the order (verified on redemption)
expnumberUnix epoch seconds; token is rejected once now > exp

Token format: base64url(JSON payload).base64url(HMAC-SHA256 signature)


OrderSession

Model: OrderSession | File: src/data/order-session/order-session.model.ts

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
discordUserIdStringYesDiscord user ID
guildIdStringNoGuild ID
stateenumYesOrder session state
items[orderItem]YesCart items
shippingAddressMixedNoShipping address
paymentMethodStringNoSelected payment method
submittedOrderIdStringNoOrder ID after submit
expiresAtDateYesSession expiry

Order flow orchestration: OrderFlowService (order-flow.service.ts) exposes getActiveSession for Discord component/modal handlers. See Order.


PaymentMethod Registry

No model (pure constant data) | File: src/data/payment-methods/payment-methods.registry.ts

Static registry mapping every PaymentMethod enum value to a PaymentMethodDescriptor. Not a database model — no Mongoose schema. Used by bot-config admin and Discord checkout to display human-readable labels.

PaymentMethodDescriptor fields

FieldTypeDescription
valuePaymentMethodThe enum value this descriptor covers
displayNamestringHuman-readable label for UI elements (e.g. "Zelle", "Cash App")
kindp2p | processor | manualBroad category driving filtering and UI logic
iconstringEmoji or symbol used next to the name in Discord messages
requiresProcessorbooleanTrue when a processor adapter must be configured before accepting payments
supportsAutomaticConfirmationbooleanTrue when a webhook can confirm payment without admin intervention
supportsRefundbooleanTrue when refunds can be issued programmatically through the processor
descriptionstringOne-line description for admin UI tooltips

Helper functions (payment-methods.service.ts)

FunctionReturnsDescription
getPaymentMethodDescriptor(method)PaymentMethodDescriptorLookup a single descriptor by enum value
getEnabledDescriptors(enabled)readonly PaymentMethodDescriptor[]Map an array of enabled methods to their descriptors
filterDescriptorsByKind(kind, enabled)readonly PaymentMethodDescriptor[]Filter enabled methods by kind (p2p / processor / manual)

Payment

Model: Payment | File: src/data/payment/payment.model.ts

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
orderIdStringYesOrder ID
methodenumYesPayment method
statusenumYesPayment status (includes P2P flow: pending_payment, awaiting_admin_approval, confirmed, rejected)
amountCentsNumberYesAmount in cents
currencyStringYesCurrency code
providerRefStringNoProvider reference (for BTC_NOWPAYMENTS: the NOWPayments invoice ID used to match IPN callbacks)
referenceTextStringNoReference text
confirmedByStringNoLegacy confirmer field
confirmedAtDateNoLegacy confirmation time
approverUserIdStringNoAdmin who confirmed or rejected the P2P payment
approvedAtDateNoWhen the payment was confirmed
rejectedAtDateNoWhen the payment was rejected
rejectionReasonStringNoAdmin-supplied rejection reason
customerReferenceNoteStringNoVenmo/CashApp note the admin observed when confirming
nowpaymentsHostedUrlStringNoBTC_NOWPAYMENTS: hosted invoice URL shown to the customer
nowpaymentsDepositAddressStringNoBTC_NOWPAYMENTS: on-chain deposit address
nowpaymentsDepositAmountCryptoStringNoBTC_NOWPAYMENTS: expected deposit amount in crypto (decimal string, e.g. "0.00012345")
nowpaymentsCryptoCurrencyStringNoBTC_NOWPAYMENTS: crypto ticker (e.g. "btc")
nowpaymentsExpiresAtDateNoBTC_NOWPAYMENTS: invoice expiry timestamp

Product

Model: Product | File: src/data/product/product.model.ts

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
nameStringYesProduct name
descriptionStringNoDescription
skuStringYesSKU
priceCentsNumberYesPrice
currencyStringYesCurrency
requiredRoleIds[String]YesRoles required to buy
grantedRoleIds[String]YesRoles granted on purchase
isDigitalBooleanYesDigital product
isActiveBooleanYesActive flag
inventoryTrackedBooleanYesTrack inventory
costCentsNumberNoAdmin-only cost basis (never returned in customer-facing output)
qtyVisibilityenumNopublic, private, or inherit (default inherit — falls back to tenant defaultQtyVisibility)

Provider

Model: Provider | File: src/data/provider/provider.model.ts

FieldTypeRequiredDescription
typeStringYesProvider type (discord, local)
tenantIdStringNoTenant
isActiveBooleanYesActive flag
configMixedYesProvider config

Role / RoleAssignment

Models: Role, RoleAssignment | Files: src/data/role/role.model.ts, role.assignments.model.ts

Role:

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
nameStringYesRole name
permissionKeys[String]YesPermission keys

RoleAssignment:

FieldTypeRequiredDescription
userIdStringYesUser ID
tenantIdStringYesTenant ID
roleIdStringYesRole ID

Shipment

Model: Shipment | File: src/data/shipment/shipment.model.ts

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
orderIdStringYesOrder ID (unique per tenant)
statusenumYespending, label_created, in_transit, delivered, exception
carrierStringNoCarrier name (e.g. USPS, UPS)
trackingNumberStringNoTracking number
labelUrlStringNoLabel URL (partner adapter only)
shippingTypeCodeStringYesReferences BotConfig.shippingTypes[].code
shippingCostCentsNumberYesCost in cents, copied from shipping type at order time
shippedAtDateNoTimestamp when marked as shipped
deliveredAtDateNoTimestamp when delivered
metadataMixedYesPartner-specific blob; default {}

Tenant

Model: Tenant | File: src/data/tenant/tenant.model.ts

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
nameStringYesTenant name
ownerUserIdStringYesOwner user ID
adminUserIds[String]YesAdmin user IDs

User

Model: User | File: src/data/user/user.model.ts

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
usernameStringYesUsername
displayNameStringYesDisplay name
emailStringNoEmail
avatarUrlStringNoAvatar URL
discordIdStringNoDiscord ID
roles[String]YesRole names
isAdminBooleanYesAdmin flag
customerIdStringNoLinked customer
primaryCustomerIdStringNoPrimary customer

UserSettings

Model: UserSettings | File: src/data/user-settings/user-settings.model.ts

FieldTypeRequiredDescription
userIdStringYesUser ID
displayNameStringNoDisplay name
activeThemeIdStringNoActive AdminJS theme ID
notificationsMixedYesNotification preferences

UserTheme

Model: UserTheme | File: src/data/user-theme/user-theme.model.ts

FieldTypeRequiredDescription
nameStringYesTheme name
slugStringYesURL slug
ownerUserIdStringNoOwner (null for system)
isSystemBooleanYesSystem theme flag
baseThemeIdStringNoBase theme to extend
overridesMixedYesTheme overrides

WebhookEvent

Model: WebhookEvent | File: src/data/webhook-event/webhook-event.model.ts

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
providerenumYesPAYPAL, CASHAPP_PAY, COINBASE_COMMERCE, DISCORD
eventIdStringYesProvider event ID
receivedAtDateYesReceipt time
payloadMixedYesWebhook payload

Analytics (virtual — no Mongoose model)

Analytics reports are computed aggregations over the Order collection. They are not persisted; results are cached in Valkey for 60 seconds.

RevenueOverviewReport

FieldTypeDescription
period.grossRevenueCentsnumberTotal revenue in cents
period.orderCountnumberSubmitted/completed orders
period.avgOrderValueCentsnumberGross / count
delta.grossRevenuePctnumber | null% change vs prior equal-length period
dailyBreakdownarray{ date, revenueCents, orderCount }[]

SalesVelocityReport

FieldTypeDescription
ordersPerDayarray{ date, orderCount }[]
dowHeatmaparray7 × 24 matrix (DOW × hour)
slowDayCalloutobject | null{ dow, label, avgOrders, lowestAvgHour }

ProductPerformanceReport

FieldTypeDescription
productsarray{ productId, name, revenueCents, unitsSold, orderCount, avgOrderValueCents, isTopRevenue, isTopVolume, isSlowMover }[]

AnalyticsShareLinkPayload (token)

FieldTypeDescription
reportTypestringOne of the 10 ANALYTICS_REPORT_TYPE values
tenantIdstringTenant the report is scoped to
period.fromstringISO-8601 start date
period.tostringISO-8601 end date
expnumberUnix expiry timestamp

CommunityFundContribution

Model: CommunityFundContribution | File: src/data/community-fund/community-fund.model.ts

Represents one voluntary donation event. Written by the service on order confirmation (order-flow integration deferred).

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
customerIdStringYesDonating customer
orderIdStringNoLinked order (null until order-flow integration lands)
amountCentsNumberYesContribution amount in cents (positive integer)
anonymousBooleanYesWhen true, celebration message omits donor name
createdAtDateAutoAuto-stamped by Mongoose

CommunityFundDisbursement

Model: CommunityFundDisbursement | File: src/data/community-fund/community-fund.model.ts

Represents one approved fund disbursement to a community member in need.

FieldTypeRequiredDescription
tenantIdStringYesTenant identifier
recipientCustomerIdStringYesBeneficiary customer ID
amountCentsNumberYesDisbursement amount in cents (positive)
reasonStringYesHuman-readable reason (audit trail)
approvedByStringYesUser ID of approver
createdAtDateAutoAuto-stamped by Mongoose

CommunityFundConfig

Model: CommunityFundConfig | File: src/data/community-fund/community-fund.model.ts

Per-tenant singleton configuration for the community fund. Created with defaults on first access.

FieldTypeRequiredDefault
tenantIdStringYes
enabledBooleanYesfalse
allowedAmountsCentsNumber[]Yes[500, 1000, 2500, 5000, 10000]
customAmountAllowedBooleanYestrue
customAmountMinCentsNumberYes100
customAmountMaxCentsNumberYes100000
celebrationChannelIdStringNonull
celebrationMessageTemplateStringYesSee spec §4
anonymousMessageTemplateStringYesSee spec §4
anonymityAllowedBooleanYestrue
disbursementApprovalRolesString[]Yes["admin", "community_leader"]
disclaimerTextStringYesSee spec §6 (informal pool, not tax-deductible)
createdAt / updatedAtDateAutoTimestamps