# rcommon-team/rcommon architecture

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

- Interactive diagram: https://gitdiagram.com/rcommon-team/rcommon
- Repository: https://github.com/rcommon-team/rcommon

## Overview

RCommon is a modular .NET infrastructure library, not a standalone application: host applications compose its abstractions and provider packages through dependency injection. A representative request path dispatches a query, optionally validates it, invokes a handler, and uses a repository/provider to access data. The library also provides transactional outbox/inbox and saga support, event and messaging adapters, caching, blob storage, and cross-cutting domain, tenant, validation, serialization, email, and security capabilities. Provider-specific links and several capability branches are documented in the README; unsampled internals are not inferred.

Main entry points: [`Src/RCommon.Persistence/Crud/IAggregateRepository.cs`](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Persistence/Crud/IAggregateRepository.cs) (Aggregate repositories), [`Src/RCommon.Persistence/Outbox/OutboxEventRouter.cs`](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Persistence/Outbox/OutboxEventRouter.cs) (Outbox event router), [`Src/RCommon.Security/Claims/ITenantIdAccessor.cs`](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Security/Claims/ITenantIdAccessor.cs) (Tenant context), [`Src/RCommon.ApplicationServices/Queries/QueryBus.cs`](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.ApplicationServices/Queries/QueryBus.cs) (Query bus)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_application["Application services"]
  node_querybus["Query bus<br/>[QueryBus.cs]"]
  node_validation["Validation service"]
  node_handler["Query handlers<br/>[IQueryHandler.cs]"]
  node_state["State machines<br/>[IStateMachine.cs]"]
end

subgraph group_persistence["Persistence and domain"]
  node_domain["Domain entities<br/>[AggregateRoot.cs]"]
  node_repositories["Aggregate repositories"]
  node_datastore["Data store factory"]
  node_outboxstore[("Outbox stores<br/>[IOutboxStore.cs]")]
end

subgraph group_events["Events and messaging"]
  node_outboxrouter["Outbox event router"]
  node_eventbus["Event handling<br/>[IEventBus.cs]"]
  node_subscription["Producer subscriptions"]
end

subgraph group_providers["Infrastructure providers"]
  node_efrepo["EF Core adapter"]
  node_dapperrepo["Dapper adapter"]
  node_linqrepo["Linq2Db adapter"]
  node_messaging["Broker adapters"]
  node_azureblob["Azure blob adapter"]
  node_s3blob["Amazon S3 adapter"]
end

subgraph group_crosscutting["Cross-cutting services"]
  node_caching["Cache abstraction<br/>[ICacheService.cs]"]
  node_querycache["Repository cache"]
  node_tenant["Tenant context"]
  node_blobapi["Blob storage API"]
  node_serialization["JSON serialization<br/>[IJsonSerializer.cs]"]
  node_email["Email service<br/>[IEmailService.cs]"]
  node_security["Principal and claims"]
end

node_host(("Host application"))

node_host -->|"dispatches query"| node_querybus
node_querybus -->|"validates optionally"| node_validation
node_querybus -->|"invokes handler"| node_handler
node_handler -.->|"uses repository"| node_repositories
node_repositories -->|"implemented by"| node_efrepo
node_repositories -->|"implemented by"| node_dapperrepo
node_repositories -->|"implemented by"| node_linqrepo
node_efrepo -->|"resolves store"| node_datastore
node_dapperrepo -->|"resolves store"| node_datastore
node_linqrepo -->|"resolves store"| node_datastore
node_repositories -.->|"persists aggregates"| node_domain
node_efrepo -->|"filters by tenant"| node_tenant
node_dapperrepo -->|"filters by tenant"| node_tenant
node_linqrepo -->|"sets tenant"| node_tenant
node_domain -.->|"buffers events"| node_outboxrouter
node_outboxrouter -->|"persists messages"| node_outboxstore
node_outboxrouter -->|"filters producers"| node_subscription
node_outboxrouter -.->|"dispatches events"| node_messaging
node_host -->|"publishes events"| node_eventbus
node_eventbus -->|"adapts to brokers"| node_messaging
node_querycache -->|"wraps repository"| node_repositories
node_querycache -->|"reads and writes cache"| node_caching
node_host -->|"stores blobs"| node_blobapi
node_blobapi -->|"implemented by"| node_azureblob
node_blobapi -->|"implemented by"| node_s3blob
node_host -->|"configures serializer"| node_serialization
node_host -->|"sends email"| node_email
node_security -->|"resolves tenant"| node_tenant
node_host -->|"configures workflows"| node_state

click node_querybus "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.ApplicationServices/Queries/QueryBus.cs"
click node_validation "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.ApplicationServices/Validation/ValidationService.cs"
click node_handler "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.ApplicationServices/Queries/IQueryHandler.cs"
click node_domain "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Entities/AggregateRoot.cs"
click node_repositories "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Persistence/Crud/IAggregateRepository.cs"
click node_efrepo "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.EfCore/Crud/EFCoreAggregateRepository.cs"
click node_dapperrepo "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Dapper/Crud/DapperAggregateRepository.cs"
click node_linqrepo "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Linq2Db/Crud/Linq2DbAggregateRepository.cs"
click node_datastore "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Persistence/IDataStoreFactory.cs"
click node_outboxrouter "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Persistence/Outbox/OutboxEventRouter.cs"
click node_outboxstore "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Persistence/Outbox/IOutboxStore.cs"
click node_eventbus "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Core/EventHandling/IEventBus.cs"
click node_subscription "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Core/EventHandling/Producers/EventSubscriptionManager.cs"
click node_messaging "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.MassTransit/Producers/PublishWithMassTransitEventProducer.cs"
click node_caching "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Caching/ICacheService.cs"
click node_querycache "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Persistence.Caching/Crud/CachingGraphRepository.cs"
click node_tenant "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Security/Claims/ITenantIdAccessor.cs"
click node_blobapi "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Blobs/IBlobStorageService.cs"
click node_azureblob "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Azure.Blobs/AzureBlobStorageService.cs"
click node_s3blob "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Amazon.S3Objects/AmazonS3StorageService.cs"
click node_serialization "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Json/IJsonSerializer.cs"
click node_email "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Emailing/IEmailService.cs"
click node_security "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Security/Claims/ICurrentPrincipalAccessor.cs"
click node_state "https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Core/StateMachines/IStateMachine.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_querybus,node_validation,node_handler,node_state toneBlue
class node_domain,node_repositories,node_datastore,node_outboxstore toneAmber
class node_outboxrouter,node_eventbus,node_subscription toneMint
class node_efrepo,node_dapperrepo,node_linqrepo,node_messaging,node_azureblob,node_s3blob toneRose
class node_caching,node_querycache,node_tenant,node_blobapi,node_serialization,node_email,node_security,node_host toneIndigo
```

## Components

### Application services

- [Query bus](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.ApplicationServices/Queries/QueryBus.cs): `Src/RCommon.ApplicationServices/Queries/QueryBus.cs`
- [Validation service](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.ApplicationServices/Validation/ValidationService.cs): `Src/RCommon.ApplicationServices/Validation/ValidationService.cs`
- [Query handlers](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.ApplicationServices/Queries/IQueryHandler.cs): `Src/RCommon.ApplicationServices/Queries/IQueryHandler.cs`
- [State machines](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Core/StateMachines/IStateMachine.cs): `Src/RCommon.Core/StateMachines/IStateMachine.cs`

### Persistence and domain

- [Domain entities](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Entities/AggregateRoot.cs): `Src/RCommon.Entities/AggregateRoot.cs`
- [Aggregate repositories](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Persistence/Crud/IAggregateRepository.cs): `Src/RCommon.Persistence/Crud/IAggregateRepository.cs`
- [Data store factory](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Persistence/IDataStoreFactory.cs): `Src/RCommon.Persistence/IDataStoreFactory.cs`
- [Outbox stores](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Persistence/Outbox/IOutboxStore.cs): `Src/RCommon.Persistence/Outbox/IOutboxStore.cs`

### Events and messaging

- [Outbox event router](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Persistence/Outbox/OutboxEventRouter.cs): `Src/RCommon.Persistence/Outbox/OutboxEventRouter.cs`
- [Event handling](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Core/EventHandling/IEventBus.cs): `Src/RCommon.Core/EventHandling/IEventBus.cs`
- [Producer subscriptions](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Core/EventHandling/Producers/EventSubscriptionManager.cs): `Src/RCommon.Core/EventHandling/Producers/EventSubscriptionManager.cs`

### Infrastructure providers

- [EF Core adapter](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.EfCore/Crud/EFCoreAggregateRepository.cs): `Src/RCommon.EfCore/Crud/EFCoreAggregateRepository.cs`
- [Dapper adapter](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Dapper/Crud/DapperAggregateRepository.cs): `Src/RCommon.Dapper/Crud/DapperAggregateRepository.cs`
- [Linq2Db adapter](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Linq2Db/Crud/Linq2DbAggregateRepository.cs): `Src/RCommon.Linq2Db/Crud/Linq2DbAggregateRepository.cs`
- [Broker adapters](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.MassTransit/Producers/PublishWithMassTransitEventProducer.cs): `Src/RCommon.MassTransit/Producers/PublishWithMassTransitEventProducer.cs`
- [Azure blob adapter](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Azure.Blobs/AzureBlobStorageService.cs): `Src/RCommon.Azure.Blobs/AzureBlobStorageService.cs`
- [Amazon S3 adapter](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Amazon.S3Objects/AmazonS3StorageService.cs): `Src/RCommon.Amazon.S3Objects/AmazonS3StorageService.cs`

### Cross-cutting services

- [Cache abstraction](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Caching/ICacheService.cs): `Src/RCommon.Caching/ICacheService.cs`
- [Repository cache](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Persistence.Caching/Crud/CachingGraphRepository.cs): `Src/RCommon.Persistence.Caching/Crud/CachingGraphRepository.cs`
- [Tenant context](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Security/Claims/ITenantIdAccessor.cs): `Src/RCommon.Security/Claims/ITenantIdAccessor.cs`
- [Blob storage API](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Blobs/IBlobStorageService.cs): `Src/RCommon.Blobs/IBlobStorageService.cs`
- [JSON serialization](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Json/IJsonSerializer.cs): `Src/RCommon.Json/IJsonSerializer.cs`
- [Email service](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Emailing/IEmailService.cs): `Src/RCommon.Emailing/IEmailService.cs`
- [Principal and claims](https://github.com/rcommon-team/rcommon/blob/main/Src/RCommon.Security/Claims/ICurrentPrincipalAccessor.cs): `Src/RCommon.Security/Claims/ICurrentPrincipalAccessor.cs`

### Other components

- **Host application**

## Connections

- Host application → Query bus: dispatches query
- Query bus → Validation service: validates optionally (evidence: `Src/RCommon.ApplicationServices/Queries/QueryBus.cs`)
- Query bus → Query handlers: invokes handler (evidence: `Src/RCommon.ApplicationServices/Queries/QueryBus.cs`)
- Query handlers → Aggregate repositories: uses repository
- Aggregate repositories → EF Core adapter: implemented by (evidence: `Src/RCommon.EfCore/Crud/EFCoreAggregateRepository.cs`)
- Aggregate repositories → Dapper adapter: implemented by (evidence: `Src/RCommon.Dapper/Crud/DapperAggregateRepository.cs`)
- Aggregate repositories → Linq2Db adapter: implemented by (evidence: `Src/RCommon.Linq2Db/Crud/Linq2DbAggregateRepository.cs`)
- EF Core adapter → Data store factory: resolves store (evidence: `Src/RCommon.EfCore/Crud/EFCoreAggregateRepository.cs`)
- Dapper adapter → Data store factory: resolves store (evidence: `Src/RCommon.Dapper/Crud/DapperAggregateRepository.cs`)
- Linq2Db adapter → Data store factory: resolves store (evidence: `Src/RCommon.Linq2Db/Crud/Linq2DbAggregateRepository.cs`)
- Aggregate repositories → Domain entities: persists aggregates
- EF Core adapter → Tenant context: filters by tenant (evidence: `Src/RCommon.EfCore/Crud/EFCoreAggregateRepository.cs`)
- Dapper adapter → Tenant context: filters by tenant (evidence: `Src/RCommon.Dapper/Crud/DapperAggregateRepository.cs`)
- Linq2Db adapter → Tenant context: sets tenant (evidence: `Src/RCommon.Linq2Db/Crud/Linq2DbAggregateRepository.cs`)
- Domain entities → Outbox event router: buffers events
- Outbox event router → Outbox stores: persists messages (evidence: `Src/RCommon.Persistence/Outbox/OutboxEventRouter.cs`)
- Outbox event router → Producer subscriptions: filters producers (evidence: `Src/RCommon.Persistence/Outbox/OutboxEventRouter.cs`)
- Outbox event router → Broker adapters: dispatches events
- Host application → Event handling: publishes events
- Event handling → Broker adapters: adapts to brokers
- Repository cache → Aggregate repositories: wraps repository (evidence: `Src/RCommon.Persistence.Caching/Crud/CachingGraphRepository.cs`)
- Repository cache → Cache abstraction: reads and writes cache (evidence: `Src/RCommon.Persistence.Caching/Crud/CachingGraphRepository.cs`)
- Host application → Blob storage API: stores blobs
- Blob storage API → Azure blob adapter: implemented by (evidence: `Src/RCommon.Azure.Blobs/AzureBlobStorageService.cs`)
- Blob storage API → Amazon S3 adapter: implemented by (evidence: `Src/RCommon.Amazon.S3Objects/AmazonS3StorageService.cs`)
- Host application → JSON serialization: configures serializer
- Host application → Email service: sends email
- Principal and claims → Tenant context: resolves tenant (evidence: `Src/RCommon.Security/Claims/ITenantIdAccessor.cs`)
- Host application → State machines: configures workflows
