Skip to content

sonnh02-dev/DDD_CQRS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸ— DDD Event-Driven Demo

This project demonstrates a Domain-Driven Design (DDD) architecture combined with an Event-Driven communication model.
It leverages RabbitMQ for asynchronous messaging, Redis Cache for read optimization, and FluentValidation for strong input validation.


πŸ“Œ Architecture Layers

πŸ› Domain Layer

  • Contains core business logic.
  • Implements Aggregates, Entities, Value Objects, Domain Events.
  • Free of infrastructure concerns.

βš™οΈ Application Layer

  • Implements use cases (CQRS: Commands & Queries).
  • Uses FluentValidation for input validation.
  • Publishes Domain Events β†’ dispatched to RabbitMQ.

πŸ—„ Infrastructure Layer

  • Handles persistence (SQL / MongoDB).
  • Integrates with RabbitMQ for event publishing/consuming.
  • Implements Redis Cache pipeline for high-performance reads.

🌐 Presentation Layer (API)

  • Exposes REST / gRPC endpoints.
  • Flow: Request β†’ Validation β†’ Application Layer β†’ Domain β†’ Response (with optional caching).

⚑ Event-Driven with RabbitMQ

  • Example: UserFollowedEvent raised in domain.
  • Converted to Domain Event β†’ published to RabbitMQ.

πŸ—ƒ Redis Cache Pipeline

  • Used for read-side CQRS optimization.
  • Common use cases:
    • Caching user profiles.
    • Caching follower/following counts.
    • Storing frequently queried read models.
  • Integrated as pipeline behavior β†’ check cache before hitting database.

βœ… Validation with FluentValidation

  • All commands/queries validated before domain execution.
  • Supports both sync & async validation.
  • Prevents invalid commands from polluting domain logic.

πŸ”‘ Key Benefits

  • Clean separation of concerns with DDD.
  • Loose coupling via Event-Driven architecture.
  • Performance boost with Redis cache.
  • Strong validation with FluentValidation.
  • Scalable and maintainable solution.

About

DDD Architecture with Event-Driven, RabbitMQ, Redis, FluentValidation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published