# realdennis/md2pdf architecture

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

- Interactive diagram: https://gitdiagram.com/realdennis/md2pdf
- Repository: https://github.com/realdennis/md2pdf

## Overview

##### Project type and purpose
- This is a single-page React-based Progressive Web App (PWA) for editing and previewing Markdown.
- There is no separate backend; all logic resides in the client, with optional file-upload utilities and service-worker support for offline caching.

##### File structure
- “src” contains the React application:
- App/Components – presentational React components (Header, Markdown editor and previewer subtrees)
- App/Container – custom hooks that encapsulate business logic and state (useText, useDrop, InitialText)
- App/Lib – utility functions (e.g., uploadFile)
- service-worker.js & serviceWorkerRegistration.js – PWA offline/caching support
- setupTests.js, App.test.js, useText.test.js – testing setup and unit tests

##### Available documentation
- README is empty; rely entirely on code layout and naming conventions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Entities
    StaticServer["CDN/Static Asset Server"]:::external
    ExternalAPI["External API"]:::external
    Deploy["GitHub Actions: Deploy Pipeline"]:::service
    PRTest["GitHub Actions: PR Testing Pipeline"]:::service

    %% Browser with nested Service Worker and React App
    subgraph "Browser / Host Environment"
        SW["Service Worker"]:::service
        SWReg["Service Worker Registration"]:::service
        ReactApp["MirrorEditor React App"] 
        subgraph "MirrorEditor React App"
            %% Presentation Layer
            subgraph "Presentation Layer"
                Header["Header"]:::ui
                Upload["Upload Component"]:::ui
                Markdown["Markdown Container"]:::ui
                DragBar["DragBar"]:::ui
                MirrorEditor["MirrorEditor (Editor)"]:::ui
                PreviewerEntry["Previewer Entry"]:::ui
                PreviewComponent["Preview Component"]:::ui
                PreviewLoading["Preview Loading State"]:::ui
                PreviewError["Preview Error Boundary"]:::ui
            end
            %% Container Layer
            subgraph "Container Layer"
                InitialText["InitialText Hook"]:::hooks
                UseDrop["useDrop Hook"]:::hooks
                UseText["useText Hook"]:::hooks
            end
            %% Library Layer
            subgraph "Library Layer"
                UploadFile["uploadFile Utility"]:::service
            end
        end
    end

    %% Connections
    StaticServer -->|"serves index.html & assets"| SW
    StaticServer -->|"serves index.html & assets"| ReactApp
    ReactApp -->|"registers"| SWReg
    SW -->|"intercepts requests / caching"| ReactApp

    MirrorEditor -->|"text update"| UseText
    UseText -->|"state update"| PreviewerEntry

    Header -->|"invokes"| UploadFile
    UploadFile -->|"uploads to"| ExternalAPI

    %% CI/CD
    Deploy -.->|"on push"| ReactApp
    PRTest -.->|"on PR"| ReactApp

    %% Click Events
    click SW "https://github.com/realdennis/md2pdf/blob/master/src/service-worker.js"
    click SWReg "https://github.com/realdennis/md2pdf/blob/master/src/serviceWorkerRegistration.js"
    click ReactApp "https://github.com/realdennis/md2pdf/blob/master/src/index.js"
    click Header "https://github.com/realdennis/md2pdf/blob/master/src/App/Components/Header/index.js"
    click Upload "https://github.com/realdennis/md2pdf/blob/master/src/App/Components/Header/Upload.js"
    click Markdown "https://github.com/realdennis/md2pdf/blob/master/src/App/Components/Markdown/index.js"
    click DragBar "https://github.com/realdennis/md2pdf/blob/master/src/App/Components/Markdown/DragBar.js"
    click MirrorEditor "https://github.com/realdennis/md2pdf/blob/master/src/App/Components/Markdown/Editor/MirrorEditor.js"
    click PreviewerEntry "https://github.com/realdennis/md2pdf/blob/master/src/App/Components/Markdown/Previewer/index.js"
    click PreviewComponent "https://github.com/realdennis/md2pdf/blob/master/src/App/Components/Markdown/Previewer/Preview.js"
    click PreviewLoading "https://github.com/realdennis/md2pdf/blob/master/src/App/Components/Markdown/Previewer/Loading.js"
    click PreviewError "https://github.com/realdennis/md2pdf/blob/master/src/App/Components/Markdown/Previewer/ErrorBoundary.js"
    click InitialText "https://github.com/realdennis/md2pdf/blob/master/src/App/Container/Hooks/InitialText.js"
    click UseDrop "https://github.com/realdennis/md2pdf/blob/master/src/App/Container/Hooks/useDrop.js"
    click UseText "https://github.com/realdennis/md2pdf/blob/master/src/App/Container/Hooks/useText.js"
    click UploadFile "https://github.com/realdennis/md2pdf/blob/master/src/App/Lib/uploadFile.js"
    click StaticServer "https://github.com/realdennis/md2pdf/blob/master/public/index.html"
    click StaticServer "https://github.com/realdennis/md2pdf/blob/master/public/manifest.json"
    click StaticServer "https://github.com/realdennis/md2pdf/tree/master/public/icons"
    click Deploy "https://github.com/realdennis/md2pdf/blob/master/.github/workflows/deploy.yaml"
    click PRTest "https://github.com/realdennis/md2pdf/blob/master/.github/workflows/pr_testing.yaml"

    %% Styles
    classDef ui fill:#bbdefb,stroke:#1e88e5,color:#0d47a1
    classDef hooks fill:#c8e6c9,stroke:#388e3c,color:#1b5e20
    classDef service fill:#ffe0b2,stroke:#fb8c00,color:#e65100
    classDef external fill:#e0e0e0,stroke:#757575,color:#263238
```
