Domain: billing
Curated entry point for the
billingbounded 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
02-business-model.md- pricing tiers, programs, unit economics05-commerce-purchase.md- purchase funnel, checkout, resets, refunds10-integrations.md- Stripe integration spec11-data-model.md- billing entities
TDD chapters
(Empty - will populate as TDDs arrive.)
ADRs that affected this domain
- ADR-0001 (transversally applies)
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
| Direction | Topic | Triggered by |
|---|---|---|
| produces | billing.payment.completed | Successful Stripe charge |
| produces | billing.payment.failed | Failed / declined charge |
| produces | billing.refund.processed | Refund issued |
| produces | billing.subscription.updated | Subscription state change |
| produces | billing.fraud.flagged | Stripe Radar / our fraud signal |
| consumes | accounts.account.state_changed | Triggers reset eligibility / refund evaluation |
External integrations
- Stripe - charges, subscriptions, refunds, Radar (fraud), tax (per Q-I in
docs/PRD/10-integrations.md)
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).