# salcc/scholar-pdf-reader-with-annotations architecture

> Architecture diagram of the GitHub repository salcc/scholar-pdf-reader-with-annotations, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/salcc/scholar-pdf-reader-with-annotations
- Repository: https://github.com/salcc/scholar-pdf-reader-with-annotations

## Overview

##### Component Details

a) Core Components:
- PDF Viewer (reader.html)
- Annotation System
- Background Service
- Storage Manager
- Language Support System

b) Worker Components:
- PDF Worker (pdf.worker.js)
- Analyzer Worker (analyzer_worker_bin.js)

##### Data Flow Representation

Key interactions:

**Browser Storage <-> Storage Manager <-> Annotation System**
**PDF Viewer <-> Annotation System <-> UI Components**
**Background Service <-> Content Scripts <-> Page Context**

##### Specific Implementation Details

- Blue rectangles: Core UI components (PDF viewer, annotation interface)
- Green rectangles: Processing components (workers, analyzers)
- Yellow diamonds: Storage components
- Purple rectangles: Extension service components

##### Component Relationships

Key relationships:

**PDF Viewer**
- > Annotation System
- > Highlight Management
- > Storage Interface
- > UI Controls
- > Document Processing
- > PDF Worker
- > Analyzer Worker

##### Special Features

- Localization System (\_locales directory)
- PDF Character Mapping (bcmaps directory)
- Settings Interface
- Import/Export Functionality

##### Security boundaries and communication channels

This system design should help developers understand both the high-level architecture and the specific implementation details of the extension.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Browser
        Storage[(Browser Storage)]
        PDFViewer["PDF Viewer Interface"]:::ui
        click PDFViewer "https://github.com/salcc/Scholar-PDF-Reader-with-Annotations/blob/main/extension/reader.html"
    end

    subgraph Extension["Extension Runtime"]
        Background["Background Service"]:::service
        click Background "https://github.com/salcc/Scholar-PDF-Reader-with-Annotations/blob/main/extension/annotation/background.js"
        
        Content["Content Scripts"]:::script
        click Content "https://github.com/salcc/Scholar-PDF-Reader-with-Annotations/blob/main/extension/annotation/content.js"
        
        subgraph Core["Core Components"]
            AnnotationSystem["Annotation System"]:::core
            click AnnotationSystem "https://github.com/salcc/Scholar-PDF-Reader-with-Annotations/blob/main/extension/annotation/annotation.js"
            
            Settings["Settings Interface"]:::ui
            click Settings "https://github.com/salcc/Scholar-PDF-Reader-with-Annotations/blob/main/extension/annotation/settings.html"
            
            StorageManager["Storage Manager"]:::storage
        end
        
        subgraph Workers["Worker Processes"]
            PDFWorker["PDF Worker"]:::worker
            click PDFWorker "https://github.com/salcc/Scholar-PDF-Reader-with-Annotations/blob/main/extension/pdf.worker.js"
            
            AnalyzerWorker["Analyzer Worker"]:::worker
            click AnalyzerWorker "https://github.com/salcc/Scholar-PDF-Reader-with-Annotations/blob/main/extension/analyzer_worker_bin.js"
        end
        
        subgraph Support["Support Systems"]
            Language["Language Support"]:::support
            click Language "https://github.com/salcc/Scholar-PDF-Reader-with-Annotations/tree/main/extension/_locales"
            
            CharMap["PDF Character Mapping"]:::support
            click CharMap "https://github.com/salcc/Scholar-PDF-Reader-with-Annotations/tree/main/extension/bcmaps"
            
            PDFLoader["PDF Loader"]:::support
            click PDFLoader "https://github.com/salcc/Scholar-PDF-Reader-with-Annotations/blob/main/extension/pdf_loader-compiled.js"
        end
    end

    %% Relationships
    PDFViewer <--> Content
    Content <--> Background
    Content <--> AnnotationSystem
    AnnotationSystem <--> StorageManager
    StorageManager <--> Storage
    PDFViewer <--> PDFWorker
    PDFViewer <--> AnalyzerWorker
    AnnotationSystem <--> Settings
    PDFViewer <--> PDFLoader
    PDFLoader --> CharMap
    AnnotationSystem --> Language

    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef service fill:#9b59b6,stroke:#8e44ad,color:white
    classDef script fill:#e74c3c,stroke:#c0392b,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef worker fill:#f1c40f,stroke:#f39c12,color:black
    classDef storage fill:#e67e22,stroke:#d35400,color:white
    classDef support fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        UI["UI Component"]:::ui
        Service["Service Component"]:::service
        Script["Script Component"]:::script
        CoreComp["Core Component"]:::core
        WorkerComp["Worker Component"]:::worker
        StorageComp["Storage Component"]:::storage
        SupportComp["Support Component"]:::support
    end
```
