Skip to content

How to model master data / tenant specific models #8

@pmartelletti

Description

@pmartelletti

Hi @codeliner ! I know you guys are busy right now with the fee office example (#7) , but just thought I'd place the question here, explain my domain and then, whenever you guys get a minute to review it, we could go over it. 😄

So, a bit of a context from our company here: we're a company that builds software for grocery stores, most of the hard work is done for the POS in the actual store and in the back office. The POS is built in .NET, and currently being rebuilt using CQRS.

My team, however, is focused more in web applications that support our customers, like transferring files from store to head office, place automatic orders, sync products and offers between the different head offices (as the main products base and offers is the same for all customers). We use PHP (mostly Laravel) to build our apps, and JS to connect to the API's we generate.

The project we're currently working is the offers one. This is already working, the customers are happy with it. However, a new requirement was added to the system, and things started to get messy: because we didn't have a log of what was happening and when in the system, we were unable to respond questions from the customers like "when was this item introduced to this offer" or "when was this offer extended". That's when we decided to stop what we're doing a try to come up with some ideas on how we could implement this. Use Laravel log could have been enough for the actual questions/reports we have, but that wouldn't help us for any future questions customers will have. That's why, after hearing the other team talking about ES all the time, we decided to give it a shot.

=======

Now, some background on the Domain and what our app needs to do.

All our customers receive daily a text file saying which offers are active (or will be), and what items are in that offer (they are all part of a cooperative group, so basically all members of the group receive the same offers, as the group makes the purchase for them). If they use our EPOS system, then we offer this added service where we parse the file and sync their Head Office with the deals, automatically - so no human interaction is needed. If they are not using our system, then they'd have to manually key in the changes daily.

The domain was easy enough when all customers receive all the same deals - however, it started getting complicated when the new requirement was added: customers would like to be able to ignore deals they are not interested to offer, to create their own deals, or to amend deals (that is, if the deal was buy any soft drink for €1, but the group said only Coca-Cola brand was in the offer, there might be a store that wants to add Pepsi brand as well).

That's were it all got complicated - we haven't found so far any Domain that talks about "Master Data" and "Tenant" specific data. The aggregate started to look really ugly when we added flags like "this offer is specific to this tenant", or "this tenant is ignoring this or that offer".

So here's where we can to your help. Can you help us try to get the correct models for our domain? Here's a bit of example of what the system should be doing.

  • Be able to import offers, that have a set of properties (like, description, start date, end date, reward, and mechanism - when an offer should be triggered).
  • Be able to add different groups to the offer. Most of the offers will only have one group (ie, buy 2 from this group and pay $3). However, there are offers that need to have more than one, for example: buy one of each group and pay $3 (meal deals, for example, where you would buy a soft drink, sandwich and dessert).
  • Be able to add/remove items from the groups.

That's essentially what we had before. The aggregates were easy to understand, it was all straightforward.

However, the things got more complicated with these new requirements, as customers should be able to say:

  • ignore any offer containing this product
  • ignore this particular offer
  • I want to edit this offer (so, change some details of it - like adding new items) but I still want to get updates from the master data
  • I want to edit this offer but stop getting updates from master data
  • I want to create a new offer that is only available for my stores, and if a deal from the master data comes in with the same details (start date, end data and deal number are used to identify an offer), then ignore it and use mine.

So, with all these new rules, it all started to get complicated and we're kind of stuck, or slowly making any progress. So wanted to know if you could help us:

a) Try to understand how tenant data would work, as I've never seen an example for DDD like that
b) How would you handle the ignores or the custom data? Where would you keep track of that?, etc

Also, we really need to have a track of the import process, what was imported and when, and what failed, what was skipped because of the customer settings, etc, as we usually get questions like "why is this item not in my deal, but it is in the other customer?". Would you do that in DDD as well?

Thanks a lot for your help in advance - and hope the problem is clear. I'll more than glad to help clear out any questions you may have about it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions