# suryanshswarn09/markdown-pdf architecture

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

- Interactive diagram: https://gitdiagram.com/suryanshswarn09/markdown-pdf
- Repository: https://github.com/suryanshswarn09/markdown-pdf

## Overview

This is a React Markdown-and-LaTeX editor with a live preview and document export/printing tools. The principal workflow is editing Markdown, sanitizing math delimiters, rendering and highlighting the preview, then optionally generating a TOC or exporting/printing the document. The README documents additional editing, persistence, security, theme, and layout capabilities. App.jsx is indexed but unsampled, so internal links beyond documented behavior are dashed where their exact call sites could not be verified.

Main entry points: [`src/App.jsx`](https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/App.jsx) (App Shell), [`src/components/PrintModal.jsx`](https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/components/PrintModal.jsx) (Print Customizer), [`src/utils/scrollSync.js`](https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/scrollSync.js) (Scroll Sync), [`src/utils/printOptions.js`](https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/printOptions.js) (Print Options)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_editing["Editing and Navigation"]
  node_app["App Shell<br/>[App.jsx]"]
  node_editor["Markdown Editor<br/>[App.jsx]"]
  node_keyboard["Editor Shortcuts"]
  node_toc["TOC Generator<br/>[tocGenerator.js]"]
  node_scroll["Scroll Sync<br/>[scrollSync.js]"]
end

subgraph group_rendering["Preview Rendering"]
  node_sanitizer["Math Sanitizer<br/>[mathSanitizer.js]"]
  node_markdown["Markdown Renderer<br/>[App.jsx]"]
  node_highlighter["Code Highlighter<br/>[highlighter.js]"]
  node_preview["Live Preview<br/>[App.jsx]"]
end

subgraph group_publishing["Export and Print"]
  node_export["Document Export<br/>[exportUtils.js]"]
  node_printmodal["Print Customizer<br/>[PrintModal.jsx]"]
  node_printoptions["Print Options<br/>[printOptions.js]"]
  node_icons["SVG Icons<br/>[Icons.jsx]"]
end

subgraph group_support["Document Support"]
  node_stats["Document Metrics<br/>[documentStats.js]"]
  node_theme["Theme Preferences<br/>[themeUtils.js]"]
  node_storage[("Browser Storage")]
end

node_user(("User"))
node_browser(("Browser"))

node_user -->|"edits document"| node_app
node_app -.->|"handles input"| node_editor
node_editor -.->|"handles indentation"| node_keyboard
node_app -->|"sanitizes math"| node_sanitizer
node_app -->|"parses Markdown"| node_markdown
node_markdown -.->|"highlights code"| node_highlighter
node_markdown -->|"renders preview"| node_preview
node_app -.->|"generates TOC"| node_toc
node_preview -.->|"syncs scrolling"| node_scroll
node_app -.->|"exports documents"| node_export
node_app -.->|"opens print layout"| node_printmodal
node_printmodal -->|"uses presets"| node_printoptions
node_printmodal -->|"renders icons"| node_icons
node_app -.->|"calculates metrics"| node_stats
node_app -.->|"loads theme"| node_theme
node_app -.->|"persists preferences"| node_storage
node_printoptions -.->|"reads and writes"| node_storage
node_scroll -.->|"reads and writes"| node_storage
node_theme -.->|"persists theme"| node_storage
node_app -.->|"prints document"| node_browser

click node_app "https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/App.jsx"
click node_editor "https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/App.jsx"
click node_keyboard "https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/editorKeyHandlers.js"
click node_toc "https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/tocGenerator.js"
click node_scroll "https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/scrollSync.js"
click node_sanitizer "https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/mathSanitizer.js"
click node_markdown "https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/App.jsx"
click node_highlighter "https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/highlighter.js"
click node_preview "https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/App.jsx"
click node_export "https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/exportUtils.js"
click node_printmodal "https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/components/PrintModal.jsx"
click node_printoptions "https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/printOptions.js"
click node_icons "https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/components/Icons.jsx"
click node_stats "https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/documentStats.js"
click node_theme "https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/themeUtils.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_editor,node_keyboard,node_toc,node_scroll,node_user,node_browser toneBlue
class node_sanitizer,node_markdown,node_highlighter,node_preview toneAmber
class node_export,node_printmodal,node_printoptions,node_icons toneMint
class node_stats,node_theme,node_storage toneRose
```

## Components

### Editing and Navigation

- [App Shell](https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/App.jsx): `src/App.jsx`
- [Markdown Editor](https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/App.jsx): `src/App.jsx`
- [Editor Shortcuts](https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/editorKeyHandlers.js): `src/utils/editorKeyHandlers.js`
- [TOC Generator](https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/tocGenerator.js): `src/utils/tocGenerator.js`
- [Scroll Sync](https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/scrollSync.js): `src/utils/scrollSync.js`

### Preview Rendering

- [Math Sanitizer](https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/mathSanitizer.js): `src/utils/mathSanitizer.js`
- [Markdown Renderer](https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/App.jsx): `src/App.jsx`
- [Code Highlighter](https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/highlighter.js): `src/utils/highlighter.js`
- [Live Preview](https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/App.jsx): `src/App.jsx`

### Export and Print

- [Document Export](https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/exportUtils.js): `src/utils/exportUtils.js`
- [Print Customizer](https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/components/PrintModal.jsx): `src/components/PrintModal.jsx`
- [Print Options](https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/printOptions.js): `src/utils/printOptions.js`
- [SVG Icons](https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/components/Icons.jsx): `src/components/Icons.jsx`

### Document Support

- [Document Metrics](https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/documentStats.js): `src/utils/documentStats.js`
- [Theme Preferences](https://github.com/suryanshswarn09/markdown-pdf/blob/main/src/utils/themeUtils.js): `src/utils/themeUtils.js`
- **Browser Storage**

### Other components

- **User**
- **Browser**

## Connections

- User → App Shell: edits document (evidence: `README.md`)
- App Shell → Markdown Editor: handles input
- Markdown Editor → Editor Shortcuts: handles indentation
- App Shell → Math Sanitizer: sanitizes math (evidence: `README.md`)
- App Shell → Markdown Renderer: parses Markdown (evidence: `README.md`)
- Markdown Renderer → Code Highlighter: highlights code
- Markdown Renderer → Live Preview: renders preview (evidence: `README.md`)
- App Shell → TOC Generator: generates TOC
- Live Preview → Scroll Sync: syncs scrolling
- App Shell → Document Export: exports documents
- App Shell → Print Customizer: opens print layout
- Print Customizer → Print Options: uses presets (evidence: `src/components/PrintModal.jsx`)
- Print Customizer → SVG Icons: renders icons (evidence: `src/components/PrintModal.jsx`)
- App Shell → Document Metrics: calculates metrics
- App Shell → Theme Preferences: loads theme
- App Shell → Browser Storage: persists preferences
- Print Options → Browser Storage: reads and writes
- Scroll Sync → Browser Storage: reads and writes
- Theme Preferences → Browser Storage: persists theme
- App Shell → Browser: prints document
