DEV Community

Jignesh Solanki
Jignesh Solanki

Posted on

Micro Frontend Architecture: The What and The How!

Introduction

Today’s most modern web applications are highly complex and visually driven due to increased competition and the need to achieve market sustenance. The commonly perceived successful architecture is the monolithic pattern, but they are considered traditional today as they might slow development. Not just that, monolithic architecture can be harder to scale. Coming to the type of application businesses often build currently is single-page applications (SPAs). SPAs focus on dynamically rewriting/loading the current page a user is accessing rather than repeatedly loading all the application pages. This helps to improve the performance. However, it has a similar limitation as a monolithic architecture regarding scalability.

What good is an architecture design if it cannot be scaled or makes the development process difficult? The necessity to build a web application that meets the expectations of all users requires immense effort from developers. Unlike the monolithic architecture, the key focus of micro frontend architecture to build highly scalable web apps. Moreover, in some cases, even building SPAs with a micro frontend architecture is efficient enough to break performance and user experience barriers. In this article, you will find information about what a micro frontend architecture is and how it works.

Moving Towards a Micro Frontend Architecture

This architecture was released as a direct solution to the limitations and problems faced while following a monolithic front-end architecture. Micro frontend architecture derives its functionality approach from the inspiration of how microservices work. It helps to fast-track development and ensures the entire process to be error-free. The State of the Frontend 2020 highlights that approximately 24.4% of the developers globally benefit from the micro front-end architecture.

Fortune 500 companies like Spotify, IKEA, American Express, Starbucks, and SoundCloud are examples of those who have adopted this architecture for its usefulness regarding UI/UX enhancement and scaling. One of the prominent examples is how Agorapulse used micro frontend to scale their application. With the help of this architecture, Agorapulse was able to automate all features end-to-end, which ultimately resulted in more clarity and speed in their multi-threaded processes.

Cutting to The Chase: What is It?

Micro frontend architecture follows a design approach that is closely related to microservices. In this architecture, the application’s front end is decomposed into individual or semi-independent features that can work without any tightly coupled dependency. For example, suppose you are a business looking for a way to migrate to a new architecture without affecting the user experience of the old existing application. In that case, the micro frontend is the solution for you. Why? The answer is simple. Since micro frontends are domain-driven and follow the decoupled architecture pattern, it supports CI/CD processes. Thus, it makes scalable development user-oriented and resilient towards any failure within the application by providing regular provisions to deploy patches.

Mode of Action: How it Works?

Although micro frontends have been gaining traction lately, there is no single answer to explain how this architecture works during implementation. This is due to the variations in the approaches micro frontends offer regarding customization according to requirements and objectives. However, micro frontend functionality can be described as splitting an entire front end of an application into smaller components based on respective features and domains. Each part is handled by an independent developer team. Hence, these micro frontends offer better flexibility, immutable testability, and backend speed similar to microservices.

Monolithic Architecture:
Monolithic Architecture
Source: https://micro-frontends.org

Micro Frontend Architecture:
Micro Frontend Architecture
Source: https://micro-frontends.org

Since the micro frontend is all about segmenting a web app into different components, its functionality can also be explained in three compositions. They are as follows:

Client-side composition
This is where app shell-like techniques are used to minimize HTML, CSS, and JavaScript to improve the user interface power and increase caching to improve performance.

Edge-side composition
The edge side of micro frontend architecture indicates the process that renders different segments/components and stitches them together.

Server-side composition
In this part, multiple frameworks can be clubbed together to build different web app components as per requirement. Also, this part deals with the database functionalities, and some of the commonly used frameworks are Ara framework, Piral, Tailor.js, etc.

Conclusion

The core idea of micro frontends is to build resilient applications with customized elements via isolated coding. Hence, it has a cleaner codebase. However, despite its autonomous deployment, this architecture can pose challenges in achieving quality in-app communication, UI/UX consistency, duplication of coding, etc. But, by staying up-to-date with the new trends, dealing with the limitations of this framework becomes easier. However, there are a plethora of architectural options available from which you can choose that best fits your requirement. Read more about the top front-end trends organizations are adopting in 2021 to know more about other various architectures and practices to develop scalable apps with high efficiency.

Top comments (0)