# adanyc/ng-micro-frontends-native-federation architecture

> Architecture diagram of the GitHub repository adanyc/ng-micro-frontends-native-federation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adanyc/ng-micro-frontends-native-federation
- Repository: https://github.com/adanyc/ng-micro-frontends-native-federation

## Overview

##### Project Type and Purpose
- This is a micro-frontends demo built with Angular and Webpack Native Federation. It contains three separate Angular applications in one repo:
a. Shell (the host/orchestrator)
b. Micro-Frontend “Mars” (remote)
c. Micro-Frontend “Venus” (remote)
- The Shell dynamically loads the Mars and Venus frontends at runtime via Webpack Module Federation.

##### File-Structure Analysis
- Top-level folders:
- ng-shell – the host application (“shell”)
- ng-mfe-mars – remote “Mars” application
- ng-mfe-venus – remote “Venus” application
- Each app has:
- angular.json, package.json, tsconfig.*.json
- federation.config.js – Webpack Module Federation settings
- src/ (standard Angular sources: bootstrap.ts, main.ts, app folder, index.html, styles.scss)
- Shell’s public/federation.manifest.json plus each remote’s federation.config.js define remoteEntry URLs and exposed modules.
- In src/app:
- app.routes.ts – defines host routes for loading remotes
- micro-frontend utilities (connect-router.ts, create-micro-frontend.ts)
- shell folder (in ng-shell) contains loader logic and location-strategy adaptations.

##### Key README Insights
- Shell orchestrates micro-frontends via native federation.
- Mars and Venus run standalone (for local dev) and as remotes when federated.
- Each app exposes a set of Angular components/views (atmosphere, volcanoes, planet view).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layer 1: Client/Browser
    subgraph "Client/Browser"
        Browser["Browser/Client"]:::infra
    end

    %% Layer 2: Shell App (Host)
    subgraph "Shell App (Host)" 
        direction TB
        FedeConfShell["federation.config.js"]:::shell
        ManifestShell["public/federation.manifest.json"]:::shell
        IndexShell["src/index.html"]:::shell
        BootstrapShell["src/bootstrap.ts"]:::shell
        MainShell["src/main.ts"]:::shell
        RoutesShell["src/app/app.routes.ts"]:::shell
        AppCompShell["src/app/app.component.ts/.html"]:::shell
        LoaderShell["src/app/shell/loader-micro-frontend.ts"]:::shell
        LocationShell["src/app/shell/location-strategy-micro-frontend.ts"]:::shell
        StartsWithShell["src/app/shell/starts-with.ts"]:::shell
        RouterShell["Angular Router"]:::shell
        MFPlugin["ModuleFederationPlugin"]:::shell
        UtilsShell["createMicroFrontend & connectRouter"]:::shell
    end

    %% Layer 3: Module Federation Loading Remotes
    subgraph "Module Federation"
        direction TB
        FetchMars["fetch remoteEntry.js (Mars)"]:::infra
        FetchVenus["fetch remoteEntry.js (Venus)"]:::infra
    end

    %% Layer 4: Remote Apps
    subgraph "RemoteApp Mars" 
        direction TB
        FedeConfMars["federation.config.js"]:::mars
        BootstrapMars["src/bootstrap.ts"]:::mars
        IndexMars["src/index.html"]:::mars
        MainMars["src/main.ts"]:::mars
        RoutesMars["src/app/app.routes.ts"]:::mars
        AppCompMars["src/app/app.component.ts/.html"]:::mars
        UtilsMars["create-micro-frontend & connect-router"]:::mars
        AtmosphereMars["atmosphere.component.ts/.html"]:::mars
        VolcanoesMars["volcanoes.component.ts/.html"]:::mars
    end

    subgraph "RemoteApp Venus"
        direction TB
        FedeConfVenus["federation.config.js"]:::venus
        BootstrapVenus["src/bootstrap.ts"]:::venus
        IndexVenus["src/index.html"]:::venus
        MainVenus["src/main.ts"]:::venus
        RoutesVenus["src/app/app.routes.ts"]:::venus
        AppCompVenus["src/app/app.component.ts/.html"]:::venus
        UtilsVenus["create-micro-frontend & connect-router"]:::venus
        AtmosphereVenus["atmosphere.component.ts/.html"]:::venus
        VolcanoesVenus["volcanoes.component.ts/.html"]:::venus
    end

    %% Infra Servers
    subgraph "Dev Servers / Static Hosts"
        direction TB
        ServerShell["ng-shell @ localhost:4200"]:::infra
        ServerMars["ng-mfe-mars @ localhost:4201"]:::infra
        ServerVenus["ng-mfe-venus @ localhost:4202"]:::infra
    end

    %% Connections
    Browser -->|loads index.html & main.js| ServerShell
    ServerShell --> IndexShell
    IndexShell --> BootstrapShell
    BootstrapShell --> MainShell
    MainShell --> RouterShell
    RouterShell -->|reads manifest| ManifestShell
    ManifestShell --> MFPlugin
    MFPlugin -->|knows endpoints| FetchMars
    MFPlugin -->|knows endpoints| FetchVenus

    FetchMars --> ServerMars
    FetchVenus --> ServerVenus

    ServerMars --> BootstrapMars
    ServerVenus --> BootstrapVenus

    BootstrapMars --> AppCompMars
    BootstrapMars --> RoutesMars
    RoutesMars --> AtmosphereMars
    RoutesMars --> VolcanoesMars

    BootstrapVenus --> AppCompVenus
    BootstrapVenus --> RoutesVenus
    RoutesVenus --> AtmosphereVenus
    RoutesVenus --> VolcanoesVenus

    %% Shell utilities integrate remotes
    UtilsShell --> FetchMars
    UtilsShell --> FetchVenus
    FetchMars -->|exposes Angular Modules| RouterShell
    FetchVenus -->|exposes Angular Modules| RouterShell

    %% Click Events for Shell
    click FedeConfShell "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-shell/federation.config.js"
    click ManifestShell "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-shell/public/federation.manifest.json"
    click IndexShell "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-shell/src/index.html"
    click BootstrapShell "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-shell/src/bootstrap.ts"
    click MainShell "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-shell/src/main.ts"
    click RoutesShell "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-shell/src/app/app.routes.ts"
    click AppCompShell "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-shell/src/app/app.component.ts"
    click LoaderShell "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-shell/src/app/shell/loader-micro-frontend.ts"
    click LocationShell "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-shell/src/app/shell/location-strategy-micro-frontend.ts"
    click StartsWithShell "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-shell/src/app/shell/starts-with.ts"

    %% Click Events for Mars
    click FedeConfMars "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-mars/federation.config.js"
    click BootstrapMars "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-mars/src/bootstrap.ts"
    click IndexMars "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-mars/src/index.html"
    click MainMars "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-mars/src/main.ts"
    click RoutesMars "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-mars/src/app/app.routes.ts"
    click AppCompMars "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-mars/src/app/app.component.ts"
    click UtilsMars "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-mars/src/app/micro-frontend/create-micro-frontend.ts"
    click UtilsMars "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-mars/src/app/micro-frontend/connect-router.ts"
    click AtmosphereMars "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-mars/src/app/views/atmosphere/atmosphere.component.ts"
    click VolcanoesMars "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-mars/src/app/views/volcanoes/volcanoes.component.ts"

    %% Click Events for Venus
    click FedeConfVenus "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-venus/federation.config.js"
    click BootstrapVenus "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-venus/src/bootstrap.ts"
    click IndexVenus "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-venus/src/index.html"
    click MainVenus "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-venus/src/main.ts"
    click RoutesVenus "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-venus/src/app/app.routes.ts"
    click AppCompVenus "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-venus/src/app/app.component.ts"
    click UtilsVenus "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-venus/src/app/micro-frontend/create-micro-frontend.ts"
    click UtilsVenus "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-venus/src/app/micro-frontend/connect-router.ts"
    click AtmosphereVenus "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-venus/src/app/views/atmosphere/atmosphere.component.ts"
    click VolcanoesVenus "https://github.com/adanyc/ng-micro-frontends-native-federation/blob/main/ng-mfe-venus/src/app/views/volcanoes/volcanoes.component.ts"

    %% Styles
    classDef shell fill:#e0f7fa,stroke:#0288d1,color:#01579b
    classDef mars fill:#ffe0b2,stroke:#fb8c00,color:#e65100
    classDef venus fill:#e8f5e9,stroke:#43a047,color:#1b5e20
    classDef infra fill:#eeeeee,stroke:#9e9e9e,color:#424242
    classDef default stroke:#000000,color:#000000
```
