Understanding CQRS architecture - Part 2

In this post, we briefly outline the distinctions between the significant concepts of strategic and tactical patterns and elucidate how CQRS aligns with these paradigms.

Disclaimer

The concepts presented in this post are subjective and do not universally apply to all organizations.

Microservices have become a buzzword, and many organizations discuss them and aspire to transition to a service-oriented architecture. While the theoretical concept is compelling, and distributed architectures are envisioned to be transformative, the practical implementation is considerably more challenging. Why ? Because organizing an entire enterprise into well-defined silos is a complex undertaking.

What is strategic design ?

Strategic design, in the context of software architecture and microservices, refers to the high-level planning and organization of services within an application or system. It involves making decisions about how to structure and partition the application to align with the business domain and goals, focuses on creating a coherent and effective arrangement of services that reflects the business's needs and priorities and finally sets the foundation for the overall architecture of a system and directly influences how individual microservices are structured and interact with each other.

It requires a deep understanding of the business domain, collaboration with stakeholders, and a focus on long-term goals and scalability. The decisions made during strategic design significantly impact the success and maintainability of the microservices architecture.

Disclaimer

In DDD terminology, strategic design involves organizing the enterprise into bounded contexts. The relationships and interactions between different bounded contexts form the context map.

What is tactical design ?

Once these patterns are in place, initiating development becomes relatively straightforward, and each service can adopt its own architectural style.

Tactical design, in the context of microservices architecture, focuses on the implementation details and specific technical choices made at the level of individual services. It involves decisions related to the internal structure, communication mechanisms, and technology stack used within each microservice. Tactical design is more concerned with the practical aspects of building and maintaining a microservice.

Key aspects of tactical design in microservices include for example choosing architectural patterns and styles for individual services, such as RESTful APIs, event-driven architecture, or microkernel architecture, deciding on the data storage approach, including the type of databases used by each microservice and how data is persisted and retrieved, determining how microservices communicate with each other, whether through synchronous RESTful calls, asynchronous messaging, or other communication patterns and so forth.

What is CRUD ? What is CQRS ?

CRUD and CQRS are both tactical patterns, concentrating on the implementation specifics at the level of individual services. Therefore, asserting that an organization relies entirely on a CQRS architecture may not be entirely accurate. While certain services may adopt this architecture, it is typical for other services to employ simpler paradigms. The entire organization may not adhere to a unified style for all problems.

  • The CRUD architecture assumes the existence of a single model for both read and update operations. CRUD operations are typically linked with traditional relational database systems, and numerous applications adopt a CRUD-based approach for data management.

  • Conversely, the CQRS architecture assumes the presence of distinct models for queries and commands. While this paradigm is more intricate to implement and introduces certain subtleties, it provides the advantage of enabling stricter enforcement of data validation, implementation of robust security measures, and optimization of performance.

These definitions may appear somewhat vague and abstract at the moment, but clarity will emerge as we delve into the details. It's important to note here that CQRS or CRUD should not be regarded as an overarching philosophy to be blindly applied in all circumstances. On the contrary, the choice between them should be made carefully based on the specific characteristics and requirements of the microservices at hand. It is time now to see them in action.

Implementing a CQRS architecture in C# - Part 3