How to implement search and visualisation

I’m starting to develop a project using AKKA and will be modelling flattish hierarchy of aggregate roots as actors deployed across a cluster e.g. Companies / Employees.

Is there an idiomatic approach to implement search and visualisation across this population of actors?

I’d like to be able to for example search for employees with salary 30-40K, and with company car, or possibly to present a RAG status for employees that haven’t clocked sufficient hours this month?

Hi @paulwilliams,

this sounds like a good use-case to use CQRS. Each aggregate could even be EventSourced and then, you can implement a projection on the events journal for each of the searches you mentioned.
We’re on the middle of writing a tutorial that will explain a step-by-step implementation of a similar project. See the high-level design of the sample application.

The gist of it is that you have certain Aggregates implemented as sharded persistent entities (using event sourcing), and then build a handful of projections.

Hope this helps,

Thank you @ignasi35, that’s the approach I typically use without AKKA in the mix, but it’s good to hear the similar approach works well with AKKA.

In projects I’ve worked on, we use CQRS and sharded actors to manage the state of the various objects. Then, we leverage PersistentQuery actors to process the event stream from the main actors to populate a view – we use both elasticsearch and postgres (for different purposes). Then, the query of the set of all objects of a given type is directed at the elasticsearch (or postgres) views. The “list” and “query” of a set of objects uses the view. A “getById” uses the sharded actor. We guarantee that the “list” / “query” results have the same schema as the getById results, so the user sees consistent results.