A .Net Core 3.1
WebApi boilerplate / template project. Repositories, Swagger, Mapper, Serilog and more implemented.
The goal of this project is to be a kickstart to your .Netcore WebApi, implementing the most common used patterns and technologies for a restful API in .net core, making your work easier.
- Use this template(github) or clone/download to your local workplace.
- Download the latest .NetCore SDK and Visual Studio/Code.
- You may need a running instance of MsSQL, with appropriate migrations initialized.
- If you want, you can change the DatabaseExtension to use UseInMemoryDatabase, instead of Mssql.
- Go to the src/Boilerplate.Api folder and run
dotnet run
, or, in visual studio set the api project as startup and run as console or docker (not IIS). - Visit http://localhost:5000/api-docs or https://localhost:5001/api-docs to access the application's swagger.
- Run
docker-compose up -d
in the root directory, or, in visual studio, set the docker-compose project as startup and run. This should start the application, DB.and Redis cache (optional) - Visit http://localhost:5000/api-docs or https://localhost:5001/api-docs to access the application's swagger.
In the root folder, run dotnet test
. This command will try to find all test projects associated with the sln file.
- SwaggerUI
- EntityFramework Core
- Code quality ruleset
- AutoMapper
- Generic repository (to easily bootstrap a CRUD repository)
- Serilog with request logging and easily configurable sinks
- .NetCore Dependency Injection
- Resource filtering
- Response compression
- CI (Github Actions)
- Unit tests
- Integration tests
- Container support with docker and docker-compose
- Services
- This folder stores your apis and any project that sends data to your users.
- Boilerplate.Api
- This is the main api project. Here are all the controllers and initialization for the api that will be used.
- docker-compose
- This project exists to allow you to run docker-compose with Visual Studio. It contains a reference to the docker-compose file and will build all the projects dependencies and run it.
- Application
- This folder stores all data transformations between your api and your domain layer. It also contains your business logic.
- Domain
- This folder contains your business models, enums and common interfaces.
- Boilerplate.Domain.Core
- Contains the base entity for all other domain entities, as well as the interface for the repository implementation.
- Boilerplate.Domain
- Contains business models and enums.
- Infra
- This folder contains all data access repositories, database contexts, anything that reaches for outside data.
- Boilerplate.Infrastructure
- This project contains the dbcontext, an generic implementation of repository pattern and a Hero(domain class) repository.
- Remove/Rename all hero related stuff to your needs.
- Rename solution, projects, namespaces, and ruleset to your use.
- Change the dockerfile and docker-compose.yml to your new csproj/folder names.
- Give this repo a star!
- Finish implementation of integration tests
- Create an MSSQL DBcontext example
- Implement redis cache
If this template was useful for you, or if you learned something, please give it a Star! ⭐
This project has great influence of https://github.com/lkurzyniec/netcore-boilerplate and https://github.com/EduardoPires/EquinoxProject. If you have time, please visit these repos, and give them a star, too!
This boilerplate/template was developed by Yan Pitangui under MIT license.