# aliahmedadd8-pixel/default-project architecture

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

- Interactive diagram: https://gitdiagram.com/aliahmedadd8-pixel/default-project
- Repository: https://github.com/aliahmedadd8-pixel/default-project

## Overview

Sahm.PartyIdentity is a modular .NET library for managing parties, user identities, client applications, roles and grants, authorization, and tenant-aware persistence. The principal workflow is an ASP.NET Core request that resolves its tenant, invokes a domain operation, and persists the result; authorization checks evaluate grants and roles. The repository also documents OIDC token and userinfo endpoints, optional KYC documents, and SQL Server/PostgreSQL providers. Some connections are documented capabilities rather than inspected call paths, so those edges are dashed or omitted.

Main entry points: [`src/EfCoreBase/PartyIdentityDbContext.cs`](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/EfCoreBase/PartyIdentityDbContext.cs) (EF Core Context), [`src/AspNetCore/PartyIdentityExtensions.cs`](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/AspNetCore/PartyIdentityExtensions.cs) (REST Endpoints), [`src/EfCoreBase/Tenancy/TenancyServices.cs`](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/EfCoreBase/Tenancy/TenancyServices.cs) (Tenant Services), [`src/Core/Party/Party.cs`](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Core/Party/Party.cs) (Parties)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["ASP.NET Core"]
  node_api["REST Endpoints"]
  node_permissions["Permission Handler<br/>[Permissions.cs]"]
end

subgraph group_domain["Identity Domain"]
  node_party["Parties<br/>[Party.cs]"]
  node_users["User Accounts<br/>[UserAccount.cs]"]
  node_applications["Client Applications<br/>[Application.cs]"]
  node_access["Roles and Grants<br/>[Access.cs]"]
  node_authorization["Authorization<br/>[Authorization.cs]"]
  node_options["Product Options"]
  node_events["Domain Events<br/>[DomainEvents.cs]"]
end

subgraph group_tenancy["Tenant Management"]
  node_tenantmiddleware["Tenant Middleware<br/>[Tenancy.cs]"]
  node_tenantservices["Tenant Services<br/>[TenancyServices.cs]"]
  node_tenantrecord["Tenant Catalog Record<br/>[TenantRecord.cs]"]
end

subgraph group_storage["Persistence"]
  node_dbcontext["EF Core Context"]
  node_sqlserver["SQL Server Provider"]
  node_postgres["PostgreSQL Provider"]
end

subgraph group_integrations["Optional Integrations"]
  node_oidc["OIDC Server<br/>[OidcExtensions.cs]"]
  node_tokenissuer["Token Issuer<br/>[OidcTokenIssuer.cs]"]
  node_kyc["KYC Documents<br/>[Documents.cs]"]
end

node_caller(("Application Client"))

node_caller -->|"calls endpoints"| node_api
node_api -.->|"uses tenant context"| node_tenantmiddleware
node_tenantmiddleware -.->|"resolves tenant"| node_tenantservices
node_api -->|"creates parties"| node_party
node_api -->|"creates applications"| node_applications
node_api -->|"assigns grants"| node_access
node_api -.->|"persists entities"| node_dbcontext
node_api -->|"checks access"| node_authorization
node_authorization -->|"evaluates grants"| node_access
node_permissions -->|"checks permissions"| node_authorization
node_dbcontext -->|"maps entities"| node_party
node_dbcontext -->|"maps entities"| node_users
node_dbcontext -->|"maps entities"| node_applications
node_dbcontext -->|"maps entities"| node_access
node_dbcontext -->|"maps catalog"| node_tenantrecord
node_tenantservices -->|"creates contexts"| node_dbcontext
node_tenantservices -->|"reads and writes"| node_tenantrecord
node_sqlserver -->|"configures provider"| node_dbcontext
node_postgres -->|"configures provider"| node_dbcontext
node_caller -->|"requests tokens"| node_oidc
node_oidc -.->|"issues tokens"| node_tokenissuer
node_caller -.->|"submits documents"| node_kyc
node_party -->|"raises events"| node_events
node_options -->|"configures tenancy"| node_tenantmiddleware

click node_api "https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/AspNetCore/PartyIdentityExtensions.cs"
click node_permissions "https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/AspNetCore/Auth/Permissions.cs"
click node_party "https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Core/Party/Party.cs"
click node_users "https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Core/Identity/UserAccount.cs"
click node_applications "https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Core/Applications/Application.cs"
click node_access "https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Core/Access/Access.cs"
click node_authorization "https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Core/Authorization/Authorization.cs"
click node_options "https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Core/Configuration/PartyIdentityOptions.cs"
click node_tenantmiddleware "https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/AspNetCore/Tenancy/Tenancy.cs"
click node_tenantservices "https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/EfCoreBase/Tenancy/TenancyServices.cs"
click node_tenantrecord "https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/EfCoreBase/TenantRecord.cs"
click node_dbcontext "https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/EfCoreBase/PartyIdentityDbContext.cs"
click node_sqlserver "https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Ef.SqlServer/SqlServerRegistration.cs"
click node_postgres "https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Ef.PostgreSql/PostgreSqlRegistration.cs"
click node_oidc "https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Oidc/OidcExtensions.cs"
click node_tokenissuer "https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Oidc/OidcTokenIssuer.cs"
click node_kyc "https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Kyc.Documents/Documents.cs"
click node_events "https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Contracts/DomainEvents.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_api,node_permissions,node_caller toneBlue
class node_party,node_users,node_applications,node_access,node_authorization,node_options,node_events toneAmber
class node_tenantmiddleware,node_tenantservices,node_tenantrecord toneMint
class node_dbcontext,node_sqlserver,node_postgres toneRose
class node_oidc,node_tokenissuer,node_kyc toneIndigo
```

## Components

### ASP.NET Core

- [REST Endpoints](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/AspNetCore/PartyIdentityExtensions.cs): `src/AspNetCore/PartyIdentityExtensions.cs`
- [Permission Handler](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/AspNetCore/Auth/Permissions.cs): `src/AspNetCore/Auth/Permissions.cs`

### Identity Domain

- [Parties](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Core/Party/Party.cs): `src/Core/Party/Party.cs`
- [User Accounts](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Core/Identity/UserAccount.cs): `src/Core/Identity/UserAccount.cs`
- [Client Applications](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Core/Applications/Application.cs): `src/Core/Applications/Application.cs`
- [Roles and Grants](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Core/Access/Access.cs): `src/Core/Access/Access.cs`
- [Authorization](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Core/Authorization/Authorization.cs): `src/Core/Authorization/Authorization.cs`
- [Product Options](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Core/Configuration/PartyIdentityOptions.cs): `src/Core/Configuration/PartyIdentityOptions.cs`
- [Domain Events](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Contracts/DomainEvents.cs): `src/Contracts/DomainEvents.cs`

### Tenant Management

- [Tenant Middleware](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/AspNetCore/Tenancy/Tenancy.cs): `src/AspNetCore/Tenancy/Tenancy.cs`
- [Tenant Services](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/EfCoreBase/Tenancy/TenancyServices.cs): `src/EfCoreBase/Tenancy/TenancyServices.cs`
- [Tenant Catalog Record](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/EfCoreBase/TenantRecord.cs): `src/EfCoreBase/TenantRecord.cs`

### Persistence

- [EF Core Context](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/EfCoreBase/PartyIdentityDbContext.cs): `src/EfCoreBase/PartyIdentityDbContext.cs`
- [SQL Server Provider](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Ef.SqlServer/SqlServerRegistration.cs): `src/Ef.SqlServer/SqlServerRegistration.cs`
- [PostgreSQL Provider](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Ef.PostgreSql/PostgreSqlRegistration.cs): `src/Ef.PostgreSql/PostgreSqlRegistration.cs`

### Optional Integrations

- [OIDC Server](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Oidc/OidcExtensions.cs): `src/Oidc/OidcExtensions.cs`
- [Token Issuer](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Oidc/OidcTokenIssuer.cs): `src/Oidc/OidcTokenIssuer.cs`
- [KYC Documents](https://github.com/aliahmedadd8-pixel/default-project/blob/main/src/Kyc.Documents/Documents.cs): `src/Kyc.Documents/Documents.cs`

### Other components

- **Application Client**

## Connections

- Application Client → REST Endpoints: calls endpoints (evidence: `README.md`)
- REST Endpoints → Tenant Middleware: uses tenant context (evidence: `src/AspNetCore/PartyIdentityExtensions.cs`)
- Tenant Middleware → Tenant Services: resolves tenant (evidence: `src/EfCoreBase/Tenancy/TenancyServices.cs`)
- REST Endpoints → Parties: creates parties (evidence: `src/AspNetCore/PartyIdentityExtensions.cs`)
- REST Endpoints → Client Applications: creates applications (evidence: `src/AspNetCore/PartyIdentityExtensions.cs`)
- REST Endpoints → Roles and Grants: assigns grants (evidence: `src/AspNetCore/PartyIdentityExtensions.cs`)
- REST Endpoints → EF Core Context: persists entities (evidence: `src/AspNetCore/PartyIdentityExtensions.cs`)
- REST Endpoints → Authorization: checks access (evidence: `README.md`)
- Authorization → Roles and Grants: evaluates grants (evidence: `src/Core/Authorization/Authorization.cs`)
- Permission Handler → Authorization: checks permissions (evidence: `src/AspNetCore/Auth/Permissions.cs`)
- EF Core Context → Parties: maps entities (evidence: `src/EfCoreBase/PartyIdentityDbContext.cs`)
- EF Core Context → User Accounts: maps entities (evidence: `src/EfCoreBase/PartyIdentityDbContext.cs`)
- EF Core Context → Client Applications: maps entities (evidence: `src/EfCoreBase/PartyIdentityDbContext.cs`)
- EF Core Context → Roles and Grants: maps entities (evidence: `src/EfCoreBase/PartyIdentityDbContext.cs`)
- EF Core Context → Tenant Catalog Record: maps catalog (evidence: `src/EfCoreBase/PartyIdentityDbContext.cs`)
- Tenant Services → EF Core Context: creates contexts (evidence: `src/EfCoreBase/Tenancy/TenancyServices.cs`)
- Tenant Services → Tenant Catalog Record: reads and writes (evidence: `src/EfCoreBase/Tenancy/TenancyServices.cs`)
- SQL Server Provider → EF Core Context: configures provider (evidence: `src/Ef.SqlServer/SqlServerRegistration.cs`)
- PostgreSQL Provider → EF Core Context: configures provider (evidence: `src/Ef.PostgreSql/PostgreSqlRegistration.cs`)
- Application Client → OIDC Server: requests tokens (evidence: `README.md`)
- OIDC Server → Token Issuer: issues tokens
- Application Client → KYC Documents: submits documents
- Parties → Domain Events: raises events (evidence: `src/Core/Party/Party.cs`)
- Product Options → Tenant Middleware: configures tenancy (evidence: `src/AspNetCore/Tenancy/Tenancy.cs`)
