In part 1 of this series, we had learned what CQRS is and what architecture style we can build just by applying this simple principle.
Before we dive into the code of simple domain problem, we need to learn few terms used in Domain Driven Design (DDD):
- Domain: the business domain, which describes the problem that the solution is trying to solve.
- Bounded Context: The term bounded context comes from Eric Evans’ book. In brief, Evans introduces this concept as a way to decompose a large, complex system into more manageable pieces; a large system is composed of multiple bounded contexts. Each bounded context is the context for its own self-contained domain model, and has its own ubiquitous language. You can also view a bounded context as an autonomous business component defining clear consistency boundaries: one bounded context typically communicates with another bounded context by raising events.
- Context Map: According to Eric Evans, you should “Describe the points of contact between the models, outlining explicit translation for any communication and highlighting any sharing.” This exercise results in what is called a context map, which serves several purposes that include providing an overview of the whole system and helping people to understand the details of how different bounded contexts interact with each other
- Aggregate: is a pattern in Domain-Driven Design. A DDD aggregate is a cluster of domain objects that can be treated as a single unit. An example may be an order and its line-items, these will be separate objects, but it’s useful to treat the order (together with its line items) as a single aggregate.
- Aggregate Root: it is one of the aggregate component objects, where any reference from outside the aggregate should only go to the aggregate root. The root can thus ensure the integrity of the aggregate as whole.
Aggregates and Process Manager
In this sample, we’ll implement simple reservation process where the reservation consist of the following steps:
- User picks number of seats to reserve and time of reservation.
- Order is created with line items represent the seats to be reserved.
- Seats reservation then check the availability of selected seats and then accept the reservation or reject it based on the availability.
- The user gets the confirmation and asked for payment.
- The user has to complete the payment within 10 minutes otherwise, the reservation will be canceled automatically.
- Once the payment is completed, then the reservation is completed and the process ends.
The following diagram illustrates the aggregates and process manager for the selected process:

In the next part, we’ll have a look into the solution structure and the implementation details.
Preparing the development Environment
- Install Visual Studio 2015 Community Edition.
- Install RabbitMQ, erlang OTP, and enable management plugin.
- Install MySQL and MySQL workbench.
- Install MongoDB.
