You are developing a new web application or you are refactoring a section of a web application to make it more modern.
How do you avoid creating a monolithic Single Page Application by placing too much functionality in a common front-end?
- You want to allow teams to be able to independently develop and release end-user functionality without having to retest or redeploy the entire UI
- You want to allow cross functional teams that own a feature from front-end to back-end.
- You want to allow teams to have the freedom to choose from multiple frameworks (such as Angular or React) when appropriate.
While the Single Page Application approach is fantastic in that it allows teams to entirely replace the UI layout and controls within a particular screen region at any time, when a team building a large application tries to apply that approach to many different areas of the business, the result can often be delays and unexpected conflicts as different aspects of the business may need slightly different UI representations. For instance, the optimal screen layout in an airline web site for choosing a flight may not be the optimal layout for viewing your frequent flyer status.
Split your Single Page Application into several Micro Frontends that align to specific business features. Allow the team responsible for that business feature to implement the full flow of the front-end for the feature.
This level of isolation allows several Micro-Frontends to be placed on a single web page that can operate independent of each other, be deployed independently and even use different frameworks, for example two different Micro Frontends on the same page could use Angular and React respectively. In order to make this function, you will often have to use a Micro Frontend framework like single-spa, which is a router that allows the different frameworks to communicate.
However, this can result in of the downsides of the Micro Frontend approach in practice. While teams have the flexibility to choose any MV* framework they choose, and also to specify their own look and feel choices through CSS, this freedom can lead to inconsistency in the UI as you move from view to view. Instead, we have often found it to be better if teams in an enterprise are consistent with the use of a single MV* framework, or at most a very small set of them, and that they also should share some common CSS files to specify a consistent look and feel for the entire web application. Note that it is an anti-pattern to have a separate team define that common set of styles and CSS files – this is actually a better application of a loose “guild” approach to ensure that your UX designers and HTML developers are working together toward common goals.
To allow the team to own features and functionality from Frontend to Backend then the Micro Frontends should be aligned to the backend Microservices especially those Microservices that implement the Backends for Frontends pattern. The best way to do this is not to separate these teams, but to keep development of an end-to-end feature together as a single Stream Team.
An example of an architecture (and team organization) that follows this pattern is shown below:
In this example, a team building a customer website for an airline is divided into three Stream Teams, each one responsible for one major epic that represents a major chunk of functionality in the application. Each Stream Team is responsible for both the front-end and back-end development of their epics, although teams may connect at the microservices level, such as the booking team needing to be able to find flight availability if a flight is cancelled and must be rebooked.
By implementing the Micro Frontend pattern you can develop and deploy small features with more agility than in a monolithic Single Page Application. This enables cross functional teams, ownership of frameworks, end to end ownership of features and reduces complexity.
Read more about Micro Frontends in the article that originally introduced them to the world.