Skip to content

xavierjohn/TrellisAspTemplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trellis ASP.NET Service Template

A dotnet new template for creating ASP.NET services using the Trellis framework with Railway-Oriented Programming (ROP) and Domain-Driven Design (DDD).

Getting Started

Install the template

dotnet new install Trellis.AspTemplate

Create a new service

dotnet new trellis-asp -n MyService --authorName "Your Name"

This creates a MyService/ directory with the full solution structure ready to build and run.

Build and test

cd MyService
dotnet build
dotnet test

Run the API

dotnet run --project Api/src

What's Included

Architecture

The template provides a layered architecture following DDD and CQRS principles:

Layer Project Purpose
Domain Domain/ Aggregates, entities, value objects — pure business logic with zero external dependencies
Application Application/ Commands, queries, handlers — orchestrates domain logic via CQRS (Mediator)
Anti-Corruption Layer Acl/ Repository implementations, external service adapters, EF Core — shields the domain from infrastructure
API Api/ Controllers, DTOs, middleware, composition root — thin HTTP layer

Each layer has src/ and tests/ projects.

Key Features

  • Railway-Oriented Programming — Errors are values (Result<T>), not exceptions. Business logic flows through composable pipelines using Bind, Map, Ensure, and Tap.
  • Domain-Driven Design — Value objects with TryCreate validation, aggregates with domain events, specifications for composable queries.
  • CQRS — Commands and queries separated via Mediator source generator.
  • Service Level Indicators — All API methods emit duration and status code metrics via ServiceLevelIndicators.
  • OpenTelemetry — Traces and metrics configured out of the box. Use the included Aspire Dashboard for local observability.
  • API Versioning — Date-based versioning with Asp.Versioning.
  • Copilot Instructions.github/copilot-instructions.md and .github/trellis-api-reference.md guide AI assistants to follow Trellis patterns.

Template Parameters

Parameter Description Default
-n / --name Service name (used for solution file, namespaces, assembly names) MyService
--authorName Author name in Directory.Build.props Your Name

Convention over Configuration for Resource Names

When deploying across multiple regions and environments, set RegionShortName and Environment to derive resource names automatically via EnvironmentOptions:

{
  "EnvironmentOptions": {
    "Environment": "test",
    "Region": "westus2",
    "RegionShortName": "usw2"
  }
}

About

Clean/Onion project layout using FunctionalDDD library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors