SN Blog

How to build Enterprise Architecture for your next project?

☕ 5 min read 541

How to build Enterprise Architecture for your next  project?

Last a few weeks, I was thinking how can I build an enterprise architecture for my project so I searched a lot about it. There are many ways you can structure your app in effective way. You might have heard about All-in-one architecture, N-Layer Architecture, Microservices and so on. All of them are good in a certain situation but the architecture that I liked most is Clean Architecture.

  This pattern is proposed by Uncle Bob in his book as a way of building flexible and maintainable software solutions. So I decided to use and extend this template. The solution template consists of 5 layers. I will show you a C# implementation for ASP Net Core applications. You can find a link to the source code at the bottom of the page.

Core Layer

The Application Core holds the business model, which includes entities, services, and interfaces. These interfaces include abstractions for operations that will be performed using Infrastructure, such as data access, file system access, network calls, etc. Sometimes services or interfaces defined at this layer will need to work with non-entity types that have no dependencies on UI or Infrastructure. These can be defined as simple Data Transfer Objects (DTOs).

Infrastructure Layer

It typically includes data access implementations. In a typical ASP.NET Core web application, these implementations include the Entity Framework (EF) DbContext, any EF Core Migration objects that have been defined, and data access implementation classes. The most common way to abstract data access implementation code is through the use of the Repository design pattern.

Web Layer

The web layer in an ASP.NET Core MVC application is the entry point for the application. This project should reference the Application Core project, and it's types should interact with Infrastructure strictly through interfaces defined in Application Core. No direct instantiation of or static calls to the Infrastructure layer types should be allowed in this layer.

Tests Layer

This layer is for testing. Here you can test all others layers by writing both Unit Tests and Integrational tests. In this way you guarantee that your project has lower chance of bugs.

Common Layer

This layer is for global constants or files that are used in others layers.


Add a comment