Yuvaraj Velmurugan
Yuvaraj Velmurugan

Reputation: 123

Onion Architecture - what are the layers and where to place the services?

I am learning and working out a sample project applying onion architecture and domain driven design.

As per my understanding I have drafted a small presentation and attached as an image in this post.

I need clarifications on layers of onion architecture and its implementation. Could you explain based on my presentation?

enter image description here

Core Project:

Domain Layer - entities, value objects, aggregate root, domain exception objects.

Domain Service Layer - business logic contracts.

Infrastructure Service Layer - persistence contracts, repository contracts, email and sms contracts, domain events and integration events contracts.

Application Service Layer - orchestration of infrastructure and domain service interfaces for uses cases.

Indentity Project:

Web Api Layer - controllers, configuration, composition root etc.

Infrastructure Layer - persistence implementation, repository implementation, email and sms implementation, message queuing etc.

Where would I implement contracts of the domain service layer from core project?

Upvotes: 3

Views: 2514

Answers (2)

Julien Gavard
Julien Gavard

Reputation: 683

The Onion architecture is cut into these layers :

  • The core contains the business rules (in DDD, the Domain Model).
  • Around the core there is the Application layer.
  • Around the Application layer there is Port (IHM, REST...) and Adapter layer (Persistence, Messaging...).

In your exemple, you have two projects, each project is an onion with all layers.

In addition, don't forget to design/cut your Subdomains with the business expert views. Technical considerations are not a good way for this.

Upvotes: 4

ismaelcabanas
ismaelcabanas

Reputation: 104

Well, as I understand the Onion architecture, there is a domain layer that, in terms of DDD, includes aggregates, entities, value objects, repositories (interfaces) and domain services.

Then, the application service layer, that orchestrate the domain stuffs.

Then, the infrastructure layer and the last, the Web Api layer.

The rule here is a layer cannot use nothing from above layer.

Upvotes: 1

Related Questions