Enterprise grade microservice template with packagable common libraries extracted to the separate repo
- ASP.NET 5
- Packageable .NET template
- Clean architecture*
- WebApi with OpenApi and Swagger UI
- RabbitMq via MassTransit lib
- Grpc setup
- Logging with Serilog
- EF core code first
- EF on SaveChanges interceptor
- MediatR (for layers separation and atomic logic split)
- Cashing with Redis via IDistributedCache
- Automapping with Mapster (fastest and comfortable mapper in .net)
- Fluent Validation as MediatR pipeline step
- Open Telemetry, Tracing with Jaeger
- Exceptions handling with Fluent Results - wraps results and errors, so only unhandled exceptions means a problem
- HealthChecks for Readiness and Liveness probes
- Tests with WebApplicationFactory, xUnit, FluentAssertions, Moq and AutoBogus with providing dependencies as test params
- Packagable base libs with microservice settings (to update all microservices by pkg update)
- Packagable OpenApi.json communication contracts as NuGet (for easy microservices connect)
- Packagable RabbitMq communication contracts as NuGet (for easy microservices connect)
- Packagable Grpc proto files as NuGet (for easy microservices connect)
- Request context passing to subrequests
- Multi-tenancy support
- Template dummy logic with examples for all layers
- Docker file and ignore file
- git ignore
- NuGet config
- ReadMe for microservice
- ReadMe for template usage
- Editor config
- Local NuGet feed for effective development
TODO features:
- Metrics with Prometeus
- Authentication and Authorization
- Upgrade cashing using CacheTower library
- Add open telemetry traceId and spanId to logs for corellation
- Add logs viewer to docker compose
- Enable logs output to the test run output
- Static analyzer
- Automatic NuGet template packaging and publish on release
- Monitoring, definition of alerts for Devops, action item for support
- GitHub CI/CD workflows for microservices
- Dev data seeding
There are two options to install the template: from local files and via nuget package.
- Clone repo
- Get shell at repo root directory
- Run:
dotnet new --install ./Template-Service
- Download the nuget.exe and save for example at:
C:\W\nuget.exe
- Pack the template to NuGet package by the instructions provided in the .nuspec file
C:\W\nuget.exe pack .\Template-Service\Template-Service.Template.CSharp.nuspec -OutputDirectory C:\Temp -NoDefaultExcludes
- Install the template from the NuGet package to the dotnet to check it works
dotnet new --install C:\Temp\MiniService.Template.CSharp.VH.0.0.1.nupkg
- See "Using Template"
dotnet new --uninstall MiniService.Template.CSharp.VH
or when installed from repo (no need to reinstall when changed files)
dotnet new --uninstall C:\W\Service-Template\Template-Service
- Clone the repo where you want the template
- Ex Command:
dotnet new mst.vh -o ../My-Service --basename MyService
- Options:
- Output (required):
-o ./path/to/repo
- Base Name (required):
--basename {ServiceName}
- gRPC:
--add-grpc {true/false}
[default: true]