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.
Comments