What is MediatR and how does it relate to Clean Architecture?
Ask by ICSM Computer
Updated 16 Jun 2025
🧭 What is MediatR?
MediatR is a simple and lightweight .NET library that implements the Mediator Pattern, which helps reduce tight coupling between components by centralizing communication.
In MediatR:
NuGet Package:
Basic MediatR Flow
Example
1. Define a Command (write action)
2. Define a Handler
3. Send from Controller
MediatR + Clean Architecture
Clean Architecture separates the system into layers:
How MediatR Fits In:
IMediator.Send(...)Benefits:
CQRS + MediatR + Clean Architecture (Typical Pattern)
Summary