Federated Microfrontends at Scale

Spanish audio is available in the player settings
Rate this content
Bookmark

The talk will be a story of how Personio went from rendering through a Monolithical PHP architecture, to a microfrontend oriented Next JS app, powered by Module Federation and the NX monorepo toolchain.

This talk has been presented at React Summit 2023, check out the latest edition of this React Conference.

Watch video on a separate page

FAQ

A federated micro-frontend is a setup where partially standalone modules are consumed by a central controller at runtime. This allows for separate module releases from a rebuild of the main host, maintaining independence across different teams and functionalities.

Personio's frontend architecture evolved through three phases: starting with a PHP monolith, then to micro-frontends still dependent on the monolith, and finally to a federated micro-frontend setup where applications are modular and managed through a central orchestrator.

The main challenges included inefficiency due to each application duplicating dependencies, difficulty in sharing state and common resources, and the need for extensive coordination among teams.

NX is used in Personio's monorepo for generating integration libraries and components for micro-frontends, ensuring code generation is streamlined and that changes within the monorepo trigger selective builds and deployments relevant to the affected applications.

Personio uses a single root package.json within their NX monorepo to manage dependencies, ensuring consistency across all applications. Shared libraries require strict version control and code coverage, with changes needing approval from all consuming teams.

The federated micro-frontend architecture has allowed Personio to maintain team independence, improve deployment efficiency, and enhance web performance by 30% due to optimized dependency management and streamlined runtime processes.

Personio utilizes TypeScript for type safety across its micro-frontends. They employ an integration library which maintains type safety during development, and runtime federation is managed internally, ensuring efficient asynchronous operations without compromising type safety.

Daniel Bolivar
Daniel Bolivar
31 min
02 Jun, 2023

Comments

Sign in or register to post your comment.

Video Summary and Transcription

This Talk discusses the transition from a PHP monolith to a federated micro-frontend setup at Personio. They implemented orchestration and federation using Next.js as a module host and router. The use of federated modules and the integration library allowed for a single runtime while building and deploying independently. The Talk also highlights the importance of early adopters and the challenges of building an internal open source system.

1. Introduction to Micro-Frontends

Short description:

Let's talk about micro-frontends, the federated kind. Personio's frontend architecture has gone through three different moments: PHP monolith, micro-frontends depending on the monolith, and federated micro-frontend setup. The change was needed because the monolith became a mythical beast, and the company grew faster than its architectural concepts. So, Personia switched to micro-frontends, with separate apps in separate repositories, assets stored in AWS S3, and a standalone React application rendered on the user's browsers.

Hey, folks, let's talk about micro-frontends, the federated kind. I was already introduced, but, you know, my name's Daniel. I've been doing frontend stuff for around 10 years and I currently work as a lead engineer at Personio. You can find me there just in case what I say is interesting. And I'm here today to tell you a little story. It's a story about change, it's a story about evolution, but it's mostly about how we are running 60-plus micro-frontends owned by dozens of teams and keeping our sanity while doing it, most of the time.

So, yeah. The story begins, of course, with change and the thing that's changing in this case is Personio's frontend architecture, which in its eight years of existence has gone through three different moments. So, the first one was PHP monolith, very simple stuff, monolith got requests, handled requests, gave stuff to client. Then, Personio's labor of micro-frontends, still very much depending on the monolith for data and as a rendering vehicle, and finally, what we call federated micro-frontend setup which is the main point of today's talk. Don't worry about the size of the graphs, we'll see them bigger later. And let's start first with the, well, before that, when we talk about change, I find that the most important things to say about change is why the change was needed, right? Because that also many times informs why we ended up where we got ended up at. So start with the first moment, how Personia came to existence and why we had to go away from it. Like I said, most people would call this legacy. I call it vintage, because it's appreciated over time, you know, it's a thing that makes money. I don't like the word legacy, it's still loaded. But it's a monolith PHP Laravel application, it does absolutely everything, and the people who built Personia started the project, it got popular, kept adding features on top of it, and we kept adding features on top of it. And you know, you look back a couple of years later, and your project, which started out pretty well, suddenly looks like this. It's a mythical beast, very powerful, but also very janky. And that's what happened to Personia, you know, the company grew faster than its architectural concepts could. In the front-end specifically, it looked like this. We had jQuery coexisting with Laravel and React, and deploying anything took one and a half hours or two hours, if you were lucky, and so something had to change.

So it changed through distribution. Now, if you were around in the front-end scene in 2019, the busiest of buzzwords was micro-front-ends. That's what Personia did. They built micro-front-ends, and our flavor of micro-front-ends looked something like this. We had separate apps in separate repositories under a single framework that was React. At build time, these applications would ship assets to file storage in AWS S3 bucket, and they would also sync their latest build with an internal service called Artifact Service. This thing kept a map of application to assets, kind of like this. Then, when the monolith got a request, it would ask the Artifact Service, hey, what assets should I render here, pass them over to the client, then those would be downloaded, JavaScript would do its thing, and a standalone React application would be rendered and mounted on the user's browsers.

2. Orchestration and Federation

Short description:

So, we transitioned from a monolith to separate microfrontends, which initially solved some issues but created inefficiencies. To address this, we introduced orchestration, which involved rendering through something different than the monolith. We implemented federation, where modules are exposed and consumed by a central controller at runtime, allowing for separate module releases. The frontend orchestrator serves as a lean controller and acts as a router to map URLs to modules.

So, to give you a visual of how this looked, this is Persona's dashboard, and we went from this, the monolith doing absolutely everything, to something like this, where we had two separate applications, two separate microfrontends, they were standalone, they didn't share anything. And this was really good. We solved part of the issues, which was people couldn't work independently, we had a mess, everything mixed together, and deploying was painful. But it was also not so great, you know? Sharing things like state, common dependencies, everything was very hard, it required a lot of coordination, and after a while we decided it was really not worthwhile, the effort, to share the stuff, so every application had everything in it, and it was very inefficient. Also, we were deprecating the monolith, so the rendering vehicle was going to go away, which is probably the main reason why we had to build something different, right?

That is the third moment, which I call orchestration. And this third moment had two objectives. One of them was to render through something different than the monolith, because remember it was going away, and the other one was to keep the good bits while improving on the limitations, so the good bits included the team's independence, and how they could build and release separately. The limitations was what I mentioned before, it was very inefficient, hard to share stuff, and so on. And it looked like this. This is a very not-so-detailed version of it, we'll go into detail in a second. But we have an NX monorepo, and then we have our microfrontends being exposed as federated modules, consumed by an application we call the frontend orchestrator, and that application renders stuff and sends it over to the client.

Let's talk about the first aspect of this, which is federation. In political terms, this thing is about provinces, you know, the most partly independent with a central government. In our world, in JavaScript, it is very similar. You have partially serve-governing or partially stand-alone things that can be consumed by a central controller. So we have two main aspects, right? We have the modules, which are exposed by a system, any system, and anything can be a module. And these are consumed by a host. And also modules can be hosts themselves. Now, if you look at this, you might ask yourself, well, what makes it different from a regular NPM install? You know, I also consume modules when I import a module from NPM, and it's a very small thing, but it is also very big. Which is that the consumption of the modules happens at runtime. So the host doesn't need to know what the module is when it's being built, it only needs to know where it lives. And then it'll fetch it and consume it at runtime. And this allows us to do something that's very powerful, which is separate module releases from a release or a rebuild of the main host. When we're talking about micro frontends and wanting to keep independency, well, this is a must.

Okay, so that's very fun. You know, you have hosts, you have modules. Modules can be hosts, but you still need something central to consume them, which is why we need a central but lean controller. The word lean has a bit of accent on it because, well, we really want the frontend orchestrator, which is how we call our central controller, to be really dumb. You know, we wanted to do two things. One of those two things is it needs to be a router so it can map URLs to modules.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Scaling Up with Remix and Micro Frontends
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Scaling Up with Remix and Micro Frontends
Top Content
This talk discusses the usage of Microfrontends in Remix and introduces the Tiny Frontend library. Kazoo, a used car buying platform, follows a domain-driven design approach and encountered issues with granular slicing. Tiny Frontend aims to solve the slicing problem and promotes type safety and compatibility of shared dependencies. The speaker demonstrates how Tiny Frontend works with server-side rendering and how Remix can consume and update components without redeploying the app. The talk also explores the usage of micro frontends and the future support for Webpack Module Federation in Remix.
Levelling up Monorepos with npm Workspaces
DevOps.js Conf 2022DevOps.js Conf 2022
33 min
Levelling up Monorepos with npm Workspaces
Top Content
NPM workspaces help manage multiple nested packages within a single top-level package, improving since the release of NPM CLI 7.0. You can easily add dependencies to workspaces and handle duplications. Running scripts and orchestration in a monorepo is made easier with NPM workspaces. The npm pkg command is useful for setting and retrieving keys and values from package.json files. NPM workspaces offer benefits compared to Lerna and future plans include better workspace linking and adding missing features.
Full Stack Components
Remix Conf Europe 2022Remix Conf Europe 2022
37 min
Full Stack Components
Top Content
RemixConf EU discussed full stack components and their benefits, such as marrying the backend and UI in the same file. The talk demonstrated the implementation of a combo box with search functionality using Remix and the Downshift library. It also highlighted the ease of creating resource routes in Remix and the importance of code organization and maintainability in full stack components. The speaker expressed gratitude towards the audience and discussed the future of Remix, including its acquisition by Shopify and the potential for collaboration with Hydrogen.
Understanding React’s Fiber Architecture
React Advanced Conference 2022React Advanced Conference 2022
29 min
Understanding React’s Fiber Architecture
Top Content
This Talk explores React's internal jargon, specifically fiber, which is an internal unit of work for rendering and committing. Fibers facilitate efficient updates to elements and play a crucial role in the reconciliation process. The work loop, complete work, and commit phase are essential steps in the rendering process. Understanding React's internals can help with optimizing code and pull request reviews. React 18 introduces the work loop sync and async functions for concurrent features and prioritization. Fiber brings benefits like async rendering and the ability to discard work-in-progress trees, improving user experience.
A Framework for Managing Technical Debt
TechLead Conference 2023TechLead Conference 2023
35 min
A Framework for Managing Technical Debt
Top Content
Today's Talk discusses the importance of managing technical debt through refactoring practices, prioritization, and planning. Successful refactoring requires establishing guidelines, maintaining an inventory, and implementing a process. Celebrating success and ensuring resilience are key to building a strong refactoring culture. Visibility, support, and transparent communication are crucial for addressing technical debt effectively. The team's responsibilities, operating style, and availability should be transparent to product managers.
Debugging JS
React Summit 2023React Summit 2023
24 min
Debugging JS
Top Content
Watch video: Debugging JS
Debugging JavaScript is a crucial skill that is often overlooked in the industry. It is important to understand the problem, reproduce the issue, and identify the root cause. Having a variety of debugging tools and techniques, such as console methods and graphical debuggers, is beneficial. Replay is a time-traveling debugger for JavaScript that allows users to record and inspect bugs. It works with Redux, plain React, and even minified code with the help of source maps.

Workshops on related topic

AI on Demand: Serverless AI
DevOps.js Conf 2024DevOps.js Conf 2024
163 min
AI on Demand: Serverless AI
Top Content
Featured WorkshopFree
Nathan Disidore
Nathan Disidore
In this workshop, we discuss the merits of serverless architecture and how it can be applied to the AI space. We'll explore options around building serverless RAG applications for a more lambda-esque approach to AI. Next, we'll get hands on and build a sample CRUD app that allows you to store information and query it using an LLM with Workers AI, Vectorize, D1, and Cloudflare Workers.
React at Scale with Nx
React Summit 2023React Summit 2023
145 min
React at Scale with Nx
Top Content
Featured WorkshopFree
Isaac Mann
Isaac Mann
We're going to be using Nx and some its plugins to accelerate the development of this app.
Some of the things you'll learn:- Generating a pristine Nx workspace- Generating frontend React apps and backend APIs inside your workspace, with pre-configured proxies- Creating shared libs for re-using code- Generating new routed components with all the routes pre-configured by Nx and ready to go- How to organize code in a monorepo- Easily move libs around your folder structure- Creating Storybook stories and e2e Cypress tests for your components
Table of contents: - Lab 1 - Generate an empty workspace- Lab 2 - Generate a React app- Lab 3 - Executors- Lab 3.1 - Migrations- Lab 4 - Generate a component lib- Lab 5 - Generate a utility lib- Lab 6 - Generate a route lib- Lab 7 - Add an Express API- Lab 8 - Displaying a full game in the routed game-detail component- Lab 9 - Generate a type lib that the API and frontend can share- Lab 10 - Generate Storybook stories for the shared ui component- Lab 11 - E2E test the shared component
Build Modern Applications Using GraphQL and Javascript
Node Congress 2024Node Congress 2024
152 min
Build Modern Applications Using GraphQL and Javascript
Featured Workshop
Emanuel Scirlet
Miguel Henriques
2 authors
Come and learn how you can supercharge your modern and secure applications using GraphQL and Javascript. In this workshop we will build a GraphQL API and we will demonstrate the benefits of the query language for APIs and what use cases that are fit for it. Basic Javascript knowledge required.
Node Monorepos with Nx
Node Congress 2023Node Congress 2023
160 min
Node Monorepos with Nx
Top Content
WorkshopFree
Isaac Mann
Isaac Mann
Multiple apis and multiple teams all in the same repository can cause a lot of headaches, but Nx has you covered. Learn to share code, maintain configuration files and coordinate changes in a monorepo that can scale as large as your organisation does. Nx allows you to bring structure to a repository with hundreds of contributors and eliminates the CI slowdowns that typically occur as the codebase grows.
Table of contents:- Lab 1 - Generate an empty workspace- Lab 2 - Generate a node api- Lab 3 - Executors- Lab 4 - Migrations- Lab 5 - Generate an auth library- Lab 6 - Generate a database library- Lab 7 - Add a node cli- Lab 8 - Module boundaries- Lab 9 - Plugins and Generators - Intro- Lab 10 - Plugins and Generators - Modifying files- Lab 11 - Setting up CI- Lab 12 - Distributed caching
Building a Shopify App with React & Node
React Summit Remote Edition 2021React Summit Remote Edition 2021
87 min
Building a Shopify App with React & Node
Top Content
WorkshopFree
Jennifer Gray
Hanna Chen
2 authors
Shopify merchants have a diverse set of needs, and developers have a unique opportunity to meet those needs building apps. Building an app can be tough work but Shopify has created a set of tools and resources to help you build out a seamless app experience as quickly as possible. Get hands on experience building an embedded Shopify app using the Shopify App CLI, Polaris and Shopify App Bridge.We’ll show you how to create an app that accesses information from a development store and can run in your local environment.
Micro Frontends with Module Federation and React
JSNation Live 2021JSNation Live 2021
113 min
Micro Frontends with Module Federation and React
Workshop
Alex Lobera
Alex Lobera
Did you ever work in a monolithic Next.js app? I did and scaling a large React app so that many teams can work simultaneously is not easy. With micro frontends you can break up a frontend monolith into smaller pieces so that each team can build and deploy independently. In this workshop you'll learn how to build large React apps that scale using micro frontends.