A
📖 Wiki
中

What is the layered architecture of DDD?

🎯 DDD 6 min read 73 views Updated 2026-09-30 🤖 机器翻译

Introduction

"What does the layered architecture of DDD look like?"It seems basic, but in fact, it contains many details. The following will be presented in a way that prioritises the conclusions.

Core Analysis

DDD's layered architecture is a four-layer architecture, consisting of the following layers from top to bottom: the user interface layer, the application layer, the domain layer, and the infrastructure layer.

1685861039102-25f6a7a4-2c2a-4f05-a775-99079935332e.png

The calling relationship between layers is that the upper layer can call the lower layer, i.e., the user interface layer can call the application layer, the domain layer and the infrastructure layer. The application layer can call the domain layer and the infrastructure layer, and the domain layer can call the infrastructure layer.

However, reverse calls from the bottom up are not allowed, and there is a strict unidirectional call dependency relationship between the various layers.

In addition to this simple four-layer architecture, DDD also has the more typical onion architecture and hexagonal architecture.

The onion architecture is an architectural form that, like an onion, consists of layers from the outside to the inside, as shown in the figure below:

1685861299754-4524e227-7f8d-4f7f-b466-2d20fdea61a1.png

Its dependency relationship is from the outside to the inside.

The hexagonal architecture is somewhat similar to the onion architecture, except that it is not circular but hexagonal:

1685861346529-f22178f9-944f-4b3b-a9c3-4fc2ed9577ea.png

Although the architectural models of DDD layered architecture, Clean Architecture, and Hexagonal Architecture are presented differently, the design philosophies of these three architectural models are all perfect embodiments of the principles of high cohesion and low coupling in microservices architecture, and are all design philosophies centred around the domain model.

1685861394105-ef041ab6-8d33-416b-9617-44a263ef1d62.png

Summary of Key Points

  • The layered architecture of DDD is a four-layer architecture, which, from top to bottom, consists of the user interface layer, the application layer, the domain layer, and the infrastructure layer.
  • The application layer can call the domain layer and the infrastructure layer, and the domain layer can call the infrastructure layer.

由站内小编编辑整理

Related