How to connect untied webapp components?

I decided to separate my webapp from:

  • The API component located on the server connects to the database, contains some logic, and returns the results to the consumer application.
  • The consumer application hosted on the server has HTML templates, viewing logic, and client-side JavaScript code. It sends queries to component 1, puts the results in templates, and displays the views.

Since an API component is required for a consumer application, it must have a low latency connection. As a result, should I host both APIs and consumer components on the same server and somehow optimize the connection between them? Or is it perfect to have them on different servers, just them fast?

+4
source share
2 answers

Modern web applications, as a rule, generate HTML on the client (browser) using libraries such as Angular. Thus, the server does not serve HTML, rather, it serves the web application (static files) for the client and provides an API for calling the client. The client retrieves data from the server API and displays the HTML.

Since an API component is required for a consumer application, it must have a low latency connection.

Since the API serves clean data (JSON, CSV, etc.) and does not display HTML, this leads to the fact that less data is transferred to the wire between the client and server. It also shrinks better.

+5
source

Source: https://habr.com/ru/post/1664184/


All Articles