# mycopilot1601/middlewareexample architecture

> Architecture diagram of the GitHub repository mycopilot1601/middlewareexample, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mycopilot1601/middlewareexample
- Repository: https://github.com/mycopilot1601/middlewareexample

## Overview

This is an ASP.NET Core middleware example: HTTP requests enter the configured application pipeline, pass through conventional middleware and timing instrumentation, and can be routed to a sample controller. The app also configures Swagger and includes an alternative factory-based middleware pair whose registrations are commented out. Edges reflect the shown setup and middleware calls; factory wiring is marked optional because it is commented out.

Main entry points: [`MiddleWareExample/Program.cs`](https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/Program.cs) (App setup), [`MiddleWareExample/MiddleWares/ConventionalMiddlewareLogging.cs`](https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/MiddleWares/ConventionalMiddlewareLogging.cs) (Conventional logging), [`MiddleWareExample/MiddleWares/ConventionalMiddleware.cs`](https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/MiddleWares/ConventionalMiddleware.cs) (Conventional middleware), [`MiddleWareExample/MiddleWares/FactoryMiddlewareLogging.cs`](https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/MiddleWares/FactoryMiddlewareLogging.cs) (Factory logging)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application setup"]
  node_program["App setup<br/>[Program.cs]"]
end

subgraph group_pipeline["Request pipeline"]
  node_conventional_logging["Conventional logging"]
  node_conventional["Conventional middleware"]
  node_scoped_service["Scoped service"]
  node_timing["Pipeline timing"]
end

subgraph group_endpoints["API and docs"]
  node_controller["Sample controller"]
  node_swagger["Swagger UI<br/>[Program.cs]"]
end

subgraph group_factory["Factory middleware"]
  node_factory_logging["Factory logging"]
  node_factory["Factory middleware"]
end

node_client(("HTTP client"))

node_client -->|"sends request"| node_program
node_program -->|"registers first"| node_conventional_logging
node_conventional_logging -->|"calls next"| node_conventional
node_conventional -->|"calls next"| node_timing
node_conventional_logging -->|"receives scoped"| node_scoped_service
node_conventional -->|"receives scoped"| node_scoped_service
node_program -->|"adds conditionally"| node_timing
node_program -->|"maps controllers"| node_controller
node_program -->|"configures UI"| node_swagger
node_program -.->|"optionally registers"| node_factory_logging
node_program -.->|"optionally registers"| node_factory
node_factory_logging -.->|"optional sequence"| node_factory

click node_program "https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/Program.cs"
click node_conventional_logging "https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/MiddleWares/ConventionalMiddlewareLogging.cs"
click node_conventional "https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/MiddleWares/ConventionalMiddleware.cs"
click node_scoped_service "https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/MiddleWares/ServiceforScoped.cs"
click node_timing "https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/MiddleWares/PipelineTimingMiddleware.cs"
click node_controller "https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/Controllers/SampleController.cs"
click node_swagger "https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/Program.cs"
click node_factory_logging "https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/MiddleWares/FactoryMiddlewareLogging.cs"
click node_factory "https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/MiddleWares/FactoryMiddleware.cs"

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_program,node_client toneBlue
class node_conventional_logging,node_conventional,node_scoped_service,node_timing toneAmber
class node_controller,node_swagger toneMint
class node_factory_logging,node_factory toneRose
```

## Components

### Application setup

- [App setup](https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/Program.cs): `MiddleWareExample/Program.cs`

### Request pipeline

- [Conventional logging](https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/MiddleWares/ConventionalMiddlewareLogging.cs): `MiddleWareExample/MiddleWares/ConventionalMiddlewareLogging.cs`
- [Conventional middleware](https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/MiddleWares/ConventionalMiddleware.cs): `MiddleWareExample/MiddleWares/ConventionalMiddleware.cs`
- [Scoped service](https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/MiddleWares/ServiceforScoped.cs): `MiddleWareExample/MiddleWares/ServiceforScoped.cs`
- [Pipeline timing](https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/MiddleWares/PipelineTimingMiddleware.cs): `MiddleWareExample/MiddleWares/PipelineTimingMiddleware.cs`

### API and docs

- [Sample controller](https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/Controllers/SampleController.cs): `MiddleWareExample/Controllers/SampleController.cs`
- [Swagger UI](https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/Program.cs): `MiddleWareExample/Program.cs`

### Factory middleware

- [Factory logging](https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/MiddleWares/FactoryMiddlewareLogging.cs): `MiddleWareExample/MiddleWares/FactoryMiddlewareLogging.cs`
- [Factory middleware](https://github.com/mycopilot1601/middlewareexample/blob/master/MiddleWareExample/MiddleWares/FactoryMiddleware.cs): `MiddleWareExample/MiddleWares/FactoryMiddleware.cs`

### Other components

- **HTTP client**

## Connections

- HTTP client → App setup: sends request
- App setup → Conventional logging: registers first (evidence: `MiddleWareExample/Program.cs`)
- Conventional logging → Conventional middleware: calls next (evidence: `MiddleWareExample/MiddleWares/ConventionalMiddlewareLogging.cs`)
- Conventional middleware → Pipeline timing: calls next (evidence: `MiddleWareExample/MiddleWares/ConventionalMiddleware.cs`)
- Conventional logging → Scoped service: receives scoped (evidence: `MiddleWareExample/MiddleWares/ConventionalMiddlewareLogging.cs`)
- Conventional middleware → Scoped service: receives scoped (evidence: `MiddleWareExample/MiddleWares/ConventionalMiddleware.cs`)
- App setup → Pipeline timing: adds conditionally (evidence: `MiddleWareExample/Program.cs`)
- App setup → Sample controller: maps controllers (evidence: `MiddleWareExample/Program.cs`)
- App setup → Swagger UI: configures UI (evidence: `MiddleWareExample/Program.cs`)
- App setup → Factory logging: optionally registers (evidence: `MiddleWareExample/Program.cs`)
- App setup → Factory middleware: optionally registers (evidence: `MiddleWareExample/Program.cs`)
- Factory logging → Factory middleware: optional sequence (evidence: `MiddleWareExample/MiddleWares/FactoryMiddlewareLogging.cs`)
