High-traffic Bank of Georgia public site, 4 min read
Module Federation micro-frontends
Split a web-component SPA serving two product lines into a shell and two independently deployed remotes that share one copy of the framework runtime. Routes moved to their owning remote one content type at a time.
The problem
Bank of Georgia's public site served retail and business customers from one SPA: one repo, one build, one deploy queue. A retail change waited on business QA, and the bundle only grew. The goal was three independently deployed apps that still behave as one SPA on one origin.
The architecture
┌──────────────────── shell (host) ────────────────────┐
│ chrome: header · footer · router · search │
│ consumes: retail remote business remote │
│ exposes: shared component layer │
└───────────────┬───────────────────────┬──────────────┘
│ import() │ import()
┌────────┴─────────┐ ┌─────────┴──────────┐
│ retail (remote) │ │ business (remote) │
└────────┬─────────┘ └─────────┬──────────┘
└────── import map ─────┘
▼
framework runtime + the design-system packages
resolved from CDN — one copy, shared by all threeKey decisions
Why Module Federation
The design system is built on custom elements, and the browser keeps one registry per window, so a second copy of the framework collides with the first. That ruled out any model that duplicates the runtime. Federation can emit real ES modules, so remotes load through the browser's native import() with no custom loader.
One shared runtime
The framework and design-system packages are externals, resolved by one import map to version-pinned CDN URLs. The details are in the design system case study.
Routes owned by each remote
Pages are keyed by CMS content type, and each remote exposes its own map of content types to lazily imported pages. The shell shipped first, wrapping the monolith's existing pages, and then routes moved to their owning remote one at a time, each with its own revert.
When a remote fails to load
The shell loads every remote through one function. A failed import is retried once with a cache-busting query, because browsers remember a module URL that failed. If the retry fails too, the header, footer and search keep working, the remote's slot shows a fallback page with a reload action, and the error is reported with the remote's name.
async function loadRemote(name) {
const url = REMOTES[name];
try {
return await import(/* webpackIgnore: true */ url);
} catch {
try {
// Browsers cache a failed module URL, so bust it
return await import(/* webpackIgnore: true */ url + "?retry=1");
} catch (error) {
report(error, { remote: name });
return { default: RemoteUnavailable };
}
}
}Deploys out of step
Each app deploys on its own, so the shell and a remote are briefly out of step. remoteEntry.js is served with no-cache and every chunk is content-hashed and cached for a year, so a new entry never points at a chunk that doesn't exist. Old chunks stay on the server for two releases, so a tab opened before a deploy keeps working. The shell and remotes talk through a small, versioned contract of properties and DOM events.
Running it locally
Each remote's URL comes from an environment variable, so a developer runs the shell and the one remote they're changing, and points the other at the test environment. The import map loads the shared runtime from the CDN everywhere, so local runs use the same copy as production.
npm run dev -w retail # http://localhost:4001
REMOTE_RETAIL=http://localhost:4001/remoteEntry.js \
REMOTE_BUSINESS=https://test.example.com/business/remoteEntry.js \
npm run dev -w shell # http://localhost:4000Impact
| Period | Month 1 | Month 2 | Month 3 | Average |
|---|---|---|---|---|
| Monolith · Sep–Nov | 6 | 5 | 7 | 6 |
| Separate apps · Feb–Apr | 9 | 10 | 11 | 10 |
MeasuredSuccessful production deploy jobs per month in GitLab's environment history for all three apps, hotfixes excluded. December and January, the cutover months, are left out.
- Releases rose from about 6 to about 10 per month, comparing the last three months of the monolith with the first three months of the separate apps, counted over working sprints.
MeasuredSuccessful production deploy jobs in GitLab's environment history, both teams combined, hotfixes excluded.
- Retail and business each have their own team and ship on their own cadence. The shared app holds libraries, utilities and components, so it is deployed rarely.
- Release conflicts between the two teams ended, and neither team waits on the other's QA.
Trade-offs
What it cost
- Three pipelines and three sets of environment config to maintain, plus one import map that every app depends on, so changes to it are made with all three apps in mind.
- A change that crosses apps, such as a header feature a remote must react to, now needs coordinated releases through the versioned contract.
- Debugging spans repos: a bug on a remote's page can come from the shell's router or the shared runtime.
What I’d change
- Add contract tests between the shell and each remote from the start. We added them after a renamed event broke business pages on test.
- Track remote load failures per release from day one.
Connected work
These case studies are parts of one platform. This one connects to: