pierregillon / Bootstrap.WebApi

A scaffolding project to quickly warmup an API with solid practices and patterns

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bootstrap WebApi

Solution scaffolding to quickly bootstrap an API.

The idea is to provide a set of ready-to-use projects with code dependencies and examples. It is especilly useful and time saving when you already know the api is not just a CRUD component but but a component that will grow fast with complex domain code.

In DDD, the idea is to have 1 BC per service, but if you are challenging boundaries and not sure yet, it is preferable to keep all your code base in the same service. You can easily adjust this project to work with multiple bounded context.

Architecture

Domain code

  • Domain Driven Design to express domain with tactical patterns like aggregate, entities, value object, domain event, ...
  • Repository pattern

Api

  • Url versioning to avoid breaking changes on api evolution
  • Swagger to document and explore which end points are available
  • Problem details to normalize error management
  • Health check to provide routes exposing application state (/hc, /liveness)

Infrastructure

Testability

    [Theory]
    [InlineData(null)]
    [InlineData("")]
    [InlineData("  ")]
    public void Renaming_a_customer_requires_a_non_empty_first_name(string emptyFirstName)
    {
        Customer customer = A.Customer;

        var action = () => customer.Rename(emptyFirstName, "some last name");

        action
            .Should()
            .Throw<ArgumentException>();
    }
  • Acceptance tests using Specflow on top of api, in order to have human readable specifications
Scenario: Registering a new customer lists it
	When I register the following new customer
		| First name | Last name |
		| John       | Doe       |
	Then the customer list is
		| Full name |
		| John Doe  |
  • Integration by only annotating @Integration some of acceptance tests
@Integration
Scenario: Renaming a customer has his name well updated in the list
	When I rename the customer "John Doe" to "Albert Rose"
	Then the "John Doe" customer is now listed with full name "Albert Rose"

Image build and deployment

Observability

Feature flags

About

A scaffolding project to quickly warmup an API with solid practices and patterns


Languages

Language:C# 85.6%Language:HTML 11.0%Language:Gherkin 3.2%Language:Dockerfile 0.2%