Dypso
Dypso

Reputation: 563

CQRS : Where are my aggregate roots?

I have a backoffice configuration system for bus operator and transportation products (currently CRUD oriented ). I need to perform the audit and keep track of the history of all the configuration parameters.
I think a CQRS approach could meet my needs. But I do not know how to model my domain? How to identify my root aggregates?

The system allows the transport network administrator to define a list of salable transport product. The system allows the transport network administrator to define the characteristics of media (card, badge, ticket and design ...) which will be sold on their product transportation. Networks can give rights to sell or to validate their respective products on other carriers. A network is operated by one or more operators who sell products or perform network transport on bus lines thereof. An operator must manage its equipment/machines (bus, avm). An operator also decides the list of products that should be send to a particular equipment software.

When an operator has configured the parameter list to be sent to his equipment, he started a process that will make available on an FTP site, varous files describing the settings/configuration made by the operator, and by others network administrators (list of rights to sell products and / validate between networks ...).

The system must allow to audit all changes and transpose settings on a server TEST.

I think I have : - A product aggregate root : with its properties, price etc... But then as a product could be referenced by others aggregates how do I handle changes for example when a product is evicted from the product catalog ? - An aggegate root per use case ?

That's like I said I'm not sure:   - If CQRS approach really fit?   - If yes, how do I designate my aggregates?

Upvotes: 0

Views: 387

Answers (1)

Codescribler
Codescribler

Reputation: 2305

Wow thats a big question. I think CQRS and Event Sourcing is a brilliant fit, especially if you need an audit log. However, you you can do event sourcing over CRUD. I've got an example on blog which you can find here Is a 100% Provable Audit Log Possible? – Hint, with Event Sourcing it Is and I’ll Show You How

Finding your aggregates is part process and part art form. The role of an aggregate is to encapsulate a 'bounded context' and ensure the invariants are maintained. You can use the invariants to help you find your aggregates. Without know the details of your domain it's hard to suggest what aggregates exist. I go into a lot more detail about how to build an aggregate (once you have worked out what they should encapsulate) again on my blog here. I hope that helps!

Upvotes: 1

Related Questions