Domain: accounts
Curated entry point for the
accountsbounded context.
Owner
Founder + agents (Phase 1).
Mission
Owns the trader-account lifecycle: provisioning evaluation accounts and instant-funded accounts; the account state machine (eval -> funded -> live); per-account configuration including the rules profile applied; the cash-and-equity ledger; and end-of-day balance computation. Boundary: accounts owns the account record itself and its lifecycle; rule evaluation lives in risk-engine; money in / money out lives in billing (in) and payouts (out).
Code paths
- Application code:
apps/api/src/modules/accounts/ - Domain logic (pure):
packages/domain/account-state/ - Contracts:
packages/contracts/api/accounts.ts,packages/contracts/events/accounts.ts - Database schemas owned:
accounts(Account, AccountConfig, AccountLedger, EodSnapshot, AccountStateTransition)
PRD chapters that touch this domain
02-business-model.md- account products, pricing, profit-split, unit economics05-commerce-purchase.md- account creation on purchase06-rules-risk-engine.md- account state on breach08-live-transition.md- graduation from sim-funded to Edge Live (real capital)11-data-model.md- core account 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 AccountsService {
// provisionAccount(userId, productId, paymentRef): Promise<Account>
// getAccount(accountId: string): Promise<Account>
// getAccountsByUser(userId: string): Promise<Account[]>
// applyStateTransition(accountId, transition: StateTransition): Promise<Account>
// getEodSnapshot(accountId, date): Promise<EodSnapshot>
// recordLedgerEntry(args): Promise<LedgerEntry>
// (full surface defined during accounts TDD)
}
Events this domain produces / consumes
| Direction | Topic | Triggered by |
|---|---|---|
| produces | accounts.account.created | New account provisioned |
| produces | accounts.account.state_changed | State machine transition (e.g., eval -> funded) |
| produces | accounts.account.eod_snapshot_taken | Daily EOD snapshot computed |
| produces | accounts.ledger.entry_recorded | Cash or equity ledger entry |
| consumes | billing.payment.completed | Triggers account provisioning |
| consumes | risk.evaluation.breach_detected | Triggers state transition to breached |
| consumes | payouts.payout.completed | Triggers ledger debit |
External integrations
- None directly; account state is internal.
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). - This domain emits events consumed by:
risk-engine(rule profile per account),audit(every state change),notifications(state-transition emails),admin(account dashboards),payouts(eligibility check).