In this article, I am going to discuss what architecture can ideally integrate with DDD and how it works. To achieve this goal, I am going to walk through the features, pros, and cons of the MVC architectural pattern, 3-tier architecture, 4-tier architecture, 5-tier architecture, and hexagonal architecture. You might want to read my previous post to better understand the concept of the coming sections.
Previous post
Three-tier architecture

It’s a simple layered architecture. Most projects can apply it. We can integrate it with the MVC Architectural Pattern.
Why do we need architecture layers?
All logical implementations are tightly coupled in a package, which undoubtedly brings a heavy maintenance cost and has poor scalability.
The layered architecture design aims to help us achieve high cohesion, low coupling, scalable, and reusable design. We can segregate responsibilities and limit change impact within each layered. However, it is a misunderstanding that having more layers brings more benefits to a system. Fewer layers mean that a workflow traverses less logic and less overhead to do so. We need to balance the trade-off to have a practical layer design.
There are two main types of layered architectures:
- Strictly layered architecture, which only allows interaction with the layer below.
- e.g. an upper presentation layer is only allowed to interact with the business logic layer below it.
- Relaxed layered architecture, it allows a layer to interact with any layers below it.
What should we do as architects?
As architects, we need to define standards that other engineers follow. We will need to document them and have all associated engineers’ awareness of them so that they won’t break the design during implementation. Documentations are essential here. If we only notify engineers in a verbal manner, people would forget over time and take them less seriously.
Four-tier architecture
To better fit the business and implement our domain-driven design, layered architecture design can help to highlight the benefits of the domain model concept. However, as we can see from the three-tier architecture, the database is its starting point, which engineers generally start with database modeling, and DDD’s focus is not on the database model, but on the domain model concept. It takes domain models as the basis for analysis to design architecture hierarchy.
What is the DDD solution for this?
Eric Evans provided a traditional four-tier architecture as the DDD solution in his book, Domain-Driven Design: Tackling Complexity in the Heart of Software.

It is a Relaxed layered architecture.
We can have the following interaction:
- User Interface –> Application, Domain, and Infrastructure
- Application –> Domain and Infrastructure
- Domain –> Infrastructure
Five-tier Architecture
Let’s take a look at the popular MVC Architectural Pattern.
MVC Architectural Pattern
Model–view–controller (MVC) is a software architectural pattern commonly used for developing user interfaces that divide the related program logic into three interconnected elements.
Wikipedia
It’s highly recommended by the Spring ecosystem. However, it has certain inherent defects.
What are the problems of MVC Architectural Pattern?
- There’s implementation redundancy across various layers.
- Human has the tendency to seek shortcut. MVC pattern itself doesn’t stop developers from writing business logic on Controllers, which brings redundancy across the controller layer and other layers. It is a prevalent issue that occurs during development.
- As more logic putting into controllers, they become complicated over time.
- Controllers are heavily dependent on models. In terms of cross-layer interaction, Controllers are strongly dependent on services while services are heavily dependent on Daos. Models play the intermediate medium role during the interaction. This means that model prototypes need to be as simple as possible.
- Objects are coupled together. For example, while we send a query request to a controller, a user object is passed to an order object.
- It neither complies with object-oriented programming principles nor domain-driven design principles. It’s the Anemia Mode. Roles objects(referred to as domain objects in DDD) only contain get and set methods. MVC is inherently in conflict with DDD in design, where DDD emphasizes the domain concept and behavioral interaction between roles/entities.
- MVC is more of a structural design pattern, while DDD is more of a behavioral design pattern.
What can we do to improve the MVC pattern?
The DCI(Data, Context, and Interaction) Architecture Pattern
Trygve Reenskaug, the inventor of MVC
James O. Coplien, author of Multi-Paradigm Design for C++
Trygve and James together invented and refined the formulation of DCI architecture. It’s complementary to the MVC pattern. It perfectly fits the domain-driven design.

The DCI architecture design in the above diagram has the physical separation of models and behaviors. Data objects are static objects which don’t possess any business logic and only contain the get, set, and some basic behaviors, such as sorting and pagination. It’s the Anemia Model. In addition, users’ behaviors and actions are extracted to those RoleObjs. They have a two-way binding relationship. As both a role object and a data object have their own boundaries, binding them together forms another boundary. As a result, we achieve high cohesion within the boundary.
The context layer is a simple and thin layer working as an interaction entrance. It is responsible for business scenario aggregation and carrying out interactions between contexts.
An e-commerce example of how DCI takes the benefit from both the anemia model and congestion model.
Let’s take a look at a product order workflow.

In an SOA or Microservices architecture, we generally have the order, product, and user modules for the above actions. Each of them contains related classes with some associated methods.
We normally have the following two approaches to handle this workflow:
- We aggregate behaviors, across several subdomains, in the current domain or specific service, e.g., a business middle platform. It’s an anemia model. Domain objects only contain some get, set, and basic methods. It’s simple and suitable for fast development.
- Domain models contain all associated objects’ behaviors to complete the business chain. It’s a congestion model. Domain models have lots of complicated both innate and non-innated behaviors. They might also cover some behaviors that belong to other domain models. It’s hard to define the abstract layer. As the business chain might involve interactions between several modules, data relations could be complicated, and it would be hard for us to define repositories and behavioral boundaries. It requires our dev team with robust skills and experiences in the domain and techs to manage it.
Both the anemia and congestion model have their pros and cons in scenarios like this. We can apply the DCI architecture pattern to put behaviors into those Role objects and data belonging to the same data boundaries into data objects.
Finally, we achieve the following benefits with the DCI pattern:
- Physical segregation and reference between Role objects and data objects to achieve high cohesion and loose coupling between data and behaviors;
- Resolve the issue of inconsistency between data and behaviors.
As we can see, the DCI architecture pattern is more flexible compared to the MVC pattern. It serves better for domain-driven design as it fits domain models better. We can practice domain-driven design by applying the DCI architecture design paradigm with Four-Color Modeling, an approach to analyzing requirements.
After we introduce the DCI architecture design pattern into 4-tier architecture, we have the following 5-tier architecture.
Five-tier Architecture — the derivative of the integration of the DCI architectural pattern and 4-tier architecture

It’s a Relaxed layered architecture. If business scenarios have complicated logic and interactions, we can also divide the domain layer into two adjacent layers, e.g., a transactional management layer and a context layer. The transactional management layer is responsible for the business logic chain execution while the context layer takes care of atomic action, such as a single synchronization message or roles’ interactions. As a result, we will have a six-tier architecture, which is also a variant form of five-tier architecture.
Six-tier Architecture

It is also a Relaxed layered architecture.
However, we might encounter system breakdown if there is infrastructure failure occur where no matter whether our architecture is strictly layered architecture or relaxed layered architecture. Also, in a strictly layered architecture, the upper layers break down if the layers below them malfunction.
How can we solve this problem?
We can apply the Dependency Inversion Principle to resolve this issue. The upper layers shouldn’t depend on the concrete implementation of the lower layers. Instead, they should rely on lower layers’ abstractions or interfaces. Also. the concrete implementations should also depend on abstraction.

There’s a more elegant architectural style, i.e., Hexagonal Architecture.
Hexagonal Architecture

Alistair Cockburn, one of the initiators of the agile movement in software development, invented the Hexagonal Architecture.
We can also call it ports and adapters architecture. It is a strictly layered, highly cohesive, and flexible architecture.
Features:
- Domain Model: Core business logic
- Public APIs: The internal application exposes public APIs for outer layer usage.
- Two types of Adapters:
- Driving Adapters are responsible for clients’ inbound requests.
- Driven Adapters are responsible for outbound interactions, e.g., interaction with a Redis cluster.
- Each adapter is paired with specific usage. (Single Responsibility Principle)
- Interactions are strictly through APIs but not code implementation, i.e., concrete application layer implementation must not occur in the domain model.
Conclusion
We’ve looked at features of various architectural styles.
Again, we use technology to empower business. Tech is supposed to be driven by business requirements, and so do architecture design. Having more tiers doesn’t mean it’s better to serve our software system and development. We should design software architecture based on business scenarios. We need to consider the trade-off between the clear responsibility of multi-tier architecture and its cost. We need to avoid over-design.
If you are interested in DDD, I suggest you also take a look at four-color modeling and event storming.
If I have time, I might write more articles about other architectural styles and how we practice DDD with implementation and project structure.
If you have any career or business opportunities to share with me, please contact me through LinkedIn.





