Table of Contents

DI Extensions Cheatsheet

The full menu of Add*Services() extensions Stratara exposes, by package.

Umbrella extensions (IHostApplicationBuilder)

These wire entire worker / host concerns in one call. Pick one per host.

Extension Brings Use for
builder.AddBackendServices() Mediator, Identity, Session, Security, Resilience ASP.NET API hosts
builder.AddCommandWorkerServices() Common framework + command-handling worker (interactive lane) Worker hosts that consume the command topic
builder.AddHeavyCommandWorkerServices(dop?) Common framework + dedicated heavy-command worker Worker hosts that drain long-running IHeavyCommand commands on a separate lane, so they don't starve interactive commands
builder.AddEventProjectionWorkerServices() Common framework + projection worker Worker hosts that update read-models
builder.AddSagaWorkerServices() Common framework + saga worker Worker hosts that orchestrate processes
builder.AddEventStreamHashWorkerServices() Common framework + event-stream-hash worker Worker hosts that hash event streams for tamper-evidence
builder.AddOutboxWorkerServices() Common framework + outbox-drain worker Worker hosts that publish from outbox_entry to the bus

AddCommonFrameworkServices() is called transitively by every worker / backend extension above — you don't call it yourself.

Domain registration (IServiceCollection)

These tell Stratara what to dispatch / project / saga. Call once per assembly that contains the relevant types.

Extension Discovers Side-effect
services.AddCommandHandlersFromAssemblyContaining<T>() ICommandHandler<TCmd> + IQueryHandler<TCmd, TResult> (the unified contract) Per-handler AddScoped
services.AddQueryHandlersFromAssemblyContaining<T>() IQueryHandler<TQuery, TResult> Per-handler AddScoped
services.AddProjectionsFromAssemblyContaining<T>() IProjection impls + their HandleAsync(SomeEvent) overloads Per-projection AddSingleton<IProjection> + event-allowlist registration
services.AddSagasFromAssemblyContaining<T>() ISaga impls + their HandleAsync(SomeEvent) overloads Per-saga AddSingleton<ISaga> + event-allowlist registration
services.AddAggregatesFromAssemblyContaining<T>() IAggregate impls + their Apply(SomeEvent) methods Adds each aggregate and each apply-target event type to ITrustedTypeResolver
services.AddDomainEventTypesFromAssemblyContaining<T>() The Apply(SomeEvent) parameter types of the assembly's aggregates Adds only those event types to ITrustedTypeResolver — no aggregate types, no handler classes. For event-only hosts (projection/saga workers) that must deserialize bus/stream payloads without wiring handler dependencies

Security + integrity

Extension What it does
services.AddStrataraFileKeyStore(configuration) Registers the production file-backed EnvelopeFileKeyStore (KEK-wrapped, versioned per-KeyScope DEKs) + FileMasterKeyProvider + the AES-GCM ISecureBlobEncryptor. Lives in Stratara.Security (dependency-light). Call before AddSecurity() so it wins the TryAdd race.
services.AddSecurity() Wires ISecureJsonSerializer ([EncryptData]), the AES-GCM blob encryptor, and a Development-only DummyKeyStore fallback (TryAdd, so a real IKeyStore registered first wins). Adds the KeyStoreStartupProbe fail-fast guard.
services.AddBusEnvelopeIntegrity(opts) Opt-in HMAC signing of CommandEnvelope + EventBundle

Validation

Extension What it does
services.AddStrataraValidation() Registers the validation pipeline behavior. Call before other AddPipelineBehavior* so it runs outermost.
services.AddValidatorsFromAssemblyContaining<T>() Discovers + registers every concrete IValidator<T> in the marker's assembly as scoped.

Tenant isolation

Extension What it does
services.AddStrataraTenantIsolation() Registers the tenant-isolation pipeline behavior. Acts only on requests implementing ITenantScopedRequest; rejects a request whose TenantId ≠ the session's data-owner tenant with TenantAccessDeniedException (→ HTTP 403). Call after AddStrataraValidation().
services.AddStrataraTenantIsolation(o => o.Mode = TenantIsolationMode.Strict) Strict mode — additionally routes every cross-tenant operation (actor tenant ≠ data-owner tenant) through ICrossTenantAuthorizer. The shipped default denies all; register your own ICrossTenantAuthorizer to grant the cross-tenant case (e.g. a platform admin).

Resilience

Extension What it does
services.AddResiliencePipelines() Registers Polly named pipelines (Stratara.OutboxPublish, Stratara.HandlerRetry, …)

Outbox transport (pick one per host)

Extension Bus
services.AddRabbitMqBus(opts) RabbitMQ
services.AddAzureServiceBus(opts) Azure Service Bus (connection-string)
services.AddAzureServiceBusWithManagedIdentity(opts) Azure Service Bus (DefaultAzureCredential)

ASP.NET specific

Extension What it does
builder.AddAspNetIdentity() Channel-agnostic ASP.NET Core identity wiring
builder.AddAspNetIdentityWithSignInManager() Above + SignInManager<TUser> wrapper
builder.AddDevelopmentNoOpEmailSender() Stub IEmailSender for development
app.MapStrataraDefaults() Health endpoints + OpenAPI

These three are extension members of IHostApplicationBuilder and live in the Microsoft.Extensions.Hosting namespace (Microsoft convention since v3.0.15).