The MD-DDL model (domain, entities, enums, the Canonical Party product declaration) moves into its own repository, owned by the domain's modelling team. Engineering teams consume its product declarations and generate products from semprini-data-product-templates. Adds the MD-DDL agent wrappers (md-ddl init), pyproject with md-ddl, and README/CLAUDE.md describing the team split and the handoff interface. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
220 lines
6.5 KiB
Markdown
220 lines
6.5 KiB
Markdown
# [Digital Core](../domain.md)
|
|
|
|
## Entities
|
|
|
|
### Transaction
|
|
|
|
A Transaction is a movement of value between parties and accounts: the thing that actually happened. It carries the amount, the timing, the mechanism, and who was involved on each side.
|
|
|
|
Transaction is the busiest entity in the domain and the one most analytics is built on. It is append-only: a settled transaction is a historical fact and correcting it by editing the row destroys the audit trail. Reversals and adjustments are new transactions that reference the original.
|
|
|
|
```mermaid
|
|
---
|
|
config:
|
|
layout: elk
|
|
---
|
|
classDiagram
|
|
class Transaction{
|
|
* Transaction Identifier : string
|
|
Transaction Date Time : datetime
|
|
Settlement Date Time : datetime
|
|
Amount : decimal
|
|
Transaction Type : enum~TransactionType~
|
|
Transaction Channel : enum~TransactionChannel~
|
|
Transaction Status : enum~TransactionStatus~
|
|
Reference : string
|
|
}
|
|
|
|
Transaction "0..*" --> "1" Payer : has payer
|
|
Transaction "0..*" --> "1" Payee : has payee
|
|
Transaction "0..*" --> "0..1" PaymentInitiator : initiated by
|
|
Transaction "0..*" --> "1" Currency : denominated in
|
|
Transaction "0..*" --> "0..1" Account : debits
|
|
Transaction "0..*" --> "0..1" Account : credits
|
|
|
|
class TransactionType["<a href='../enums.md#transaction-type'>Transaction Type</a>"]{<<enumeration>>}
|
|
class TransactionChannel["<a href='../enums.md#transaction-channel'>Transaction Channel</a>"]{<<enumeration>>}
|
|
class TransactionStatus["<a href='../enums.md#transaction-status'>Transaction Status</a>"]{<<enumeration>>}
|
|
class Payer["<a href='./payer.md'>Payer</a>"]
|
|
class Payee["<a href='./payee.md'>Payee</a>"]
|
|
class PaymentInitiator["<a href='./payment_initiator.md'>Payment Initiator</a>"]
|
|
class Currency["<a href='./currency.md'>Currency</a>"]
|
|
class Account["<a href='./account.md'>Account</a>"]
|
|
```
|
|
|
|
```yaml
|
|
existence: dependent
|
|
mutability: append_only
|
|
temporal:
|
|
tracking: transaction_time
|
|
description: >
|
|
Transactions are append-only. Once settled they are never modified. Transaction time
|
|
records when the business captured the event. A reversal is a new record that references
|
|
the original identifier, so both the mistake and the correction remain visible.
|
|
attributes:
|
|
Transaction Identifier:
|
|
type: string
|
|
identifier: primary
|
|
description: >
|
|
Globally unique identifier for the transaction. Immutable once assigned. A reversal
|
|
carries its own identifier and names the original in its Reference.
|
|
|
|
Transaction Date Time:
|
|
type: datetime
|
|
description: >
|
|
When the transaction was initiated. This is the event time most reporting is grouped by.
|
|
|
|
Settlement Date Time:
|
|
type: datetime
|
|
description: >
|
|
When settlement actually completed. Often a different day from initiation, which is
|
|
why both are held — the gap between them is where reconciliation problems live.
|
|
|
|
Amount:
|
|
type: decimal
|
|
description: >
|
|
Value moved, in the denomination currency. Always positive: direction comes from the
|
|
payer and payee relationships, not from the sign. Signed amounts invite the bug where
|
|
a refund and a charge cancel out in a sum.
|
|
|
|
Transaction Type:
|
|
type: enum:Transaction Type
|
|
description: >
|
|
The mechanism the value moved by, such as card payment, direct debit or refund.
|
|
|
|
Transaction Channel:
|
|
type: enum:Transaction Channel
|
|
description: >
|
|
Where the transaction came from — web, mobile app, point of sale, contact centre.
|
|
Together with type this is the main dimension pair for behavioural analysis.
|
|
|
|
Transaction Status:
|
|
type: enum:Transaction Status
|
|
description: >
|
|
Current lifecycle state. Failed and cancelled transactions are retained: what did not
|
|
happen is often as informative as what did.
|
|
|
|
Reference:
|
|
type: string
|
|
description: >
|
|
Free-text reference supplied by the initiating party — an invoice number, a description,
|
|
or for a reversal, the identifier of the transaction being reversed.
|
|
```
|
|
|
|
```yaml
|
|
constraints:
|
|
Settlement After Initiation:
|
|
check: "Settlement Date Time IS NULL OR Settlement Date Time >= Transaction Date Time"
|
|
description: >
|
|
Settlement cannot precede initiation. Null settlement means the transaction has not
|
|
settled yet.
|
|
|
|
Settled Transaction Has Settlement Time:
|
|
check: >
|
|
Transaction Status != 'Settled'
|
|
OR Settlement Date Time IS NOT NULL
|
|
description: >
|
|
A transaction marked Settled must record when it settled.
|
|
|
|
Amount Must Be Positive:
|
|
check: "Amount > 0"
|
|
description: >
|
|
Amounts are always positive. Direction is carried by the payer and payee relationships.
|
|
```
|
|
|
|
```yaml
|
|
governance:
|
|
pii: false
|
|
classification: Confidential
|
|
retention: 7 years
|
|
retention_basis: Domain default
|
|
description: >
|
|
Transactions are not personal data on their own but reveal a great deal about a person
|
|
once joined to a party, so they are treated as confidential. Records are append-only and
|
|
are never modified or deleted; corrections are new records.
|
|
access_role:
|
|
- CUSTOMER_SERVICE
|
|
- DATA_ANALYST
|
|
- FINANCE
|
|
```
|
|
|
|
## Relationships
|
|
|
|
### Transaction Has Payer
|
|
|
|
A Transaction has one Payer: the party the value came from.
|
|
|
|
```yaml
|
|
source: Transaction
|
|
type: has
|
|
target: Payer
|
|
cardinality: one-to-many
|
|
granularity: atomic
|
|
ownership: Transaction
|
|
```
|
|
|
|
### Transaction Has Payee
|
|
|
|
A Transaction has one Payee: the party the value went to.
|
|
|
|
```yaml
|
|
source: Transaction
|
|
type: has
|
|
target: Payee
|
|
cardinality: one-to-many
|
|
granularity: atomic
|
|
ownership: Transaction
|
|
```
|
|
|
|
### Transaction Initiated By Payment Initiator
|
|
|
|
A Transaction may be initiated by a Payment Initiator acting on behalf of the payer.
|
|
|
|
```yaml
|
|
source: Transaction
|
|
type: references
|
|
target: Payment Initiator
|
|
cardinality: many-to-one
|
|
granularity: atomic
|
|
ownership: Transaction
|
|
```
|
|
|
|
### Transaction Denominated In Currency
|
|
|
|
A Transaction is denominated in exactly one Currency.
|
|
|
|
```yaml
|
|
source: Transaction
|
|
type: references
|
|
target: Currency
|
|
cardinality: many-to-one
|
|
granularity: atomic
|
|
ownership: Transaction
|
|
```
|
|
|
|
### Transaction Has Debit Account
|
|
|
|
The internal account value is taken from. Null when the paying side is external to the business.
|
|
|
|
```yaml
|
|
source: Transaction
|
|
type: references
|
|
target: Account
|
|
cardinality: many-to-one
|
|
granularity: atomic
|
|
ownership: Transaction
|
|
```
|
|
|
|
### Transaction Has Credit Account
|
|
|
|
The internal account value is paid into. Null when the receiving side is external to the business.
|
|
|
|
```yaml
|
|
source: Transaction
|
|
type: references
|
|
target: Account
|
|
cardinality: many-to-one
|
|
granularity: atomic
|
|
ownership: Transaction
|
|
```
|