2

I recently came across a demand to create a web system (which will be done in PHP, but is for any language), to have the same functionalities of a mobile application already ready. This app has a complete and well written API in NodeJS.

With this situation, I had a question about the possibility of using the API in the system too, rather than connecting this directly to the database and rewriting all the functions already in the API.

To better illustrate what I mean, here are the two methods:

More common:

System -> Database

APP -> API -> Database

That is, a system in php connects directly to the database, while an app (for security reasons and in order to avoid reverse engineering) has the API as an intermediary. However, considering that I come across a fully functional and functional API here, I thought of this new method:

System -> Api -> Database

APP -> API -> Database

The major drawbacks I see in doing this would be the fact of losing performance, since a direct connection would be much faster than making a request and handling the response. However, the advantage of having just one maintenance area (the API) catches my attention.

What other disadvantages would I have in this method?

1 Answer 1

3

Connect your new system to the same API your mobile App is using. With current network performances the loss will be minimal and you'll have a decent architecture with minimal code duplication. Consider how many hours of development time you'll save.

This solution in fact is currently a very common (if not standard) practice. Many architectures are disallowing the Client facing applications to connect directly to the database, but instead work as an UI Client only and utilize an API backend with Microservices for dealing with data. Thus, rise in popularity of SPA Javascript applications that simply consume the APIs and act as just another API client.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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