Clean Architecture Structure
Component | Description |
---|---|
WebAPI | Web API providing HTTP Endpoints. |
Application | Contains the UseCases, Domain Model and the interfaces for the UseCase, Presenter and Repository. The
"Application" does not know anything about WebAPI or Persistence details.
Note: The Application Dependencies never point outwards its boundaries. The WebAPI and the Persistance Implementation are Plugins for the Application! |
Persistence Implementation | Implements the Repository Interface from "Application". Can use a Database Framework. |
Controller
The Controller takes the HTTP Request and transforms it into the UseCase Request. In a Queue based environment, this would be the listener receiving the message from the Queue.
UseCase Request
The UseCase Request is a data structure without any logic. It contains request data as a plain DTO (Data Transfer Object).
UseCase Interactor
The Interactor orchestrates the use case. It takes the data from the request, validates it, fetches the Entities from the Repository Interface, let the Entity execute the business rules, and save the Entities in their new states via the Repository Interface.
Entities
The Business Objects. Contain all the Enterprise Business Rules. When you like to do Domain Driven Design, this is the Domain Model (Aggregate Root, with Entities and Value Objects).
Repository Interface
Defines the interface on how to access and save data to the Data Source. Allows separation of frameworks and your application.
Response
The Response has all the response data. Its a basic data structure without any business logic.
Repository Plugin
Database Access Framework Implementation of your choice. Implements all the Repository Interfaces from your Application.
Database Model
The Database Model is the Data Access Object that represents the structure of the database. No business rules in here.
Presenter Implementation
Takes the Response and formats it to the desired form (ViewModel). For instance, if you have a DateTime object in your Response, the presenter would format the date into the desired string. The Presenter creates the ViewModel and passes it to the View or uses the HttpResponse to create a Response.