Hi,
This question has been bothering me for a while now. Assume a DDD/CQRS/ES architecture.
The user needs to be able to determine when the stock in the warehouse is running low so that they can plan purchase orders and productions. This planning is done days, even weeks or months ahead of time and might be subject to constant changes and improvements.
There are thousands of different items to track over multiple warehouses.
I assume that this "planning" bounded context will receive events from other contexts that determine the projected demand on the items and changes in stock level.
I would expect stock level changes to happen only in the past, but that is not a safe guarantee (if it makes sense from a business perspective to have manipulations of the warehouse in the past - I would argue that any manipulations should usually be done "now" when they are detected/made). Planned purchases and productions can be mostly handled by my own BC.
In order to inform the users about projected shortages, we need to be able to track and estimate the stock progression over time. This is also how the user might perceive the forecast demand and stock level - as a graph.
So my read model is centred around each article (sorted by articles that are running low on stock first) and must start from the current (or past few day's) stock level and project over a granular enough sample rate (every few hours?). Determining sub-sample shortages might be hard and not worth the effort (we keep a large enough buffer of stocked items - however if we can keep this low enough, we could gain more benefits) so I wouldn't focus on that right now (unless someone has a solution that doesn't focus on discrete samples).
How could I design such a read model for such a graph and how would the projections from the event stream alter it?
We also face the issue of migrating and coexisting with existing data so we might have an initial stock level of date X and further changes to it afterwards (booking list). We're a strangler application, doing event interception and asset capture.
Our read model store is most likely going to be a RDBMS, but I wouldn't rule out a document database (ravendb).
Regards,
urbanhusky