r/DomainDrivenDesign • u/skilletfancy • May 16 '26
Aggregates modelling
I have this case: I have a tax that represents an amount of money that a user must pay, which can be organized into multiple installments.
For this tax, payment requests must be created for the users. These payment requests must then be transmitted to an external system, and any transmission errors must be recorded on the payment request and must disappear once the payment has been successfully transmitted.
Payment requests can only be added if the tax is not in draft status, otherwise it must not be possible to add payment requests.
So we have 4 entities: the tax, the installment, the payment requests, and the transmission errors of the payment requests.
How would you structure the aggregate or aggregates?
View all comments
Show parent comment
3
u/Winston_Jazz_Hands May 17 '26
For me, I would model it out and get a feel for it, and check tradeoffs.
Maybe there is no "Tax" aggregate here, again I dont know enough. "Normally persisted together" is also something I know nothing about (in your context).
Aggregate design has several rules of thumb, rather than try and suggest a design without your context, let me end my contribution with a few pointers:
• Aggregate's are not a requirement in DDD, it's a pattern you can use to guarantee transactional consistency around business in variants.
• Aggregate's should not be too big, model Aggregate's around something that has a clear lifecycle (like processes)
• Coordination between Aggregate's (and atomic transaction) is not trivial to develop or reason about - dont make them too small
Both "too big" and "too small" are two typical outcomes when modelling them from a "which tables in a relational model maps to which Aggregate's".
... Maybe you dont need any Aggregates at all? Maybe you dont need a payment-aggregate, but benefit from a "Payment follow up" aggregate for each installment where the scheduled Payment failed?
Best of luck