# hwangjungeon/pwa-install architecture

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

- Interactive diagram: https://gitdiagram.com/hwangjungeon/pwa-install
- Repository: https://github.com/hwangjungeon/pwa-install

## Overview

##### Project type and purpose
- This is a front-end library published to npm (“@khmyznikov/pwa-install”) that delivers a reusable Web Component for installing Progressive Web Apps (PWAs) across platforms. It offers a customizable dialog/gallery, localization support, and builds multiple bundle formats (ES modules, UMD, React).

##### File structure
- Top-level:
- src/ – TypeScript source organized into subpackages:
– index.ts (entry-point Web Component)
– fallback/ (React fallback component)
– gallery/ (gallery UI)
– localization/ (runtime locale selection + locale data)
– templates/ (device-specific templates & styles)
– types/ (global/type declarations)
– utils.ts (shared helpers)
- i18n/ + lit-localize.json – raw XLF translation files & config
- webpack/ – multiple configs (common, dev, prod, module, react, UMD, service-worker stub)
- custom-elements-*.mjs/json – manifest generation for custom elements
- dist/ – build outputs:
– es/ (ESM bundles & maps)
– umd/ (UMD bundles & maps)
– pwa-install.bundle.js (standalone bundle)
– pwa-install.react.js (React wrapper)
– types/ (declaration files)
- docs/ – static demo site & service worker, preview assets
- package.json, tsconfig.json, .gitignore, CI configs, etc.

##### Key insights from the README
- Core feature: `<pwa-install>` custom element with attributes, events, methods
- Extensibility: “manual” display, externalPromptEvent for async mode
- Localization: auto language switching, XLF sources in i18n/
- Build targets: modern ESM, UMD for CDN, React polyfill wrapper
- Demo site at khmyznikov.com/pwa-install

##### Essential details
- Src subfolder as its own component
- Webpack configs as stages (dev vs. prod vs. UMD vs. React)
- Custom-elements-manifest step for automated metadata
- Localization workflow: XLF → compiled locale TS → runtime locale lookup
- Style pipelines (SCSS templates → CSS in bundles)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Source Modules
    subgraph "Source Modules"
        direction TB
        Core["Core Web Component"]:::source
        Fallback["Fallback React Component"]:::source
        Gallery["Gallery UI Module"]:::source
        Templates["Templates & Styles"]:::source
        Localization["Localization Engine & Locale Data"]:::source
        Utils["Utility Library"]:::source
    end

    %% Build & Packaging
    Build["Build & Packaging Layer"]:::build

    %% Distribution Artifacts
    subgraph "Distribution Artifacts"
        direction TB
        DistES["ESM Bundles"]:::artifact
        DistUMD["UMD Bundles"]:::artifact
        DistReact["React Wrapper Bundle"]:::artifact
        DistTypes["Type Declaration Files"]:::artifact
    end

    %% Documentation & Demo
    Docs["Documentation & Demo Site"]:::docs

    %% Registry & CDN
    Registry("npm & CDN"):::registry

    %% Consumers
    subgraph "Consumers"
        direction TB
        ConsumersEsm["Modern Framework / Vanilla JS"]:::consumer
        ConsumersUmd["Static Sites (UMD)"]:::consumer
        ConsumersReact["React Apps"]:::consumer
    end

    %% Relationships
    Core -->|writes code| Build
    Fallback -->|writes code| Build
    Gallery -->|writes code| Build
    Templates -->|writes code| Build
    Localization -->|writes code| Build
    Utils -->|writes code| Build
    i18nFiles["XLF Translation Files"]:::source -->|feeds| Build

    Build -->|outputs| DistES
    Build -->|outputs| DistUMD
    Build -->|outputs| DistReact
    Build -->|outputs| DistTypes

    DistES -->|published to| Registry
    DistUMD -->|published to| Registry
    DistReact -->|published to| Registry
    DistTypes -->|published to| Registry

    DistES -->|used by| Docs
    Docs -->|references assets| DistES

    Registry -->|install/import| ConsumersEsm
    Registry -->|include via script| ConsumersUmd
    Registry -->|import React polyfill| ConsumersReact

    %% Click Events
    click Core "https://github.com/hwangjungeon/pwa-install/blob/main/src/index.ts"
    click Fallback "https://github.com/hwangjungeon/pwa-install/blob/main/src/fallback/react.ts"
    click Gallery "https://github.com/hwangjungeon/pwa-install/blob/main/src/gallery/index.ts"
    click Templates "https://github.com/hwangjungeon/pwa-install/blob/main/src/templates/apple/template-apple.ts"
    click Localization "https://github.com/hwangjungeon/pwa-install/blob/main/src/localization/index.ts"
    click Utils "https://github.com/hwangjungeon/pwa-install/blob/main/src/utils.ts"
    click Build "https://github.com/hwangjungeon/pwa-install/blob/main/webpack/webpack.common.js"
    click DistES "https://github.com/hwangjungeon/pwa-install/tree/main/dist/es/"
    click DistUMD "https://github.com/hwangjungeon/pwa-install/tree/main/dist/umd/"
    click DistReact "https://github.com/hwangjungeon/pwa-install/blob/main/dist/pwa-install.react.js"
    click DistTypes "https://github.com/hwangjungeon/pwa-install/tree/main/dist/types/"
    click Docs "https://github.com/hwangjungeon/pwa-install/blob/main/docs/index.html"

    %% Styles
    classDef source fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef build fill:#FFA500,stroke:#333,stroke-width:1px,shape:cylinder
    classDef artifact fill:#90EE90,stroke:#333,stroke-width:1px
    classDef docs fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef registry fill:#DDA0DD,stroke:#333,stroke-width:1px
    classDef consumer fill:#FFFF66,stroke:#333,stroke-width:1px
```
