Skip to main content

Workflow Runtime Composition

Summary

Program.cs is the composition root. It registers the DbContext, ports and adapters, repositories, command/query classes, messaging, authentication, authorization, health checks, OpenAPI and one hosted outbox relay.

Service registration

Scoped registrations include tenant context, unit of work, audit and timeline writers, two repositories, a definition loader, two command classes and the query class. The outbox store is scoped; the relay resolves its processor in a new scope per polling iteration.

Request pipeline

Correlation middleware runs before OpenAPI UI, authentication and authorization. A later exception middleware maps tenant-related InvalidOperationException failures to bad requests. Health, service information and Workflow endpoints are then mapped.

Startup behavior

Development startup can apply migrations and seed definitions unless a migration-skip setting is active. This behavior is environment-conditional and is not documented as a production deployment procedure.

Background work

OutboxRelayHostedService polls, requests a bounded batch from the shared processor and logs warning-level failures. Request transactions do not wait for broker publication.

Limitations

No Workflow-specific scheduled executor, SLA worker, reminder worker, callback worker or cleanup worker is registered.

Requires Confirmation

Production migration ownership, hosted-relay concurrency, shutdown objectives and runtime configuration values require confirmation.

Source References

  • microservices/src/workflow-service/Program.cs
  • microservices/src/workflow-service/Messaging/OutboxRelayHostedService.cs
  • microservices/src/shared-kernel/Extensions/ObservabilityExtensions.cs
  • microservices/src/shared-kernel/Extensions/ServiceCollectionExtensions.cs

See Also

Keywords

Workflow architecture, approval engine, Workflow Service, technical foundation.

Revision Information

  • Status: Draft
  • Last reviewed: 2026-07-20
  • Next review: 2026-10-20