The generated project implements Layered Architecture. Internal implementation uses CQRS principle to split query use cases from command use cases.
Supreme.Api: Responsible for showing information to user and interpreting user's commands.
Supreme.Application: Defines the jobs that project is supposed to do and directs expressive domain objects to work.
Supreme.Domain: Responsible for representing concepts of business, information about business situation and business rules.
Supreme.Infrastructure: Provides generic technical capabilities that support higher layers.
Supreme.Api.Tests: Provides you to add unit tests for API layer. It's up to you to enable integration tests at this layer.
Supreme.Application.Tests: Provides you to add both unit and integration tests for Application Layer. For integration tests currently TestContainers are being used. Depending on your choices, RabbitMQ, MySQL, PostgreSQL containers will be registered.
Supreme.Infrastructure.Tests: Provides you to add unit tests for Infrastructure Layer. It's up to you to enable integration tests at this layer.
PS: When you name your project Supreme will be replaced with the name of project.
-
DomainEvents, IntegrationEvents and outbox messaging can be used so as to have eventual consistency and strong consistency (requires enabled outbox pattern. Check Template Options).
-
You can add distributed rate limiting per endpoints. If you enable rate limiting, you can find rate limit types under Supreme.Api/Filters/RateLimits folder. Concurrent, Fixed Window, Sliding Window, Token Bucket rate limits are implemented. Currently, adding requests to queue when limit has been reached not supported.
[FixedWindowRateLimitFilter(policyKey: "foo", limit: 5, expireInSeconds: 60)]
[HttpGet("{id}", Name = "GetIndividualFoo")]
[ProducesResponseType(typeof(GetFooResponse), StatusCodes.Status200OK)]
public async Task<IActionResult> GetAsync([FromRoute] long id,
CancellationToken cancellationToken)
{
var query = FooMapper.MapFrom(id);
var result = await _mediator.Send(query, cancellationToken);
var response = FooMapper.MapFrom(result);
return StatusCode(StatusCodes.Status200OK, response);
}
-
You can enable open telemetry (Check Template Options).
-
You can define database by selecting one of the available options. (Check Template Options). Current options are PostgreSQL and MySQL. Default value is MySQL.
The basic template depends on below resources.
- .NET7
- MySQL or PostgreSQL (depending on your choice)
- Redis
If you would like to add outbox pattern functionality, you are required to have
- RabbitMQ
You can find docker images for above resources via here
First, install template
dotnet new install Supreme.Dotnet.Api.Template
Run
## dotnet new supremeapi [options] [template options]
dotnet new supremeapi -n "MyService" -eop -eot -erl -db mysql
Option | Description |
---|---|
-f, --framework | Currently net7.0 is supported. The default value is net7.0 |
-eop, --enable-outbox-pattern | Enables outbox pattern by using CAP |
-eot, --enable-open-telemetry | Adds open telemetry configuration with Jaeger support |
-erl, --enable-rate-limiting | Adds basic rate limiting action filters that uses Redis behind |
-db, --database | The target database. mysql and postgres are supported. Default value is mysql |
- Owner: @kapozade
- Ardalis.Specification
- EasyCaching
- FluentValidation
- DotNetCore.CAP with RabbitMQ and MySQL or PostgreSQL (depending on your choice)
- MediatR
- Npgsql.EntityFrameworkCore.PostgreSQL
- OpenTelemetry
- Pomelo.EntityFrameworkCore
- Scrutor
- Serilog
- StackExchange.Redis
- Swashbuckle
- Testcontainers
- Icon created by Austin Andrews from pictogrammers.com