Skip to content
Open source ย ยทย  MIT License
Behavioral Patterns for .NET

Lightweight & composable. Zero boilerplate.

CQRS & MediatorDecorator PatternChain of ResponsibilityPublish / Subscribe

Build and TestForma.CoreForma.MediatorForma.DecoratorForma.ChainsForma.PubSub.InMemory
33%Faster than MediatR
5Independent packages
0Core dependencies
.NET 6+Compatible

Get started

Pick what you need

Each package is fully independent โ€” install only the patterns your project uses.

๐Ÿ”€Mediator
dotnet add package Forma.Mediator
๐ŸŽจDecorator
dotnet add package Forma.Decorator
โ›“๏ธChains
dotnet add package Forma.Chains
๐Ÿ“กPubSub
dotnet add package Forma.PubSub.InMemory

In action

Clean, decoupled, testable

Define a request, write a handler โ€” Forma wires everything through the DI container. No base classes, no magic strings, no reflection surprises.

Explore all patterns โ†’
GetProductHandler.cs
// 1. Define the query
public record GetProductQuery(int Id)
    : IRequest<Product>;

// 2. Implement the handler
public class GetProductHandler
    : IRequestHandler<GetProductQuery, Product>
{
    public Task<Product> Handle(
        GetProductQuery q, CancellationToken ct)
        => _repo.FindAsync(q.Id, ct);
}

// 3. Register once, call anywhere
builder.Services.AddFormaMediator(
    typeof(Program).Assembly);

var product = await sender.Send(
    new GetProductQuery(42));

Released under the MIT License.