# gagunsarthak/microfrontend_workspace architecture

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

- Interactive diagram: https://gitdiagram.com/gagunsarthak/microfrontend_workspace
- Repository: https://github.com/gagunsarthak/microfrontend_workspace

## Overview

##### Project type and purpose
- This is a front-end-only, micro-frontend architecture built with Angular CLI and Angular Elements.
- It consists of a “shell” or host container and multiple independently developed Angular apps (appone, apptwo, footerApp, headerApp, mainApp, sideApp, statementApp, subApp, tempapp, transferApp, demoapp). Each micro-app is compiled as a web component via Angular Elements.
- The README confirms the goal: “Microfrontends using Angular Elements.”

##### File structure
- Top-level artifacts:
- angular.json, tsconfig.json, ts lint and webpack.extra.js – indicating an Angular workspace configured for multiple projects.
- build-elements.js – a custom script to bundle each Angular app into an Angular Element (web component).
- projects/… contains one directory per micro-frontend. Each has the standard Angular CLI layout:
- src/app – components, routing, module definition
- src/environments – environment configs
- e2e, karma.conf.js, tsconfig.* – test configurations
- webpack.externals.js – to externalize shared vendor libs (Angular core, zone.js, RxJS)
- No backend code or server; this is strictly client-side.

##### README for additional insights
- References a tutorial on building and deploying micro-frontends locally.

##### Main components and their interactions
a. Host Shell Container (mainApp or index.html)
- Loads and instantiates multiple Angular Elements (micro-apps) at runtime.
- Responsible for global layout, shared header/footer, navigation, event bus, and loading child web components.
b. Micro-frontend Web Components
- headerApp, footerApp – the shared page chrome.
- sideApp, statementApp, transferApp, demoapp, appone, apptwo, tempapp, subApp – feature-specific modules packaged as custom elements.
c. Shared Vendor Bundle
- Externalized Angular framework, RxJS, zone.js – loaded once by the shell to minimize duplication.
d. Build Pipeline
- build-elements.js runs builds for each project, generates .js bundles for each Angular Element.
- webpack.extra.js configures externals to keep vendor shared.

##### Architectural patterns and design principles
- Micro-frontend pattern: each feature as an independent deployable Angular Element.
- Web components (Angular Elements) for framework-agnostic integration.
- Shell-and-spoke: a container app orchestrates and renders micro-frontends.
- Event-driven communication (via CustomEvents or a shared event bus) rather than direct Angular service injection.
- Lazy loading: micro-apps are only fetched and instantiated when needed.
- Shared dependencies externalized to reduce payload and enforce consistency.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Host Shell Container" 
        HS["Host Shell Container<br/>(mainApp)"]:::shell
    end

    subgraph "Build Pipeline"
        BES["build-elements.js"]:::pipeline
        WEBPACK["webpack.extra.js"]:::pipeline
    end

    Vendor["Vendor Bundle<br/>(Angular core, RxJS, zone.js)"]:::vendor

    subgraph "Micro-Frontends"
        Header["<header-app><br/>headerApp"]:::micro
        Footer["<footer-app><br/>footerApp"]:::micro
        Side["<side-app><br/>sideApp"]:::micro
        Statement["<statement-app><br/>statementApp"]:::micro
        Transfer["<transfer-app><br/>transferApp"]:::micro
        Demo["<demo-app><br/>demoapp"]:::micro
        AppOne["<app-one><br/>appone"]:::micro
        AppTwo["<app-two><br/>apptwo"]:::micro
        Temp["<temp-app><br/>tempapp"]:::micro
        Sub["<sub-app><br/>subApp"]:::micro
    end

    %% Connections
    BES -->|build bundles| Header
    BES -->|build bundles| Footer
    BES -->|build bundles| Side
    BES -->|build bundles| Statement
    BES -->|build bundles| Transfer
    BES -->|build bundles| Demo
    BES -->|build bundles| AppOne
    BES -->|build bundles| AppTwo
    BES -->|build bundles| Temp
    BES -->|build bundles| Sub

    WEBPACK -->|config externals| Vendor

    HS -->|loads once| Vendor
    HS -->|instantiates| Header
    HS -->|instantiates| Footer
    HS -->|instantiates| Side
    HS -->|instantiates| Statement
    HS -->|instantiates| Transfer
    HS -->|instantiates| Demo
    HS -->|instantiates| AppOne
    HS -->|instantiates| AppTwo
    HS -->|instantiates| Temp
    HS -->|instantiates| Sub

    Transfer -->|CustomEvent:transferCompleted| Statement

    %% Click Events
    click HS "https://github.com/gagunsarthak/microfrontend_workspace/tree/master/projects/mainApp"
    click BES "https://github.com/gagunsarthak/microfrontend_workspace/blob/master/build-elements.js"
    click WEBPACK "https://github.com/gagunsarthak/microfrontend_workspace/blob/master/webpack.extra.js"
    click Header "https://github.com/gagunsarthak/microfrontend_workspace/tree/master/projects/headerApp"
    click Footer "https://github.com/gagunsarthak/microfrontend_workspace/tree/master/projects/footerApp"
    click Side "https://github.com/gagunsarthak/microfrontend_workspace/tree/master/projects/sideApp"
    click Statement "https://github.com/gagunsarthak/microfrontend_workspace/tree/master/projects/statementApp"
    click Transfer "https://github.com/gagunsarthak/microfrontend_workspace/tree/master/projects/transferApp"
    click Demo "https://github.com/gagunsarthak/microfrontend_workspace/tree/master/projects/demoapp"
    click AppOne "https://github.com/gagunsarthak/microfrontend_workspace/tree/master/projects/appone"
    click AppTwo "https://github.com/gagunsarthak/microfrontend_workspace/tree/master/projects/apptwo"
    click Temp "https://github.com/gagunsarthak/microfrontend_workspace/tree/master/projects/tempapp"
    click Sub "https://github.com/gagunsarthak/microfrontend_workspace/tree/master/projects/subApp"

    %% Styles
    classDef shell fill:#cce5ff,stroke:#004085,color:#004085;
    classDef pipeline fill:#fff3cd,stroke:#856404,color:#856404;
    classDef vendor fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
    classDef micro fill:#d4edda,stroke:#155724,color:#155724;
```
