How should I structure my Actors in Akka persistent (Eventsourcing/CQRS) ?
I have these domain objects in my ecommerce application
So my question is how should I structure my Actors ? What are advantages and disadvantages of choosing one over the other specially in relation to an Ecommerce domain model ?
I think your question is more about the boundaries of your aggregates.
In any case, there should be NO hierarchical structure between aggregates. Aggregates should be independent from each other. No parent child relationship.
According to your description. There is a User Aggregate that can create stores and add products to it.
Store could be an apart aggregate that is initiated by the User aggregate. Note that the fact that an user can create a Store doesn't mean that they should have a parent/child relationship. It's more about access control. A Store is created by a user and only this user have right to add products to it.
However, Product seems to be a entity inside the Store aggregate.
Your fourth example, "Cart - A User can add any product from other User's stores into the Cart", reveals something totally different. You have two kind of users. Users that create and manage stores and consumers of a given store. They are not the same and they should be modeled differently.
Try to model the domain of your business without trying to reuse objects just because they are similar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With