# amadeusitgroup/microfrontends architecture

> Architecture diagram of the GitHub repository amadeusitgroup/microfrontends, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amadeusitgroup/microfrontends
- Repository: https://github.com/amadeusitgroup/microfrontends

## Overview

##### Project type and purpose
- This is a toolset for building micro-frontend applications.
- It consists of:
- A core JavaScript library (packages/core) that handles message‐based communication between host and micro-frontends.
- An Angular integration package (packages/angular) that provides Angular services/components to wire micro-frontends into an Angular host.
- End-to-end test cases (packages/core-e2e) that spin up host and child iframes to validate your messaging/handshake logic.
- A demo application (demos/app-angular) that shows how to wire everything together in an Angular shell.

##### File structure
- Top-level directories:
- packages/core – the core runtime library (emitter, endpoint, peer, message-channel, utils).
- packages/angular – an Angular wrapper that registers a MessagePeerService, provides Angular components, types, and public API.
- packages/core-e2e – Playwright- and HTML-based test scenarios simulating iframe handshake and connection switching.
- demos/app-angular – a sample Angular shell consuming both host and client micro-frontends via the core and Angular packages.
- scripts – build orchestration (prepare-packages.js).
- GitHub workflows, linting, commit hooks, changelog, contribution docs.

##### README insights
- The README confirms this repo publishes two NPM packages: the core library and the Angular integration.
- It points to individual package READMEs for usage details.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Messaging Library
    subgraph "Core Messaging Library"
        direction TB
        CoreLibDir["packages/core/src"]:::coreLib
        Emitter["Emitter"]:::coreLib
        Endpoint["Endpoint"]:::coreLib
        Peer["Peer"]:::coreLib
        LocalChannel["LocalMessageChannel"]:::coreLib
        Message["Message"]:::coreLib
        MessageError["MessageError"]:::coreLib
        Utils["Utils"]:::coreLib
        RollupConfig["rollup.config.js"]:::infra
    end

    %% Angular Integration Layer
    subgraph "Angular Integration Layer"
        direction TB
        AngularDir["packages/angular/lib/src"]:::angularAdapter
        MessagePeerService["MessagePeerService"]:::angularAdapter
        PublicAPI["public-api.ts"]:::angularAdapter
        NgPackage["ng-package.json"]:::infra
        AngularJsonPkg["angular.json"]:::infra
    end

    %% Demo Host Application
    subgraph "Demo Host Application"
        direction TB
        DemoDir["demos/app-angular/src/app"]:::ui
        HostComponent["host.component.ts"]:::ui
        ClientCoreComponent["client-core.component.ts"]:::ui
        ClientAngularComponent["client-angular.component.ts"]:::ui
        OneComponent["one.component.ts"]:::ui
        MessagingService["messaging.service.ts"]:::ui
        MessagesFile["messages.ts"]:::ui
        AppConfig["app.config.ts"]:::ui
        AppRoutes["app.routes.ts"]:::ui
        MainEntry["main.ts"]:::ui
        DemoAngularJson["angular.json"]:::infra
    end

    %% End-to-End Test Harness
    subgraph "End-to-End Test Harness"
        direction TB
        CoreE2EDir["packages/core-e2e"]:::testHarness
        HandshakeHTML["cases/handshake/*.html"]:::testHarness
        SwitchHTML["cases/switch-connection/*.html"]:::testHarness
        HandshakeSpec["handshake.spec.ts"]:::testHarness
        SwitchSpec["switch-connection.spec.ts"]:::testHarness
        PlaywrightConfig["playwright.config.ts"]:::testHarness
    end

    %% Build & CI
    subgraph "Build & CI"
        direction TB
        PrepareScript["prepare-packages.js"]:::infra
        CIWorkflow[".github/workflows/ci.yml"]:::infra
    end

    %% Communication Flow
    HostComponent -->|"injects"| MessagePeerService
    MessagePeerService -->|"uses"| Peer
    Peer -->|"creates"| Endpoint
    Endpoint <-->|"postMessage handshake & messaging"| Endpoint
    ClientCoreComponent -->|"uses"| Peer
    ClientAngularComponent -->|"injects"| MessagePeerService

    %% Module Dependencies
    AngularDir -->|imports| CoreLibDir
    DemoDir -->|imports| AngularDir
    DemoDir -->|imports| CoreLibDir

    %% Click Events for Core Library
    click CoreLibDir "https://github.com/amadeusitgroup/microfrontends/tree/main/packages/core/src"
    click Emitter "https://github.com/amadeusitgroup/microfrontends/blob/main/packages/core/src/emitter.ts"
    click Endpoint "https://github.com/amadeusitgroup/microfrontends/blob/main/packages/core/src/endpoint.ts"
    click Peer "https://github.com/amadeusitgroup/microfrontends/blob/main/packages/core/src/peer.ts"
    click LocalChannel "https://github.com/amadeusitgroup/microfrontends/blob/main/packages/core/src/local-message-channel.ts"
    click Message "https://github.com/amadeusitgroup/microfrontends/blob/main/packages/core/src/message.ts"
    click MessageError "https://github.com/amadeusitgroup/microfrontends/blob/main/packages/core/src/message-error.ts"
    click Utils "https://github.com/amadeusitgroup/microfrontends/blob/main/packages/core/src/utils.ts"
    click RollupConfig "https://github.com/amadeusitgroup/microfrontends/blob/main/packages/core/rollup.config.js"

    %% Click Events for Angular Integration
    click AngularDir "https://github.com/amadeusitgroup/microfrontends/tree/main/packages/angular/lib/src"
    click MessagePeerService "https://github.com/amadeusitgroup/microfrontends/blob/main/packages/angular/lib/src/message-peer.service.ts"
    click PublicAPI "https://github.com/amadeusitgroup/microfrontends/blob/main/packages/angular/lib/src/public-api.ts"
    click NgPackage "https://github.com/amadeusitgroup/microfrontends/blob/main/packages/angular/lib/ng-package.json"
    click AngularJsonPkg "https://github.com/amadeusitgroup/microfrontends/blob/main/packages/angular/angular.json"

    %% Click Events for E2E Test Harness
    click CoreE2EDir "https://github.com/amadeusitgroup/microfrontends/tree/main/packages/core-e2e"
    click HandshakeHTML "https://github.com/amadeusitgroup/microfrontends/blob/main/packages/core-e2e/cases/handshake/*.html"
    click SwitchHTML "https://github.com/amadeusitgroup/microfrontends/blob/main/packages/core-e2e/cases/switch-connection/*.html"
    click HandshakeSpec "https://github.com/amadeusitgroup/microfrontends/blob/main/packages/core-e2e/tests/handshake.spec.ts"
    click SwitchSpec "https://github.com/amadeusitgroup/microfrontends/blob/main/packages/core-e2e/tests/switch-connection.spec.ts"
    click PlaywrightConfig "https://github.com/amadeusitgroup/microfrontends/blob/main/packages/core-e2e/playwright.config.ts"

    %% Click Events for Demo App
    click DemoDir "https://github.com/amadeusitgroup/microfrontends/tree/main/demos/app-angular/src/app"
    click HostComponent "https://github.com/amadeusitgroup/microfrontends/blob/main/demos/app-angular/src/app/host.component.ts"
    click ClientCoreComponent "https://github.com/amadeusitgroup/microfrontends/blob/main/demos/app-angular/src/app/client-core.component.ts"
    click ClientAngularComponent "https://github.com/amadeusitgroup/microfrontends/blob/main/demos/app-angular/src/app/client-angular.component.ts"
    click OneComponent "https://github.com/amadeusitgroup/microfrontends/blob/main/demos/app-angular/src/app/one.component.ts"
    click MessagingService "https://github.com/amadeusitgroup/microfrontends/blob/main/demos/app-angular/src/app/messaging.service.ts"
    click MessagesFile "https://github.com/amadeusitgroup/microfrontends/blob/main/demos/app-angular/src/app/messages.ts"
    click AppConfig "https://github.com/amadeusitgroup/microfrontends/blob/main/demos/app-angular/src/app/app.config.ts"
    click AppRoutes "https://github.com/amadeusitgroup/microfrontends/blob/main/demos/app-angular/src/app/app.routes.ts"
    click MainEntry "https://github.com/amadeusitgroup/microfrontends/blob/main/demos/app-angular/src/main.ts"
    click DemoAngularJson "https://github.com/amadeusitgroup/microfrontends/blob/main/demos/app-angular/angular.json"

    %% Click Events for Build & CI
    click PrepareScript "https://github.com/amadeusitgroup/microfrontends/blob/main/scripts/prepare-packages.js"
    click CIWorkflow "https://github.com/amadeusitgroup/microfrontends/blob/main/.github/workflows/ci.yml"

    %% Styles
    classDef coreLib fill:#add8e6,stroke:#333,stroke-width:1px
    classDef angularAdapter fill:#90ee90,stroke:#333,stroke-width:1px
    classDef ui fill:#ffa500,stroke:#333,stroke-width:1px
    classDef testHarness fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef infra fill:#f0e68c,stroke:#333,stroke-width:1px
```
