
Explore advanced scenarios for software development with .Net core applications. The module introduces clean architecture and guides developing the course application through upcoming modules.
Define software architecture as the fundamental structure of a software system, outlining components, relationships, and layers to ensure quality, maintainability, scalability, and performance.
Explores software architecture styles, from monolithic apps housed in a single dll to layered designs with presentation, services, and data access layers, highlighting scalability and maintenance trade-offs; introduce clean architecture.
Clean architecture centers business logic by organizing code into domain, application, infrastructure, and UI layers with dependencies flowing from outside in, enabling easier testing, maintainability, and tech swaps.
Operate with separation of concerns by assigning each module a single responsibility across layers; inject a repository interface to access data, keeping presentation, application, and infrastructure decoupled.
Understand the single responsibility principle, ensuring a class has only one reason to change by splitting validation, saving, and emails into separate classes, and compare SRP with separation of concerns.
Demonstrate persistence ignorance by keeping the domain away from data access details, such as tables and keys, and remaining agnostic to storage implementations like SQL Server or EF Core.
Build a multi-layer ASP.NET Core app for a fictitious dental company, detailing core domain entities, features like creating and canceling appointments, and infrastructure, API, and security layers.
Explore clean architecture in ASP.NET Core by placing business logic at the center, independent of databases, logging, file system access, guided by dependency inversion, separation of concerns, and persistence ignorance.
Explore the domain layer of an ASP.NET Core application, covering entities, value objects, and aggregates, and perform unit tests on this layer.
Build a centralized web api for a dental network, managing offices, dentists, patients, and appointments, with email notifications, access control, filtering, and clean architecture for maintainability and testing.
Create a new blank solution, organize it into API, core, infrastructure, and testing folders, then start work on the domain layer for a clean architecture setup.
Explore the domain layer, the heart of the system, modeling entities, value objects, and aggregates with invariants and business rules, while staying independent of persistence and tech decisions.
Create domain project that won't reference other projects and define entities for a dental appointment system—dental office, dentist, patient, and appointment with a status enum—preserving persistence ignorance through private setters.
Transform anemic domain models by embedding behavior in entities to enforce business rules, using custom exceptions and methods like cancel and complete for appointment lifecycle.
Encapsulate email as an immutable value object to share validation rules across patient and dentist entities, and create a time interval value object to enforce start-before-end constraints.
Develop and run a domain layer test suite using mstest to validate value objects like email and time interval, asserting business rule exceptions and confirming valid constructions.
Test domain entities: dental office, dentist, patient, and appointment. Verify null name or email triggers a business rule exception and appointment transitions from scheduled to canceled or completed.
Build and test the domain layer by modeling entities as identity-bearing objects that encapsulate shared functionality, and perform automated tests to validate the domain layer.
Begin building the application layer in clean architecture. Discuss what to include in that layer, introduce the pattern, and start coding to solve user tasks.
Create the application layer in the core folder by adding a new class library named Clean application, then delete this class and discuss the application layer.
Coordinate a feature set by orchestrating domain driven actions without infrastructure or UI dependencies, using contracts and the dependency inversion principle to implement tasks like creating appointments.
Explore the CQRS pattern by separating commands that modify state from queries that read data, and learn command and query handlers, single responsibility, testable and maintainable code, and feature-based organization.
Implement a create dental office command and its handler to add a record to the dental offices table, scaffolding the repository integration for future data persistence.
Define a generic IRepository<T> with common CRUD operations in the application layer, create an entity-specific IDentalOfficeRepository, and wire them through a handler to persist a dental office.
Learn how to use the unit of work pattern to group operations into a transaction, committing on success and rolling back on error to maintain data integrity in clean architecture.
Implement application layer validations with Fluent Validation to accumulate errors when creating a dental office by validating the create dental office command and returning a comprehensive error response.
Throw validation exceptions in the application layer to centralize error handling and return a standard API response, using a custom validation exception that collects all errors from fluent validation.
Explore how the mediator pattern decouples controllers from handlers, enabling centralized logging and flexible communication between UI and application layers. Implement a custom mediator to avoid external dependencies.
Implement the mediator pattern to centralize API to layer communication by defining I request, I mediator, and I request handler, wiring handlers via dependency injection, and dispatching commands and queries.
Test a simple mediator with automated tests using substitute mocks for a request handler and service provider. Verify the handler is called when registered, and an exception occurs when absent.
Centralize validation by integrating fluent validation into the mediator, automatically applying rules for each request, and throwing a custom validation exception when invalid, keeping handlers clean.
Test the dental office command handler by mocking the repository and unit of work, verifying the handle returns the dental office id and errors trigger rollback.
Apply CQRS to separate queries from commands, and implement a first query that retrieves a dental office by ID, returning a dental office detail DTO via a handler and repository.
Unit tests validate the dental office detail query handler using a mocked repository, confirming a DTO with id and name, and a not found exception when the office is missing.
Register the application layer services with a public static extension method, wiring mediator and scoped handlers for dental office command and detail query in the web api.
Orchestrate business logic in the application layer without infrastructure or presentation concerns, using CQRS to separate read and write models, features to represent actions, and a mediator to centralize communication.
Begin implementing the infrastructure layer, focusing on persistence and database communication within the clean architecture with ASP.NET Core.
Create the persistence project inside the infrastructure folder by adding a new class library, delete the default class, and plan what to include in this infrastructure project.
Understand the infrastructure layer as the outer boundary that connects the app to databases, cloud services, and external systems, while implementing inner layer contracts and applying dependency inversion.
Install entity framework core in the persistence project and add the Microsoft.EntityFrameworkCore.SqlServer provider. Create a public DbContext with a dental offices DbSet and register it with UseSqlServer for repositories.
Configure the database with C sharp code by creating a dental office config that defines the table schema and column constraints, then apply configurations from the assembly in the DbContext.
Implement a generic base repository using Entity Framework Core to centralize CRUD operations, inject DbContext, defer save changes to unit of work, and register dental office repository with dependency injection.
Implement a unit of work in clean architecture using Entity Framework Core, injecting the DbContext, committing with await context.SaveChangesAsync, and registering the service.
Learn to implement the persistence layer with Entity Framework Core by configuring infrastructure, building repositories and the unit of work, and enabling data access from features.
Begin developing the presentation layer by building a web API in ASP.NET Core to see our clean architecture in action.
Create the api project for a clean architecture app by adding a web api with controllers, naming it clean teeth dot api, and consider minimal apis by unchecking the checkbox.
The presentation layer serves as the entry point, validating data and translating requests into commands or queries, then delegates to the application layer via a mediator, preserving separation of concerns.
Configure the web api to wire application and persistence layers, set the development connection string, install ef core tools, and create a migration to add the dental offices table.
Create our first ASP.NET Core dental offices controller with a create dental office DTO, mediator, and HTTP post; test via HTTP files and SQL Server.
Learn to retrieve a dental office by id in a clean architecture ASP.NET Core app using a mediator query, including JSON tests and not found handling.
Implement a custom error handling middleware to centralize exception handling, return 404 for not found, 400 for validation errors, and 500 by default with a JSON response.
Develop the presentation layer as a web API, decouple controllers with the mediator to avoid repositories and Entity Framework dependencies, and centralize exception handling in middleware to simplify controller logic.
Felipe Gavilan introduces this module to develop the app's features after an initial overview. He guides you to understand what we are building and to get started with implementation.
implement a query to fetch the dental offices list, map to a dto, and expose it via a web api controller using mediator and repository with dependency injection.
Write automated tests for the dental offices list feature in a clean architecture ASP.NET Core project, verifying repository results and validating IDs and names.
Refactor the mediator to handle requests without a return by adding non-generic IRequest and IRequestHandler and a send method, and extract private validations into a shared apply_validations.
Implement an update dental office feature using a command pattern in clean architecture. Validate and enforce business rules, wire DTO, handler, repository, and return 204 no content.
Test the dental office update command handler by validating the happy path where the office exists and is updated and committed, and verify rollback on errors and not found scenarios.
Implement delete dental office via a delete command and handler, use repository and unit of work, throw not found if absent, and expose an http delete endpoint returning no content.
Develop and test the delete dental office command handler, covering happy path, not-found exception, and rollback on errors, using repository and unit of work patterns.
Automate use case handler registration in the application layer with the scooter NuGet package by a single command that scans assemblies for IRequestHandler implementations and registers them with scope lifetime.
Configure the patient table in the persistence layer by mapping email value object via complex properties in EF Core, enforce name constraints, and register a patient repository with dependency injection.
Implement the create patient feature using a command, validator, and handler within a clean architecture setup, wired through a mediator, data transfer object, controller, and repository with unit of work.
Learn how to write automated tests for creating a patient, including happy path validation, repository interactions, and rollback on error using a command handler and unit of work.
Implement a read-only patient list endpoint by building a get patients list query and handler, a patient list dto, and a mapping extension to convert patients to dtos.
Implement page-based patient retrieval by adding a total records counter, a paginate extension, and a paginated dto, and expose the count in http headers.
Implement automated tests for the patient list feature, focusing on the get patient list query handler and repository interactions, and validate pagination with two records per page.
implement get patient by id by creating a patient detail dto, mapping extensions, get patient detail query and handler, repository lookup with notfoundexception, and an http get endpoint via mediator.
We extend the patients filter dto with optional name and email fields, then build a dynamic IQueryable query to filter by name or email and return matching patients.
implement an update patient feature using a command, validator, and handler, updating name and email via repository and unit of work, exposed through a http put endpoint.
Implement a delete patient feature with a command and handler, backed by repository and unit of work, including not found checks and a http delete endpoint.
Build a simplified clean architecture demo in ASP.NET Core by treating dentist and patient entities as similar, practice commands and queries, and implement web API endpoints with code on GitHub.
Build the dentist table and dbcontext with dentists dbset, configure columns, implement a dentist repository with a get filter by name or email, and expose endpoints via the dentist controller.
Map the appointments entity in infrastructure persistence, with a time interval value object mapped to start and end date columns, create migrations, and implement a repository with dependency injection.
Create an appointment feature by implementing a create appointment command, validating start and end dates, preventing overlapping dentist schedules, and exposing a post endpoint with a dto-driven api.
Fetch an appointment by id with a detail query that joins patient, dentist, and dental office names, and implement the repository, handler, and API endpoint to return a detail DTO.
Implement a get appointments feature with filtering by patient, dentist, dental office, and date in a clean architecture ASP.NET Core app, including repository, DTOs, mapping, and mediator query.
Complete an appointment by issuing a complete appointment command via mediator, updating it through repository and unit of work, with error handling for not found and business rule exceptions.
implement a cancel appointment feature in a clean architecture ASP.NET Core app by adding a cancel appointment command and handler, repository, and mediator-driven endpoint with commit and rollback.
Prepare the app for email notifications by defining an appointment confirmation DTO, a mapping extension, and an email service, then wire infrastructure services for DI in the web API.
Configure and test an email sending service in an ASP.NET Core app using Gmail, app settings, user secrets, and SMTP to send appointment confirmations.
Execute a daily background job to send reminder emails for tomorrow's appointments. Reuse filters, map to reminder DTOs, and run at 8 a.m. EST via a hosted service.
This module implements crud for domain entities, adds pagination to limit results, and creates a recurring job to send daily appointment reminders.
Explore authentication and authorization configuration in a clean architecture project. Learn a basic setup that highlights realistic security considerations without deep dives.
Configure security infrastructure by adding a project with identity and EF Core, create security and application contexts, apply identity migrations, and expose bearer authentication endpoints for registration and login.
Configure identity and authorize endpoints to protect routes, test with https and access tokens, and centralize authorization across the api for secure access.
Enforce an admin policy using claim-based authorization in ASP.NET Core; require the admin claim for access and show 403 forbidden until the token includes the claim.
Implement a new IUserService contract to obtain the authenticated user id. Use HTTP context accessor to read the name identifier claim and register the service for injection.
Implement an audit trail in EF Core with an auditable base class, override save changes to populate creation time, last modified date, and last modified by using a user service.
Configure authentication and authorization in a clean architecture project using identity for login and registration, with a separate context for identity tables and claim-based authorization to protect web api endpoints.
Do you want to take your .NET applications to the next level?
In this course, you’ll learn step by step how to implement Clean Architecture with ASP.NET Core, developing a real application from scratch with principles that will allow you to build professional, maintainable, and scalable software.
Throughout the lessons, you’ll discover how to structure your code so it’s easy to test, extend, and maintain, applying best practices such as Dependency Inversion, Separation of Concerns, and the Single Responsibility Principle.
You’ll implement CQRS to separate commands and queries, use the Mediator pattern to centralize communication with features, handle transactions with Unit of Work, and apply validations in an elegant and consistent way. You’ll also learn how to configure authentication and authorization with Identity, and how to integrate services such as email sending without coupling them to your domain.
By the end of the course, you will be able to:
Model the domain with entities, value objects, and aggregates.
Create use cases with CQRS and Mediator.
Implement repositories and Unit of Work with EF Core.
Build clean, scalable APIs with ASP.NET Core.
Configure security with authentication and claim-based authorization.
Integrate external services in a decoupled way.
Learn how to build robust applications that stand the test of time and become a software developer who delivers professional-quality solutions.