Skip to content

Diagrams Worth Memorizing

← Roadmap · README

Every 🎯 topic in the roadmap should end up here. These are the drawings that turn a rambling verbal answer into a confident one — when you can draw it, you stop backtracking, and the interviewer can follow you.

Practise on paper. Being able to read a diagram is not the same as being able to produce one under pressure with a marker in your hand.

Diagrams use Mermaid, which renders in the VS Code preview (with Markdown Preview Enhanced), on GitHub, and in the exported PDF.


1. The ASP.NET Core request pipeline · 5.1

The single most useful diagram in this repo. If you can draw this and narrate it, you can answer a large fraction of every ASP.NET Core interview.

flowchart TD
    A[HTTP Request] --> B[Kestrel]
    B --> C[ExceptionHandler]
    C --> D[HSTS / HttpsRedirection]
    D --> E[StaticFiles]
    E --> F[Routing]
    F --> G[CORS]
    G --> H[Authentication]
    H --> I[Authorization]
    I --> J[Custom middleware]
    J --> K[Endpoint: filters → action]
    K --> L[Response travels back up]
    L --> A

The narration: each middleware gets the HttpContext, does work before calling next(), then does work after it returns. So the pipeline is a nested set of try/finally-shaped calls, not a flat list — which is exactly why order matters and why response-modifying middleware has to be registered early.


2. DI service lifetimes · 6.3

flowchart LR
    subgraph App["Application (root scope)"]
        S["Singleton — one instance forever"]
        subgraph R1["Request 1 scope"]
            SC1["Scoped — one per request"]
            T1["Transient"] & T2["Transient"]
        end
        subgraph R2["Request 2 scope"]
            SC2["Scoped — a different one"]
            T3["Transient"]
        end
    end

The narration: transient is per-injection, scoped is per-request, singleton is per-app. The captive dependency problem is what happens when you draw an arrow from S into SC1 — the singleton pins a request-scoped object alive forever.


3. OAuth 2.0 authorization code flow with PKCE · 15.8

sequenceDiagram
    participant U as User
    participant C as Client app
    participant A as Auth server
    participant R as Resource API

    C->>C: Generate code_verifier + code_challenge
    U->>C: Click "Log in"
    C->>A: /authorize (+ code_challenge)
    A->>U: Login + consent
    U->>A: Credentials
    A->>C: Redirect with authorization code
    C->>A: /token (code + code_verifier)
    A->>A: Verify challenge matches verifier
    A->>C: Access token (+ refresh token)
    C->>R: Request + Bearer token
    R->>R: Validate signature, issuer, audience, expiry
    R->>C: Protected resource

4. Clean Architecture layers · 22.7

flowchart TD
    I["Infrastructure — EF Core, HTTP clients, file system"] --> A
    W["Web / API — controllers, middleware, DI wiring"] --> A
    A["Application — use cases, interfaces, DTOs"] --> D
    D["Domain — entities, value objects, domain events"]

The one rule: dependencies point inward. Domain knows nothing about anything. The interface for a repository lives in Application; the implementation lives in Infrastructure. That inversion is the entire point — everything else is folder naming.


To be added

Each of these is a 🎯 topic in the roadmap. Draw it when you write the note.

  • [ ] Kestrel vs IIS hosting models — 4.9
  • [ ] Application lifecycle and graceful shutdown — 4.6
  • [ ] Middleware vs filters — where each sits — 5.13
  • [ ] The filter pipeline and its five types — 12.1
  • [ ] GC generations and promotion — 3.4
  • [ ] async/await state machine — 2.11
  • [ ] Thread vs Task vs ThreadPool — 2.10
  • [ ] CORS preflight exchange — 10.10
  • [ ] The N+1 query problem — 13.9
  • [ ] Index B-tree structure — 14.2
  • [ ] Isolation levels vs read phenomena (the classic grid) — 14.3
  • [ ] CSRF attack sequence — 17.4
  • [ ] Cache-aside read and write paths — 19.1
  • [ ] Circuit breaker state machine — 19.11
  • [ ] Saga: orchestration vs choreography — 23.8
  • [ ] Outbox pattern — 23.8
  • [ ] API Gateway / BFF topology — 23.10
  • [ ] Blue-green vs canary rollout — 24.11