This project demonstrates a lightweight implementation of the CQRS pattern with a custom mediator implementation, as an alternative to using the MediatR library.
Based on the article The Easiest Way to Replace MediatR, this project implements:
- A custom mediator that supports commands and queries
- Clean separation of concerns following CQRS principles
- Simple handlers for each command and query
- A Todo API as a practical demonstration
-
SimpleCqrsMediator.Core:
- Mediator, Command/Query interfaces
- Domain models and DTOs
- Mapping extensions
- In-memory repositories
- Pipeline behaviors
-
SimpleCqrsMediator.Api:
- Controllers with versioning
- Feature-organized command and query handlers
- HTTP requests file for testing
-
SimpleCqrsMediator.Tests:
- Unit tests for Mediator, Command/Query interfaces
The API implements RESTful endpoints for Todo management:
GET /api/v1/todos- Retrieve all todosGET /api/v1/todos/{id}- Retrieve a specific todoPOST /api/v1/todos- Create a new todoPUT /api/v1/todos/{id}- Update an existing todoPATCH /api/v1/todos/{id}/toggle- Toggle todo completion statusDELETE /api/v1/todos/{id}- Delete a todo
Use the included HTTP file (Requests.http) to test the API endpoints.