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
| Domain | Examples |
|---|---|
| Auth and organizations | users, sessions, members, invitations, organizations |
| API access | API secrets and organization/testmode context |
| Catalog | products, variants, options, images, collections |
| Customers | customers, addresses, segments |
| Checkout and orders | checkout sessions, orders, refunds, disputes |
| Pricing | discounts, markets, taxes, subscriptions |
| Operations | inventory, reserves, locations, shipping profiles |
| Finance | payouts 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.