I am building a REST Api from scratch so i am overthinking and revisiting various approaches and best practices.
I have a Materials
repository that serve all the sub-domains of our logic.
Also i have a Sales
and Inventory
sub domains that both relate to the Materials
.
I found this question that evolves exactly around what i am doing and after going and now another question arises for me in regards to Repository pattern.
Let's consider the following REST Api routes:
/masterdata/materials
. Provide a list of materials and their master data./sales/materials
. Provide Sales per material in different granularoty.
Where the methods that satisfy /sales/materials
have to be implemented?
In the Repository of Materials
or in the Sales
repository?
/sales/materials
implies that your aggregate is "sales," so that's where I would start. But at the end of the day it doesn't really matter where you retrieve the materials from, since there's no all-seeing, all-knowing authority looking over your shoulder telling you whether you're doing it right or wrong. Put the materials retrieval method where it makes the most sense to you.