Docs

Data Model

High-level overview of the core Betterstore database domains.

The canonical schema lives in @repo/database. Application code should treat the schema and existing behavior as the source of truth.

Core domains

DomainExamples
Auth and organizationsusers, sessions, members, invitations, organizations
API accessAPI secrets and organization/testmode context
Catalogproducts, variants, options, images, collections
Customerscustomers, addresses, segments
Checkout and orderscheckout sessions, orders, refunds, disputes
Pricingdiscounts, markets, taxes, subscriptions
Operationsinventory, reserves, locations, shipping profiles
Financepayouts and Stripe account status

Test mode

API and platform logic commonly carries organization and testmode context. Keep testmode behavior intact when moving code between apps or packages.

External side effects

Be careful around flows that call external systems:

  • Stripe customer, Connect account, payment, payout, and checkout logic.
  • Email and invitation delivery.
  • Cloudinary image uploads.
  • Shipping provider integrations.
  • Inventory reservations and fulfillment updates.

These flows should be validated with targeted tests and local smoke checks before refactoring.

On this page