Docs

Platform Architecture

Understand the Betterstore apps, packages, and request flow.

App ownership

Betterstore is split into focused apps:

  • apps/marketing serves public marketing pages, legal pages, blog pages, inquiry pages, and documentation.
  • apps/platform serves authenticated merchant and admin workflows.
  • apps/api serves Hono OpenAPI-backed API routes for products, collections, customers, auth, checkout, client checkout, utilities, and internal integrations.

The former combined web app has been retired. New public work should go to marketing, and new authenticated dashboard work should go to platform.

Shared packages

Shared packages hold cross-app behavior:

PackageResponsibility
@repo/databaseDrizzle schema, database clients, and generated types
@repo/uiShared design-system primitives and global styles
@repo/configApp, company, platform, marketing, and SEO configuration
@repo/stripeStripe integration helpers
@repo/shippingShipping profiles, locations, rates, and shipping logic
@repo/inventoryInventory and reservation behavior
@repo/discountsDiscount validation and application logic
@repo/fulfillmentFulfillment and payment-intent related flows
@repo/emailsTransactional email rendering and delivery helpers
@repo/observabilityLogging and monitoring integrations

Typical data flow

Most platform workflows follow this path:

UI or server component
  -> server action or feature module
  -> shared package or app database helper
  -> Drizzle query
  -> Neon/Postgres

Most public API workflows follow this path:

Hono route
  -> request validation
  -> handler
  -> service/query parser/domain package
  -> Drizzle query
  -> typed JSON response

Refactor expectations

When changing platform or API behavior:

  • Preserve route paths, response shapes, permissions, form validation, and payment semantics unless a behavior change is explicitly approved.
  • Prefer feature-by-feature migration and verification over large rewrites.
  • Add tests before refactoring checkout, discounts, shipping, fulfillment, inventory reservations, finance, or payout behavior.
  • Use shared design-system components for user-facing UI.

On this page