.NET 8 · MongoDB · ErrorOr · Minimal API

Skip the boilerplate.
Ship your API today.

A production-ready .NET 8 Minimal API starter with clean architecture, dual pagination, global error handling, and a fully extensible repository layer — ready to run in one command.

One-time payment  ·  Unlimited projects  ·  Lifetime access

.NET 8 Minimal API
MongoDB + Docker
ErrorOr result pattern
Cursor + offset pagination
RFC 7807 error responses
Full XML documentation

Everything you need.
Nothing you don't.

🏗️

Extensible Repository Layer

BaseRepository with 7 overridable hooks for validation and mapping. Add a new resource in minutes without touching the core CRUD logic.

ErrorOr Result Pattern

No exceptions for control flow. Every operation returns ErrorOr<T> — errors propagate cleanly through the entire stack from the database up to the HTTP response.

📄

Summary / Detail Split

List endpoints return a lightweight SummaryResponse. Single-item endpoints return the full DetailResponse. Smaller payloads, cleaner contracts.

🔄

Dual Pagination

Offset pagination for back-office UIs with page numbers. Cursor pagination for feeds and large collections — O(log n) via MongoDB _id index, consistent under concurrent writes.

🛡️

Global Error Handler

Every unhandled exception is caught and converted to an RFC 7807 ProblemDetails JSON response with trace ID. No stack traces leaked to the client.

🐳

Docker + Compose

API and MongoDB spin up together with one command. Health-check-gated startup — the API waits for MongoDB to be ready. No race conditions, no manual setup.

❤️

Health Checks

Liveness probe at /health/live and readiness probe at /health/ready (checks MongoDB). Drop-in for Kubernetes or any load balancer.

📖

Full Swagger + XML Docs

Every endpoint, model, error, and parameter is documented with XML comments wired into Swagger UI automatically. Open /swagger and everything is already there.

Override only what you need.

BaseRepository handles all CRUD logic. You override the hooks that matter for your domain — everything else runs automatically.

Each hook returns ErrorOr<T> so any failure aborts the operation cleanly before the database is touched.

  • OnValidateCreateAsync — uniqueness, ranges, business rules
  • OnMapCreateAsync — server-side fields: slugs, tenant IDs
  • OnMapToDetailAsync — build the full single-item response
  • OnMapToSummaryAsync — build the lightweight list response
  • OnValidateUpdateAsync — validate the fully merged entity
  • OnMapUpdateAsync — recompute derived fields on update
  • OnValidateDeleteAsync — guard against invalid deletions
ProductRepository.cs
protected override Task<ErrorOr<Product>>
    OnMapCreateAsync(
        ProductCreateRequest request,
        Product entity,
        CancellationToken ct)
{
    // Slug is server-side — never from the client
    entity.Slug = ToSlug(request.Name);
    return Task.FromResult<ErrorOr<Product>>(entity);
}

protected override Task<ErrorOr<ProductDetailResponse>>
    OnMapToDetailAsync(
        Product entity,
        CancellationToken ct)
{
    var response = ProductDetailResponse.From(entity);
    // Computed at response time — never stored in DB
    response.FormattedPrice = $"€{entity.Price:F2}";
    return Task.FromResult<ErrorOr<ProductDetailResponse>>(response);
}

Two strategies. One kit.

Offset

Page-based pagination

Classic page 1, 2, 3 navigation. Returns totalCount, totalPages, hasNext, hasPrev. Ideal for back-office UIs and small-to-medium collections.

  • Jump to any page
  • Total count included
  • Familiar UX for admin panels
Cursor

Cursor-based pagination

O(log n) performance via MongoDB _id index. Consistent results even under concurrent writes. No degradation as your collection grows.

  • Scales without performance degradation
  • No duplicates under concurrent inserts
  • Forward and backward navigation

Simple, one-time pricing.

NET 8 Minimal API Starter Kit

35

One-time payment. No subscription. Yours forever.

  • Full source code
  • BaseRepository with 7 hooks
  • Offset + cursor pagination
  • Docker + docker-compose
  • Global error handler (RFC 7807)
  • Health checks (live + ready)
  • Swagger + full XML documentation
  • Unlimited projects
  • Entire team included
  • Lifetime access + future updates
Buy now — €35

Secure checkout via Lemon Squeezy  ·  Instant delivery by email

Common questions.

Is authentication included?

No — by design. Auth requirements vary too much across projects (JWT, API keys, OAuth, Keycloak). The kit gives you a clean, production-ready foundation and you add the auth layer that fits your project.

How many projects can I use this on?

Unlimited. One purchase covers you for as many projects as you want, for your entire team, forever.

What .NET version does this require?

The kit targets .NET 8. It uses Minimal API features introduced in .NET 7 and refined in .NET 8 — it will not run on older versions without changes.

Do I need Docker to run it?

No. Docker is included for convenience but the project runs fine with a local MongoDB instance — just configure the connection string in appsettings.json.

What do I receive after purchase?

A .zip file with the complete source code, delivered instantly to your email. Unzip, copy .env.example to .env, run docker compose up --build and you're running in under a minute.