Skip to content

dotnet new.NET 10 · Aspire 13 · PostgreSQL · Blazor

Clean Architecture the tests enforce.

Rich DDD aggregates, a hand-rolled command pipeline that returns Results instead of throwing, a transactional outbox, Aspire orchestration and a Blazor UI. The rules are written twice: as architecture tests, and as instructions an AI agent follows.

terminal
dotnet new install Trellis.Templates
dotnet new trellis -n Acme.Shop -o Acme.Shop
# the AppHost needs Docker running
cd Acme.Shop && dotnet run --project tools/Acme.Shop.AppHost

Trellis.Templates on nuget.org

Concentric rings: Domain and SharedKernel at the centre, Application around them, then Infrastructure and Persistence as two halves of one split ring, and Presentation outside.Concentric rings: Domain and SharedKernel at the centre, Application around them, then Infrastructure and Persistence as two halves of one split ring, and Presentation outside.
Dependencies point inward. Infrastructure and Persistence are peers that never reference each other.
  • Domain
  • Application
  • Infrastructure
  • Persistence
  • Presentation
11source projects in four rings
6test projects, unit to browser
13operations in the committed OpenAPI contract
31decision records with their why
5toggles; scaffold only what you need

What you get

Opinionated where it pays, open where it should be

Section titled “Opinionated where it pays, open where it should be”

Every card opens the page that explains the piece, rendered from the repository's own docs/.

A pipeline, no mediator

Commands and queries run through decorators: tracing, logging, validation, unit of work. Failures travel as a Result and reach the client as RFC 9457 problem details. A discarded Result fails the build. Paying an invoice is this whole handler:

PayInvoiceCommandHandler.cs
internal sealed class PayInvoiceCommandHandler(IInvoiceRepository invoices, TimeProvider timeProvider)
: ICommandHandler<PayInvoiceCommand>
{
public async Task<Result> Handle(PayInvoiceCommand command, CancellationToken cancellationToken)
{
Invoice? loaded = await invoices.GetByIdAsync(command.InvoiceId, cancellationToken);
return loaded.ToWrite(command.InvoiceId, command.ExpectedVersion)
.Bind(invoice => invoice.MarkPaid(timeProvider.GetUtcNow()));
}
}
src/Core/Trellis.Application/Features/Invoices/PayInvoice/PayInvoiceCommandHandler.cs, lines 7–17 at v0.2.0

See the architecture →

A rich domain, worked end to end

Aggregates created through Create(...) that returns a Result, value objects as sealed records mapped as EF complex types, hand-rolled strongly typed ids. The Invoices slice is the reference: create, issue, pay, void, list, with a receipt e-mail after the commit.

Invoice.cs
public Result MarkPaid(DateTimeOffset paidAtUtc)
{
if (Status != InvoiceStatus.Issued)
{
return Result.Failure(InvoiceErrors.NotIssued);
}
Status = InvoiceStatus.Paid;
PaidAtUtc = paidAtUtc;
Raise(new InvoicePaidDomainEvent(Id, CustomerEmail.Value));
return Result.Success();
}
src/Core/Trellis.Domain/Invoices/Invoice.cs, lines 142–153 at v0.2.0

Read the reference feature →

Outbox and idempotency

Domain events are written in the same transaction and dispatched after it, at least once, with per-handler checkpoints. Idempotency keys and strong ETags on the API.

The outbox decision →

Tests that hold the shape

Architecture tests pin the layer rules, integration tests run on a real PostgreSQL in Testcontainers, API tests go through the real pipeline, and a Playwright suite is one toggle away.

The testing page →

Built for agents too

AGENTS.md, path-scoped rules, skills for adding a feature or an integration, and a docs-drift gate in CI, so a person and an AI assistant read the same instructions.

Read the agent instructions →

Quick start

Forward slashes throughout; every command runs the same in bash, zsh and PowerShell.

  1. Install the template

    Needs the .NET 10 SDK (10.0.403 or later). Nothing else yet.

    Terminal window
    dotnet new install Trellis.Templates
  2. Create a solution

    Name it the way you would name the root namespace. Add toggles as you need them.

    Terminal window
    dotnet new trellis -n Acme.Shop -o Acme.Shop
    dotnet new trellis -n Acme.Tenants -o Acme.Tenants --use-multitenancy --use-redis --use-serilog
  3. Run it

    Needs Docker running. The AppHost starts PostgreSQL, applies the migrations, seeds the first administrator and opens the Aspire dashboard.

    Terminal window
    cd Acme.Shop
    dotnet run --project tools/Acme.Shop.AppHost

    Sign in with the seeded administrator named in the generated README, or walk the thirteen requests of Trellis.Api.http from the Try it section.

Options

Generated from template.json at build time, so it cannot drift from what dotnet new trellis --help prints.

OptionDefaultWhat it does
--include-uionInclude the Blazor web UI (UI.Common + UI.Web) and wire it into the Aspire AppHost.
--use-redisoffAdd a Redis-protocol distributed cache (HybridCache L2), Valkey by default, and wire it into the Aspire AppHost.
--use-serilogoffUse Serilog for structured logging (console sink) in the API and web hosts, alongside OpenTelemetry.
--use-multitenancyoffAdd a tenant seam: a tenant claim on the principal (ITenantContext), a TenantId shadow column and a "Tenant" EF query filter on every aggregate root. Regenerate the initial migration after enabling.
--include-ui-testsoffInclude a browser-driven UI test project (Playwright). Tests are opt-in at run time via RUN_UI_TESTS=1.
Concentric rings: Domain and SharedKernel at the centre, Application around them, then Infrastructure and Persistence as two halves of one split ring, and Presentation outside.Concentric rings: Domain and SharedKernel at the centre, Application around them, then Infrastructure and Persistence as two halves of one split ring, and Presentation outside.
  • Domain · SharedKernel
  • Application
  • Infrastructure
  • Persistence
  • Presentation

Architecture

The rule in one sentence

Dependencies point inward. The Domain knows nothing about EF, HTTP or DI; Application defines the ports; Infrastructure and Persistence are peers that implement them and never reference each other.

Grouped by ring on disk: src/Core, src/Infrastructure, src/Presentation, src/Shared. Features are vertical slices inside the layers. The architecture tests fail the build when a reference crosses the wrong way. Architecture →

Documentation

The pages are the files under docs/, read in place, each with an edit link back to the gated file.

Trellis is MIT-licensed. GitHub · Changelog · Contributing · Set in Geist and Geist Mono, served by this site (SIL Open Font License)

The documentation of Trellis.Templates 0.2.0 · release notes