# stephanrauh/ngx-extended-pdf-viewer architecture

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

- Interactive diagram: https://gitdiagram.com/stephanrauh/ngx-extended-pdf-viewer
- Repository: https://github.com/stephanrauh/ngx-extended-pdf-viewer

## Overview

##### Project type and purpose
- This is an Angular “monorepo” workspace containing an open-source PDF-viewer library (ngx-extended-pdf-viewer), its CLI schematics, a showcase/demo application, plus build and test tooling.
- The core purpose is to wrap Mozilla’s pdf.js in an Angular module, add UI components, localization assets, and provide a ready-to-use npm package and demo site.

##### High-level file-structure analysis
- Root
– angular.json, tsconfig.json, package.json, build-tools/ (shell & Node scripts)
– compatibility-tests/ (Angular examples + Playwright)
- projects/ngx-extended-pdf-viewer/
– src/lib/ (components, services, options, dialogs, theme, toolbar, sidebar)
– assets/ (cmaps, fonts, locale files)
– schematics/ (ng-add generator)
– types/ (TypeScript declarations wrapping pdf.js)
- projects/showcase-schematics/ (schematic to scaffold docs pages)
- projects/showcase/
– src/app/ (Angular modules, routing, core, pages, shared components, assets)
– server.ts (SSR entrypoint for Node)

##### Key README insights
- Library wraps pdf.js and ships UI.
- Available at pdfviewer.net demonstrates features.
- Build-from-scratch walkthrough in how-to-build.md.

a. Main components
– Build Tools: shell scripts & Node scripts that compile library, schematics, showcase, run tests, publish to npm.
– PDF Viewer Library: Angular module + assets, schematics generator, TypeScript API, packaging config.
– pdf.js Core: third-party worker and API loaded at runtime by pdf-script-loader.service.
– Showcase Application: Angular SPA/SSR that imports the published library, routes pages, loads PDFs.
– Compatibility Tests: Angular demo apps + Playwright scripts verify cross-version behavior.
– CI/CD Pipeline: GitHub Actions, Dependabot, SonarCloud, npm registry, unpkg/CND.

b. Relationships & data flows
– Developer invokes “ng build” or build-tools scripts → compiles library + assets → outputs bundles.
– Packaging step → publishes to npm registry & unpkg CDN.
– Showcase and compatibility demos declare dependency on the npm package → on install they pull the bundles.
– At runtime the PDF Viewer component calls pdf.js via the script loader service → worker thread processes PDF → UI components render.
– CI triggers build → runs compatibility-tests (Angular examples + Playwright) → reports to SonarCloud → on success publishes new version.

c. Architectural patterns & principles
– Monorepo (Angular CLI workspace) for code sharing.
– Modular Angular architecture: library encapsulates PDF functionality behind a single NgModule.
– Schematics for zero-config setup (ng-add).
– Separation of concerns: core library vs. demo vs. tooling vs. tests.
– Automated CI/CD ensures package quality and versioning.

d. Technologies & frameworks
– Angular (components, modules, services, schematics)
– TypeScript declarations wrapping pdf.js APIs
– Node.js scripts & Bash for build orchestration
– Playwright for end-to-end compatibility testing
– GitHub Actions, SonarCloud for CI/CD
– npm registry & unpkg CDN for distribution

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Build & Release Tools
    subgraph "Build & Release Tools"
        BT["Build Tools"]:::pipeline
        RS["Release Scripts"]:::pipeline
    end
    click BT "https://github.com/stephanrauh/ngx-extended-pdf-viewer/tree/main/build-tools/"
    click RS "https://github.com/stephanrauh/ngx-extended-pdf-viewer/blob/main/build-tools/5-release-library.js"
    click RS "https://github.com/stephanrauh/ngx-extended-pdf-viewer/blob/main/build-tools/6-release-showcase.js"

    %% PDF Viewer Library
    subgraph "PDF Viewer Library" 
        direction TB
        LIB_API["Public API Entry Point"]:::library
        click LIB_API "https://github.com/stephanrauh/ngx-extended-pdf-viewer/blob/main/projects/ngx-extended-pdf-viewer/public_api.ts"
        MODULE_LIB["Library Modules"]:::library
        click MODULE_LIB "https://github.com/stephanrauh/ngx-extended-pdf-viewer/tree/main/projects/ngx-extended-pdf-viewer/src/lib/"
        ASSETS["Library Assets"]:::library
        click ASSETS "https://github.com/stephanrauh/ngx-extended-pdf-viewer/tree/main/projects/ngx-extended-pdf-viewer/assets/"
        SCHEM["Schematics Generator (ng-add)"]:::library
        click SCHEM "https://github.com/stephanrauh/ngx-extended-pdf-viewer/tree/main/projects/ngx-extended-pdf-viewer/schematics/ng-add/"
        TYPES["TypeScript Declarations"]:::library
        click TYPES "https://github.com/stephanrauh/ngx-extended-pdf-viewer/tree/main/projects/ngx-extended-pdf-viewer/types/"
        PKG_CFG["Packaging Configuration"]:::library
        click PKG_CFG "https://github.com/stephanrauh/ngx-extended-pdf-viewer/blob/main/projects/ngx-extended-pdf-viewer/ng-package.json"
        click PKG_CFG "https://github.com/stephanrauh/ngx-extended-pdf-viewer/blob/main/projects/ngx-extended-pdf-viewer/ng-package.prod.json"
        LOADER["PDF Script Loader Service"]:::library
        click LOADER "https://github.com/stephanrauh/ngx-extended-pdf-viewer/blob/main/projects/ngx-extended-pdf-viewer/src/lib/pdf-script-loader.service.ts"
    end

    %% Showcase Application
    subgraph "Showcase Application"
        direction TB
        SC_APP["SPA/SSR Source"]:::app
        click SC_APP "https://github.com/stephanrauh/ngx-extended-pdf-viewer/tree/main/projects/showcase/src/app/"
        SSR["SSR Entrypoint"]:::app
        click SSR "https://github.com/stephanrauh/ngx-extended-pdf-viewer/blob/main/projects/showcase/server.ts"
        SC_ASSETS["Showcase Assets"]:::app
        click SC_ASSETS "https://github.com/stephanrauh/ngx-extended-pdf-viewer/tree/main/projects/showcase/src/assets/"
    end

    %% Showcase Schematics
    SS_SCHEM["Showcase Schematics"]:::library
    click SS_SCHEM "https://github.com/stephanrauh/ngx-extended-pdf-viewer/tree/main/projects/showcase-schematics/src/"

    %% Compatibility Tests
    subgraph "Compatibility Tests"
        direction TB
        CT_APPS["Angular Demo Apps"]:::pipeline
        PW["Playwright Runner"]:::pipeline
        click CT_APPS "https://github.com/stephanrauh/ngx-extended-pdf-viewer/tree/main/compatibility-tests/"
        click PW "https://github.com/stephanrauh/ngx-extended-pdf-viewer/tree/main/compatibility-tests/playwright/"
    end

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        direction TB
        GH["GitHub Actions"]:::external
        click GH "https://github.com/stephanrauh/ngx-extended-pdf-viewer/blob/main/.github/sonar-cloud.yml"
        DEP["Dependabot"]:::external
        click DEP "https://github.com/stephanrauh/ngx-extended-pdf-viewer/blob/main/.github/dependabot.yml"
        click DEP "https://github.com/stephanrauh/ngx-extended-pdf-viewer/blob/main/dependabot.yml"
        SONAR["SonarCloud"]:::external
        click SONAR "https://github.com/stephanrauh/ngx-extended-pdf-viewer/blob/main/sonar-project.properties"
        NPM["npm Registry"]:::storage
        CDN["unpkg CDN"]:::storage
    end

    %% External pdf.js
    PDFJS["pdf.js Core"]:::external

    %% Flows
    BT -->|"compile library & assets"| LIB_API
    BT -->|"compile schematics"| SCHEM
    BT -->|"run release scripts"| RS
    RS -->|"publish bundles"| NPM
    RS -->|"publish bundles"| CDN

    NPM -->|"install dependency"| SC_APP
    NPM -->|"install dependency"| CT_APPS

    SC_APP -->|"ng-add"| SCHEM
    SC_APP -->|"runtime load"| LOADER
    LOADER -->|"load worker"| PDFJS

    GH -->|"trigger build"| BT
    GH -->|"run tests"| CT_APPS
    CT_APPS -->|"e2e tests"| PW
    PW -->|"report results"| SONAR
    SONAR -->|"on success"| RS

    SS_SCHEM -->|"scaffold docs"| SC_APP

    %% Styles
    classDef library fill:#cfe2f3,stroke:#0b5394,color:#073763;
    classDef pipeline fill:#d9ead3,stroke:#6aa84f,color:#38761d;
    classDef external fill:#fce5cd,stroke:#e69138,color:#b45f06;
    classDef storage fill:#fff2cc,stroke:#bf9000,color:#7f6000;
    classDef app fill:#ead1dc,stroke:#a64d79,color:#741b47;
    class BT,RS,CT_APPS,PW pipeline
    class LIB_API,MODULE_LIB,ASSETS,SCHEM,TYPES,PKG_CFG,LOADER library
    class SC_APP,SSR,SC_ASSETS app
    class GH,DEP,SONAR,PDFJS external
    class NPM,CDN storage
```
