Since I came across this scenario a while ago, here I take it. The user and the element are part of different aggregates that they do not know / do not care about each other (even if the element has userId). A "similar system" (LS) is a different collection of tracking, similar to , who , what .
LS also does not care about the user or the element, although, since I do not see a case where something other than the user may like something, I can say that Like will always mean userId (not the whole User concept) and the subject ( Item, VIdeo, Picture, Post, etc.).
LS simply supports the association of a user ID and another itemId of a certain type (which can be a string if you want LS not to be associated with what Item is). Every time a user likes a command: RegisterLikeForItem {UserId, ItemId, ItemType}. The LS handler will save this information and then post the UserLikedItem event. One of its handlers will be a counter that will count how many users liked this element. Another handler can make a list of what one user liked (this will be requested by the user interface).
Each handler serves one use case and, perhaps, each has its own repository. I know that this looks rather complicated, but in fact it is simple (one use case requires a processor and, possibly, storage) and all the bets, it is very flexible and supported. And the system works with one or 1000 types of elements.
source share