/domain-message-flow-modelling

Design & visualise the flow of commands, events, and queries between your bounded contexts

Creative Commons Attribution Share Alike 4.0 InternationalCC-BY-SA-4.0

Domain Message Flow Modelling

Designing loosely-coupled systems requires more than carefully designed boundaries. Carefully defined interactions between bounded contexts is equally important for avoiding tight coupling as Stefan Tilkov articulates:

I think that for any given interaction triggered by some outside event – like e.g. a user clicking a button after entering data into a form – I’d end up touching maybe 3-5 of them [microservices].

A bounded context is a sub-system in a software architecture aligned to a part of the domain. It can be implemented as a microservice or a module within a monolith.

A Domain Message Flow Diagram is a simple visualisation showing the flow of messages (commands, events, queries) between actors, bounded contexts, and systems, for a single scenario.

alt text

How to Use

When you have an initial cut of your architecture - you have identified candidate bounded contexts - you can begin design the message flows.

Start by creating a list of of scenarios to model. And then for each scenario create a diagram

When creating a diagram, the typical flow is:

  1. Start with an actor/context/system
  2. Create the message they want to send
  3. Add the recipient of the message and a line connecting the sender and the receiver
  4. Place the message close to the line
  5. Repeat steps 1 - 4 until your scenario is complete

The message should contain 3 elements:

  1. The name of the message
  2. The significant data contained within the message
  3. The order in which the message occurs in the flow being modelled

Visualisation Tips

The number one problem with Domain Message Flow Diagrams, and diagrams in general, is too much information. Miller's Law is a good heuristic to use here. Aim to have between 5 and 9 messages on your diagram.

If you find that adding the data to each message is breaking your flow of progress, you can defer the data section of each message it until you have placed all of your messages.

Additional Resources

Contributors

Thank you to the following individuals who have all contributed to Domain Message Flow Modelling:

Domain Message Flow Diagrams are heavily inspired by:

Contributions and Feedback

The Domain Message Flow Modelling notation is freely available for you to use. In addition, your feedback and ideas are welcome to improve the technique or to create alternative versions.

Feel free to also send us a pull request with your examples.

CC BY 4.0

This work is licensed under a Creative Commons Attribution 4.0 International License.

CC BY 4.0