Casey Crouse and I have a new book out from Packt: Clean Architecture with .NET: Design scalable .NET applications by using Clean Architecture principles and proven patterns. Jason Taylor wrote the foreword.
Why We Wrote It
I’ve been talking and writing about Clean Architecture for years - in conference talks, in blog posts, and in the ASP.NET Core Clean Architecture solution template that has been used by many thousands of developers. The template gets you a folder structure and helps make it harder to make certain kinds of mistakes. What it can’t do is explain the hundred small decisions you’ll face once you start putting real features into it.
That’s the gap this book fills. Clean Architecture is a set of organizing principles, not a code template. So instead of showing you a finished solution and describing it, we build one, start to finish, and explain the reasoning at each step.
We also deliberately included the parts that usually get skipped. Plenty of Clean Architecture material stops once the layers exist. Real applications need authentication, secrets management, database migrations, a deployment story, logging, and health checks. Those concerns are where architectural boundaries often leak, so they’re where the discipline matters most. They’re in the book, too, for this reason.
Who It’s For
.NET developers, software engineers, and solution architects who want applications that are easier to understand, test, and evolve over time. If you already know C# and .NET and want a clearer, more practical way to structure real-world applications, this is written for you. Basic familiarity with web development and Azure will help you follow along, but you don’t need to be an expert in either.
If you’ve ever inherited a codebase where changing one thing broke three others, the first chapter will feel uncomfortably familiar.
What You’ll Learn
- Design scalable .NET applications with Clean Architecture principles
- Structure core logic using use cases, CQRS, and domain modeling
- Integrate Azure External ID, Key Vault, and secure service configurations
- Use EF Core with a code-first approach to manage database schemas and persistence
- Apply MediatR and FluentValidation for streamlined workflows
- Build rich UIs using Blazor Server and MudBlazor
- Build scalable multi-host applications with structured, transparent service composition
- Reduce architectural boilerplate while maintaining structure
Everything is built around a single e-commerce application, Project Odyssey, with real use cases like shopping cart management and payment processing. The full source code is on GitHub, organized by chapter so you can see the application grow.
Chapter Overview
- Understanding the Limitations of Tightly Coupled Architectures
- Introduction to Clean Architecture
- Adapting Clean Architecture to .NET
- Designing a Clean Architecture Application
- Implementing the Core Layer
- Implementing the Infrastructure Layer
- Implementing the Persistence Layer
- Implementing the Presentation Layer with Identity
- Building Secure, Testable UI Components for Use Cases
- Improving Clean Architecture in .NET with Structured Service Composition
- Securing a Clean Architecture Application
- Reducing Boilerplate in Clean Architecture Applications
- Deploying a Clean Architecture Application in Azure
- Managing and Evolving a Clean Architecture Application
- Conclusion
A few of those are worth calling out. Chapter 5 makes the case for an application-first approach and shows how to test the Core layer with xUnit and NSubstitute before any infrastructure exists. Chapter 9 covers testing Blazor components with bUnit, which is the part of the Presentation layer people most often assume can’t be tested. And Chapter 14 is about sustaining the architecture as the application scales - the question I get asked more than any other (and where I usually point to Modular Monoliths as a starting point).
Where to Get It
Related Resources
- Clean Architecture solution template - the ASP.NET Core template referenced throughout
- Clean Architecture with ASP.NET Core - the short version of the argument
- Clean Architecture Sucks - where it isn’t a good fit, because it isn’t always
- ASP.NET Core Clean Architecture Template version 8
- My other books
Thanks to Casey for being a great lead author (he wrote most of the book and code), to Jason Taylor for the foreword, and to the Packt team for shepherding this one through. If you pick up a copy, I’d love to hear what you think.