# codewithmukesh/dotnet-webapi-zero-to-hero-course architecture

> Architecture diagram of the GitHub repository codewithmukesh/dotnet-webapi-zero-to-hero-course, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codewithmukesh/dotnet-webapi-zero-to-hero-course
- Repository: https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course

## Overview

1. **Repository shape**
   This is a **course monorepo**, not a single product. The top level contains many **independent sample applications** grouped by learning module, plus an `archive/` folder with older .NET 8-era examples. Each sample has its own solution/project layout and can be run in isolation.

2. **Primary architectural boundary**
   The strongest boundary is **module-level isolation**. Nothing in one lesson depends on another lesson’s code. For diagramming, treat each lesson folder as a separate system with its own runtime, dependencies, and sometimes its own database or Docker setup.

3. **Common application shape**
   Most samples are **ASP.NET Core Web APIs** using either **Minimal APIs** or controllers. Typical layers are:
   - API entry point in `Program.cs`
   - feature/endpoint classes
   - application services or handlers
   - persistence via EF Core
   - DTOs/models/validators
   This makes request flow easy to diagram as: HTTP request → API endpoint → service/handler → database/caching/security component → HTTP response.

4. **Data access backbone**
   Many lessons use **Entity Framework Core** with a `DbContext` and entity/configuration classes. Database-focused modules commonly include:
   - `Persistence` or `Data` folders
   - migrations
   - seed scripts
   - PostgreSQL via `docker-compose.yml`
   Some lessons use a **single DbContext**, while others demonstrate **multiple DbContexts**, concurrency, soft deletes, interceptors, bulk operations, or tracking behavior.

5. **Feature organization styles**
   The repo demonstrates two major code organization models:
   - **Vertical slice / feature folders**: commands, queries, handlers, notifications grouped by feature
   - **Layered/Clean Architecture**: separate `Domain`, `Application`, `Infrastructure`, and `Api` projects
   A diagram should reflect that some samples keep business logic near endpoints, while others enforce strict project boundaries.

6. **CQRS and MediatR-based flows**
   Several modules split **commands** and **queries** into separate request/handler pairs. In those samples, the request path is:
   HTTP endpoint → command/query object → MediatR or custom dispatcher → handler → persistence/domain
   Some versions also include **pipeline behaviors** for validation, caching, or logging before the handler runs.

7. **Cross-cutting concerns**
   The repository contains dedicated samples for:
   - **global exception handling**
   - **validation** with FluentValidation
   - **middleware / filters**
   - **structured logging**
   - **caching**
   - **health checks**
   These are important architectural overlays, not business features. In diagrams, they sit on the request pipeline or around the data access path rather than inside the core domain.

8. **Security subsystem**
   The security module group shows multiple authentication/authorization strategies:
   - JWT authentication
   - refresh tokens
   - API key auth
   - role-based, claim-based, and policy-based authorization
   - custom user management and Identity endpoints
   These samples usually introduce an **Auth/Identity boundary** in front of secured endpoints, with token generation/validation and database-backed user stores.

9. **Performance and caching**
   Caching is treated as a separate subsystem with multiple implementations:
   - **in-memory cache**
   - **Redis distributed cache**
   - **HybridCache**
   - response caching via behaviors in CQRS samples
   Benchmarks appear in dedicated projects. For diagrams, show cache as a side store between API/service layer and the database or expensive computation.

10. **Observability and runtime operations**
    The observability module includes **health checks** and external dependency checks. Logging samples use **Serilog** and correlation IDs. These features typically plug into the host startup and request pipeline rather than the domain model.

11. **Background processing**
    The background-processing module shows **IHostedService** and **BackgroundService** patterns. These run outside normal HTTP requests and interact with application services or persistence on a timer or startup event. In architecture terms, they are a separate execution path within the same host.

12. **Supporting infrastructure**
    Several lessons include:
    - `docker-compose.yml` for database or supporting services
    - `launchSettings.json` for local host configuration
    - `.http` request files for manual API testing
    - benchmark projects for performance comparisons
    These are development/runtime supports rather than core business components, but they matter for environment diagrams.

13. **Technology profile**
    The repo is centered on **.NET 10**, **ASP.NET Core**, **EF Core**, **PostgreSQL**, **Docker**, **FluentValidation**, **MediatR**, **Serilog**, and in some samples **Redis** and **Identity**. The `archive/` folder contains older .NET 8 variants, but the main course content targets .NET 10.

14. **How to read the repository in one diagram**
    The best high-level diagram is a **collection of isolated sample apps**, each with:
    - an HTTP/API entry point
    - optional pipeline concerns
    - application logic in services/handlers
    - persistence via EF Core and PostgreSQL
    - optional cache/auth/background worker integrations
    The repo is best represented as a **teaching platform of multiple small architectures**, not one unified distributed system.

Main entry points: [`modules/02-database-management-with-ef-core/aspnet-core-webapi-crud-with-entity-framework-core-full-course/MovieApi.Api`](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/blob/main/modules/02-database-management-with-ef-core/aspnet-core-webapi-crud-with-entity-framework-core-full-course/MovieApi.Api) (EF CRUD), [`modules/02-database-management-with-ef-core`](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/02-database-management-with-ef-core) (Database Mgmt), [`modules/03-advanced-api-patterns`](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/03-advanced-api-patterns) (Advanced APIs), [`modules/08-architecture-best-practices`](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/08-architecture-best-practices) (Architecture)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g_getting_started["01 Getting Started"]
  node_getting_started["Getting Started<br/>module hub"]
  node_http_pipeline["HTTP Pipeline<br/>api host<br/>[Program.cs]"]
  node_cross_cutting{{"Cross-Cutting<br/>middleware/filter layer"}}
end

subgraph group_g_database["02 Database Management"]
  node_db_management[("Database Mgmt<br/>module hub")]
  node_efcore_crud[("EF CRUD<br/>api+persistence<br/>[MovieApi.Api]")]
  node_efcore_advanced[("EF Advanced<br/>persistence behaviors")]
end

subgraph group_g_advanced["03 Advanced API Patterns"]
  node_advanced_api["Advanced APIs<br/>module hub"]
  node_cqrs_mediatr["CQRS + MediatR<br/>request handlers<br/>[CqrsMediatr.Api]"]
  node_custom_dispatcher["Custom CQRS<br/>dispatcher<br/>[CqrsCustom.Api]"]
end

subgraph group_g_perf["04 Performance & Caching"]
  node_perf_cache["Perf & Cache<br/>module hub"]
  node_cache_layer[("Cache Layer<br/>cache subsystem")]
end

subgraph group_g_security["05 API Security"]
  node_security["Security<br/>module hub"]
  node_auth_boundary{{"Auth Boundary<br/>identity/security"}}
end

subgraph group_g_arch["08 Architecture Best Practices"]
  node_architecture["Architecture<br/>module hub"]
  node_clean_arch["Clean Arch<br/>layered app"]
  node_vertical_slice["Vertical Slice<br/>feature folders<br/>[VerticalSlice.Api]"]
end

subgraph group_g_obs["10 Observability"]
  node_observability(("Observability<br/>module hub"))
  node_health_checks(("Health Checks<br/>runtime checks<br/>[HealthChecks.Api]"))
end

subgraph group_g_bg["12 Background Processing"]
  node_background["Background Jobs<br/>module hub"]
  node_hosted_services["Hosted Services<br/>background workers<br/>[HostedServices.Api]"]
end

subgraph group_g_archive["archive"]
  node_archive_legacy["Archive<br/>legacy samples"]
end

node_repo["Course Repo<br/>monorepo"]

node_repo -->|"contains"| node_getting_started
node_repo -->|"contains"| node_db_management
node_repo -->|"contains"| node_advanced_api
node_repo -->|"contains"| node_perf_cache
node_repo -->|"contains"| node_security
node_repo -->|"contains"| node_architecture
node_repo -->|"contains"| node_observability
node_repo -->|"contains"| node_background
node_repo -.->|"contains"| node_archive_legacy
node_getting_started -->|"hosts"| node_http_pipeline
node_http_pipeline -->|"applies"| node_cross_cutting
node_db_management -->|"hosts"| node_efcore_crud
node_db_management -->|"shows"| node_efcore_advanced
node_efcore_crud -.->|"shares"| node_efcore_advanced
node_advanced_api -->|"hosts"| node_cqrs_mediatr
node_advanced_api -->|"hosts"| node_custom_dispatcher
node_cqrs_mediatr -->|"uses"| node_efcore_crud
node_custom_dispatcher -->|"uses"| node_efcore_crud
node_perf_cache -->|"contains"| node_cache_layer
node_cache_layer -->|"fronts"| node_efcore_crud
node_security -->|"contains"| node_auth_boundary
node_auth_boundary -->|"stores"| node_efcore_crud
node_architecture -->|"contains"| node_clean_arch
node_architecture -->|"contains"| node_vertical_slice
node_clean_arch -->|"depends on"| node_efcore_crud
node_vertical_slice -->|"uses"| node_efcore_crud
node_observability -->|"contains"| node_health_checks
node_background -->|"contains"| node_hosted_services
node_hosted_services -.->|"runs with"| node_efcore_crud
node_archive_legacy -.->|"includes"| node_http_pipeline

click node_getting_started "https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/01-getting-started"
click node_db_management "https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/02-database-management-with-ef-core"
click node_advanced_api "https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/03-advanced-api-patterns"
click node_perf_cache "https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/04-performance-and-caching"
click node_security "https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/05-api-security"
click node_architecture "https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/08-architecture-best-practices"
click node_observability "https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/10-observability"
click node_background "https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/12-background-processing"
click node_archive_legacy "https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/archive"
click node_http_pipeline "https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/blob/main/modules/01-getting-started/filters-in-aspnet-core/FilterSamples.Api/Program.cs"
click node_efcore_crud "https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/blob/main/modules/02-database-management-with-ef-core/aspnet-core-webapi-crud-with-entity-framework-core-full-course/MovieApi.Api"
click node_cqrs_mediatr "https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/blob/main/modules/03-advanced-api-patterns/cqrs-and-mediatr-in-aspnet-core/CqrsMediatr.Api"
click node_custom_dispatcher "https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/blob/main/modules/03-advanced-api-patterns/cqrs-without-mediatr/CqrsCustom.Api"
click node_clean_arch "https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/08-architecture-best-practices/clean-architecture-dotnet/src"
click node_vertical_slice "https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/blob/main/modules/08-architecture-best-practices/clean-architecture-vs-vertical-slice-architecture/VerticalSlice/VerticalSlice.Api"
click node_health_checks "https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/blob/main/modules/10-observability/health-checks-in-aspnet-core/src/HealthChecks.Api"
click node_hosted_services "https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/blob/main/modules/12-background-processing/ihostedservice-backgroundservice/HostedServices.Api"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_getting_started,node_http_pipeline,node_cross_cutting,node_observability,node_health_checks toneBlue
class node_db_management,node_efcore_crud,node_efcore_advanced,node_background,node_hosted_services toneAmber
class node_advanced_api,node_cqrs_mediatr,node_custom_dispatcher,node_archive_legacy toneMint
class node_perf_cache,node_cache_layer toneRose
class node_security,node_auth_boundary toneIndigo
class node_architecture,node_clean_arch,node_vertical_slice toneTeal
class node_repo toneNeutral
```

## Components

### 01 Getting Started

Introductory ASP.NET Core samples and lightweight API patterns.

- [Getting Started](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/01-getting-started): module hub · Entry-level API and ASP.NET Core middleware/filter examples. · `modules/01-getting-started`
- [HTTP Pipeline](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/blob/main/modules/01-getting-started/filters-in-aspnet-core/FilterSamples.Api/Program.cs): api host · Program.cs host wiring, endpoints, middleware, filters, and request handling. · `modules/01-getting-started/filters-in-aspnet-core/FilterSamples.Api/Program.cs`
- **Cross-Cutting**: middleware/filter layer · Logging, exception handling, validation, response wrapping, and timing concerns.

### 02 Database Management

EF Core CRUD, migrations, performance, and persistence behavior samples.

- [Database Mgmt](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/02-database-management-with-ef-core): module hub · EF Core persistence, migrations, concurrency, and query behavior examples. · `modules/02-database-management-with-ef-core`
- [EF CRUD](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/blob/main/modules/02-database-management-with-ef-core/aspnet-core-webapi-crud-with-entity-framework-core-full-course/MovieApi.Api): api+persistence · Minimal API CRUD backed by a DbContext, entities, and migrations. · `modules/02-database-management-with-ef-core/aspnet-core-webapi-crud-with-entity-framework-core-full-course/MovieApi.Api`
- **EF Advanced**: persistence behaviors · Interceptors, soft deletes, tracking, concurrency, bulk operations, and multiple DbContexts.

### 03 Advanced API Patterns

CQRS, MediatR, custom dispatching, versioning, and mapping patterns.

- [Advanced APIs](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/03-advanced-api-patterns): module hub · CQRS, MediatR, custom dispatching, and mapping patterns. · `modules/03-advanced-api-patterns`
- [CQRS + MediatR](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/blob/main/modules/03-advanced-api-patterns/cqrs-and-mediatr-in-aspnet-core/CqrsMediatr.Api): request handlers · Command/query handlers, notifications, and MediatR pipeline behaviors. · `modules/03-advanced-api-patterns/cqrs-and-mediatr-in-aspnet-core/CqrsMediatr.Api`
- [Custom CQRS](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/blob/main/modules/03-advanced-api-patterns/cqrs-without-mediatr/CqrsCustom.Api): dispatcher · Homegrown dispatcher with request, notification, and behavior abstractions. · `modules/03-advanced-api-patterns/cqrs-without-mediatr/CqrsCustom.Api`

### 04 Performance & Caching

Caching strategies and benchmark-driven comparisons.

- [Perf & Cache](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/04-performance-and-caching): module hub · Caching implementations and benchmark suites. · `modules/04-performance-and-caching`
- **Cache Layer**: cache subsystem · In-memory, Redis, HybridCache, and response caching behaviors.

### 05 API Security

Authentication and authorization strategies with JWT, Identity, and policies.

- [Security](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/05-api-security): module hub · JWT, refresh tokens, API keys, roles, claims, and policies. · `modules/05-api-security`
- **Auth Boundary**: identity/security · JWT issuance, refresh tokens, API keys, and Identity-backed user stores.

### 08 Architecture Best Practices

Clean architecture and vertical slice comparisons.

- [Architecture](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/08-architecture-best-practices): module hub · Clean architecture and vertical slice contrasts. · `modules/08-architecture-best-practices`
- [Clean Arch](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/08-architecture-best-practices/clean-architecture-dotnet/src): layered app · Domain, Application, Infrastructure, and API project boundaries. · `modules/08-architecture-best-practices/clean-architecture-dotnet/src`
- [Vertical Slice](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/blob/main/modules/08-architecture-best-practices/clean-architecture-vs-vertical-slice-architecture/VerticalSlice/VerticalSlice.Api): feature folders · Feature-centric endpoints and handlers kept close to the API surface. · `modules/08-architecture-best-practices/clean-architecture-vs-vertical-slice-architecture/VerticalSlice/VerticalSlice.Api`

### 10 Observability

Health checks and runtime visibility samples.

- [Observability](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/10-observability): module hub · Health checks and runtime diagnostics samples. · `modules/10-observability`
- [Health Checks](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/blob/main/modules/10-observability/health-checks-in-aspnet-core/src/HealthChecks.Api): runtime checks · Application and dependency health probes wired into the host. · `modules/10-observability/health-checks-in-aspnet-core/src/HealthChecks.Api`

### 12 Background Processing

Hosted service and background worker samples.

- [Background Jobs](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/modules/12-background-processing): module hub · Hosted services and non-HTTP execution paths. · `modules/12-background-processing`
- [Hosted Services](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/blob/main/modules/12-background-processing/ihostedservice-backgroundservice/HostedServices.Api): background workers · IHostedService and BackgroundService execution outside normal requests. · `modules/12-background-processing/ihostedservice-backgroundservice/HostedServices.Api`

### archive

Older .NET 8-era course examples and legacy variants.

- [Archive](https://github.com/codewithmukesh/dotnet-webapi-zero-to-hero-course/tree/main/archive): legacy samples · Older .NET 8-era variants and earlier course lessons. · `archive`

### Other components

- **Course Repo**: monorepo · Teaching platform of isolated sample applications, grouped by module.

## Connections

- Course Repo → Getting Started: contains · Course module boundary
- Course Repo → Database Mgmt: contains · Course module boundary
- Course Repo → Advanced APIs: contains · Course module boundary
- Course Repo → Perf & Cache: contains · Course module boundary
- Course Repo → Security: contains · Course module boundary
- Course Repo → Architecture: contains · Course module boundary
- Course Repo → Observability: contains · Course module boundary
- Course Repo → Background Jobs: contains · Course module boundary
- Course Repo → Archive: contains · Legacy examples
- Getting Started → HTTP Pipeline: hosts · API host and request pipeline samples
- HTTP Pipeline → Cross-Cutting: applies · Filters and middleware wrap the request path
- Database Mgmt → EF CRUD: hosts · Representative CRUD + EF Core sample
- Database Mgmt → EF Advanced: shows · Advanced persistence behaviors
- EF CRUD → EF Advanced: shares · Common EF Core backbone
- Advanced APIs → CQRS + MediatR: hosts · MediatR-based flow
- Advanced APIs → Custom CQRS: hosts · MediatR alternative flow
- CQRS + MediatR → EF CRUD: uses · Handlers persist through EF Core
- Custom CQRS → EF CRUD: uses · Dispatcher-driven handlers persist through EF Core
- Perf & Cache → Cache Layer: contains · Cache implementations and benchmarks
- Cache Layer → EF CRUD: fronts · Cache sits between API/service and database
- Security → Auth Boundary: contains · Authentication and authorization strategies
- Auth Boundary → EF CRUD: stores · Identity and token data use persistence
- Architecture → Clean Arch: contains · Layered architecture sample
- Architecture → Vertical Slice: contains · Feature-folder sample
- Clean Arch → EF CRUD: depends on · Infrastructure persistence behind application layer
- Vertical Slice → EF CRUD: uses · Feature endpoints still depend on EF Core persistence
- Observability → Health Checks: contains · Health probe sample
- Background Jobs → Hosted Services: contains · Background execution sample
- Hosted Services → EF CRUD: runs with · Workers can interact with persistence or app services
- Archive → HTTP Pipeline: includes · Older structured logging and exception samples
