$ show codewithmukesh/dotnet-webapi-zero-to-hero-course
This repository is a comprehensive educational course titled '.NET Web API Zero to Hero' by codewithmukesh. It contains over 50 independent ASP.NET Core Web API sample projects organized into modules covering fundamentals (minimal APIs, exception handling, logging), database management with EF Core (CRUD, migrations, interceptors, soft deletes, bulk operations, pagination), advanced API patterns (CQRS with MediatR, custom dispatcher, Result pattern, mapping benchmarks), performance and caching (in-memory, Redis, HybridCache, EF second-level cache), API security (JWT, refresh tokens, role/claims/policy/permission-based authorization, API keys, CORS, rate limiting), file handling (PDF invoice generation), architecture (Clean Architecture vs Vertical Slice), observability (health checks, structured logging), and background processing. Each sample is a self-contained, runnable project with minimal setup (often using in-memory databases) and includes extensive BenchmarkDotNet performance comparisons. The code is well-structured, follows modern .NET 10 patterns, and demonstrates production-quality implementations of cross-cutting concerns like global exception handling, validation pipelines, and caching strategies. While the repo is primarily a teaching resource, many components (custom CQRS dispatcher, Result pattern, EF Core interceptors, permission-based authorization) are genuinely reusable in other projects.
The LLM identified 5 files worth highlighting for reuse:
A complete, self-contained custom CQRS dispatcher that replaces MediatR. Includes interfaces (IRequest, IRequestHandler, ISender, IPublisher, IPipelineBehavior, INotification), generic request/notification handler wrappers, a dispatcher implementation using FrozenDictionary for fast handler resolution, and a registration extension. Demonstrates how to build a lightweight mediator with pipeline behaviors (logging, validation, caching, transaction) without external dependencies. Highly reusable and extractable.
A clean implementation of the Result pattern with generic Result<T> and non-generic Result types, Error record with error type classification (Validation, NotFound, Conflict, Failure, Unexpected), and extension methods for mapping to ProblemDetails and ASP.NET Core IResult. Includes BindAsync for minimal API integration. The pattern is self-contained, well-tested, and can be extracted into any .NET project to replace exception-based error handling.
An EF Core SaveChangesInterceptor that automatically sets audit fields (CreatedAt, CreatedBy, UpdatedAt, UpdatedBy) on entities implementing IAuditable, and applies soft-delete logic for ISoftDeletable entities by setting DeletedAt and a global query filter. Demonstrates a clean, reusable pattern for cross-cutting data concerns without polluting business logic. Can be extracted with its interfaces and registered in any EF Core DbContext.
A dynamic permission-based authorization system consisting of a custom AuthorizationPolicyProvider, a single PermissionRequirement with a handler that checks permissions from a store, and a PermissionStore that manages user-permission mappings. Supports runtime permission changes without re-login. The pattern is self-contained and can be extracted to add fine-grained, database-driven authorization to any ASP.NET Core application.
A background PDF rendering system using System.Threading.Channels. PdfRenderQueue wraps a bounded Channel<RenderJob> and exposes a TryWrite method. A BackgroundService worker (PdfRenderWorker) reads from the channel and processes jobs. Demonstrates a clean, testable pattern for offloading expensive operations (like Chrome-based PDF generation) to a background queue with backpressure. Can be extracted and adapted for any background job scenario.