This repo is a .NET 8 Web API template. The primary way to use it is to run the PowerShell generator that copies the template into your own folder and replaces APITemplate with your project name.
- Install the .NET 8 SDK.
- Install PowerShell 7 (for macOS/Linux use
pwsh). - Run the generator from the repo root:
pwsh -File ./New-ApiProjectFromTemplate.ps1Follow the prompts for project name and destination path. The script will not create a subfolder; it copies directly into the destination folder.
A clean .NET 8 Web API template using MediatR, FluentValidation, and a Dapper-based infrastructure layer. The structure emphasizes a thin controller layer, a request/handler service layer, and a repository/DTO infrastructure layer. Model new endpoints after the existing Health flow.
- Install the .NET 8 SDK.
- Run the API:
dotnet run --project APITemplate.Application.APIThe default health endpoint is GET /api/health.
APITemplate.Application.API- Web API entrypoint (controllers, middleware).APITemplate.Application.CLI- CLI entrypoint.APITemplate.Core.Application- composition root (wires settings, services, infrastructure).APITemplate.Services- MediatR requests/handlers/response models.APITemplate.Infrastructure- repositories and DTOs (Dapper/Dapper.Contrib).APITemplate.Application.Settings- configuration models and appsettings.APITemplate.Core.Services/APITemplate.Core.Infrastructure- shared core utilities.APITemplate.Domain- domain entities (minimal by default).
- .NET 8
- MediatR (request/handler pattern)
- FluentValidation (input validation)
- Dapper and Dapper.Contrib (data access)
- Swashbuckle (OpenAPI/Swagger)
Controller -> MediatR Request -> RequestHandler -> Repository -> DTOs
Refer to AGENT.md for the precise folder structure and examples when adding new controllers, endpoints, services, or repositories.