0
votes

We have microservices architecture project with two API:

  • External user API - API for users who are registered/logged in our website.
  • Internal user API - API for users who are not registered in our website and who makes request from another website (users don't know about our website X, they just making request to site Y and site Y makes request to our site to get data for user).

Format of requests/responses are totally different for both APIs, but processing/logic - totally same.

Question - how to keep two different services (API) but not copy-paste code for processing?

Technologies we use: Python(Flask).

1
is it out of question to have the external API call the internal API behind the scenes? (after doing some request argument formatting) - c8999c 3f964f64
yes, I was thinking about it as well, sounds OK. - Grzegorzg

1 Answers

2
votes

In a microservices architecture, you want to keep your services as independent of each other as possible. Therefore, a typical advice is to avoid sharing or reusing business logic between the services.

So I see the following options:

  • Use only one service with both the internal and the external interfaces.
  • Create a new service for the common logic.

Further reading: