CQRS implementation best approach - using Views or Value Entities?

Hello experts,
I have 10+ event sourced entity micro services, each representing a subdomain. In order to achieve CQRS, we want to keep our read model separate. I have a requirement where I need to bring data from various (ranging from 1 to 5) entities to return to the UI.

We think we can implement this using the below 2 ways:

  1. Implementing multiple views tables in a view service where each view table represents a domain entity. We then write query endpoints to query the required entities and join them in the query (using advanced view features).
  2. Implementing a Value entity service which represents a flatter representation of entities after joining them into a single value entity. We then use service-to-service eventing and update the value entity on all the required events and implement query endpoints which manually parse the value entity data and prepare the response as required by the UI.

We would like to know the pros and cons of these approaches from complexity, performance and any other perspective. Please advise which approach better aligned to Kalix best practices and is recommended by Lightbend.

Thank you!

Hi @rushi both solution has some pros and cons. A lot depends on your actual business use cases. I would start with advanced views as it is more flexible from the queries perspective. Remember that you can query the VE only by the id. A range query will not be possible.

hi @aludwiko ,
Thanks for your prompt reply. I will discuss this internally and get back if we have follow-up questions.