# pankajpat85/angular-spa architecture

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

- Interactive diagram: https://gitdiagram.com/pankajpat85/angular-spa
- Repository: https://github.com/pankajpat85/angular-spa

## Overview

##### Project type and purpose
- This is a micro-frontend system built with Angular and orchestrated by Single-SPA.
- There are four main Angular apps:
- root (the single-spa “root-config”/shell)
- layout (a layout/navigation micro-frontend)
- profile (a user-profile micro-frontend)
- settings (a settings micro-frontend)
- The LinkedIn article explains how Single-SPA loads each Angular app as a separate bundle at runtime.

##### File structure
- Top level:
- README.md – points to the implementation article
- layout/, profile/, settings/ – each is an Angular project with its own package.json, angular.json, src/app, single-spa-webpack.config.js, tsconfigs
- root/ – contains the Single-SPA root-config and HTML template (microfrontend-layout.html), webpack.config.js, angular19-root-config.ts
- Each micro-frontend follows the same pattern:
- src/app/app.routes.ts – declares Single-SPA routes (mount points)
- src/app/app.config.ts – Single-SPA lifecycles (bootstrap, mount, unmount)
- EmptyRoute folder – a placeholder component to handle non-matched routes.
- Configuration files: single-spa-webpack.config.js in each micro-frontend, root’s webpack.config.js for the shell.

##### README for additional insights
- The README simply points to an article describing an Angular-based micro-frontend architecture using Single-SPA.

##### Elements
- Browser → Root (initial load)
- Root → micro-frontends (fetch/registration)
- Browser navigation → Single-SPA → mount/unmount lifecycles
- Shell (blue), micro-frontends (green), shared deps (yellow), client (gray).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client
    Browser["Browser (Client)"]:::client

    %% Shell
    Root["Single-SPA Root Config (shell)\n(html & routes)"]:::shell

    %% Shared Dependencies
    Shared["Shared Dependencies\n(import-maps / Module Federation)"]:::shared

    %% Micro-Frontends Group
    subgraph "Micro-Frontends"
        direction TB
        Layout["Layout App\n(bootstrap→mount→unmount)"]:::micro
        Profile["Profile App\n(bootstrap→mount→unmount)"]:::micro
        Settings["Settings App\n(bootstrap→mount→unmount)"]:::micro
    end

    %% Initial Load
    Browser -->|initial load| Root
    Root -->|fetch shared deps| Shared

    %% Registration
    Root -->|registers & imports| Layout
    Root -->|registers & imports| Profile
    Root -->|registers & imports| Settings

    %% Always-mounted
    Root -->|always mount| Layout

    %% Route-driven mounts
    Browser -->|navigate /profile| Profile
    Browser -->|navigate /settings| Settings

    %% Shared deps consumption
    Shared -->|provides deps| Layout
    Shared -->|provides deps| Profile
    Shared -->|provides deps| Settings

    %% Click Events
    click Root "https://github.com/pankajpat85/angular-spa/blob/main/root/src/angular19-root-config.ts"
    click Root "https://github.com/pankajpat85/angular-spa/blob/main/root/src/microfrontend-layout.html"
    click Root "https://github.com/pankajpat85/angular-spa/blob/main/root/webpack.config.js"
    click Layout "https://github.com/pankajpat85/angular-spa/blob/main/layout/src/app/app.routes.ts"
    click Layout "https://github.com/pankajpat85/angular-spa/blob/main/layout/src/app/app.config.ts"
    click Layout "https://github.com/pankajpat85/angular-spa/blob/main/layout/single-spa-webpack.config.js"
    click Profile "https://github.com/pankajpat85/angular-spa/blob/main/profile/src/app/app.routes.ts"
    click Profile "https://github.com/pankajpat85/angular-spa/blob/main/profile/src/app/app.config.ts"
    click Profile "https://github.com/pankajpat85/angular-spa/blob/main/profile/single-spa-webpack.config.js"
    click Settings "https://github.com/pankajpat85/angular-spa/blob/main/settings/src/app/app.routes.ts"
    click Settings "https://github.com/pankajpat85/angular-spa/blob/main/settings/src/app/app.config.ts"
    click Settings "https://github.com/pankajpat85/angular-spa/blob/main/settings/single-spa-webpack.config.js"
    click Shared "https://github.com/pankajpat85/angular-spa/blob/main/root/package.json"
    click Shared "https://github.com/pankajpat85/angular-spa/blob/main/root/webpack.config.js"

    %% Styles
    classDef client fill:#cccccc,stroke:#333,stroke-width:1px
    classDef shell fill:#add8e6,stroke:#333,stroke-width:1px
    classDef micro fill:#90ee90,stroke:#333,stroke-width:1px
    classDef shared fill:#fffacd,stroke:#333,stroke-width:1px
```
