Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This is a **Clean Architecture template** for .NET 9 that demonstrates Domain-Dr
- Always use {} for blocks except single-line exits (e.g. `return`, `throw`)
- Always keep single line blocks on one line (e.g., `if (x) return y;`)
- Prefer primary constructors for required dependencies
- Never use primary constructor parameters directly - always assign to private fields for clarity and testability

### Core Dependencies Flow
- **Core** ← UseCases ← Infrastructure
Expand All @@ -22,7 +23,7 @@ This is a **Clean Architecture template** for .NET 9 that demonstrates Domain-Dr

### Key Projects
- **Core**: Domain entities, aggregates, value objects, specifications, interfaces
- **UseCases**: Commands/queries (CQRS), MediatR handlers, application logic
- **UseCases**: Commands/queries (CQRS), Mediator handlers, application logic
- **Infrastructure**: EF Core, external services, email, file access
- **Web**: FastEndpoints API, REPR pattern, validation

Expand All @@ -44,7 +45,7 @@ This is a **Clean Architecture template** for .NET 9 that demonstrates Domain-Dr
### Use Cases (CQRS)
- Commands for mutations, Queries for reads
- Queries can bypass repository pattern for performance
- Use MediatR for command/query handling
- Use Mediator (source generator) for command/query handling
- Chain of responsibility for cross-cutting concerns (logging, validation)

### Validation Strategy
Expand Down Expand Up @@ -78,7 +79,7 @@ dotnet new clean-arch -o Your.ProjectName

### Primary Libraries
- **FastEndpoints**: API endpoints (replaced Controllers/Minimal APIs)
- **MediatR**: Command/query handling in UseCases
- **Mediator**: Command/query handling in UseCases
- **EF Core**: Data access (SQLite default, easily changed to SQL Server)
- **Ardalis.Specification**: Repository query specifications
- **Ardalis.Result**: Error handling pattern
Expand Down
8 changes: 4 additions & 4 deletions MinimalClean.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
<metadata>
<id>Ardalis.MinimalClean.Template</id>
<title>ASP.NET Minimal Clean Architecture Solution</title>
<version>1.0.0-beta1</version>
<version>1.0.0</version>
<authors>Steve Smith</authors>
<description>
A simplified Clean Architecture template using vertical slice architecture in a single project.
Perfect for MVPs, smaller applications, or teams wanting architectural guidance without multi-project complexity.
Features Domain-Driven Design patterns, FastEndpoints, Entity Framework Core, and optional Aspire support.
Built with .NET 10 and C# 13.
Built with .NET 10 and C#.
</description>
<language>en-US</language>
<license type="expression">MIT</license>
<projectUrl>https://github.com/ardalis/CleanArchitecture</projectUrl>
<releaseNotes>
* Initial release of Minimal Clean Architecture template
* Single-project vertical slice architecture
* Built with .NET 10 and C# 13
* Built with .NET 10 and C#.
* FastEndpoints for REPR pattern
* Pragmatic DDD with simplified patterns
* Optional Aspire support
* Aspire support
</releaseNotes>
<packageTypes>
<packageType name="Template" />
Expand Down
243 changes: 243 additions & 0 deletions MinimalClean/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/

# Visual Studio 2015/2017/2019/2022 cache/options directory
.vs/
.vscode/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml

# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c

# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/

# ASP.NET Scaffolding
ScaffoldingReadMe.txt

# Database files
*.db
*.db-shm
*.db-wal
*.sqlite
*.sqlite3

# Entity Framework Core migrations (keep migrations folder, ignore db files)
**/Migrations/*.db

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Mac desktop service store files
.DS_Store

# JetBrains Rider
.idea/
*.sln.iml

# CodeRush
.cr/

# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc

# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config

# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*

# MightyMoose
*.mm.*
AutoTest.Net/

# Web workbench (sass)
.sass-cache/

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets

# Microsoft Azure Build Output
csx/
*.build.csdef

# Microsoft Azure Emulator
ecf/
rcf/

# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/

# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
*.mdf
*.ldf
*.ndf

# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings

# Microsoft Fakes
FakesAssemblies/

# GhostDoc plugin setting file
*.GhostDoc.xml

# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/

# Typescript v1 declaration files
typings/

# Visual Studio 6 build log
*.plg

# Visual Studio 6 workspace options file
*.opt

# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw

# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions

# Paket dependency manager
.paket/paket.exe
paket-files/

# FAKE - F# Make
.fake/

# JetBrains Rider
.idea/
*.sln.iml

# CodeRush
.cr/

# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc

# Cake - Uncomment if you are using it
# tools/

# Telerik's JustMock configuration file
*.jmconfig

# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
29 changes: 21 additions & 8 deletions MinimalClean/README.template.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,24 @@ dotnet run --project src/MinimalClean.Architecture.AspireHost

### Database Setup

This template uses **SQL Server in a container** managed by Aspire. When you run the Aspire AppHost, it automatically starts a SQL Server container and creates the database.

#### Option 1: Run with Aspire (Recommended)

```powershell
dotnet ef database update -c AppDbContext -p src/MinimalClean.Architecture.Web -s src/MinimalClean.Architecture.Web
dotnet run --project src/MinimalClean.Architecture.AspireHost
```

The database file will be created at: `src/MinimalClean.Architecture.Web/ToDo.db`
The SQL Server container and database are automatically provisioned and migrations are applied on startup.

#### Option 2: Run Web project directly (SQL Server LocalDB)

If running the Web project without Aspire, update `appsettings.json` to use LocalDB:

```powershell
dotnet ef database update -c AppDbContext -p src/MinimalClean.Architecture.Web -s src/MinimalClean.Architecture.Web
dotnet run --project src/MinimalClean.Architecture.Web
```

## Project Structure

Expand Down Expand Up @@ -70,10 +83,10 @@ This minimal template simplifies the full Clean Architecture template:
| Full Template | Minimal Template |
|--------------|------------------|
| 4+ projects (Core, UseCases, Infrastructure, Web) | 1 Web project |
| Repository pattern with Specifications | Direct DbContext usage (or simple repositories) |
| Repository pattern with Specifications | Repository pattern with Specifications if needed |
| Extensive use of interfaces and abstractions | Pragmatic abstractions where needed |
| Separate Use Cases project with MediatR | Optional MediatR, logic can be in endpoints |
| Complex domain patterns (Aggregates, Value Objects, Domain Events) | Simplified domain model, pragmatic DDD |
| Separate Use Cases project with Mediator | Optional Mediator; logic can be in endpoints |
| Complex domain patterns (Aggregates, Value Objects, Domain Events) | Pragmatic DDD patterns (Aggregates, Value Objects) |

## When to Use This Template

Expand All @@ -98,8 +111,8 @@ This minimal template simplifies the full Clean Architecture template:
- **.NET 10**: Latest LTS framework
- **FastEndpoints**: REPR pattern for API endpoints
- **Entity Framework Core**: Data access with migrations
- **SQLite**: Default database (easily switched to SQL Server, PostgreSQL, etc.)
- **Aspire**: Optional cloud-ready orchestration and observability
- **SQL Server**: Containerized database via Aspire (easily switched to PostgreSQL, SQLite, etc.)
- **Aspire**: Cloud-ready orchestration and observability
- **Serilog**: Structured logging
- **FluentValidation**: Request validation

Expand Down Expand Up @@ -135,7 +148,7 @@ dotnet test
As your application grows, you can migrate to the full Clean Architecture template:

1. **Extract Core**: Move Domain entities to separate Core project
2. **Extract UseCases**: Move business logic to UseCases project with MediatR
2. **Extract UseCases**: Move business logic to UseCases project with Mediator
3. **Extract Infrastructure**: Move data access to Infrastructure project
4. **Update Dependencies**: Set up proper dependency flow (Core ← UseCases ← Infrastructure)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static IServiceCollection AddServiceConfigs(this IServiceCollection servi
services.AddScoped<IEmailSender, MimeKitEmailSender>();
}

logger.LogInformation("{Project} services registered", "Mediatr and Email Sender");
logger.LogInformation("{Project} services registered", "Mediator and Email Sender");

return services;
}
Expand Down
Loading
Loading