# [Digital Core](../domain.md) ## Entities ### Account An Account is the running record of what a Customer holds and owes. Balances live here and transactions move them. Account is where a lot of businesses accidentally encode their product catalogue into a status column. Keeping the account generic and pushing the specifics onto Product and Agreement is what lets a new offering launch without a schema change. ```mermaid --- config: layout: elk --- classDiagram class Account{ * Account Identifier : string Account Number : string Account Type : enum~AccountType~ Account Status : enum~AccountStatus~ Opened Date : date Closed Date : date } Customer "0..*" --> "0..*" Account : holds Account "0..*" --> "1" Product : instance of Account "0..*" --> "1" Currency : denominated in ServiceLocation "1" --> "0..*" Account : serves class AccountType["Account Type"]{<>} class AccountStatus["Account Status"]{<>} class Customer["Customer"] class Product["Product"] class Currency["Currency"] class ServiceLocation["Service Location"] ``` ```yaml existence: independent mutability: slowly_changing temporal: tracking: valid_time description: > Account status moves back and forth — Active to Suspended and back again — and the dates of those moves matter. Valid time tracking supports questions like "was this account suspended when that charge was applied?". Opened Date and Closed Date are the outer boundaries of the account's life. attributes: Account Identifier: type: string identifier: primary description: > Globally unique identifier for this account. Immutable once assigned. Account Number: type: string description: > The account number as shown to the customer. Distinct from the identifier: this one appears on statements and can change if the account is renumbered during a migration. Account Type: type: enum:Account Type description: > What the account is for — billing, subscription, prepaid, wallet and so on. Different types behave differently: a prepaid account cannot go negative, a credit account can. Account Status: type: enum:Account Status description: > Current operational state. Suspension and closure are recorded with their effective dates so that history can be reconstructed. Opened Date: type: date description: > Date the account was opened. Starts the account's valid time period and feeds dormancy and tenure calculations. Closed Date: type: date description: > Date the account was permanently closed. Null means still open. Accounts are closed, never deleted — a deleted account orphans every transaction that referenced it. ``` ```yaml constraints: Closed Account Requires Closed Date: check: > Account Status != 'Closed' OR Closed Date IS NOT NULL description: > An account with status Closed must record when it closed. Closed Date After Opened Date: check: "Closed Date IS NULL OR Closed Date > Opened Date" description: > An account's closure date must be later than its opening date. ``` ```yaml governance: pii: false classification: Confidential retention: 7 years retention_basis: Domain default description: > An account is not personal data in itself, but balances and holdings are commercially sensitive and readily identify a customer through the holder relationship. Retained for seven years after closure to cover billing disputes and tax records. access_role: - CUSTOMER_SERVICE - DATA_ANALYST ``` ## Relationships ### Account Holds Product An Account is an instance of one Product definition. ```yaml source: Account type: references target: Product cardinality: many-to-one granularity: atomic ownership: Account ``` ### Account Denominated In Currency An Account is denominated in exactly one Currency. All balances and amounts on the account are expressed in it. ```yaml source: Account type: references target: Currency cardinality: many-to-one granularity: atomic ownership: Account ```