In a major application REST API that covers several related domains, does it make more sense to split resources into 'areas' based on the business domain they belong to or is it better to to maintain a single model?
For example, there are 'Sales' and 'Inventory' sub-domains. Users of the system typically only care about one domain at a time, but exceptions are possible. There is an 'Item' concept that exists in both domains so we could implement the 'item' resource in two different ways.
have different resources to represent the concept in each domain, each resource holding only the relevant data:
/sales/items/:id
/inventory/items/:id
have a single resource with all the data to be used in all contexts:
/items/:id
There are also plenty of resources that only belong to one of the domains.
pros of 'areas'
- easier to understand the API for users who only care about a single domain
- easier to implement resources (less stuff to read/update at a time)
- resources can be more specialized/optimized for each particular domain
- ability to control access to resources at more granular level
pros of a single unified model
- no duplicated resources for concepts that belong to more than one domain
- if a user needs to work with multiple domains, he will only have to use a single API that covers all his needs
Is API partitioning as described above a valid way to reduce complexity of both API contract and implementation? I haven't seen it mentioned much anywhere.
Are there any more things that need to be considered to make a decision in favor of either approach?