Micro-Frontends composition
This page defines how shells and MFEs are wired together with Module Federation: how remotes are registered and loaded, which dependencies are shared and how, how sub-shells nest, and how remote assets are resolved across environments. It turns the architecture directives into concrete composition structure. The checked-in configuration is documented in implementation.
Shells, remotes, and sub-shells
| Role | Module Federation shape | ION examples |
|---|---|---|
| Shell (host) | Declares shared singletons; no exposes; loads remotes at runtime | alya_shell, bondi_shell |
| Remote (provider) | Declares exposes; built and deployed independently | mfe_service_management, mfe_customers, mfe_iwkb, mfe_ion_iq_*, bondi_core |
| Sub-shell (provider and host) | exposes its own surfaces and registers/loads other remotes | mfe_incidents_management |
A sub-shell is the composition primitive for naturally nested domains. The
Incidents MFE exposes ./App to the Alya shell and also consumes the Investigation
cards (mfe_iwkb/*) and ION IQ surfaces (mfe_ion_iq_*). The Alya shell delegates
the entire incident journey — including investigation — to Incidents and never loads
Investigation directly. This keeps the incident ↔ investigation contract owned by the
teams that share it, not the platform shell.
Runtime registration and loading
Remotes are not hard-coded into a shell’s build. They are registered at runtime from environment configuration, so the same build runs against any environment:
- A runtime config object (
window.RUNTIME_CONFIG) lists the remotes — each with a name, alias, and per-ingress entry origin. - On startup the shell maps that list into Module Federation remote descriptors
pointing at each remote’s
mf-manifest.json, and callsregisterRemotes(...). - When a route resolves to a remote, the shell lazily calls
loadRemote(...)and renders the exposed component inside an error boundary.
Sub-shells use the same registration mechanism as shells: the Incidents MFE runs
its own registerRemotes(...) for the Investigation and ION IQ remotes it consumes.
How the shell chooses a remote’s entry origin per ingress (Front Door vs Application Gateway) and how each remote resolves its own asset origin is documented in routing and ingress.
Shared dependencies
Sharing is what makes composition coherent: shell and remotes must agree on a single instance of each framework and context provider. ION’s rules:
- Shared as singletons (shell + every remote):
react,react-dom,react-router,@azure/msal-react,@azure/msal-browser,@mui/material,@emotion/react,@mui/x-date-pickers-pro,notistack,@tanstack/react-query,@tanstack/query-broadcast-client-experimental,@fe-ws/mfe-utils, and the Application Insights packages. A single instance guarantees hooks, theme/cache, auth context, and the query client resolve identically across boundaries. - The shell shares eagerly; remotes share non-eagerly for heavy UI libs. The
shell loads first, so it can afford eager singletons. Remotes keep
@mui/materialand@mui/x-date-pickers-pronon-eager so theirremoteEntry/manifest stays small and they reuse the host’s already-loaded copy rather than bundling their own. - Deliberately NOT shared:
@emotion/styled(a stateless factory that breaks when federated) and@mui/icons-material(a ~4 MB barrel that cannot be tree-shaken when shared — deep imports per icon are used instead). - Share strategy
loaded-first. Both shells and sub-shells resolve shared singletons against remotes only as those remotes are actually loaded, instead of eagerly querying every registered remote’s manifest at boot. This avoids a flood of startup requests and is required for sub-shells that register many remotes.
Rationale for each inclusion/exclusion is grounded in the actual configs in implementation; the directive is: share what must be one instance (runtime + context), bundle what must stay tree-shakeable or stateless.
Provider / consumer context boundaries
| Provider | Hosted by | Consumed by MFEs |
|---|---|---|
| Theme (MUI), MSAL, Notifications (Notistack), Telemetry (App Insights) | Shell | Yes — reverse dependency, documented |
QueryClient / QueryClientProvider | Each MFE | No — kept local so one MFE cannot invalidate another’s cache |
| Error boundary | Shell wraps each remote; MFEs may add their own | — |
This split is a hard rule: cross-cutting providers belong to the shell, while query caching and error handling stay inside each MFE. A remote must never reach into a global provider to mutate another MFE’s state.
Cross-MFE communication
MFEs are self-contained and do not call each other directly. The sanctioned channels, in order of preference:
- URL / routes. Deep-linking via a shared route contract (e.g.
/incidents-management/incident/investigation/:selectedTicket). The target MFE’s own router extracts parameters. Routes are a stable, user-facing contract and changing one is a coordinated change. - Explicit sub-shell consumption. A parent MFE consumes named exposed components
from a child (Incidents consumes
mfe_iwkb/AssessmentCard, etc.). The contract is the set of exposed component names and their props. - Backend / events. Shared truth flows through each MFE’s BFF and the platform event backbone, never a shared browser store.
- Shared connection state. The shell’s single SignalR connection and its state
are shared through the
@fe-ws/signalrsingleton (useSignalR,useHubEvent). MFEs read it; they never open their own connection. See real-time (SignalR).
A runtime pub/sub event bus for business data is explicitly out of scope for V3.
Standalone mode
Every MFE must also run as a standalone application for local development and testing.
In standalone mode the MFE provides its own auth, routing, theme, and (if needed)
telemetry via an async bootstrap boundary, while in federated mode it consumes the
shell’s. The async import boundary is what lets the same build operate both ways.