Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build front end for Microservices

Let's say I have a dozen microservices. I am wondering where should the front end go. Let's say front end is HTML, Javascript, CSS. One way is to make it a separate service handled by a UI team. So it can form the API gateway where the request from browser comes in first. But this seems against the idea of independent self contained services.
browser ------> API Gateway ------> Microservices
In this link, they say that Javascript and CSS should be served by microservices. API gateway should serve only the HTML page. THere is a nice diagram showing this >> microservices with UI I have two questions
1. How will this be implemented? How will API gateway serve the JS and CSS files in microservices, and maybe HTML fragments too. How will initial page load happen and from where.
2. Now we are mingling HTML into microservices. But what if I want to serve Android and iOS apps too? THanks.

like image 650
Apurva Singh Avatar asked Feb 23 '17 00:02

Apurva Singh


People also ask

Can a Microservice have a frontend?

Fig. 2: Frontend integration: The frontend is a component of each microservice. Each must be connected separately to provide users with a uniform UI/UX. Build-time integration is based on providing the frontends using packages, which a container app then loads as a dependency.

Is microservices front-end or backend?

Therefore, if you plan for your microservices-based system to have multiple clients or distinct business domains, you should rather use the Backend for Frontend design pattern from the start.


1 Answers

let me try to answer your 2 questions directly without discussing either approaches.

How will this be implemented?

Modular Web Apps are possible if you use an MV* pattern. AngularJS and ReactJS both support building modular Apps and load modules on demand via webpack or requireJs.

Since your UI is composed of fragments coming from different microservices, you might need a reverse proxy and some CDN or caching to speed up page load by curating client requests to a single host (domain).

what if I want to serve Android and iOS apps?

Native Apps will require an API layer and you can curate your microservices into a single API gateway, maybe even develop a mediator API between mobile apps and actual microservices to expose only a simple subset of your actual backend.

like image 151
Bishoy Avatar answered Oct 30 '22 13:10

Bishoy