Skip to content

About

Lightweight .NET CQRS mediator with extensible pipeline behaviors (validation, caching, transactions, logging).

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

94 Commits

Folders and files

Repository files navigation

NexMediator logo

A modern, extensible, and high-performance .NET library for clean CQRS applications.

NuGet version Coverage report


📘 Overview

NexMediator is a clean, modular, and pluggable mediator engine for .NET 8+ applications — a robust alternative to MediatR with:

  • ✅ Built-in pipeline behaviors (logging, validation, caching, transactions)
  • 📣 Parallel notifications
  • 📡 Async streaming with IAsyncEnumerable<T>
  • 🧩 Full DI support and testable architecture
  • ⚡ Compiled delegates (no runtime reflection)

Inspired by CQRS, Clean Architecture and DDD.


📦 Installation

Install via CLI:

dotnet add package NexMediator

Or via NuGet:

NuGet\Install-Package NexMediator

🚀 Quick Start

builder.Services.AddNexMediator();

This registers the core engine and auto-discovers all handlers.


🧱 Built-in Pipeline Behaviors

You can add any of the built-in behaviors:

builder.Services.AddNexMediator(options =>
{
    options.AddBehavior(typeof(LoggingBehavior<,>), 1);
    options.AddBehavior(typeof(FluentValidationBehavior<,>), 2);
    options.AddBehavior(typeof(CachingBehavior<,>), 3);
    options.AddBehavior(typeof(TransactionBehavior<,>), 4);
});
Behavior Description
LoggingBehavior<,> Logs execution details and correlation ID
FluentValidation<,> Validates using FluentValidation
CachingBehavior<,> Adds response-level caching support
TransactionBehavior<,> Wraps command in transaction scope

🧩 Want to customize? You can implement your own INexPipelineBehavior<TRequest, TResponse>
and register it with any order:

options.AddBehavior(typeof(MyCustomBehavior<,>), 99);

📖 Documentation

📚 Complete guides, examples and usage patterns available in the Wiki:
👉 https://github.com/vagnerjsmello/NexMediator/wiki

Includes:

  • Core concepts (requests, handlers, notifications, streams)
  • Usage with Minimal APIs
  • Real-world example: AuctionBoardGame
  • Custom behaviors, caching, transactions
  • Error handling, correlation ID, tests

🤝 Contributing

We welcome contributions!
Star ⭐ the repo, suggest improvements, or submit PRs via feature/* branches.

✅ Use Conventional Commits
📦 Follow our branch strategy: main, develop, feature/*

See Contributing Guide


📄 License

Apache 2.0 License — free for commercial and open source use.

© 2024–2025 Vagner Mello
🔗 LinkedIn


🏷 Tags

.NET • C# • CQRS • Mediator • Open Source • NuGet • Clean Architecture • Pipeline • Notifications • Streaming • Validation • Transactions • TDD • DDD ""

About

Lightweight .NET CQRS mediator with extensible pipeline behaviors (validation, caching, transactions, logging).

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages