Skip to content

a practical ASP.NET Core 9 project showcasing CQRS pattern with MediatR and Clean Architecture for clean, scalable, and testable code.

Notifications You must be signed in to change notification settings

hvaezapp/CQRSConcept

Repository files navigation

CQRS Concept

A clean and pragmatic ASP.NET Core 9 solution demonstrating the CQRS (Command Query Responsibility Segregation) pattern using MediatR, MongoDB, SQL Server, and a Component-Based Architecture.


CQRS Architecture

🧩 Architecture Overview

This project follows a multi-layered, component-based architecture with full separation of concerns using CQRS principles:

  • Command Side:

    • Uses SQL Server for handling write operations.
    • MediatR dispatches commands to appropriate handlers.
    • Triggers events to keep the read models in sync.
  • Query Side:

    • Uses MongoDB for efficient, scalable read operations.
    • Queries are handled via MediatR and mapped to read models.
  • Component Layers:

    • CQRSConcept.Api – The API layer exposing HTTP endpoints, features, consumers.
    • CQRSConcept.Domain – Core domain and services (domain logic), contracts.
    • CQRSConcept.Infrastructure – Data persistence, repositories, external services.

Api endpoints

🗂️ Project Structure

CQRSConcept/
│
├── src/
│   ├── CQRSConcept.Api               # ASP.NET Core Web API (.NET 9)
│   ├── CQRSConcept.Domain            # Domain logic & contracts
│   └── CQRSConcept.Infrastructure    # Data access, MongoDB & SQL integration
│
└── docker-compose/                   # Docker setup (MongoDB, etc.)

💡 Getting Started

Prerequisites

  • .NET 9
  • Docker
  • Running Mongo Instance with Docker

Setup

  1. Clone the repository:

    git clone https://github.com/hvaezapp/CQRSConcept.git
    
  2. Run :

    dotnet restore
    dotnet build
    dotnet run

About

a practical ASP.NET Core 9 project showcasing CQRS pattern with MediatR and Clean Architecture for clean, scalable, and testable code.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published