Skip to content

Micro-Frontends Architecture Diagram: Composition Patterns and Trade-offs

How micro-frontends are composed on the server, at the edge or in the browser: app shells, import maps, Module Federation, team contracts and the real costs.

· Founder & developer

Published

Architecture diagram: inside one browser page, an app shell routes URLs to the Catalog, Checkout and Account micro-frontends, loaded from a CDN. Each calls its own BFF and service, and a dashed event runs from Catalog to Checkout.

Your web app is one repository and one deployment, and five teams work in it. Every release waits for the slowest team's tests, and a framework upgrade needs everyone's agreement. Micro-frontends split that application the way microservices split a backend: by business area, so each team ships its part on its own schedule.

This post covers where the parts are put back together, how import maps and Module Federation share code, the contracts between teams and the costs, with a micro-frontends architecture diagram you can copy.

What a micro-frontend is, and when it pays off

Cam Jackson's Micro Frontends article on martinfowler.com (2019) describes the style as independently deliverable frontend applications composed into a greater whole. Michael Geers' micro-frontends.org adds the team model: each team is cross-functional, owns one business area and builds its features end to end, from the database to the user interface.

The unit is a business capability such as catalog or checkout, not a technical layer: a "header team" that everyone depends on brings back the coordination you wanted to remove.

Signal Micro-frontends help Probably not worth it
Teams on the frontend Several, each with a clear business area One or two
Releases Teams wait for each other to ship Already independent enough
Technology A gradual migration, or more than one stack One stack, no migration planned
Operations Automated pipeline and monitoring per team Manual deploys, one shared environment

Where the parts are composed

The main decision is where the parts meet. There are four places, and real systems often combine two.

Where Mechanism Deploys independently Main cost
Build time Each part is a package that a container app depends on No Lockstep releases
Server The page server includes fragments, or a proxy sends URL paths to separate apps Yes The slowest fragment sets the response time
Edge A CDN assembles fragments with Edge Side Includes Yes Provider support and cache rules
Browser An app shell loads and mounts each part at runtime Yes Bundle size and runtime coupling

Build-time integration looks tidy: each team publishes an npm package and a container app imports them all. But every change needs a container release, so teams ship in lockstep again, and Jackson's article recommends strongly against it. Packages suit a design system, not features.

With server, edge or browser composition, you can split by route (one micro-frontend per page) or by component (several on one page). Route-level splits are simpler, so start there.

Server-side and edge composition

With server-side includes, the page is a template that names fragments by URL, and the web server replaces each include with the fragment's response:

<!--# include virtual="/fragments/header" -->
<main>
  <!--# include virtual="/fragments/product/42" -->
  <!--# include virtual="/fragments/recommendations/42" -->
</main>

Each team serves its own fragments. With nginx SSI, subrequests to proxied servers run in parallel unless you add wait="yes", but the page waits for all of them, so the slowest fragment sets the response time. Geers suggests loading slow fragments in the browser instead, with a skeleton so the layout does not shift.

Edge Side Includes, a 2001 W3C Note from Akamai, Oracle and others, moves this to the CDN. An esi:include names a fragment, an alt resource if it is missing, and onerror="continue" to drop it silently. Support varies by CDN.

Route-level composition needs no includes: a proxy sends each path to a separate app, as in Next.js Multi-Zones. Moving to another zone is a hard navigation that loads a new page, so pages visited together belong in one zone.

Client-side composition with an app shell

In the browser, a small app shell owns the document: it renders the layout, listens to the URL and mounts the matching micro-frontend. In single-spa, a root config registers each application with a name, a loading function and a rule for when it is active, and each application exports bootstrap, mount and unmount.

With a native import map, the bare names resolve to versioned files on a CDN:

<script type="importmap">
{
  "imports": {
    "single-spa": "/shared/single-spa/index.js",
    "@shop/catalog": "/catalog/2.4.1/app.js",
    "@shop/checkout": "/checkout/1.9.0/app.js",
    "@shop/account": "/account/3.0.2/app.js"
  }
}
</script>
<script type="module">
  import { registerApplication, start } from "single-spa";

  registerApplication({ name: "@shop/catalog", app: () => import("@shop/catalog"), activeWhen: ["/products"] });
  registerApplication({ name: "@shop/checkout", app: () => import("@shop/checkout"), activeWhen: ["/cart", "/checkout"] });
  registerApplication({ name: "@shop/account", app: () => import("@shop/account"), activeWhen: ["/account"] });
  start();
</script>

A Catalog release is an upload of /catalog/2.5.0/app.js plus a one-line change to the map; a rollback reverses it. Cache the versioned bundles forever and the map briefly, both in the browser and in CDN edge caches. To try a version on some users first, serve them a different map: a canary release, as in deployment strategies.

Sharing dependencies: import maps and Module Federation

Separately built micro-frontends each bundle their own framework copy unless you share it on purpose.

Import maps Module Federation
What it is An HTML standard, supported in all major browsers since March 2023 A bundler feature, added in webpack 5 (October 2020)
How code is found The browser maps bare names to URLs A host loads a remote's container entry, usually remoteEntry.js
Shared libraries Each library is mapped once, as an ES module you host shared modules go into a share scope that every build reads
Versions Whatever the map says The highest version that satisfies each consumer's range

Module Federation lets each build expose modules and load other builds' modules at runtime. The plugin docs point out that libraries with global internal state, such as react and react-dom, must run as one instance: mark them singleton with a requiredVersion, and strictVersion makes a mismatch a runtime error instead of a warning. Avoid eager, which downloads shared modules up front; use an entry file that only calls import("./bootstrap").

Either way, catch a failed import in the shell and render a fallback, so a broken Checkout bundle costs the cart, not the page.

Iframes and Web Components: how much isolation you get

Client-side composition shares one document by default; more isolation has a price.

Approach CSS isolation JavaScript isolation Price
Plain mount, mount(el, props) None: prefix classes or use CSS Modules None: one window Most flexible, needs discipline
Custom element with shadow DOM Page styles stop at the shadow root None: one window Popups rendered into document.body lose the styles
Iframe Complete A separate window, and origin if hosted elsewhere Routing, deep links, sizing, focus and accessibility across frames

Shadow DOM keeps page CSS out and component CSS in, but inherited properties and CSS custom properties still flow in, so design tokens work. Closed mode hides the shadow root from page scripts, though MDN notes it is not a strong security mechanism. Iframes talk through postMessage: name the target origin and check event.origin. They suit embedded legacy or third-party screens.

Contracts between micro-frontends

Teams stay independent only while the interfaces between their parts stay small and explicit.

Need Channel Example
Open another team's page The URL A link to /cart
Say that something happened A DOM event with a team prefix catalog:add-to-cart with { sku, qty }
Pass settings down Props or element attributes Locale, a token getter
Fetch data The team's own backend GET /bff/catalog/products/42
  • Mount API or custom element: a function taking an element and props, or a tag whose attributes and events Geers treats as the public API. In single-spa, the bootstrap, mount and unmount lifecycles play the same role.
  • No shared store: a global state object couples every release to its shape. The URL is the shared state.
  • Team prefixes on CSS classes, events, storage keys and cookies avoid collisions and show ownership.
  • Authentication in the shell: it signs the user in, for example with OpenID Connect, and passes a token getter, so refresh happens once.
  • A backend per frontend: each micro-frontend calls its team's backend for frontend (BFF), as in the API gateway diagram.

Test each part alone, then the composition; consumer-driven contracts check that events and props still match.

Styling, design system and performance

Global CSS is where micro-frontends collide first: two teams style h2 differently and the last stylesheet wins. Pick one rule, such as team prefixes, CSS Modules or shadow DOM, and put colors, spacing and type in design tokens as CSS custom properties.

Jackson's advice for a shared component library: extract it late, keep domain logic out and give it a custodian who reviews contributions. Because each team upgrades on its own schedule, expect two button versions in production for a while.

Measure the composed page, not each part: separate bundles can each ship the same framework, and sharing it adds coupling. Set a JavaScript budget per team and test regularly where all parts run together, because a part that works alone can break under another team's styles.

The rest is operational cost: more repositories, pipelines and dashboards. A single frontend with clear folder ownership is a valid alternative.

The micro-frontends architecture diagram

Architecture diagram: inside one browser page, an app shell routes URLs to the Catalog, Checkout and Account micro-frontends, loaded from a CDN. Each calls its own BFF and service, and a dashed event runs from Catalog to Checkout.

18 components · 13 connections

Open in Archboard
Diagram contents
  • Browser: one page, one URL
  • App shell
  • Catalog MFE
  • Checkout MFE
  • Account MFE
  • Shopper
  • CDN
  • Identity provider
  • Catalog BFF
  • Checkout BFF
  • Account BFF
  • Catalog service
  • Orders service
  • Customer service
  • opens /products/42
  • HTML, import map, bundles
  • OIDC sign-in
  • /products/*
  • /cart, /checkout/*
  • /account/*
  • catalog:add-to-cart
  • HTTPS + token
An online shop split into three micro-frontends. The app shell routes URLs to Catalog, Checkout and Account, loaded from a CDN through an import map. Each team also owns a BFF and a service.

How to read it:

  • The frame is one browser page. The gray app shell at its top belongs to the platform team.
  • Colored columns are teams: green Catalog, blue Checkout and pink Account each own a micro-frontend, a BFF and a service, shipped through their own pipeline.
  • Route labels show which URL prefix mounts which micro-frontend, so /products/42 activates Catalog.
  • On the left, the CDN serves the HTML, import map and versioned bundles.
  • The orange dashed edge is the only link between micro-frontends: a DOM event with a team prefix.
  • The Markdown block lists the contract, shared libraries, deploys and isolation rules.

Drawing micro-frontend diagrams clearly

  • Show ownership first: one color or lane per team, since ownership is the reason for the architecture.
  • Show where composition happens: a frame for the browser page, or the server or CDN node that assembles fragments.
  • Label routes on the shell's edges and name events between parts.
  • Draw contracts, not internals: mount API, event names and shared libraries with versions; not the components inside a part.
  • Keep runtime and delivery apart: pipelines and CDN paths go in a second view. The container level of the C4 model fits the runtime view.

Common mistakes are splitting by technical layer, direct imports between micro-frontends, a shared global store, a shell with no owner and parts that all call one monolith API. To carve micro-frontends out of an existing app, use the strangler fig pattern; the backend side of a similar online store is in the five-service microservices example.

Build it in Archboard

  1. Sign in with Google or GitHub and create a diagram.
  2. Add a Core Frame named "Browser: one page, one URL".
  3. From the C4 Model pack, add a Container across the top of the frame for the app shell, and three Container nodes below it for the Catalog, Checkout and Account micro-frontends.
  4. Outside the frame, add a C4 Model Person for the shopper, a CDN from the Cloud pack and an Identity Provider from the Security pack.
  5. Below the frame, add six more Container nodes, a BFF and a service under each micro-frontend, and give each team one accent color.
  6. Connect the shell to each micro-frontend and label each edge with its URL prefix. Draw the add-to-cart event as an orange dashed edge, and connect each micro-frontend to its BFF and each BFF to its service. Connect the shopper to the shell, the CDN to the frame and the shell to the identity provider with a dashed OIDC sign-in edge.
  7. Add a Core Markdown block for the contract and deploy rules, and Core Text notes for ownership, the CDN and the event.

If your structure lives in a Mermaid flowchart, the Mermaid converter turns it into a first draft; the microservices architecture template covers the backend, and the C4 use case shows the rest of the pack. The example uses 15 diagram nodes, the most the Free plan allows in one diagram.

FAQ

What is a micro-frontend architecture? A frontend split by business area into parts that separate teams build, test and deploy on their own, then composed into one application on the server, at the edge or in the browser.

Do I need Module Federation for micro-frontends? No. It is one way to load separately deployed code and share libraries. Import maps, server-side includes, Web Components and iframes also work.

How should micro-frontends communicate? As little as possible: through the URL, DOM events with a team prefix, and props or attributes from the shell. A shared global store ties every release together again.

Do micro-frontends hurt performance? They can, because separately built bundles may each ship the same framework. Share large libraries once, give each team a size budget and measure the composed page.

When should I not use micro-frontends? When one or two teams own the whole frontend, releases are not a bottleneck, or teams lack their own automated pipelines. A modular single frontend is cheaper then.

Start free — one seat, no credit card.

Related posts

← Back to blog

Open a canvas in a minute

Sign in with Google or GitHub. Free for a single seat. Upgrade when the team joins.