# saradune6/pdf_sign architecture

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

- Interactive diagram: https://gitdiagram.com/saradune6/pdf_sign
- Repository: https://github.com/saradune6/pdf_sign

## Overview

##### Project type and purpose
- This is a pure-frontend, single-page web application (Vue 3 + TypeScript) for signing PDF documents in the browser.
- It leverages client-side storage (IndexedDB via idb-keyval, localStorage), a PDF generation engine (jsPDF + @component-hook/pdf-canvas), and internationalization (vue-i18n).

##### File structure
- Top-level config and tooling
- `.github/workflows/ci.yml`, `deploy.yml`, `preview.yml` (CI/CD pipelines)
- `vite.config.ts`, `tsconfig.json` (build & TS config)
- `package.json`, linters (`eslint.config.js`, `prettier.config.js`), husky hooks
- Public assets
- Source code (`src/`)
- `pages/` – view-level Vue files organized by feature (home, upload, signature, complete)
- `store/` – Pinia stores managing PDF blobs, signature info, UI state
- `router/` – vue-router setup, route events
- `plugins/` – global Vue plugins (error handler, i18n, preload fonts/locales)
- `hooks/` – composable functions for canvas loading, pointer handling, redirect, resize, warning popups
- `utils/` – general utilities (IDB wrapper, image compression, PDF readers, toast notifications)
- `assets/` and `styles/` – static images and Tailwind/CSS styles
- Tests
- Unit & mocking (`src/__tests__`, Vitest)
- E2E (`playwright.config.ts`, `src/__tests__/e2e`)

##### README for additional insights
- Tech stack: Vue 3, TypeScript, Pinia, jsPDF, browser-image-compression, vue-i18n, idb-keyval.
- Deployment: Vercel, GitHub Actions for CI, preview, and production.

##### Detail without overcomplication
- Every distinct module (pages, components, hooks, plugins, utils).
- How they interconnect via the Vue application bootstrap (`main.ts`) and plugin registration.
- Two storage mediums (IndexedDB vs. localStorage) separately.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser Client
    BrowserClient["Browser Client\n(Vue 3 SPA)"]:::ui

    %% UI Layer
    subgraph "UI Layer" 
        direction TB
        UI_Pages["Pages (Home, Upload, Signature, Complete)"]:::ui
        UI_Components["Reusable Components"]:::ui
    end

    %% State & Storage Layer
    subgraph "State & Storage" 
        direction TB
        PiniaStores["Pinia Stores"]:::state
        Router["Vue-Router"]:::state
        IndexedDB["IndexedDB Storage"]:::state
        LocalStorage["localStorage Templates"]:::state
    end

    %% Engine & Utilities Layer
    subgraph "Engine & Utilities"
        direction TB
        PDFEngine["PDF Engine\n(jsPDF + pdf-canvas)"]:::engine
        Utilities["Utilities\n(compression, reader, toast)"]:::engine
    end

    %% Plugins & Hooks
    subgraph "Plugins & Hooks"
        direction TB
        Plugins["Vue Plugins\n(i18n, error handler, preload)"]:::engine
        Hooks["Composables & Hooks"]:::engine
    end

    %% Resources and Assets
    subgraph "Resources & Assets"
        direction TB
        I18nResources["Intl Resources"]:::state
        AssetsStyles["Static Assets & Styles"]:::state
    end

    %% CI/CD Pipeline
    CICDPipeline["CI/CD Pipeline\n(GitHub Actions & Vercel)"]:::ci

    %% Connections
    BrowserClient --> UI_Pages
    BrowserClient --> UI_Components

    UI_Pages -->|invoke store actions| PiniaStores
    UI_Pages -->|navigates via| Router
    UI_Pages -->|renders PDF| PDFEngine

    PDFEngine -->|reads/writes blob| IndexedDB
    PiniaStores -->|persists signature data| LocalStorage

    Router --> UI_Pages
    Plugins --> BrowserClient
    Hooks --> BrowserClient

    BrowserClient --> Utilities

    UI_Pages --> CSSStyles[I18n & Assets]:::state
    BrowserClient --> I18nResources

    CICDPipeline -.->|deploy| BrowserClient

    %% Click Events
    click BrowserClient "https://github.com/saradune6/pdf_sign/blob/main/src/main.ts"
    click BrowserClient "https://github.com/saradune6/pdf_sign/blob/main/src/App.vue"
    click UI_Pages "https://github.com/saradune6/pdf_sign/tree/main/src/pages/"
    click UI_Components "https://github.com/saradune6/pdf_sign/tree/main/src/components/"
    click PiniaStores "https://github.com/saradune6/pdf_sign/tree/main/src/store/"
    click Router "https://github.com/saradune6/pdf_sign/tree/main/src/router/"
    click PDFEngine "https://github.com/saradune6/pdf_sign/blob/main/src/utils/jspdf.ts"
    click PDFEngine "https://github.com/saradune6/pdf_sign/blob/main/src/hooks/use-load-canvas.ts"
    click IndexedDB "https://github.com/saradune6/pdf_sign/blob/main/src/utils/idb.ts"
    click IndexedDB "https://github.com/saradune6/pdf_sign/blob/main/src/constants/idb.ts"
    click LocalStorage "https://github.com/saradune6/pdf_sign/blob/main/src/store/signature.ts"
    click LocalStorage "https://github.com/saradune6/pdf_sign/blob/main/src/store/literal.ts"
    click LocalStorage "https://github.com/saradune6/pdf_sign/blob/main/src/store/image.ts"
    click Plugins "https://github.com/saradune6/pdf_sign/tree/main/src/plugins/"
    click Hooks "https://github.com/saradune6/pdf_sign/tree/main/src/hooks/"
    click Utilities "https://github.com/saradune6/pdf_sign/tree/main/src/utils/"
    click I18nResources "https://github.com/saradune6/pdf_sign/tree/main/src/locales/"
    click AssetsStyles "https://github.com/saradune6/pdf_sign/tree/main/src/assets/"
    click AssetsStyles "https://github.com/saradune6/pdf_sign/tree/main/src/styles/"
    click CICDPipeline "https://github.com/saradune6/pdf_sign/blob/main/.github/workflows/ci.yml"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000;
    classDef state fill:#90EE90,stroke:#000;
    classDef engine fill:#FFA500,stroke:#000;
    classDef ci fill:#D3D3D3,stroke:#000;
```
