Tutorials & samples

Learn Relay by building.

Hands-on guides for everything Relay does — commands and queries, event sourcing, projections, messaging, workflows, operations. Every article is paired with a test-backed sample project you can dotnet run today. Pick the capability you need below.

Mediator & CQRS

4 articles

Event Sourcing

8 articles

Projections & Read Models

7 articles

Messaging & Reliability

4 articles

Sagas & Workflows

4 articles

Scheduling & Time

2 articles

Tenancy & Security

2 articles

Production Operations

7 articles

Observability: Telemetry, Metrics, Tracing, Health

You cannot operate what you cannot see. Relay is instrumented with OpenTelemetry-native primitives out of the box — no wrappers, no proprietary format.

Resiliency: Retries, Circuit Breakers, Rate & Concurrency Limits

Distributed systems fail in partial, transient ways: a database blips, a downstream API times out, a queue backs up.

Distributed Coordination: Locks, Leader Election, Partitioning

You scale a service by running more copies of it — but now those copies can step on each other: two instances run the same nightly job, or both try to advance the same projection, or process the same key out of order.

Reference Architecture: A Production Service End-to-End

The previous twenty-four articles each isolated one capability.

Fenced Leadership & Cluster Membership

The Distributed Coordination article elects a leader the simple way: a connection-bound ILeaderElector holds a PostgreSQL advisory lock for as long as its connection lives, and the database drops that lock when the process dies.

Operational Event Queries: A Forensic Scan over the Log

The event store is an append-only log, and Event Sourcing Basics is emphatic about the rule that follows from that: never query the event store for reads.

Telemetry Segmentation: Per-Tenant & Per-Dimension Metrics

Relay's command/query metrics are tagged by message type out of the box — relay.commands.executed and relay.queries.executed carry a command/query name plus success, and a matching duration histogram.