Clean Architecture in .NET 8
Building testable and maintainable code is a hard requirement these days. It’s vital that your software supports changes over a prolonged period of time. That is something that can be achieved only if you set up an architecture which supports this. In this course, you’ll learn about Clean Architecture applied to ASP.NET Core 8. Clean architecture has over the years proven to be a way to create a solid foundation for enterprise-ready applications.
You'll learn about the tools, frameworks and best practices to create an architecture that's tested and is powering many applications. You’ll then use the API from a Blazor front-end.
After attending this course, you'll walk away with ideas to create your next applications but now, based on best practices!
This course uses .NET 8 and Visual Studio 2022.
Target audience and prerequisites
This course is intended for software architects and web developers. You should have experience developing web applications with C# and ASP .NET.
About the trainer
Gill Cleeren has been working with ASP.NET since its inception in the early 2000s and has guided numerous projects based around .NET to a success. He has been teaching about the subject for many years and is also the author of several ASP.NET courses on Pluralsight, including the successful ASP.NET Core Fundamentals, ASP.NET Core Clean Architecture and ASP.NET Core Blazor Fundamentals. He’s an MVP and Microsoft Regional Director.
An overview of ASP.NET Core and ASP.NET Core APIs
In this first chapter, we will make sure we’re all on the same page about ASP.NET Core and creating APIs with the technology. Although having previous experience with ASP.NET Core will come in handy, you will learn all that’s required about some of the foundational concepts such as dependency injection, middleware and more.
Introducing core architectural principles and clean architecture
Clean architecture is in essence not much more than applying well-known architectural principles in a correct way. Most developers will know these but we will start with an overview of these. Next, we will inspect the concept of clean architecture and the different parts that make up the structure of it.
Creating the application core
We will start the creation of our application from the very core. In this chapter, we will understand how to structure code around contracts, apply clean structuring, add CQRS, implement business rules and much more. We will see how common packages such as Mediator and AutoMapper can be used correctly here.
Adding the infrastructure layer
So far, our code is nicely structured but it doesn’t “do” a lot yet. That’ll quickly change in this chapter when we start adding infrastructure concerns. This will bring in functionalities such as data access based on EF Core and working with external services.
Adding an API
We’ve written a lot of code already but now we’ll want to see the fruits of our hard labor. We’ll start with the creation of the API that’ll use the core and infrastructure code that we have created. On this API, we’ll also enable the use of Swagger so that it can more easily be consumed from clients.
We started of with the idea that the code we’re going to create is more testable, so now the proof is in the pudding. We’ll create tests for the different parts of the application that we have written so far.
Understanding ASP.NET Core Blazor
Blazor introduces a radical new way for .NET developers to build client-side applications and since .NET 8, also server-side rendered applications. We will in this chapter understand the core concepts of Blazor, which we’ll use to consume the API.
Adding the Blazor UI
Although it’s not the focus of this course to create a UI, it’s definitely useful to see how we can interact with our newly created API. In this chapter, we will learn how we can generate code for the client and we’ll build the Blazor app together that uses the API.
Completing the API with extra behaviors
Our API is functional but there are areas where improvements can be made. In this final chapter, we will extend our API with other cross-cutting concerns such as authentication, logging and more.