Hack3rlife.ASP.NETCore.WebAPI
1.0.409
dotnet new install Hack3rlife.ASP.NETCore.WebAPI::1.0.409
Clean Architecture Template
The following solution template can be used for creating C# ASP .NET Core WebAPI using Clean Architecture Design Pattern Principles.
Frameworks, tools and techologies used
- ASP .NET Core 3.1
- MediatR
- FluentValidation
- FluentAssertions
- Moq
- Docker
- Lorem.Universal.NET
- Newtonsoft.Json
- xUnit
- Swashbuckle.AspNetCore
Getting Started
- Install Visual Studio
- Install the latest .NET 5 SDK | .NET 6 SDK
- Install .Net Core 3.1 SDK.
Local Installation
- Clone this repository in your computer in a local
<DIRECTORY>
(e.g.: C:\Users\hack3rlife\source\repos
). - Install the template by running the following command:
dotnet new <DIRECTORY>
. - Create a new directory (
e.g.: hack3rlife-cleanarchitecture
) andcd
into it. - Create a new solution by executing the following command
dotnet new -i CleanArchitectureNetCoreWebAPI -n <PROJECT_NAME>
.
NuGet Installation
- Execute
dotnet new -i Hack3rlife.ASP.NETCore.WebAPI
to install the latest version.- Execute
dotnet new -u Hack3rlife.ASP.NETCore.WebAPI
to uninstall the template.
- Execute
How the code is organized
The solution is organized in the following way
- BlogWebApi.WebApi.sln
| - README.md
| - src
| - BlogWebApi.Application
| - BlogWebApi.Domain
| - BlogWebApi.Infrastructure
|- BlogWebApi.WebApi
| - tests
| - Application.UnitTest
| - Infrastructure.IntegrationTests
| - WebApi.EndToEndTests
Domain Project
This project will include Domain Models, Interfaces that will be implemented by the outside layers, enums, etc., specific to the domain logic. This project should not have any dependecy to another project since it is the core of the project.
Domain Types
- Domain Models
- Interfaces
- Exceptions
- Enums
Application Project
This project will contain the application logic. The only dependency that should have is the Domain project. Any other project dependency must be removed.
Appllication Types
- Exceptions
- Interfaces
- DTOs
- Mappers
Infrastructure Project
The Infrastructure project generally includes data access implementations or accessing external resources as file sytems, SMTP, third-party services, etc. These classes should implementations of the Interfaces defined in the Domain Project. Therefore, the only dependency in this project should be to the Domain Project. Any other dependency must be removed.
Infrastructure Types
- EF Core Types
- Repository Implementation
WebAPI Project
This is the entry point of our application and it depends on the Application and Infrastrucre projects. The dependency on Infrastructre Project is requiered to support Dependency Injection in the Startup.cs
class. Therefore, no direct instantiation of or static calls to the Infrastucture project should be allowed.
WebAPI Types
- Controllers
- Startup
- Program
References
-
.NETCoreApp 3.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.