Catga 0.1.0

dotnet add package Catga --version 0.1.0
                    
NuGet\Install-Package Catga -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Catga" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Catga" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Catga" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Catga --version 0.1.0
                    
#r "nuget: Catga, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Catga@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Catga&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Catga&version=0.1.0
                    
Install as a Cake Tool

<div align="center">

<img src="docs/web/favicon.svg" width="120" height="120" alt="Catga Logo"/>

Catga

High-Performance .NET CQRS/Event Sourcing Framework

.NET 9 Native AOT License

Zero Reflection · Source Generated · Native AOT · Distributed Ready

Quick Start · Performance · Examples · Documentation

</div>


⚡ Performance

BenchmarkDotNet on AMD Ryzen 7 5800H, .NET 9.0.8

Scenario Latency Memory Throughput
Create Order (Command) 351 ns 104 B 2.8M ops/sec
Get Order (Query) 337 ns 80 B 2.9M ops/sec
Event (3 handlers) 352 ns 208 B 2.8M ops/sec
Complete Flow (Command + Event) 729 ns 312 B 1.4M ops/sec
E-Commerce (Order + Payment + Query) 923 ns 416 B 1.1M ops/sec
Batch 10 Flows 10.2 μs 4.2 KB 98K flows/sec
Concurrent 10 Flows 9.3 μs 4.3 KB 108K flows/sec
High-Throughput 20 Orders 5.8 μs 5.4 KB 172K ops/sec

✨ Features

  • Zero Reflection - Source Generator, compile-time handler discovery
  • Native AOT - Full support, trimming safe
  • Distributed - Redis Streams, NATS JetStream
  • Event Sourcing - Event Store, Snapshots, Projections, Time Travel
  • Flow DSL - Distributed workflows, Sagas, ForEach parallel processing
  • Reliability - Outbox/Inbox, Idempotency, Dead Letter Queue
  • Observability - OpenTelemetry tracing, Metrics

🚀 Quick Start

dotnet add package Catga
dotnet add package Catga.Transport.InMemory
dotnet add package Catga.Persistence.InMemory
dotnet add package Catga.Serialization.MemoryPack
// Define command
[MemoryPackable]
public partial record CreateOrder(string ProductId, int Quantity) : IRequest<Order>;

// Define handler
public class CreateOrderHandler : IRequestHandler<CreateOrder, Order>
{
    public ValueTask<CatgaResult<Order>> HandleAsync(CreateOrder cmd, CancellationToken ct = default)
        => new(CatgaResult<Order>.Success(new Order(cmd.ProductId, cmd.Quantity)));
}

// Configure
builder.Services.AddCatga().UseMemoryPack();
builder.Services.AddInMemoryTransport();
builder.Services.AddInMemoryPersistence();

// Use
var result = await mediator.SendAsync<CreateOrder, Order>(new("PROD-001", 5));

📦 Packages

Package Description
Catga Core framework
Catga.Transport.InMemory In-memory transport
Catga.Transport.Redis Redis Streams
Catga.Transport.Nats NATS JetStream
Catga.Persistence.InMemory In-memory persistence
Catga.Persistence.Redis Redis persistence
Catga.Persistence.Nats NATS persistence
Catga.Serialization.MemoryPack Binary serialization
Catga.AspNetCore ASP.NET Core integration

🛒 OrderSystem Example

A complete e-commerce system demonstrating best practices. Focus on your business logic, not framework boilerplate.

examples/OrderSystem.Api/
├── Domain/           # Business entities
├── Messages/         # Commands, Queries, Events
├── Handlers/         # Business logic
├── Flows/            # Distributed workflows
└── Program.cs        # Minimal setup

Run

cd examples/OrderSystem.Api
dotnet run

Key Patterns

1. Commands & Queries - Clean separation of write/read operations

// Command - changes state
public record CreateOrder(string CustomerId, List<OrderItem> Items) : IRequest<Order>;

// Query - reads state
public record GetOrder(string OrderId) : IRequest<Order>;

2. Event Sourcing - Full audit trail

public record OrderCreated(string OrderId, string CustomerId) : IEvent;
public record OrderShipped(string OrderId, string TrackingNumber) : IEvent;

3. Flow DSL - Distributed workflows

public class OrderFlow : FlowConfig<OrderState>
{
    protected override void Configure(IFlowBuilder<OrderState> flow)
    {
        flow.Send(s => new ReserveInventory(s.Items))
            .IfFail(s => new ReleaseInventory(s.ReservationId));
        
        flow.Send(s => new ProcessPayment(s.OrderId, s.Total))
            .IfFail(s => new RefundPayment(s.PaymentId));
        
        flow.Publish(s => new OrderCompleted(s.OrderId));
    }
}

🗄️ Event Sourcing

// Append events
await eventStore.AppendAsync("Order-123", new[] { orderCreated, itemAdded });

// Read stream
var stream = await eventStore.ReadAsync("Order-123");

// Snapshots
await snapshotStore.SaveAsync("Order-123", aggregate, version);

// Time Travel
var stateAtV5 = await timeTravelService.GetStateAtVersionAsync("order-1", 5);

🔄 Flow DSL

public class ProcessOrderFlow : FlowConfig<OrderState>
{
    protected override void Configure(IFlowBuilder<OrderState> flow)
    {
        // Sequential steps with compensation
        flow.Send(s => new ReserveInventory(s.OrderId))
            .Into(s => s.ReservationId)
            .IfFail(s => new ReleaseInventory(s.ReservationId));

        // Parallel processing
        flow.ForEach<OrderItem>(s => s.Items)
            .Configure((item, f) => f.Send(s => new ProcessItem(item.Id)))
            .WithParallelism(4)
            .ContinueOnFailure()
        .EndForEach();

        // Conditional logic
        flow.If(s => s.AllItemsProcessed)
            .Send(s => new CompleteOrder(s.OrderId))
        .EndIf();
    }
}

🔧 Configuration

// OpenTelemetry
builder.Services.AddOpenTelemetry()
    .WithTracing(t => t.AddSource(CatgaOpenTelemetryExtensions.ActivitySourceName))
    .WithMetrics(m => m.AddMeter(CatgaOpenTelemetryExtensions.MeterName));

// Resilience
builder.Services.AddCatga()
    .UseResilience(o => o.TransportRetryCount = 3);

// Reliability
builder.Services.AddCatga()
    .UseInbox()
    .UseOutbox();

📚 Documentation


📄 License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (11)

Showing the top 5 NuGet packages that depend on Catga:

Package Downloads
Catga.Transport.Nats

NATS transport for Catga - JetStream messaging

Catga.Persistence.Redis

Redis persistence for Catga - event store, snapshot, idempotency

Catga.Transport.Redis

Redis transport for Catga - Pub/Sub and Streams messaging

Catga.Transport.InMemory

In-memory message transport for Catga - for development and testing

Catga.Persistence.InMemory

In-memory persistence for Catga - event store, cache, outbox/inbox

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 132 12/24/2025