-
Notifications
You must be signed in to change notification settings - Fork 4
Architecture
Clean Architecture is a software architecture intended to keep the code under control without all tidiness that spooks anyone from touching a code after the release. The main concept of Clean Architecture is the application code/logic which is very unlikely to change, has to be written without any direct dependencies. So it means that if I change my framework, database, or UI, the core of the system(Business Rules/ Domain) should not be changed. It means external dependencies are completely replaceable.
There are four layers of clean architecture,
In Clean architecture, the Domain and Application layers remain at the center of the design which is known as the Core of the system.

The Domain layer contains enterprise logic, entities, enums, models, exceptions, interfaces. Enterprise logic can be shared across many systems. Note that this layer will never depend on anything else.
The Application layer contains business logic, interfaces, CQRS features and types. The business logic will typically only be used within the system.
Core should not be dependent on data access and other infrastructure concerns so those dependencies are inverted. This is achieved by adding interfaces or abstractions within Core that are implemented by layers outside of Core. For example, if you wanted to implement the Repository pattern you would do so by adding an interface within Core and adding the implementation within Infrastructure. This is also known and DIP or Dependency Inversion Principle.
All dependencies flow inwards and Core has no dependency on any other layer. Infrastructure and Presentation depend on Core, but not on one another.
The Infrastructure layer contains classes for accessing external resources such as file systems, web services, SMTP, and so on. These classes should be based on interfaces defined within the Application layer. Whenever there is a requirement to communicate with an external source, we implement it on the Infrastructure Layer. For example, Database or other Services will be included here.