# openiddict/openiddict-core architecture

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

- Interactive diagram: https://gitdiagram.com/openiddict/openiddict-core
- Repository: https://github.com/openiddict/openiddict-core

## Overview

#### Purpose and entry points
OpenIddict is a modular .NET framework for implementing OAuth 2.0/OpenID Connect clients, authorization servers, and token validation—not a deployable identity product. Consumers compose services through builders/extensions and select hosting, persistence, and protection adapters. The solution is `OpenIddict.slnx`; package entry APIs begin at `src/OpenIddict.Abstractions/OpenIddictBuilder.cs`, `src/OpenIddict.Client/OpenIddictClientBuilder.cs`, and `src/OpenIddict.Server/OpenIddictServerBuilder.cs`.

#### Shared contracts and domain boundary
`OpenIddict.Abstractions` defines protocol primitives, constants, descriptors, and persistence contracts. Requests/responses/messages form the protocol data boundary; descriptors model applications, authorizations, resources, scopes, sessions, and tokens. Managers and store interfaces isolate domain operations from databases.
Paths: `src/OpenIddict.Abstractions/Primitives/OpenIddictRequest.cs`, `src/OpenIddict.Abstractions/Stores/IOpenIddictTokenStore.cs`, `src/OpenIddict.Abstractions/Managers/IOpenIddictApplicationManager.cs`.

#### Core persistence orchestration
`OpenIddict.Core` implements manager and cache services over the abstract stores. This is the central application-data layer used by server behavior and configurable independently of concrete persistence. Entity Framework Core, EF6, and MongoDB provide entity models, configuration/context, and store implementations; custom stores can replace them.
Paths: `src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs`, `src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs`, `src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs`.

#### Client protocol pipeline
The client subsystem represents each operation as a transaction/event context and dispatches ordered, filterable handlers for discovery, authorization, device flow, token exchange, introspection, revocation, session, userinfo, and protection. HTTP transport and provider-specific web integrations are separate adapters; system integration adds native callback activation/listening for desktop/mobile platforms.
Paths: `src/OpenIddict.Client/OpenIddictClientDispatcher.cs`, `src/OpenIddict.Client/OpenIddictClientHandlers.Exchange.cs`, `src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Discovery.cs`, `src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationService.cs`.

#### Server protocol pipeline
The server similarly routes endpoint-specific transactions through dispatchers and handlers. It covers authentication/authorization, discovery, token exchange, device authorization, introspection, revocation, logout/session, and userinfo. Application-specific identity, consent, and authorization UI remain outside the framework, typically implemented by host controllers.
Paths: `src/OpenIddict.Server/OpenIddictServerDispatcher.cs`, `src/OpenIddict.Server/OpenIddictServerHandlers.Authentication.cs`, `src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs`.

#### Host, validation, and security adapters
ASP.NET Core and OWIN packages bridge host middleware/request features into the client, server, and validation pipelines. Validation has its own dispatcher and can obtain configuration/introspection data through System.Net.Http or integrate with a colocated server. Data Protection adapters implement protected-token formatting; Quartz supplies scheduled maintenance execution.
Paths: `src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandler.cs`, `src/OpenIddict.Validation/OpenIddictValidationDispatcher.cs`, `src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Introspection.cs`, `src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionFormatter.cs`, `src/OpenIddict.Quartz/OpenIddictQuartzJob.cs`.

#### Runtimes, examples, and delivery
Primary runtimes are .NET, ASP.NET Core, ASP.NET/OWIN, and client OS integrations; external persistence targets are EF Core, EF6, and MongoDB. Sandboxes demonstrate executable hosts across ASP.NET Core, classic ASP.NET, console, MAUI, WinForms, and WPF, with server/client requests crossing normal OAuth/OIDC HTTP boundaries. A source generator produces web-integration provider code from provider metadata. Build scripts/package settings support NuGet distribution and CI.
Paths: `sandbox/OpenIddict.Sandbox.AspNetCore.Server/Program.cs`, `sandbox/OpenIddict.Sandbox.Maui.Client/MauiProgram.cs`, `gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs`.

Main entry points: [`src/OpenIddict.Server/OpenIddictServerDispatcher.cs`](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Server/OpenIddictServerDispatcher.cs) (Server dispatcher), [`src/OpenIddict.Client/OpenIddictClientDispatcher.cs`](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Client/OpenIddictClientDispatcher.cs) (Client dispatcher), [`src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs`](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs) (Core managers and cache), [`src/OpenIddict.Abstractions/OpenIddictBuilder.cs`](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Abstractions/OpenIddictBuilder.cs) (Service builders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_foundation["Foundation"]
  node_builders["Service builders<br/>composition API"]
  node_protocol_messages["Protocol messages<br/>request/response model"]
  node_store_contracts["Store contracts<br/>persistence interfaces"]
  node_manager_contracts["Manager contracts<br/>domain interfaces"]
  node_core_managers["Core managers and cache<br/>application-data layer"]
end

subgraph group_protocol["Protocol engines"]
  node_client_dispatcher["Client dispatcher<br/>protocol dispatcher"]
  node_client_exchange["Client exchange handlers<br/>client pipeline"]
  node_server_dispatcher["Server dispatcher<br/>protocol dispatcher"]
  node_server_authentication["Server authentication handlers<br/>server pipeline"]
  node_server_exchange["Server exchange handlers<br/>server pipeline"]
  node_validation_dispatcher["Validation dispatcher<br/>validation pipeline"]
end

subgraph group_adapters["Adapters and runtimes"]
  node_persistence_adapters[("EF Core, EF6, MongoDB stores<br/>storage adapters")]
  node_mongodb_store[("MongoDB application store<br/>storage adapter")]
  node_http_transport["System.Net.Http adapters<br/>HTTP transport"]
  node_system_integration["Client system integration<br/>native callback adapter"]
  node_aspnetcore_host["ASP.NET Core host bridge<br/>host middleware adapter"]
  node_validation_introspection["Validation introspection<br/>remote validation adapter"]
  node_data_protection["Data Protection formatter<br/>token protection adapter"]
  node_quartz["Quartz maintenance job<br/>scheduled maintenance"]
end

subgraph group_delivery["Examples and delivery"]
  node_web_generator{{"Web integration generator<br/>source generator"}}
  node_aspnet_sandbox["ASP.NET Core server sandbox<br/>example host<br/>[Program.cs]"]
  node_maui_sandbox["MAUI client sandbox<br/>example client<br/>[MauiProgram.cs]"]
end

node_builders -->|"configures"| node_store_contracts
node_builders -->|"registers"| node_core_managers
node_builders -->|"composes"| node_client_dispatcher
node_builders -->|"composes"| node_server_dispatcher
node_store_contracts -->|"implemented behind"| node_core_managers
node_manager_contracts -->|"implemented by"| node_core_managers
node_persistence_adapters -->|"implements"| node_store_contracts
node_mongodb_store -->|"implements"| node_store_contracts
node_client_dispatcher -->|"dispatches"| node_client_exchange
node_client_dispatcher -->|"processes"| node_protocol_messages
node_client_dispatcher -->|"uses"| node_http_transport
node_client_dispatcher -->|"uses"| node_system_integration
node_server_dispatcher -->|"dispatches"| node_server_authentication
node_server_dispatcher -->|"dispatches"| node_server_exchange
node_server_dispatcher -->|"uses"| node_core_managers
node_server_dispatcher -->|"processes"| node_protocol_messages
node_aspnetcore_host -->|"bridges requests to"| node_server_dispatcher
node_server_dispatcher -->|"formats tokens with"| node_data_protection
node_quartz -->|"maintains"| node_core_managers
node_validation_dispatcher -->|"uses"| node_validation_introspection
node_validation_introspection -->|"uses transport"| node_http_transport
node_web_generator -.->|"generates integrations for"| node_client_dispatcher
node_aspnet_sandbox -.->|"demonstrates"| node_aspnetcore_host
node_maui_sandbox -.->|"demonstrates"| node_system_integration
node_maui_sandbox -.->|"issues OAuth/OIDC requests"| node_client_dispatcher

click node_builders "https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Abstractions/OpenIddictBuilder.cs"
click node_protocol_messages "https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Abstractions/Primitives/OpenIddictRequest.cs"
click node_store_contracts "https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Abstractions/Stores/IOpenIddictTokenStore.cs"
click node_manager_contracts "https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Abstractions/Managers/IOpenIddictApplicationManager.cs"
click node_core_managers "https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs"
click node_persistence_adapters "https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs"
click node_mongodb_store "https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs"
click node_client_dispatcher "https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Client/OpenIddictClientDispatcher.cs"
click node_client_exchange "https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Client/OpenIddictClientHandlers.Exchange.cs"
click node_server_dispatcher "https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Server/OpenIddictServerDispatcher.cs"
click node_server_authentication "https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Server/OpenIddictServerHandlers.Authentication.cs"
click node_server_exchange "https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs"
click node_validation_dispatcher "https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Validation/OpenIddictValidationDispatcher.cs"
click node_http_transport "https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Discovery.cs"
click node_system_integration "https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationService.cs"
click node_aspnetcore_host "https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandler.cs"
click node_validation_introspection "https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Introspection.cs"
click node_data_protection "https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionFormatter.cs"
click node_quartz "https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Quartz/OpenIddictQuartzJob.cs"
click node_web_generator "https://github.com/openiddict/openiddict-core/blob/dev/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs"
click node_aspnet_sandbox "https://github.com/openiddict/openiddict-core/blob/dev/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Program.cs"
click node_maui_sandbox "https://github.com/openiddict/openiddict-core/blob/dev/sandbox/OpenIddict.Sandbox.Maui.Client/MauiProgram.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_builders,node_protocol_messages,node_store_contracts,node_manager_contracts,node_core_managers toneBlue
class node_client_dispatcher,node_client_exchange,node_server_dispatcher,node_server_authentication,node_server_exchange,node_validation_dispatcher toneAmber
class node_persistence_adapters,node_mongodb_store,node_http_transport,node_system_integration,node_aspnetcore_host,node_validation_introspection,node_data_protection,node_quartz toneMint
class node_web_generator,node_aspnet_sandbox,node_maui_sandbox toneRose
```

## Components

### Foundation

Shared contracts and persistence orchestration.

- [Service builders](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Abstractions/OpenIddictBuilder.cs): composition API · Consumers compose OpenIddict services and adapters. · `src/OpenIddict.Abstractions/OpenIddictBuilder.cs`
- [Protocol messages](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Abstractions/Primitives/OpenIddictRequest.cs): request/response model · OAuth/OIDC protocol data boundary. · `src/OpenIddict.Abstractions/Primitives/OpenIddictRequest.cs`
- [Store contracts](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Abstractions/Stores/IOpenIddictTokenStore.cs): persistence interfaces · Abstract persistence boundary for domain entities. · `src/OpenIddict.Abstractions/Stores/IOpenIddictTokenStore.cs`
- [Manager contracts](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Abstractions/Managers/IOpenIddictApplicationManager.cs): domain interfaces · Application-domain operations exposed to protocol services. · `src/OpenIddict.Abstractions/Managers/IOpenIddictApplicationManager.cs`
- [Core managers and cache](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs): application-data layer · Implements managers over abstract stores. · `src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs`

### Protocol engines

Event-driven client, server, and validation processing.

- [Client dispatcher](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Client/OpenIddictClientDispatcher.cs): protocol dispatcher · Runs ordered, filterable client handlers per transaction. · `src/OpenIddict.Client/OpenIddictClientDispatcher.cs`
- [Client exchange handlers](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Client/OpenIddictClientHandlers.Exchange.cs): client pipeline · Handles token and related client exchanges. · `src/OpenIddict.Client/OpenIddictClientHandlers.Exchange.cs`
- [Server dispatcher](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Server/OpenIddictServerDispatcher.cs): protocol dispatcher · Routes endpoint transactions through server handlers. · `src/OpenIddict.Server/OpenIddictServerDispatcher.cs`
- [Server authentication handlers](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Server/OpenIddictServerHandlers.Authentication.cs): server pipeline · `src/OpenIddict.Server/OpenIddictServerHandlers.Authentication.cs`
- [Server exchange handlers](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs): server pipeline · Handles token exchange processing. · `src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs`
- [Validation dispatcher](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Validation/OpenIddictValidationDispatcher.cs): validation pipeline · Processes token validation transactions. · `src/OpenIddict.Validation/OpenIddictValidationDispatcher.cs`

### Adapters and runtimes

Hosting, transport, protection, storage, and scheduling integrations.

- [EF Core, EF6, MongoDB stores](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs): storage adapters · Replaceable concrete store implementations. · `src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs`
- [MongoDB application store](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs): storage adapter · `src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs`
- [System.Net.Http adapters](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Discovery.cs): HTTP transport · Provides discovery and remote introspection transport. · `src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Discovery.cs`
- [Client system integration](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationService.cs): native callback adapter · Activates and listens for desktop/mobile callbacks. · `src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationService.cs`
- [ASP.NET Core host bridge](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandler.cs): host middleware adapter · Bridges ASP.NET Core request features into protocol pipelines. · `src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandler.cs`
- [Validation introspection](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Introspection.cs): remote validation adapter · `src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Introspection.cs`
- [Data Protection formatter](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionFormatter.cs): token protection adapter · Formats protected server tokens. · `src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionFormatter.cs`
- [Quartz maintenance job](https://github.com/openiddict/openiddict-core/blob/dev/src/OpenIddict.Quartz/OpenIddictQuartzJob.cs): scheduled maintenance · Executes scheduled maintenance work. · `src/OpenIddict.Quartz/OpenIddictQuartzJob.cs`

### Examples and delivery

Executable hosts and generated provider integrations.

- [Web integration generator](https://github.com/openiddict/openiddict-core/blob/dev/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs): source generator · Generates provider-specific web integration code. · `gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs`
- [ASP.NET Core server sandbox](https://github.com/openiddict/openiddict-core/blob/dev/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Program.cs): example host · Example OAuth/OIDC server host. · `sandbox/OpenIddict.Sandbox.AspNetCore.Server/Program.cs`
- [MAUI client sandbox](https://github.com/openiddict/openiddict-core/blob/dev/sandbox/OpenIddict.Sandbox.Maui.Client/MauiProgram.cs): example client · Example native client host. · `sandbox/OpenIddict.Sandbox.Maui.Client/MauiProgram.cs`

## Connections

- Service builders → Store contracts: configures
- Service builders → Core managers and cache: registers
- Service builders → Client dispatcher: composes
- Service builders → Server dispatcher: composes
- Store contracts → Core managers and cache: implemented behind
- Manager contracts → Core managers and cache: implemented by
- EF Core, EF6, MongoDB stores → Store contracts: implements
- MongoDB application store → Store contracts: implements
- Client dispatcher → Client exchange handlers: dispatches
- Client dispatcher → Protocol messages: processes
- Client dispatcher → System.Net.Http adapters: uses
- Client dispatcher → Client system integration: uses
- Server dispatcher → Server authentication handlers: dispatches
- Server dispatcher → Server exchange handlers: dispatches
- Server dispatcher → Core managers and cache: uses
- Server dispatcher → Protocol messages: processes
- ASP.NET Core host bridge → Server dispatcher: bridges requests to
- Server dispatcher → Data Protection formatter: formats tokens with
- Quartz maintenance job → Core managers and cache: maintains
- Validation dispatcher → Validation introspection: uses
- Validation introspection → System.Net.Http adapters: uses transport
- Web integration generator → Client dispatcher: generates integrations for
- ASP.NET Core server sandbox → ASP.NET Core host bridge: demonstrates
- MAUI client sandbox → Client system integration: demonstrates
- MAUI client sandbox → Client dispatcher: issues OAuth/OIDC requests
