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.

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
Do you have a large product built by many teams? Are you struggling to release often? Did your frontend turn into a massive unmaintainable monolith? If, like me, you’ve answered yes to any of those questions, this talk is for you! I’ll show you exactly how you can build a micro frontend architecture with Remix to solve those challenges.
Levelling up Monorepos with npm Workspaces
DevOps.js Conf 2022DevOps.js Conf 2022
33 min
Levelling up Monorepos with npm Workspaces
Top Content
Learn more about how to leverage the default features of npm workspaces to help you manage your monorepo project while also checking out some of the new npm cli features.
Full Stack Components
Remix Conf Europe 2022Remix Conf Europe 2022
37 min
Full Stack Components
Top Content
Remix is a web framework that gives you the simple mental model of a Multi-Page App (MPA) but the power and capabilities of a Single-Page App (SPA). One of the big challenges of SPAs is network management resulting in a great deal of indirection and buggy code. This is especially noticeable in application state which Remix completely eliminates, but it's also an issue in individual components that communicate with a single-purpose backend endpoint (like a combobox search for example).
In this talk, Kent will demonstrate how Remix enables you to build complex UI components that are connected to a backend in the simplest and most powerful way you've ever seen. Leaving you time to chill with your family or whatever else you do for fun.
Understanding React’s Fiber Architecture
React Advanced Conference 2022React Advanced Conference 2022
29 min
Understanding React’s Fiber Architecture
Top Content
We've heard a lot about React's Fiber Architecture, but it feels like few of us understand it in depth (or have the time to). In this talk, Tejas will go over his best attempt at understanding Fiber (reviewed by other experts), and present it in an 'explain-like-I'm-five years old' way.
A Framework for Managing Technical Debt
TechLead Conference 2023TechLead Conference 2023
35 min
A Framework for Managing Technical Debt
Top Content
Let’s face it: technical debt is inevitable and rewriting your code every 6 months is not an option. Refactoring is a complex topic that doesn't have a one-size-fits-all solution. Frontend applications are particularly sensitive because of frequent requirements and user flows changes. New abstractions, updated patterns and cleaning up those old functions - it all sounds great on paper, but it often fails in practice: todos accumulate, tickets end up rotting in the backlog and legacy code crops up in every corner of your codebase. So a process of continuous refactoring is the only weapon you have against tech debt.In the past three years, I’ve been exploring different strategies and processes for refactoring code. In this talk I will describe the key components of a framework for tackling refactoring and I will share some of the learnings accumulated along the way. Hopefully, this will help you in your quest of improving the code quality of your codebases.

Debugging JS
React Summit 2023React Summit 2023
24 min
Debugging JS
Top Content
As developers, we spend much of our time debugging apps - often code we didn't even write. Sadly, few developers have ever been taught how to approach debugging - it's something most of us learn through painful experience.  The good news is you _can_ learn how to debug effectively, and there's several key techniques and tools you can use for debugging JS and React apps.

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
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.
Build a chat room with Appwrite and React
JSNation 2022JSNation 2022
41 min
Build a chat room with Appwrite and React
WorkshopFree
Wess Cope
Wess Cope
API's/Backends are difficult and we need websockets. You will be using VS Code as your editor, Parcel.js, Chakra-ui, React, React Icons, and Appwrite. By the end of this workshop, you will have the knowledge to build a real-time app using Appwrite and zero API development. Follow along and you'll have an awesome chat app to show off!