# ertugrulozcan/ertisauth architecture

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

- Interactive diagram: https://gitdiagram.com/ertugrulozcan/ertisauth
- Repository: https://github.com/ertugrulozcan/ertisauth

## Overview

ErtisAuth is a self-hosted, multi-tenant identity and access-management API. A client signs in or exchanges an external-provider identity, receives tokens, and uses them to access membership-scoped resources under RBAC/UBAC rules; administrators manage tenants and their users, roles, applications, providers, and policies through the same API. The graph also preserves dynamic user types, lifecycle operations, event-driven hooks, and .NET SDK integrations. Relationships are based on the README and the indexed excerpts; unsampled implementation details are represented at directory level.

Main entry points: [`src/ErtisAuth.WebAPI/Controllers`](https://github.com/ertugrulozcan/ertisauth/tree/master/src/ErtisAuth.WebAPI/Controllers) (REST API), [`src/ErtisAuth.Dao/Repositories`](https://github.com/ertugrulozcan/ertisauth/tree/master/src/ErtisAuth.Dao/Repositories) (Repositories), [`src/ErtisAuth.Infrastructure/Services/TokenService.cs`](https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/TokenService.cs) (Token services), [`src/ErtisAuth.Infrastructure/Services/EventService.cs`](https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/EventService.cs) (Event log and dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and clients"]
  node_webapi["REST API<br/>[Controllers]"]
  node_sdk["Typed .NET SDK<br/>[Services]"]
  node_aspnet["ASP.NET integration<br/>[Middleware]"]
end

subgraph group_identity["Identity and access"]
  node_authn["Request authentication"]
  node_tokens["Token operations"]
  node_tokenservice["Token services<br/>[TokenService.cs]"]
  node_access["RBAC and UBAC"]
  node_oauth["Provider sign-in"]
end

subgraph group_domain["Tenant domain"]
  node_users["Users and lifecycle<br/>[UsersController.cs]"]
  node_memberships["Memberships and setup"]
  node_types["Dynamic user types<br/>[UserTypeService.cs]"]
  node_roles["Roles and permissions<br/>[RoleService.cs]"]
  node_applications["Applications"]
  node_providers["Provider configuration<br/>[ProviderService.cs]"]
end

subgraph group_persistence["Persistence"]
  node_mongo[("MongoDB")]
  node_repositories["Repositories<br/>[Repositories]"]
end

subgraph group_automation["Events and delivery"]
  node_events["Event log and dispatch<br/>[EventService.cs]"]
  node_webhooks["Webhook delivery"]
  node_mail["Mail hooks and providers"]
end

node_client(("Applications and operators"))

node_client -->|"manages and authenticates"| node_webapi
node_client -->|"uses"| node_sdk
node_sdk -.->|"calls REST API"| node_webapi
node_client -->|"integrates with"| node_aspnet
node_webapi -->|"routes token requests"| node_tokens
node_tokens -->|"invokes"| node_tokenservice
node_webapi -->|"routes user requests"| node_users
node_users -->|"uses token operations"| node_tokenservice
node_authn -->|"validates tokens"| node_tokenservice
node_authn -->|"checks access"| node_access
node_webapi -->|"manages tenants"| node_memberships
node_webapi -->|"manages schemas"| node_types
node_webapi -->|"manages permissions"| node_roles
node_webapi -->|"manages clients"| node_applications
node_webapi -->|"configures providers"| node_providers
node_oauth -->|"uses provider configuration"| node_providers
node_oauth -->|"signs in users"| node_users
node_memberships -.->|"persists tenant data"| node_repositories
node_types -.->|"persists type data"| node_repositories
node_roles -.->|"persists roles"| node_repositories
node_applications -.->|"persists applications"| node_repositories
node_providers -.->|"persists providers"| node_repositories
node_tokenservice -.->|"stores token state"| node_repositories
node_repositories -->|"reads and writes"| node_mongo
node_webapi -->|"records operations"| node_events
node_events -->|"triggers queued calls"| node_webhooks
node_events -->|"triggers mail hooks"| node_mail

click node_webapi "https://github.com/ertugrulozcan/ertisauth/tree/master/src/ErtisAuth.WebAPI/Controllers"
click node_sdk "https://github.com/ertugrulozcan/ertisauth/tree/master/src/ErtisAuth.Sdk/Services"
click node_aspnet "https://github.com/ertugrulozcan/ertisauth/tree/master/src/ErtisAuth.Sdk.AspNetCore/Middleware"
click node_authn "https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Extensions.AspNetCore/Middleware/ErtisAuthAuthenticationHandler.cs"
click node_tokens "https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.WebAPI/Controllers/TokensController.cs"
click node_tokenservice "https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/TokenService.cs"
click node_access "https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/AccessControlService.cs"
click node_oauth "https://github.com/ertugrulozcan/ertisauth/tree/master/src/ErtisAuth.Integrations.OAuth"
click node_users "https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.WebAPI/Controllers/UsersController.cs"
click node_memberships "https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/MembershipService.cs"
click node_types "https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/UserTypeService.cs"
click node_roles "https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/RoleService.cs"
click node_applications "https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/ApplicationService.cs"
click node_providers "https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/ProviderService.cs"
click node_repositories "https://github.com/ertugrulozcan/ertisauth/tree/master/src/ErtisAuth.Dao/Repositories"
click node_events "https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/EventService.cs"
click node_webhooks "https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/WebhookBackgroundService.cs"
click node_mail "https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/MailBackgroundService.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_webapi,node_sdk,node_aspnet toneBlue
class node_authn,node_tokens,node_tokenservice,node_access,node_oauth toneAmber
class node_users,node_memberships,node_types,node_roles,node_applications,node_providers toneMint
class node_mongo,node_repositories toneRose
class node_events,node_webhooks,node_mail,node_client toneIndigo
```

## Components

### API and clients

- [REST API](https://github.com/ertugrulozcan/ertisauth/tree/master/src/ErtisAuth.WebAPI/Controllers): `src/ErtisAuth.WebAPI/Controllers`
- [Typed .NET SDK](https://github.com/ertugrulozcan/ertisauth/tree/master/src/ErtisAuth.Sdk/Services): `src/ErtisAuth.Sdk/Services`
- [ASP.NET integration](https://github.com/ertugrulozcan/ertisauth/tree/master/src/ErtisAuth.Sdk.AspNetCore/Middleware): `src/ErtisAuth.Sdk.AspNetCore/Middleware`

### Identity and access

- [Request authentication](https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Extensions.AspNetCore/Middleware/ErtisAuthAuthenticationHandler.cs): `src/ErtisAuth.Extensions.AspNetCore/Middleware/ErtisAuthAuthenticationHandler.cs`
- [Token operations](https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.WebAPI/Controllers/TokensController.cs): `src/ErtisAuth.WebAPI/Controllers/TokensController.cs`
- [Token services](https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/TokenService.cs): `src/ErtisAuth.Infrastructure/Services/TokenService.cs`
- [RBAC and UBAC](https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/AccessControlService.cs): `src/ErtisAuth.Infrastructure/Services/AccessControlService.cs`
- [Provider sign-in](https://github.com/ertugrulozcan/ertisauth/tree/master/src/ErtisAuth.Integrations.OAuth): `src/ErtisAuth.Integrations.OAuth`

### Tenant domain

- [Users and lifecycle](https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.WebAPI/Controllers/UsersController.cs): `src/ErtisAuth.WebAPI/Controllers/UsersController.cs`
- [Memberships and setup](https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/MembershipService.cs): `src/ErtisAuth.Infrastructure/Services/MembershipService.cs`
- [Dynamic user types](https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/UserTypeService.cs): `src/ErtisAuth.Infrastructure/Services/UserTypeService.cs`
- [Roles and permissions](https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/RoleService.cs): `src/ErtisAuth.Infrastructure/Services/RoleService.cs`
- [Applications](https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/ApplicationService.cs): `src/ErtisAuth.Infrastructure/Services/ApplicationService.cs`
- [Provider configuration](https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/ProviderService.cs): `src/ErtisAuth.Infrastructure/Services/ProviderService.cs`

### Persistence

- **MongoDB**
- [Repositories](https://github.com/ertugrulozcan/ertisauth/tree/master/src/ErtisAuth.Dao/Repositories): `src/ErtisAuth.Dao/Repositories`

### Events and delivery

- [Event log and dispatch](https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/EventService.cs): `src/ErtisAuth.Infrastructure/Services/EventService.cs`
- [Webhook delivery](https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/WebhookBackgroundService.cs): `src/ErtisAuth.Infrastructure/Services/WebhookBackgroundService.cs`
- [Mail hooks and providers](https://github.com/ertugrulozcan/ertisauth/blob/master/src/ErtisAuth.Infrastructure/Services/MailBackgroundService.cs): `src/ErtisAuth.Infrastructure/Services/MailBackgroundService.cs`

### Other components

- **Applications and operators**

## Connections

- Applications and operators → REST API: manages and authenticates (evidence: `README.md`)
- Applications and operators → Typed .NET SDK: uses (evidence: `README.md`)
- Typed .NET SDK → REST API: calls REST API
- Applications and operators → ASP.NET integration: integrates with (evidence: `README.md`)
- REST API → Token operations: routes token requests (evidence: `src/ErtisAuth.WebAPI/Controllers/TokensController.cs`)
- Token operations → Token services: invokes (evidence: `src/ErtisAuth.WebAPI/Controllers/TokensController.cs`)
- REST API → Users and lifecycle: routes user requests (evidence: `src/ErtisAuth.WebAPI/Controllers/UsersController.cs`)
- Users and lifecycle → Token services: uses token operations (evidence: `src/ErtisAuth.WebAPI/Controllers/UsersController.cs`)
- Request authentication → Token services: validates tokens (evidence: `src/ErtisAuth.Extensions.AspNetCore/Middleware/ErtisAuthAuthenticationHandler.cs`)
- Request authentication → RBAC and UBAC: checks access (evidence: `src/ErtisAuth.Extensions.AspNetCore/Middleware/ErtisAuthAuthenticationHandler.cs`)
- REST API → Memberships and setup: manages tenants (evidence: `README.md`)
- REST API → Dynamic user types: manages schemas (evidence: `README.md`)
- REST API → Roles and permissions: manages permissions (evidence: `README.md`)
- REST API → Applications: manages clients (evidence: `README.md`)
- REST API → Provider configuration: configures providers (evidence: `README.md`)
- Provider sign-in → Provider configuration: uses provider configuration (evidence: `README.md`)
- Provider sign-in → Users and lifecycle: signs in users (evidence: `README.md`)
- Memberships and setup → Repositories: persists tenant data
- Dynamic user types → Repositories: persists type data
- Roles and permissions → Repositories: persists roles
- Applications → Repositories: persists applications
- Provider configuration → Repositories: persists providers
- Token services → Repositories: stores token state
- Repositories → MongoDB: reads and writes
- REST API → Event log and dispatch: records operations (evidence: `README.md`)
- Event log and dispatch → Webhook delivery: triggers queued calls (evidence: `README.md`)
- Event log and dispatch → Mail hooks and providers: triggers mail hooks (evidence: `README.md`)
