README.md

Introduction

This is Microservice Boilerplate repository. The Boilerplate is aimed to unify behavior among microservice implementations and avoid developer to duplicate infrastructural code. The repository contains 3 solutions:

  1. Boilerplate - contains basic Nuget libraries that are supposed to be published and re-used by all microservice instances that follows the Boilerplate;

  2. Boilerplate.BlaBlaBla - a typical microservice solution with synchronous and asynchronous contracts, relational database, integration tests;

  3. RestApi.Template - a Nuget library that allows to publish typical microservice solution as reusable dotnet template.

Technologies

  1. ASP.NET Core 8
  2. Entity Framework Core 8
  3. MediatR
  4. OpenApi + NSwag
  5. FluentValidation
  6. FluentAssertions
  7. xUnit
  8. Moq
  9. Respawn
  10. MassTransit

RestApi Template Solution Overview

Current solution follows Onion Architecture. More information about layers can be found below. With .NET core it’s now possible to create custom templates for any type of projects. Please read more on how to customize the template before starting.

Getting Started

Using dotnet new command

Suggested way to start development on new API is by using dotnet template:

  1. Install Azure Artifacts Credential Provider from the official page
  2. Install the template:

    dotnet new -i RestApi.Template --interactive --nuget-source https://pkgs.dev.azure.com/if-it/_packaging/Boilerplate/nuget/v3/index.json

    Same command can be used if template is already installed and needs to be updated to latest version.

  3. Create api from template:

    dotnet new rest-api -n [name of the project]

In Debug mode migrations are automatically launched during startup. So the only thing that developer needs to do in order to launch web api is press F5.

Presentation Layer (WebApi)

This layer is based on ASP.NET Core framework. Presentation layer-specific middlewares (MediatR, ProblemDetails) are configured via Boilerplate.Mvc. Persistence layer-specific Mvc filters are configured additionally via Boilerplate.Mvc.EntityFramework. Orchestration feature is supported by Boilerplate.Orchestration.

Application Layer

Contains all application logic. The layer wires up Domain & Persistence layers. Application logic is triggered through in-process messaging and MediatR.

Domain Layer

Contains DDD/Ef entities, DDD value objects, enumerators, exceptions, interfaces, types and logic specific to the business of the product.

Rich Domain model should be implemented with the following concepts in mind:

Persistence Layer

Contains description and configuration of EF Core DbContext through fluent validation. Uses domain model as a source for data model. Is based on the nuget Boilerplate.EntityFramework.

Typical Package Dependencies in Microservice

Typical Dependencies in Microservice

Описание

Пет-проект с реализацией проекта-шаблона для микросервиса с поддержкой синхронного и асинхронного взаимодействия, базы данных, интеграционных тестов, DDD.

Конвейеры
0 успешных
0 с ошибкой