DDD Lite

The name of the DDD Domain Driven Design (DOMD) is well known, but very few projects have fully implemented DDD. Because DDD concept is complex, domain, subdomain, core subdomain, general subdomain, entity, value object, domain service, application service, domain event, context and so on a lot of concepts, directly confusing people, corresponding to the actual business model, the horizontal view of the mountain and the side of the peak, developers are difficult to reach a consensus.

Because DDD was originally designed as a solution for complex software, but most of our applications are not that complex, a simple application using such a complex set of concepts is a bit self-defeating. In the era of microservices, the design principle is to divide the context according to the domain, and the complexity of individual applications is greatly reduced. Microservices need a streamlined architecture.

Here I propose a lightweight DDD architecture: DDD Lite, to make it better fit with microservices.

Layered architecture is widely used in MVC, and DDD also has a variety of schools, such as four-tier architecture, five-tier architecture, hexagonal architecture and so on. DDD Lite uses a relatively simple four-tier architecture, from top to bottom:

  • Interface
  • Service
  • Model
  • Infrastructure



The interface layer.

Interports such as HTTP and RPC are provided externally. Logic such as parameter verification and codec is processed at this layer. Business status codes and external data structures are defined at this layer.


The service layer.

The main business logic layer, calling Model layer Repository interface to realize the domain business logic, transaction assembly. A Service corresponds to a domain, which is a grouping of similar business logic. A microservice usually has only one or two services, not too many.


Data model layer.

Define the data structure and the Repository interface corresponding to the data model, but do not contain the concrete implementation. The domain is composed of multiple related models. Here, the domain is simplified and no longer entangled with fine-grained concepts such as subdomain, entity and value object. Definition of Repository interface around Model, without mixing business logic, for the Service layer to call, facilitate the composition of transactions in the Service layer.

Repository pattern

Here’s a separate look at the Repository design pattern, which is the most important part of designing a good data model.

Repository pattern is to abstract the operation of data structure into interface, business logic (business logic) and data access (data access) separation, joined an abstraction layer.

With the Repository interface, the dependencies go from concrete to abstract, decoupling from base layer dependencies such as DB, and facilitating TDD (test-driven development) implementation.

The Repository interface should be fine-grained and designed to be generic enough to reduce business attributes and facilitate reuse.


Infrastructure layer.

Realize Model layer Repository interface, docking DB, MQ and other data persistence, or RPC remote call back-end services.

You can also provide a Repository Fake implementation for unit testing at the Service layer.


There are many methodologies in DDD, most of which you have seen or practiced in project engineering. However, the preconditions required by DDD are too ideal, such as domain experts and common language, etc., but they are too illusory and difficult to be implemented under the environment of migrant workers’ agile development, changing demands and 996 acceleration. So we do not need to copy everything, should be adapted to local conditions, to take the essence and discard its dross, refining suitable for their own application architecture. DDD Lite simplifies the design pattern of DDD, which is a summary and reflection of the author’s theory of DDD combined with practical engineering experience.

DDD Lite architecture is for personal understanding only, if you have ideas, welcome to exchange.

Complete project code: Win5DO/Go-MicroService-Demo (github.com)


DDD layered architecture: https://www.yyang.io/2015/12/31/DDD-and-Layered-Architecture/

Foreign leaders put forward the DDD Lite architecture: https://threedots.tech/post/ddd-lite-in-go-introduction/

Domestic bosses complete follow Go demo of DDD design, personal feel slightly cumbersome: https://github.com/agiledragon/ddd-sample-in-golang