A real-world example of CQRS with Event Sourcing
In this section, I’m going to provide a real-world example diagram of a banking system using CQRS with Event Sourcing. We’re going to focus on the bank account side. Take, for instance, a bank that has to do with opening accounts, depositing money, processing transactions, and closing accounts. To execute these tasks adequately, the bank puts into practice a system based on CQRS combined with Event Sourcing.
The following diagram shows how the system works:
Figure 2.11: Banking example using the CQRS pattern with Event Sourcing
Let’s break down this diagram in simple terms:
- Command: This is where you tell the bank what you want to do. For example,
OpenAccountCommand
is like walking into the bank and saying, “I want to open a new account.” These commands are part of the Bank Account Command API, which is just some fancy way of saying that this system understands...