MFE UI Interaction
Source references:
Event Sourcing- MFE UI Interaction Design Pattern.md;
Micro Frontends.md;
MFE Patterns.md;
MFE- Authentication & Authorisation Patterns.md;
Planned MFE Architecture for Incidents and Investigation in Alya FE.md.
Problem
ION V3 composes user experiences from independently deliverable
Micro-Frontends (see ADR-0023).
This introduces UI-composition problems the single-app pattern in
ui-interaction.md does not answer:
- If every MFE opens its own SignalR connection, Azure SignalR concurrent connection quotas explode (≥ N MFEs × M users) and reconnection storms amplify.
- If the Shell owns all message routing, it becomes a Single Point of Failure — a crash in the Shell freezes real-time updates for every MFE.
- MFEs must not couple to each other (independent delivery is the whole point), yet they must cooperate on shared cross-cutting concerns: auth token, capabilities, theme, notifications, connection lifecycle.
- MFEs are composed across multiple shells (Alya, Veritas) with different user personas — a single hard-wired assumption breaks reuse.
Solution
Shell owns cross-cutting concerns and the SignalR connection lifecycle only. MFEs own their business subscriptions, data, state, and side effects.
Composition topology
┌───────────────── Shell (Alya | Veritas) ────────────────────┐
│ Auth (MSAL) · Capabilities · Theme · Notifications · Router│
│ ┌────────────────────────────────────────────────┐ │
│ │ SignalRProvider (@fe-ws/signalr, MF singleton) │ │
│ │ single connection · { connection, isConnected } │ │
│ └───────────────────────┬────────────────────────┘ │
└────────────────────────────────┼───────────────────────────┘
│ useSignalR · useHubEvent
┌─────────────────┼──────────────────────┐
▼ ▼ ▼
┌────────────┐ ┌─────────────┐ ┌────────────┐
│ Incidents │◀───│Investigation│ │ Service │
│ MFE │sub-│ MFE │ │ Requests │
│ │shell│ │ │ MFE │
└────────────┘ └─────────────┘ └────────────┘
│ own BFF │ own BFF │ own BFF
▼ ▼ ▼
BFF/APIM ───────── subscribe via APIM assgr-int ──────▶ Shell SignalR BFF
Core rules:
- One SignalR connection per authenticated browser session. Shell
creates it after MSAL login by calling the Shell SignalR BFF
negotiate endpoint (the BFF validates the Entra token and returns a
SignalR client token bound to the user’s
oid). - Shell owns the connection, not the business. The connection and
its state are shared through the
@fe-ws/signalrModule Federation singleton (useSignalR,useHubEvent). The shell never subscribes to entities, never parses business payloads, and never invokes MFE methods directly. - MFEs subscribe via their own BFF. Once a connection exists, each
MFE calls its own BFF (for example
POST /api/subscriptions/investigation/{id}). The BFF authorizes the user for the entity, then asks the Shell SignalR BFF to add the user to the group{entity_name}-{entity_id}. Group membership is backend-controlled — never asserted from the client. - MFEs re-register on a new connection. When the connection ID changes, each MFE re-subscribes and issues a REST catch-up call to fill the gap. Delivery to the browser is at most once.
- Capability header propagation. Shell holds the JWT and capability token (see Auth / AuthZ); MFEs attach both to every BFF call, including the subscription call.
- Cross-MFE communication only via URL, events, or backend. Direct
imports across MFEs are forbidden. Deep-linking via routes is the
normal composition primitive (Incidents MFE hosts Investigation MFE
as a sub-shell for
/incidents-management/incident/investigation/:id). - Shared context providers stay in Shell. Theme, MSAL, Notifications, Telemetry, and the SignalR connection — provided by Shell. Local providers stay in MFE — React Query client, error boundaries, feature-flag scope. This prevents one MFE from invalidating queries in another.
- Timeout fallback. If the connection is not established, or stays down, for longer than N seconds, the MFE downgrades to REST polling with the same catch-up endpoint. (Directive; not yet implemented — see the V3 real-time gaps.)
When to use
- Use for any Shell composing multiple MFEs (Alya, Veritas today; future portal shells).
- Use the sub-shell pattern (MFE composes another MFE) when domains are naturally nested — e.g. Investigation surfaces are entered via Incident context (see referenced Alya plan).
- Do not open a second SignalR connection from an MFE — always ride
the Shell’s connection through
@fe-ws/signalr. - Do not send client-to-hub messages (
useHubSend). The hub is Serverless with no upstream; commands go over REST to the MFE’s BFF. - Do not route business messages through the Shell — the Shell shares the connection only.
- Do not put role/persona branching inside MFEs — use the capability contract (see Auth / AuthZ).
Consequences
Positive
- Connection count is bounded (1 per session) regardless of MFE count.
- Shell is small and stable — reduces SPOF surface to lifecycle only.
- MFEs are independently deployable and testable; a broken MFE cannot bring down its neighbours (error boundaries at the Shell).
- Same MFE runs across multiple shells (Alya + Veritas) with different personas without code changes — capability contract absorbs the difference.
Negative
- Requires disciplined ownership: Shell team and MFE teams must agree on the lifecycle contract and BFF subscription convention.
- Debugging real-time issues spans Shell (connection) + MFE (subscription)
- BFF (group management) — three logs to correlate.
- Module Federation runtime (
rsbuild) adds build-time complexity and a shared-deps discipline.
Failure modes
- Shell UI thread block — SignalR keep-alives may time out. Mitigation: keep Shell rendering minimal; consider WebWorker-hosted SignalR client for heavy Shells.
- MFE unmount leaks — MFEs that keep hub handlers or subscriptions
after unmount hold references to detached trees.
useHubEventunregisters its handler on unmount; MFEs must do the same for any handler they register directly. - Subscription drift after reconnect — MFE sees a new connection but forgets to re-subscribe. Catch-up REST call is mandatory as belt-and-braces.
- User-wide unsubscribe — group membership is per user, so an unsubscribe in one tab also stops events in the user’s other tabs. The catch-up rule limits the impact.
- Capability mismatch across shells — same MFE + different Shell
yields different visible actions; validate via capability contract in
BFF, not by inspecting
Shellname in FE code.
References
- ADRs: ADR-0023 MFE UI architecture; ADR-0009 API contracts (REST + JSON:API); ADR-0012 Identity; ADR-0013 AuthN/AuthZ.
- Patterns: UI Interaction; Auth / AuthZ; Async REST; Notifications.
- WA:
well-architected/performance-efficiency/ui-responsiveness/;well-architected/reliability/graceful-degradation/.
Applied in
- Alya Shell — hosts Incidents MFE (which sub-shells Investigation MFE), Service Requests MFE, Automation Workbench MFE. The Shell SignalR BFF realizes this pattern; see the V3 real-time design.
- Veritas — customer & advisor portal shells compose overlapping MFE set with public-persona capability scope.
- Pigeon — adaptive-card UI in Teams reuses the same subscription contract via its bot-side BFF (no browser SignalR, but the group model is identical).