We have a system with a few microservices and multiple clients (Web, mobile). Currently, only one microservice (let's call it "Master MS") exposes a public API, which is used by all clients. This worked well until now: Master MS did occasionally ask for data from other microservices, aggregated it, and sent to clients. Now the system started to grow.
PROBLEM 1:
We have now more microservices that should provide data to end clients on the one hand, and Master MS should not really know that these microservices events exist.
PROBLEM 2:
Client has very specific needs now (Web client wants more data in coarse requests than mobiles, also some pre-evaluated data, e.g. not GET /resources1 and GET /resources2 but GET /info {hasResources1 = true, hasResources2 = false}).
So we want to go with an Application Gateway (or more like Backends for frontends) pattern and currently, YARP is our favourite for the task (lots of .net developers in the team, low cost as open source). The idea is to set up two YARP gateways, for web and mobiles, that reroute to backend microservices. PROBLEM 1 is thus solved, partly also PROBLEM 2, and here comes the question.
Where should I do the aggregation? Let's say Web client wants to get data for the dashboard. This involves e.g. asking Service1 for customer data and sending two requests to Service2, for let's say purchase and client history. All these responses should be transformed into a single DTO.
So who hosts this aggregated endpoint? YARP gateway itself? That seems to be not the purpose of YARP, I cannot find a place or way to put the code there in a meaningful way. The code also doesn't fit either to Service 1 nor Service 2. So where should it go?