Replies: 2 comments 4 replies
-
|
Hey @tatemz! Thanks for your question. I've been deep in exploring Event Sourcing and CQRS for most of the past year, so I'm always happy to discuss the subject. Before answering your question, let us align on a some event sourcing/CQRS concepts just so we can more easily understand each other:
How LiveStore Maps to These Concepts?In LiveStore, the store is the consistency boundary. It combines an event log and a state DB that are strongly consistent with each other within a single client session. Because of this design, a store functions as a single aggregate where:
Aggregates in LiveStoreTo answer your question: I believe LiveStore does support aggregates — but in an implicit way. Rather than requiring you to explicitly define aggregate entities, a LiveStore store is the aggregate. The consistency boundary, event stream, and state reconstruction are all built into the store itself. This should mean you don't need to set up an If your domain requires multiple aggregates (e.g., That said, I'd love to hear your thoughts on this mental model. Does it align with how you're thinking about your domain? Are there specific use cases you have in mind that might not be well supported yet or feel unergonomic with the current LiveStore API? Your feedback would be really valuable as we continue to refine the developer experience. |
Beta Was this translation helpful? Give feedback.
-
|
I’ve been exploring similar questions while evaluating Livestore. I am currently using it in a new dashboard tool serving as a projection for event-sourced stores in other systems. I would love to fully replace my existing infrastructure with Livestore, but I have hit the same roadblocks mentioned in this thread. Specifically, the concept of "The Store is the Aggregate" feels problematic for production Event Sourcing patterns. The Consistency Boundary ProblemIn traditional DDD/ES, an Aggregate serves as a consistency boundary. It ensures that business invariants are maintained within that specific entity. However, Livestore treats the entire Store as the consistency boundary. This conflation creates issues with optimistic concurrency control. In Livestore, validation seems to rely entirely on the global sequence number rather than the aggregate version. Consider this scenario with two aggregates ( - seq: 1, id: 1, version: 1
- seq: 2, id: 1, version: 2
- seq: 3, id: 2, version: 1
- seq: 4, id: 2, version: 2If I attempt to publish an event like Without a distinct concept of The "Store per Aggregate" SolutionThe logical workaround—and the "Cloudflare way"—would be to map 1 Aggregate → 1 Store → 1 Durable Object. This architecture would unlock the massive potential of Cloudflare Durable Objects, allowing for patterns like "database-per-user" where data is co-located closer to where the user is making requests from. In this setup, the specific Store instance correctly acts as the consistency boundary. However, Livestore does not seem to support this dynamically:
Right now, utilising Livestore feels like accepting a monolithic consistency boundary, which negates the potential benefits of distributed systems and architectures like those of serverless environments. Having said that, I'm enjoying using Livestore for an app that syncs the data from other sources to the browser for an offline application. It really is quite something! But at the moment I don't see how I can use it for anything more unless I went all in towards a more monolithic approach. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I learned what I know about Event Sourcing from @gregoryyoung who has a lot of older material and CQRS examples on the subject. I think Livestore is a great solution for getting developers familiar with the patterns and principles. The strong type-safety is great, too!
I have setup a sample repo here showing the ES concepts I am wanting to discuss within this thread: https://github.com/tatemz/es-poc
I have a question related to traditional domain aggregates. From my limited experience in Event Sourcing & DDD, domain aggregates are the result of a pure left-fold over events for a given domain entity (example).
I think where I am having trouble is with Livestore materializers. To me, materializers are great at subscribing to events and building projections, but it is a well-documented idea that projections and aggregates are different concepts.
Why do aggregates matter?
Aggregates could allow end users to apply events to a domain object and preview them before committing/saving. This also allows for easy rollback to an aggregate version.
Livestore seems to support a lot of event sourcing concepts out of the box, but does it support traditional domain aggregate concepts? Should it? Or was it an intentional decision to not? Or perhaps is there a suggested workaround?
I would hate to have to setup a materializer to build an
eventsByAggregatetable because that would feel like it is duplicating the entire event log.Check out my sample repo for a demonstration of where my brain is at. https://github.com/tatemz/es-poc
Thanks for all the hard work on a great project!
Beta Was this translation helpful? Give feedback.
All reactions