DEV Community

Fmaes
Fmaes

Posted on Edited on AI-assisted

A .NET 10 Minimal API starter, so you can skip the boilerplate

Starting a new .NET API means spending hours on the same setup before you write the first useful line: authentication, error handling, validation, logging, Docker, tests and CI. I got tired of repeating it on every project, so I packaged it into a template and put it on GitHub for anyone who wants to skip that part.

Repo: https://github.com/Fmaes2/dotnet-minimal-api-starter

Who is this for?

  • People learning ASP.NET Core who want a small, working API to read, run and modify instead of starting from an empty project.
  • Developers who want to spin up a small side project quickly without rebuilding the same foundation again.

It's a starting point and a learning reference, not a production-ready base. More on that below.

What's inside

  • Minimal APIs organized by feature with MapGroup
  • ASP.NET Core Identity with JWT authentication
  • EF Core with PostgreSQL, migrations and paginated endpoints
  • FluentValidation through a reusable endpoint filter
  • Global error handling with ProblemDetails
  • Serilog logging to console and file
  • Unit and integration tests (xUnit, Moq, in-memory SQLite)
  • Dockerfile and docker-compose with a database healthcheck
  • GitHub Actions CI

A few decisions worth mentioning

Minimal APIs, but not a giant Program.cs. Each feature lives in its own file with an extension method, and a route group takes care of the shared pieces:

var group = app.MapGroup("/api/products")
    .WithTags("Products")
    .RequireAuthorization();

group.MapPost("/", Create).AddEndpointFilter<ValidationFilter<ProductRequest>>();
Enter fullscreen mode Exit fullscreen mode

The group applies the route prefix, the OpenAPI tag and the authorization requirement to every endpoint inside it, and the filter validates the request body before the handler runs.

Integration tests that don't need Docker. They run against in-memory SQLite, so dotnet test works on a fresh machine. The trade-off is that SQLite and PostgreSQL differ in small details, and the README says so.

Try it

docker compose up --build
Enter fullscreen mode Exit fullscreen mode

The README covers the local development flow too, and how to add your own entity by copying the products feature. The repo is MIT licensed and marked as a template, so you can use the Use this template button.

What it's not (yet)

I'd rather tell you now than have you find out later:

Update: product ownership is now implemented. Read how it works in the second post.

  • Anyone can register, and login attempts aren't limited. There's no lockout or rate limiting.
  • Tokens last 60 minutes with no refresh or revocation.
  • /health always answers "ok" without checking the database.
  • Endpoints talk to the DbContext directly. That's fine for a simple CRUD, but you'll want more structure as the business logic grows.

What would you add?

I'm deciding what to build next. If you've set up a .NET API recently, what took you the most time? Refresh tokens, roles, ownership checks, multi-tenancy, something else? Tell me in the comments or open a Discussion.

Top comments (0)