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 >>
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.
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.
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.
let me try to answer your 2 questions directly without discussing either approaches.
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).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With