# samuelnotfound/drive-preview-exporter architecture

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

- Interactive diagram: https://gitdiagram.com/samuelnotfound/drive-preview-exporter
- Repository: https://github.com/samuelnotfound/drive-preview-exporter

## Overview

Drive Preview Exporter adds an Export action to Google Drive and produces local PDF or video files from view-only previews. The principal paths are menu selection, PDF page capture and PDF construction, or video stream detection, download, remux, and save. Quality selection and Classroom handling are distinct supporting capabilities. The README documents the end-to-end export behavior; source excerpts show selected messaging, capture, and processing details, so unsampled links are omitted.

Main entry points: [`src/content/drive/ui.js`](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/drive/ui.js) (Export menu), [`src/offscreen/video-stage-processor.js`](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/offscreen/video-stage-processor.js) (Remux and save), [`src/content/drive/pdf.js`](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/drive/pdf.js) (PDF menu handler), [`src/content/drive/video.js`](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/drive/video.js) (Video menu handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_drive_ui["Drive interface"]
  node_drive_menu["Export menu<br/>[ui.js]"]
  node_pdf_menu["PDF menu handler<br/>[pdf.js]"]
  node_video_menu["Video menu handler<br/>[video.js]"]
  node_quality_picker["Quality picker<br/>[quality-picker.js]"]
  node_quality_trigger["Quality automation<br/>[quality-trigger.js]"]
  node_classroom["Classroom export"]
end

subgraph group_pdf_export["PDF export"]
  node_pdf_capture["Page capture<br/>[capture.js]"]
  node_pdf_writer["PDF construction<br/>[writer.js]"]
end

subgraph group_video_capture["Video capture"]
  node_network_bridge["Page network bridge<br/>[network-bridge.js]"]
  node_network_capture["Stream capture<br/>[network-capture.js]"]
  node_format_catalog["Format catalog<br/>[format-catalog.js]"]
  node_video_context["Video context<br/>[context.js]"]
end

subgraph group_video_processing["Video processing"]
  node_message_router["Message router<br/>[message-router.js]"]
  node_video_jobs["Video job coordination<br/>[video-jobs.js]"]
  node_downloader["Stream downloader"]
  node_processor["Remux and save"]
  node_disk_storage[("Temporary disk storage")]
end

node_user(("Drive user"))

node_user -->|"opens File menu"| node_drive_menu
node_drive_menu -->|"selects PDF export"| node_pdf_menu
node_drive_menu -->|"selects video export"| node_video_menu
node_pdf_menu -->|"starts capture"| node_pdf_capture
node_pdf_capture -->|"builds PDF"| node_pdf_writer
node_video_menu -->|"offers quality choice"| node_quality_picker
node_quality_picker -->|"sets stream quality"| node_quality_trigger
node_network_bridge -->|"forwards stream URLs"| node_video_context
node_network_capture -.->|"catalogs captured streams"| node_format_catalog
node_video_context -->|"requests video download"| node_message_router
node_message_router -->|"coordinates video stages"| node_video_jobs
node_downloader -->|"hands off streams"| node_processor
node_processor -->|"reads merged output"| node_disk_storage
node_processor -->|"saves MP4"| node_user
node_classroom -.->|"supports Classroom PDFs"| node_pdf_menu

click node_drive_menu "https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/drive/ui.js"
click node_pdf_menu "https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/drive/pdf.js"
click node_video_menu "https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/drive/video.js"
click node_quality_picker "https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/drive/video/quality-picker.js"
click node_quality_trigger "https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/automation/quality-trigger.js"
click node_classroom "https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/background/classroom-export.js"
click node_pdf_capture "https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/drive/pdf/capture.js"
click node_pdf_writer "https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/drive/pdf/writer.js"
click node_network_bridge "https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/media/network-bridge.js"
click node_network_capture "https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/background/network-capture.js"
click node_format_catalog "https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/background/format-catalog.js"
click node_video_context "https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/drive/video/context.js"
click node_message_router "https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/background/message-router.js"
click node_video_jobs "https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/background/video-jobs.js"
click node_downloader "https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/offscreen/video-stage-downloader.js"
click node_processor "https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/offscreen/video-stage-processor.js"
click node_disk_storage "https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/offscreen/video-stage-storage.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_drive_menu,node_pdf_menu,node_video_menu,node_quality_picker,node_quality_trigger,node_classroom,node_user toneBlue
class node_pdf_capture,node_pdf_writer toneAmber
class node_network_bridge,node_network_capture,node_format_catalog,node_video_context toneMint
class node_message_router,node_video_jobs,node_downloader,node_processor,node_disk_storage toneRose
```

## Components

### Drive interface

- [Export menu](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/drive/ui.js): `src/content/drive/ui.js`
- [PDF menu handler](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/drive/pdf.js): `src/content/drive/pdf.js`
- [Video menu handler](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/drive/video.js): `src/content/drive/video.js`
- [Quality picker](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/drive/video/quality-picker.js): `src/content/drive/video/quality-picker.js`
- [Quality automation](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/automation/quality-trigger.js): `src/content/automation/quality-trigger.js`
- [Classroom export](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/background/classroom-export.js): `src/background/classroom-export.js`

### PDF export

- [Page capture](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/drive/pdf/capture.js): `src/content/drive/pdf/capture.js`
- [PDF construction](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/drive/pdf/writer.js): `src/content/drive/pdf/writer.js`

### Video capture

- [Page network bridge](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/media/network-bridge.js): `src/content/media/network-bridge.js`
- [Stream capture](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/background/network-capture.js): `src/background/network-capture.js`
- [Format catalog](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/background/format-catalog.js): `src/background/format-catalog.js`
- [Video context](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/content/drive/video/context.js): `src/content/drive/video/context.js`

### Video processing

- [Message router](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/background/message-router.js): `src/background/message-router.js`
- [Video job coordination](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/background/video-jobs.js): `src/background/video-jobs.js`
- [Stream downloader](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/offscreen/video-stage-downloader.js): `src/offscreen/video-stage-downloader.js`
- [Remux and save](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/offscreen/video-stage-processor.js): `src/offscreen/video-stage-processor.js`
- [Temporary disk storage](https://github.com/samuelnotfound/drive-preview-exporter/blob/main/src/offscreen/video-stage-storage.js): `src/offscreen/video-stage-storage.js`

### Other components

- **Drive user**

## Connections

- Drive user → Export menu: opens File menu (evidence: `README.md`)
- Export menu → PDF menu handler: selects PDF export (evidence: `README.md`)
- Export menu → Video menu handler: selects video export (evidence: `README.md`)
- PDF menu handler → Page capture: starts capture (evidence: `README.md`)
- Page capture → PDF construction: builds PDF (evidence: `README.md`)
- Video menu handler → Quality picker: offers quality choice (evidence: `README.md`)
- Quality picker → Quality automation: sets stream quality (evidence: `src/content/automation/quality-trigger.js`)
- Page network bridge → Video context: forwards stream URLs (evidence: `src/content/media/network-bridge.js`)
- Stream capture → Format catalog: catalogs captured streams
- Video context → Message router: requests video download (evidence: `src/content/drive/video/context.js`)
- Message router → Video job coordination: coordinates video stages (evidence: `src/background/message-router.js`)
- Stream downloader → Remux and save: hands off streams (evidence: `src/offscreen/video-stage-processor.js`)
- Remux and save → Temporary disk storage: reads merged output (evidence: `src/offscreen/video-stage-processor.js`)
- Remux and save → Drive user: saves MP4 (evidence: `README.md`)
- Classroom export → PDF menu handler: supports Classroom PDFs
