Roadmap › 1. .NET › Step 25
Arc

.NET Project Architectures & Folder Structures — Layered, Clean, Onion, Vertical Slice

How real .NET solutions are organised — solution and project structure, 3-tier and N-layer architecture, Onion, Hexagonal (ports and adapters) and Clean Architecture, Vertical Slice architecture, modular monolith, DDD building blocks, CQRS, the folder structure of each style with naming conventions, shared build settings (Directory.Build.props, central package management), test projects, where cross-cutting concerns live, and how to choose an architecture.
What it is & where it is used

Architecture = how code is split into parts, what each part is responsible for, and which parts may depend on which. A good structure makes code easy to find, change, test and deploy.

StyleCore ideaTypical fit
3-tier / N-layerUI → Business (BLL) → Data (DAL)Classic enterprise apps, Web Forms/MVC 5
Onion / Clean / HexagonalDomain at the centre; infrastructure and UI depend inward on interfacesMedium–large apps with real business logic, long life
Vertical SliceOrganise by feature (one folder per use case), not by technical layerAPIs with many independent features, CQRS
Modular monolithOne deployable, split into independent modulesGrowing products; stepping stone to microservices
MicroservicesSeparate deployable services per business capabilityLarge organisations (see the Microservices course)
Versions & history
YearMilestone
1990sClient/server, then 3-tier architecture
2002Fowler's Patterns of Enterprise Application Architecture (layers, repository, unit of work)
2003Domain-Driven Design (Eric Evans)
2005Hexagonal architecture / ports and adapters (Alistair Cockburn)
2008Onion architecture (Jeffrey Palermo)
2010CQRS popularised (Greg Young)
2012Clean Architecture (Robert C. Martin)
2018Vertical Slice architecture (Jimmy Bogard)
2020sModular monoliths; templates: Jason Taylor's CleanArchitecture, Ardalis CleanArchitecture; .NET Aspire solution layouts; .slnx solution format (VS 2022 17.13+/.NET 9 SDK)
Lifecycle

How a request flows through a Clean Architecture ASP.NET Core API:

text
HTTP request
 → Api (controller / minimal endpoint, model binding, auth)            [Presentation]
 → Application (use case / command handler, validation, DTO mapping)  [Application]
 → Domain (entities enforce business rules, domain events)            [Domain — no dependencies]
 → Application calls interfaces (IOrderRepository, IEmailSender, IClock)
 → Infrastructure implements them (EF Core DbContext, SMTP, Azure Blob) [Infrastructure]
 → database / external services
 ← result → DTO → HTTP response

Dependency rule: source-code dependencies point inwards (Api → Application → Domain; Infrastructure → Application/Domain). The Domain knows nothing about EF Core, ASP.NET or SQL.

Tools used to develop
  • dotnet new sln, dotnet new classlib/webapi/xunit, dotnet sln add, dotnet add reference.
  • Templates: Clean.Architecture.Solution.Template (Jason Taylor), Ardalis.CleanArchitecture.Template, .NET Aspire starter.
  • Architecture tests: NetArchTest, ArchUnitNET (enforce "Domain must not reference Infrastructure").
  • Visual Studio dependency diagrams / code maps, NDepend.
  • Diagrams: C4 model, draw.io, Structurizr.