NLayer Architecture

DineConnect follows the principles of Domain Driven Design.There are four fundamental layers in Domain Driven Design (DDD):

Presentation Layer: Provides an interface to the user. Uses the Application Layer to achieve user interactions.

Application Layer: Mediates between the Presentation and Domain Layers. Orchestrates business objects to perform specific application tasks.

Domain Layer: Includes business objects and their rules. This is the heart of the application.

Infrastructure Layer: Provides generic technical capabilities that support higher layers mostly using 3rd-party libraries.

DineConnect Application Architecture Model
In addition to DDD, there are also other logical and physical layers in a modern architected application. The model below is suggested and implemented for DineConnect. DineConnect not only makes implementing this model easier by providing base classes and services.

Client Applications
These are remote clients that use the application as a service via HTTP APIs (API Controllers, OData Controllers, maybe even a GraphQL endpoint). A remote client can be a SPA (Single Page App), a mobile application, or a 3rd-party consumer. Localization and Navigation can be done inside these applications.

Presentation Layer
ASP.NET [Core] MVC (Model-View-Controller) can be considered to be the presentation layer. It can be a physical layer (uses the application via HTTP APIs) or a logical layer (directly injects and uses application services). In either case, it can include Localization, Navigation, Object Mapping, Caching, Configuration Management, Audit Logging and so on. It also deals with Authorization, Session, Features (for multi-tenant applications) and Exception Handling.

Distributed Service Layer
This layer is used to serve application/domain functionality via remote APIs like REST, OData, GraphQL... They don't contain business logic but only translate HTTP requests to domain interactions, or can use application services to delegate the operation. This layer generally includes Authorization, Caching, Audit Logging, Object Mapping, Exception Handling, Session and so on...

Application Layer
The application layer mainly includes Application Services that use domain layer and domain objects (Domain Services, Entities...) to perform requested application functionalities. It uses Data Transfer Objects to get data from and return data to the presentation or distributed service layer. It can also deal with Authorization, Caching, Audit Logging, Object Mapping, the Session and so on...

Domain Layer
This is the main layer that implements our domain logic. It includes Entities, Value Objects, and Domain Services to perform business/domain logic. It can also include Specifications and trigger Domain Events. It defines Repository Interfaces to read and persist entities from the data source (generally a DBMS).

Infrastructure Layer
The infrastructure layer makes other layers work: It implements the repository interfaces (using Entity Framework Core for example) to actually work with a real database. It may also include an integration to a vendor to send emails and so on. This is not a strict layer below all layers but actually supports other layers by implementing the abstract concepts of them.


Revision #1
Created 3 months ago by HM
Updated 2 months ago by HM