A sample code structure for a microservices +ddd (Domain driven design)

Source: Internet
Author: User

I was fortunate to have read many great gods on the realization of DDD, such as the landing of articles, learning more, benefited, in this recommendation:

Www.cnblogs.com/hafiz/p/9388334.html
78909897
Www.cnblogs.com/netfocus/archive/2011/10/10/2204949.html
6681253

The following reference to the structure of the official DDD, summed up the relevant experience of predecessors, and then based on their own micro-services and DDD learning and understanding, made a use of springcloud to build the most basic structural example. Personal Caishuxueqian, if there are similarities or inappropriate, hope that the big guys forgive me and help correct me.

First Classics, refer to the official architecture sketch, DDD overall structure is divided into four layers: Infrastructure (Basic implementation layer), domain (domain layer), application (Application layer), Interfaces (presentation layer, also called user interface layer or interface layer), The roles of each level are described below.

                        

                    

For the design of DDD, the most important thing is how to divide the domain and divide the boundary. In the code design, previously saw the big guy uses the module (Modules) to carry on the context demarcation and the division. Under

For the micro-service, it is very suitable from the business to divide the above each modules, divided the various business sectors.

MicroServices + DDD, the personal feel should be the first is from the perspective of micro-service (how to divide the micro-service) to consider to divide the large business module, each micro-service should be a separate deployment, the respective module;

In the actual development of micro-services, combining the idea of ddd to divide all of their own fields.

example, for me project, is a module has been divided into micro-service applications, code design is divided into infrastructure,domain,application,interfaces:

            

Infrastructure Layer: Basic implementation layer, providing common technical capabilities to other tiers (e.g., tool classes, third-party library classes, common basic configurations, data access underlying implementations)

Domain layer: Mainly responsible for the expression of business concepts, business status information and business rules, is the core layer of the entire system, almost all of the business logic will be implemented in this layer.

Application layer: Relative to the domain layer, the application layer is a very thin layer, the application layer defines the software to complete the task, to be as simple as possible.

Note: The inside and outside of the diagram, in the case of the program, in fact, from the presentation layer calls the application layer, the application layer calls the domain layer, the domain layer or call the basic implementation layer.

    

Interfaces layer: Responsible for displaying information and explaining user commands to the user, requesting the application layer to obtain the data that the user needs to show (such as obtaining the product data of the homepage)

   

Above, is the individual to micro-service +DDD code structure example, complete code see GITHUB.COM/EALENXIE/SPRINGCLOUD-MICROSERVICE-DDD

Thank you for your comments and support.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.