https://github.com/magmablinker/axent
Axent is a source-generated CQRS library for modern .NET with typed pipelines and ASP.NET Core integration.
https://github.com/magmablinker/axent
aspnetcore cqrs csharp dotnet mediator nuget-package pipeline sourcegenerator
Last synced: 16 days ago
JSON representation
Axent is a source-generated CQRS library for modern .NET with typed pipelines and ASP.NET Core integration.
- Host: GitHub
- URL: https://github.com/magmablinker/axent
- Owner: magmablinker
- License: apache-2.0
- Created: 2026-02-24T17:57:57.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-05-06T09:26:34.000Z (27 days ago)
- Last Synced: 2026-05-06T10:36:59.499Z (27 days ago)
- Topics: aspnetcore, cqrs, csharp, dotnet, mediator, nuget-package, pipeline, sourcegenerator
- Language: C#
- Homepage:
- Size: 165 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Axent


[](https://www.nuget.org/packages/Axent.Core)
[](https://www.nuget.org/packages/Axent.Core/)
[](https://sonarcloud.io/summary/new_code?id=magmablinker_Axent)
**Axent** is a source-generated CQRS library for modern .NET with typed pipelines and ASP.NET Core integration. It is currently ~2x faster than [MediatR (v12.5)](https://github.com/LuckyPennySoftware/MediatR) with fewer allocations.
---
## Why Axent?
* 🚀 Fast: source generated dispatch with zero reflection
* 🧩 Minimal: very little setup
* 🧠 Strongly typed, extensible pipelines for cross-cutting concerns
* 🌐 First class ASP.NET Core integration
* ⚙️ Built for modern .NET (8+)
## 📦 Features
- Minimal setup and boilerplate
- Source-generated dispatch — no reflection at runtime
- Typed pipelines with support for generic and request-specific pipes
- Separate marker interfaces for commands and queries (`ICommand`, `IQuery`)
- Built-in support for transactions, logging, and error handling via pipeline options
- ASP.NET Core integration
- .NET 8+ optimized
---
## Prerequisites
- .NET 8 or later
## 🚀 Getting Started
#### 1. Install Packages
```shell
dotnet add package Axent.Core
dotnet add package Axent.Extensions.AspNetCore
```
#### 2. Register Services
```csharp
builder.Services.AddAxent()
.AddRequestHandlers(AssemblyProvider.Current);
```
#### 3. Create a Request and Handler
- IQuery for read operations
- ICommand for write operations
- IRequest if you don't want to differentiate
- IRequestHandler to handle them
```csharp
using Axent.Abstractions.Models;
using Axent.Abstractions.Requests;
using Axent.Abstractions.Services;
namespace Axent.ExampleApi;
internal sealed record ExampleQuery(string Message) : IQuery;
internal sealed class ExampleQueryHandler : IRequestHandler
{
private readonly ILogger _logger;
public ExampleQueryHandler(ILogger logger)
{
_logger = logger;
}
public ValueTask> HandleAsync(RequestContext context, CancellationToken cancellationToken = default)
{
_logger.LogInformation("Message from request '{Message}'", context.Request.Message);
return ValueTask.FromResult(Response.Success(Unit.Value));
}
}
```
#### 4. Send a Request
Inject ISender into endpoints or application services.
```csharp
app.MapGet("/api/example", async (ISender sender, CancellationToken cancellationToken) =>
{
var response = await sender.SendAsync(new ExampleQuery("Hello World!"), cancellationToken);
return response.ToResult();
});
```
---
Alternatively using the template
```shell
dotnet new install Axent.Templates
dotnet new axent-api
```
## 📖 Docs
To learn more about the features of Axent, checkout the [documentation](https://github.com/magmablinker/Axent/tree/main/docs)
## 📊 Benchmarks
### Axent (Source Generated Dispatch)
```
BenchmarkDotNet v0.14.0, Windows 11 (10.0.26200.7840)
Unknown processor
.NET SDK 10.0.200-preview.0.26103.119
[Host] : .NET 8.0.23 (8.0.2325.60607), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI [AttachedDebugger]
DefaultJob : .NET 8.0.23 (8.0.2325.60607), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
```
| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio |
|-------------------------------------------|---------:|---------:|---------:|------:|--------:|-------:|----------:|------------:|
| 'SendAsync (cold)' | 36.74 ns | 0.741 ns | 1.702 ns | 1.00 | 0.06 | 0.0196 | 328 B | 1.00 |
| 'SendAsync (warm, same instance)' | 33.97 ns | 0.423 ns | 0.353 ns | 0.93 | 0.04 | 0.0181 | 304 B | 0.93 |
### MediatR (v12.5.0)
```
BenchmarkDotNet v0.14.0, Windows 11 (10.0.26200.7840)
Unknown processor
.NET SDK 10.0.200-preview.0.26103.119
[Host] : .NET 8.0.23 (8.0.2325.60607), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI [AttachedDebugger]
DefaultJob : .NET 8.0.23 (8.0.2325.60607), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
```
| Method | Mean | Error | StdDev | Gen0 | Allocated |
|--------------------------------------|---------:|---------:|---------:|-------:|----------:|
| 'Send (cold)' | 79.03 ns | 1.526 ns | 2.713 ns | 0.0257 | 432 B |
| 'Send (warm, same instance)' | 79.21 ns | 1.566 ns | 3.783 ns | 0.0243 | 408 B |
## 🤝 Contributing
Contributions are welcome.
If you find a bug, have an improvement, or want to propose a feature:
1. Open an issue
2. Start a discussion
3. Submit a pull request
## 📄 License
This project is licensed under the Apache License 2.0. See [`LICENSE`](https://github.com/magmablinker/Axent/blob/main/LICENSE) for details.