Ever since the microservices pattern took the web development by storm, it was inevitable that it would be applied to the frontend development as well - in a form of micro frontends. The idea was to create your web interface in such a way that any segment (no matter how granular) can be deployed and developed separately.
This is something we became aware of when we took over the development of a monolithic application inherited from the previous development team. The main reasons for refactoring the application into a more maintainable and manageable number of microservices were:
- long application deployment time (which prevented application deployments during client work hours) and
- long developer onboarding time (it took months before new team members would become productive).
Taking into account that this application was not publicly accessible we did not have to worry about SEO - all of the focus was put on the functionality of the interface itself. We realized we could solve the aforementioned issues by introducing a set of limitations in a way that would still allow us to build a fast, user-friendly and functional interface.
Each of the microservices returns only static blocks of HTML. To change the look and feel of each block, microservice can include (scoped) style tag that holds any custom CSS. Keeping blocks simple and static makes testing much more manageable.
Taking advantage of the browser’s default behavior and the fact servers can shift some of the burdens from the client-side was a must. The browser recognizes the style tag automatically when inserted into the DOM and applies it to the page. Query strings can be used to store data between page requests, form submissions and communication between individual segments on the page.
Single pages should not hold a large number of forms because with this approach communication among them is limited. This can be solved by creating multi-step forms that can move in both directions while being careful not to break the good user experience.
Utilizing these limitations, while applying the microservices pattern, the development process became much simpler without the need to juggle complex build processes. Newer recruits could join the regular development process much sooner and the number of development stacks has been significantly reduced compared to the old monolithic application structure.