I've been searching online for any information relating to using both Domain Driven Design and Graph databases such as Neo4j, I've got to say there's not a lot of information to be had!
My main queries come in with the apparent overlap between the two, i.e. both graph databases and DDD model the domain, Graph databases however only hold state, not behaviour. I'm not really sure how to mix the two... how do I mix in the behaviour? Perhaps using domain services? Creating domain entities/values for each graph node seems a ridiculous way to add behaviour.
Any ideas?
They can co-exist in a way that graph databases are commonly used on the "read" side.
What people do sometimes is they apply CQRS to a given Bounded Context and use Graph DB for projections where it makes sense.
This depends on your bounded context and how you use the data.
data consuming bounded context:
You could use a domain service to hide technolegy details. There is a very good example in the famous dddsample. They use a RoutingService to seperate routing knowledge(evloved as routing bounded context) from cargo booking bounded context.
The implementation behind the domain service is probably even not developed using ddd. You could develop it in a graph database friendly way.
data producing bounded context:
CQRS may be a good solution to fix the gap between domain model and graph database. In this case, domain models are used to to produce calculated nodes and relationships.
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