# sandipwane/custom-font-plus architecture

> Architecture diagram of the GitHub repository sandipwane/custom-font-plus, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sandipwane/custom-font-plus
- Repository: https://github.com/sandipwane/custom-font-plus

## Overview

##### Main Components
- Manifest & Configuration: The manifest.json (along with files like google9eb51814538804eb.html and privacy-policy.md) defines the extension’s permissions, entry points, and metadata.
- Content Script: The content.js file is the core piece that runs in the context of webpages, enforcing the custom fonts and handling the fallback system.
- Popup Interface: popup.html and popup.js (supported by styles.css) build the UI that users interact with to configure the extension (setting primary and fallback fonts).

##### Relationships and Data Flow
- The manifest.json links the popup (user interface) and the content script. It specifies where content.js should be injected (i.e., on which webpages) and registers the popup.
- User interactions occur in the popup interface (popup.html and popup.js). When a user selects fonts and saves the settings, these selections are stored (likely through the browser's extension storage) and used to control the behavior of the content script.

##### Important Architectural Patterns and Design Principles
- Separation of Concerns: Different parts of the extension are dedicated to specific roles; the popup handles configuration, and the content script manages web page modifications.
- Modularity: Each file has a distinct purpose (UI, script injection, configuration, assets), making the extension maintainable.
- Reusability and Declarative Configuration: The manifest serves as the declarative configuration file that ties together the various components.

##### Technologies, Frameworks, or Libraries
- Chrome Extension APIs: Used within content.js and popup.js to interact with the browser.
- Standard HTML/CSS/JavaScript: For building the user interface in popup.html and managing styles in styles.css.

- Content Script interacting directly with “webpage” representations, indicating that it’s the element modifying the site’s font styling.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Manifest & Configuration Subgraph
    subgraph "Manifest & Configuration"
        MAN["Manifest"]:::config
        GVer["Google Verification"]:::config
        PP["Privacy Policy"]:::config
    end

    %% Popup Interface Subgraph
    subgraph "Popup Interface"
        PH["Popup HTML"]:::ui
        PJ["Popup JS"]:::ui
        PS["Stylesheet"]:::ui
    end

    %% Content Script Subgraph
    subgraph "Content Script"
        CS["Content Script"]:::script
    end

    %% Other Components
    ST["Extension Storage"]:::storage
    WP["Webpage (Modified)"]:::web

    %% Assets & Documentation Subgraph
    subgraph "Assets & Documentation"
        IC["Icons"]:::assets
        LIC["LICENSE"]:::assets
        RD["README"]:::assets
    end

    %% Connections
    MAN -->|"defines"| PH
    MAN -->|"injects"| CS
    PH -->|"saves"| ST
    ST -->|"updates"| CS
    CS -->|"modifies"| WP
    MAN -.->|"supports"| IC

    %% Click Events
    click MAN "https://github.com/sandipwane/custom-font-plus/blob/main/manifest.json"
    click GVer "https://github.com/sandipwane/custom-font-plus/blob/main/google9eb51814538804eb.html"
    click PP "https://github.com/sandipwane/custom-font-plus/blob/main/privacy-policy.md"
    click CS "https://github.com/sandipwane/custom-font-plus/blob/main/content.js"
    click PH "https://github.com/sandipwane/custom-font-plus/blob/main/popup.html"
    click PJ "https://github.com/sandipwane/custom-font-plus/blob/main/popup.js"
    click PS "https://github.com/sandipwane/custom-font-plus/blob/main/styles.css"
    click IC "https://github.com/sandipwane/custom-font-plus/tree/main/icons"
    click LIC "https://github.com/sandipwane/custom-font-plus/tree/main/LICENSE"
    click RD "https://github.com/sandipwane/custom-font-plus/blob/main/README.md"

    %% Styles
    classDef config fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef ui fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef script fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef storage fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef web fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef assets fill:#F5DEB3,stroke:#000,stroke-width:2px;
```
