Skip to main content

Domain: billing

Curated entry point for the billing bounded context.

Owner

Founder + agents (Phase 1).

Mission

Owns money flowing in to Astrix Trading: Stripe integration, evaluation purchases, instant-funded purchases, subscriptions, resets, refunds, coupon redemption, fraud signals, and invoice generation. Boundary: billing owns the cash-in side of the ledger; account-state changes triggered by purchase live in accounts; cash-out flows live in payouts.

Code paths

  • Application code: apps/api/src/modules/billing/
  • Domain logic (pure): packages/domain/pricing/
  • Contracts: packages/contracts/api/billing.ts, packages/contracts/events/billing.ts
  • External clients: packages/clients/stripe/
  • Database schemas owned: billing (Charge, Subscription, Invoice, Refund, Coupon, FraudSignal, StripeWebhookEvent)

PRD chapters that touch this domain

TDD chapters

(Empty - will populate as TDDs arrive.)

ADRs that affected this domain

Service interfaces this domain exposes

export interface BillingService {
// createCheckoutSession(userId, productId, couponCode?): Promise<CheckoutSession>
// handleStripeWebhook(payload, signature): Promise<void>
// refundCharge(chargeId, reason): Promise<Refund>
// listInvoices(userId): Promise<Invoice[]>
// applyCoupon(code, productId): Promise<DiscountedPrice>
// (full surface defined during billing TDD)
}

Events this domain produces / consumes

DirectionTopicTriggered by
producesbilling.payment.completedSuccessful Stripe charge
producesbilling.payment.failedFailed / declined charge
producesbilling.refund.processedRefund issued
producesbilling.subscription.updatedSubscription state change
producesbilling.fraud.flaggedStripe Radar / our fraud signal
consumesaccounts.account.state_changedTriggers reset eligibility / refund evaluation

External integrations

Runbooks for this domain

(Empty - will populate when alerts are defined in Section 17.6.)

On-call

To be filled in Section 17.6.

Cross-domain dependencies

  • This domain calls: identity (actor lookup), accounts (post-purchase account provisioning).
  • This domain emits events consumed by: accounts (provision on payment.completed), audit (every payment event), notifications (receipts, refund confirmations), admin (revenue dashboards, support-side refund tooling).