ardanlabs / service

Starter-kit for writing services in Go using Kubernetes.

Home Page:https://www.ardanlabs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about implemented architecture

baransonmez opened this issue · comments

In this example repository, we can say that clean architecture is applied in general. At this point, I wonder how it would be more accurate to position a scenario where user and product need each other.
For example, if we wanted to check the existence of the user with the user_id we received when adding the product, it would be more correct to do this at what stage. service/business/core/product/product.go seems like the best place, but it seems like it wouldn't be right for us to access the user directly here as well.
What do you think should be the approach for this use case? If this example didn't make sense, we can also consider the scenario where the user has a wish list of products and manages that list.

In the case where product needed to check the existence of a user based on a userID, I would put that inside the product package to not have the dependency to the user package.

Eventually you will start writing new business packages that provide higher order functionality that will import user and product. For now user and product are base business packages that should stay separated.