Questions tagged [cqrs]

Command Query Responsibility Segregation design pattern

Filter by
Sorted by
Tagged with
0 votes
0 answers
27 views

Avoiding reloading entities many times with EF Core and Mediatr

We have a largeish .NET Core project which uses Mediatr and EF Core. Many of the queries look something like: public class GetSomeInformation : IRequest<string> { public int DocumentId { get;...
  • 265
0 votes
0 answers
94 views

Designing a follow relationship in a Instagram-like application using DDD

I'm developing a Instagram-like app using DDD and CQRS (along with nestjs and neo4j). I have a users module which handles user profile and it is responsible for incrementing the number of followers, ...
1 vote
1 answer
108 views

How to scale transactional outbox pattern with document database?

I'm trying to understand CQRS, DDD by writing a small pet project which is somewhat similar to this great repo. I've come across Transactional Outbox pattern and as imo it was correctly pointed out in ...
  • 31
1 vote
1 answer
105 views

Tight coupling between micro services

I have got the following scenario, which I have been thinking what would be the "best" way to solve it. Request comes from the FE, which changes the status of a delivery, and that should ...
0 votes
0 answers
64 views

In CQRS, how does the event processor know how to populate the read-side database?

I'm currently playing around with a CQRS implementation and I'm having some trouble understanding the following concept: Event Bus for publishing update events (required): Whenever the write database ...
2 votes
3 answers
206 views

How to implement HATEOAS with CQRS?

Let's say I have a CQRS system where my write model contains the business rules. My read model is simply a DTO; it is a collection of properties and "dumb". Now if you were to create a REST ...
0 votes
1 answer
560 views

How to handle duplicate validation logic with CQRS pattern

I am implementing a CQRS pattern in ASP.NET Core with MediatR, and I am wondering what the general consensus is for handling duplicate validation logic for queries/commands which operate on the same ...
0 votes
0 answers
132 views

CQRS, DDD and batch, CRUD-y operations

How to perform basic CRUD operations (especially batch) by playing with DDD and CQRS? Let's say I have a list of IDs in my controller that need to be removed (soft delete). Currently, I treat this ...
0 votes
0 answers
84 views

How to model an event-driven system for replays

Let's say I have a system to which I can upload documents via an API. There are three services: the UploadService - responsible for providing a HTTP endpoint the StorageService - responsible for ...
0 votes
3 answers
213 views

Should I perform simple validation (not null, max length, etc.) in a web api controller and duplicate in a command handler?

I have a question about DDD. I wonder if I should add validation in a web api controller and duplicate it in a command handler? Is it good approach to validate a DTO and a command even if the ...
0 votes
0 answers
170 views

.Net Core Api - multiple Dto’s for single entity

I want to know the best Practice is about having multiple dto’s for different use cases. Let’s say we have an api with a set of controllers to handle requests coming from a administration backend and ...
0 votes
1 answer
81 views

One read model project/microservice for all other bounded contexts - is it a good idea?

I have three bounded contexts: Users (generic subdomain), Groups (supporting subdomain) and Events (core domain). Basically users can create/join groups, create events within those groups, and sign up ...
1 vote
1 answer
91 views

What to improve/change and how to move forward with my Event Storming session?

I'm doing alone session with Event Storming for my application that I plan to build with DDD approach later on. Event Storming session is for learning purposes. My application domain logic is rather ...
0 votes
0 answers
40 views

DDD & ES – modeling crossing context between domains

I've been experimenting with DDD, CQRS and Event Sourcing recently as part of a small application I'm writing for my own use. Unfortunately, I'm not quite sure how to play some things out correctly ...
  • 1
1 vote
2 answers
297 views

CQRS MediatR Create many items commad - is it a good practise?

I am here to ask question about: is it good practice to insert many records using CQRS and MediatR? how to structure that in terms of names and folders? A have to insert into database over 500 ...
0 votes
4 answers
241 views

Should queries in CQRS be designed based on external demand?

I'm working in a microservice application which has some level of coupling between the microservices (some of them talk with each other via rest api - I know it is bad, but it is what it is; also I ...
0 votes
1 answer
157 views

DDD+CQRS - Should I always check if the Databases are online?

I'm developing an intranet application and I'm trying to use some concepts from Domain Driven Design (DDD) and Command and Query Responsibility Segregation (CQRS) in .NET Core, with EFCore. But, to ...
0 votes
0 answers
122 views

Saga / Processmanager?

I'm thinking about this scenario: I can receive customer inquiries by Email. Those inquiries can be sent from existing customers or unknown "customers" - I'll call latter "Leads". ...
  • 1
0 votes
1 answer
173 views

Should Commands always be a facade to inner layers in CQRS?

In a DDD-CQRS scenario, should my commands in the Application/Service layer always be just a facade to different aggregation method and other inner layers like repository calls in the infrastructure ...
1 vote
2 answers
620 views

In CQRS/ES should database calls be done in command handlers or domain models?

In the context of a DDD application following CQRS and the event sourcing pattern, I have 2 questions. At which layer should the direct calls to the Infrastructure layer be made? At the Application ...
0 votes
2 answers
135 views

May the left-side know the right-side when using CQRS with Hexagonal?

I'm trying to use the hexagonal architecture but I want the flexibility to make CUSTOM queries right to the database (or cache) to populate DTOs right from the left-side without passing through the ...
  • 109
0 votes
0 answers
235 views

Authorization and Cross-Cutting Concerns in DDD (CQRS) - Filtering Data

We are currently in the early phases of developing several applications that differ significantly in their functionality. As part of building these applications, we have also developed a few generic ...
  • 49
0 votes
1 answer
87 views

Duplicate Query rest end points in microservices - CQRS

I am a newbie to microservice. Currently I'm learning microservices by creating 2 microservices with CQRS pattern, with NO event sourcing, but each service has separate DB. Each service has separate ...
2 votes
2 answers
311 views

Microservices: Is the Saga Pattern correctly applied here?

I'm trying to understand and learn how to build microservice messages the best and came up with this task for myself: Services given: Accounts Service Token Service Email Service When a user ...
  • 461
1 vote
2 answers
191 views

CQRS: Is it an antipattern if the Command invokes a database interface which contains business logic?

Martin Fowler states that, Command module executes validations and consequential logic which aligns with every CQRS demo app that I've studied. That is to say: validation -- does this Jedi exist? -- ...
  • 1,349
3 votes
0 answers
261 views

Implementation of projections in event-sourced system

I'm working on a application which uses event-sourcing and CQRS to define it's domain model. Background We have implemented projections to aggregate stream of all domain events into a read models used ...
  • 35.6k
1 vote
0 answers
136 views

Where does a Process Manager live with a Hexagonal/Ports and Adapters Architecture?

Context: I initially asked this question. I lacked some understanding and phrasing to ask the actual question I wanted to ask. The answer though helped me understand the friction points a bit better ...
  • 2,361
1 vote
1 answer
256 views

In CQRS/ES where does an Aggregate Root belong?

Disclaimer: This question may be related to the framework I'm using to support CQRS/ES rather than the concepts themselves but many of these frameworks implement the same strategies, making me think ...
  • 111
4 votes
3 answers
540 views

CQRS: getOrCreate - is this a command, query, or both?

Consider the following scenario: If the user isn't registered in the database, register them. Return their ID. If the user is in the database, return their ID. The API endpoint for this may look ...
  • 1,349
0 votes
2 answers
212 views

How to manage primary keys in CQRS

I'm building a backend following the CQRS pattern and I don't know how to manage properly the primary keys (surrogate keys) between the command and query databases. For example: I have a model with ...
1 vote
1 answer
182 views

Does CQRS Handler can invoke another Handler because of relations to another Domain?

I have read DDD Vaughn Vernon book. There is a info about CQRS architecture. He mention that Handler can only do one Handler task, which I understand his and he cannot invoke other Handler. And even ...
  • 111
0 votes
2 answers
243 views

Is there alternative to applying events synchronously in command handler in CQRS?

I have workflow where I have complex command handlers encapsulated inside aggregate. These handlers emit some events, and then further logic based on result of these events can emit more events. ...
  • 101
-1 votes
2 answers
169 views

How to avoid CRUD and layered architectures in REST backends?

I'm creating a .Net 5 API backend and use EF Core for the database part. The simple CRUD way I know: API layer calling a command or query from the application layer using MediatR Application layer ...
0 votes
1 answer
328 views

How do I implement a domain entity behaviour that depends on some external infrastructure?

I am in the process of developing some software using CQRS, ES and DDD. A part of the system is writing services for controlling devices and collecting data from them. Consider a "Start" ...
  • 11
0 votes
1 answer
574 views

Where to put SaveChanges in unit of work?

For the sake of discussion, you can assume I'm using Entity Framework and a mediator pattern implementation in .NET. I'm going back and forth trying to decide how to structure some of my data access ...
2 votes
1 answer
221 views

Microservices: CQRS - how does the command side query data?

I’m trying to think what’s the best approach when I need data present in different services in a microservices-based architecture. In an e-commerce context, when a user creates an order the ...
1 vote
1 answer
247 views

C# Design for database queries and commands

Currently I'm working on a project that will interact with a database. Based on my research, I would like to develop a repository class which responsability is to write/extract entities to/from a ...
0 votes
3 answers
837 views

How can I coordinate updating multiple Aggregates as a result of one command, without introducing exploitative possibilities?

I'm trying to figure out how to integrate one command that updates multiple Aggregates in different contexts in a video game. The components/considerations for my particular design are DDD, CQRS, ...
  • 2,361
-1 votes
1 answer
972 views

How can I orchestrate multiple business tasks?

I have a WebApi backend with a Blazor WASM frontend. The application is split up into 3 main parts. Core, Infrastructure and Presentation. Basic onion architecture structure. Core.Domain Domain ...
0 votes
1 answer
388 views

Query authorization in read model for listing items in DDD/CQRS

In my example app there are admins and modules. Each admin may have some permissions to access a module. Also please note that I am assuming "simplified" DDD/CQRS where read models are ...
5 votes
2 answers
2k views

Data Repository and Complex Queries (DTO)

Following the classic 3 layer architecture domain Model (a list of domain models live there and has no dependencies) DAL layer - My Repositories lives there with DBContext implementation (Ado.net) ...
-3 votes
1 answer
866 views

Comparison of CQRS and MVC

Command Query Responsibility Segregation and Model–view–controller patterns look pretty similar to me. Are they comparable? Do they act at the same layer of abstraction? How do they differ? Can they ...
  • 133
2 votes
2 answers
184 views

How can we update potentially many Read Model Projections based on an Event that is not within the native context?

I have a Shop which sells Items for a given Price. To be clear, this is in the context of a video game, not an enterprise ERP system. The game operator can create Shops that Players can use to buy ...
  • 2,361
0 votes
2 answers
444 views

In an event sourced system, how do I get a current state of an entity?

Let's assume I use Kafka as an event store and put there all the lifecycle events of an order. Now I need to get the current state of this order in my system in during some business process. What's ...
4 votes
1 answer
516 views

DDD and CQRS in web applications

Premise A web application that has a frontend / backend separation. The frontend can be the JS framework of the month, which talks to a REST API in the backend. The backend part of the system accepts ...
  • 3,478
0 votes
0 answers
84 views

How to name multiple entities returned from a Query Handler?

I've got the following flow: HTTP API is exposing data from 2 database tables that are combined into one JSON structure. We're implementing this using CQRS - splitting the reads from multiple tables ...
1 vote
1 answer
469 views

Upholding business logic and invariants in an event sourced CQRS architecture

My understanding of a CQRS architecture is that a micro-service is split to two servers each with its own database such that the first server handles all the writes and the second server handles all ...
  • 13
2 votes
1 answer
435 views

Event Sourcing - More complex example

Usually when I read Event Sourcing examples - they are pretty simple. When trying to implement something even more complex - it seems to get pretty ugly pretty quickly. Let me explain this on one ...
3 votes
1 answer
2k views

Moving shared CQRS/Mediatr Request Handler logic into services and avoiding code/logic duplicity?

We recently embraced Clean Architecture and CQRS, by way of Mediatr, in several of our new applications. A similar (SPA-based) demo can be seen here. For many of our WebApi-based projects, this worked ...
  • 1,327
1 vote
2 answers
587 views

Primitive obsession, value objects, Commands, Events and where to convert

I tried to combine two rules. Don't fall to primitive obsession (e.g. EMailAddress should be a value object in domain objects and not a string). Don't use value objects in commands and events.1, 2, 3 ...
  • 111

1
2 3 4 5 6