In my company we made almost every system in micro-service architecture. I working on the backend system, we have many api that working separately from each others. Today We're come up with the question that which component should have the responsible to give front end the data their required.

Let's say we have

  1. Customer API which :: handle the request that related to customer data
  2. GiftCard API which :: handle the request that related to giftcard data

We have the story to made our website header show 'total amount of the giftcard that customer has'. GiftCard Api already has the endpoint to get this data but for this story, we're all agree that FE should called to Customer API and Customer API should called to GiftCard Api to grab that data and return to FE because customer's total giftcard balance is basic customer's information which customer api should provide.

But should Customer API be the one who has responsible to return the list of the giftcards information that customer has to FE as well? (RetrieveCard endpoint which required member id as a parameter) We're arguing about that.

Some said we should let's FE called to GiftCard API to get that data because customer's giftcards information are 'Cards information' exist in the GiftCard service level which giftcard api should provide while customer's total giftcard balance is basic customer information which customer api should provide like I mention before. (And this is what happen in our company right now. FE > GiftCard API directly)

Others said we should change the way we're doing right now to let FE called to Customer API instead of GiftCard API because, anyway, giftcards are own by customer so Customer Api should be the one take this responsible. (FE > Customer Api > GiftCard API)

Right now I'm convinced with the second opinion but I still skeptic about that and want to here the opinion from your guys.

Thank you in advanced!

Edit :: In my company the frontend team already has the system called frontend service which provide the data to the frontend stuff by called to multiple backend service and manage the data first. But they want to change the front end service to called to only 1 endpoint if possible. In this case, for the second option, its mean they want to called to Customer API only and let the Customer API called to GiftCard API by itself.

  • 2
    Possible duplicate of How to query data from multiple microservices
    – Samuel
    Commented Nov 6, 2017 at 22:24
  • My situation is a littl bit different than that topic. In my company we already have the frond end service. The things that guys in my company want are made front end service called to only 1 backend service instead of n.
    – Natechawin
    Commented Nov 8, 2017 at 7:30
  • IMO the frontend's service whole purpose is to execute as many requests as necessary to serve the frontend's needs. The frontend's service should be in the same network as the other services, so you take a slight performance hit for a better more maintainable SOA.
    – Samuel
    Commented Nov 8, 2017 at 8:44

1 Answer 1


Avoid choosing what goes in what api by the name of the thing or api. It's too subjective.

Choose by what is performant and scalable for your system.

In this case, you presumably have a performant query, get gift cards by customer id, which is made available in your giftCardApi and a performant get customer by id query in your CustomerApi.

Posting requests to more than one api on the front end when you don't have to, is non performant. But permanently merging the two, so that you always get gift cards whenever you get a customer is also a problem.

Simply make a new CustomerWithGiftCards ViewModel and endpoint specifically for this page. Have it call both services assemble the ViewModel and cache the result.

  • In my company we already have thing called front end service which called to multiple backend service but right now front end team want that service to called to only 1 end point. The approach is they're going to let Customer API build the new endpoint (exactly the same as CustomerWithGiftCards that you mention) and they'll get the customer data by them self and called to GiftCard API after that (or parallelly) which I still don't sure that this is the right approach.
    – Natechawin
    Commented Nov 8, 2017 at 7:37
  • Front end guys can get caught up in making an app in javascript rather than a webpage. but as long as you have that server side code thats just for that website, you can always tweak it later
    – Ewan
    Commented Nov 8, 2017 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.