Clean.Lean.Architecture.WebApi.AspNetCore.Solution.Template
9.0.0
See the version list below for details.
dotnet new install Clean.Lean.Architecture.WebApi.AspNetCore.Solution.Template::9.0.0
Clean Lean Architecture Solution Template
Summary
The objective of this .NET Core template is to expedite the process for developers to swiftly establish a .NET Core Web API project that adheres to clean architecture principles.
This templates currently provides you the following out of the box :
- A dotnet core 9.0 solution built using clean architecture principles.
- Mediatr pipeline with logging, error handling and validation implemented as cross-cutting concerns
- FluentValidation for validating api inputs
- API integration with a 3rd party (https://jsonplaceholder.typicode.com) using HttpClient & Polly for retries.
- Efcore Sql Server implementation with localdb.
- An .editorconfig file for defining consistent code styles
- Husky pre-commit hooks that format code on git commit.
If you find this project useful, please give it a star on github. Thanks! ⭐
Prerequisites
- .NET 9.0 SDK (https://dotnet.microsoft.com/en-us/download)
- Optionally Visual Studio 2022 or above (https://visualstudio.microsoft.com/downloads/)
Getting Started
One of the most straightforward methods to begin is by installing this .NET template using your command line.
dotnet new install Clean.Lean.Architecture.WebApi.AspNetCore.Solution.Template
Once installed, create a new solution using the template.
dotnet new cla-sln --name YourSolutionName
Launch the app:
To launch your app, first move to the WebApi project in your solution.
cd <sln-name>\src\WebApi\
Then run the app
dotnet run
Looking at the command output you can see the app is running on https://localhost:7292
Open your browser and go to https://localhost:7292/swagger/ to view your api swagger file.
Configure Husky Pre-commit Hooks
Before installing husky, you will need to restore it.
dotnet tool restore
Also make sure you have initialized git at the root of your solution
git init
To install husky, run the following command from the root of your solution
dotnet husky install
You will then notice that whenever you commit your code, husky automatically runs dotnet format
to ensure your coding styles are consistent and fixes and issues for you. You can find the husky hook in the <root>/.husky/pre-commit
file
Configure Database
This solution uses EF Core with SQL Server localDB.
To switch with your SQL server connection string update the SqlServerConnectionString value in appsettings.json
, or alternatively you can continue to use localDB.
"Persistence": {
"SqlServerConnectionString": "Server=(localdb)\\mssqllocaldb;Database=clean-app-db;Trusted_Connection=True;MultipleActiveResultSets=true"
}
To run a database migration
dotnet ef migrations add "MyMigrationName" --project .\src\Infrastructure\ --startup-project .\src\WebApi\
To update your database with schema updates
dotnet ef database update --project .\src\WebApi\
Note that you might need to install dotnet ef tools first before you run db migrations and updates : dotnet tool install --global dotnet-ef
This package has 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.
Version | Downloads | Last Updated |
---|---|---|
9.1.0 | 220 | 11/22/2024 |
9.0.0 | 136 | 11/20/2024 |
8.3.5 | 459 | 4/27/2024 |
8.3.4 | 248 | 4/12/2024 |
8.3.3 | 190 | 4/2/2024 |
8.3.2 | 208 | 4/1/2024 |
8.3.1 | 223 | 4/1/2024 |
8.3.0 | 195 | 3/31/2024 |
8.2.1 | 543 | 3/9/2024 |
8.2.0 | 238 | 3/9/2024 |
8.1.0 | 960 | 2/9/2024 |
8.0.0 | 523 | 1/27/2024 |
0.5.0 | 3,247 | 10/2/2023 |
0.4.0 | 363 | 9/30/2023 |
0.3.0 | 333 | 9/21/2023 |
0.2.0 | 279 | 9/17/2023 |
0.1.0 | 245 | 9/13/2023 |
0.0.3 | 301 | 9/13/2023 |
0.0.2 | 288 | 9/11/2023 |
0.0.1 | 320 | 9/10/2023 |