# radiantbeing/medium-kr-font-extension architecture

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

- Interactive diagram: https://gitdiagram.com/radiantbeing/medium-kr-font-extension
- Repository: https://github.com/radiantbeing/medium-kr-font-extension

## Overview

##### Project Type Analysis
This is a Chrome Browser Extension that modifies the font rendering on Medium.com websites. The project has a specific purpose of injecting Korean fonts into Medium's website.

##### Main Components

A. Browser Components:
- Chrome Browser
- Extension Popup UI
- Content Script
- Service Worker (Background Script)

B. Resource Components:
- Font Files Repository
- Settings Storage
- Font Injection System

**Top Layer: User Interface**
**Middle Layer: Extension Core**
**Bottom Layer: Target Website**

##### Component Relationships

a) User Interaction Flow:
- User → Popup Interface → Settings Storage
- Settings Storage → Content Script → Page Modification

b) Font Implementation Flow:
- Font Files → Content Script → Medium.com DOM

##### Specific Implementation Details

Technical aspects:
- URL Pattern Matching (*.medium.com/*)
- Font Categories (Sans Serif, Serif, Monospace)
- Storage Management
- DOM Manipulation

##### Key Elements to Highlight

**┌─ Chrome Browser ─────────────────────┐**

- ┌─ Extension UI ─┐   ┌─ Medium.com ─┐
- Popup         │   │ Modified DOM │
- Font Selector │   │ Custom Fonts │
- ┘   └─────────────┘

- ┌─ Extension Core ────────────────┐ │
- Content Script                  │ │
- Service Worker                  │ │
- Font Management                 │ │
- ┘ │

- ┌─ Resources ───────────────────┐  │
- Font Files                    │  │
- Settings Storage              │  │
- ┘ │
- ┘

##### Important Notes

- Clear separation between extension components and the target website
- Font injection flow
- URL pattern matching mechanism
- Storage and settings management
- Supported font categories
- Automatic monospace font application for code blocks

##### Technical Details

- TypeScript implementation
- Webpack bundling process
- Chrome Extension Manifest V3 architecture
- Content Script injection points
- Service Worker event handling

Remember to maintain a balance between technical detail and clarity, focusing on the extension's primary purpose of font management and injection while showing the complete system architecture.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Browser
        Chrome["Chrome Browser"]
        
        subgraph ExtensionUI
            Popup["Extension Popup UI"]:::ui
            FontSelector["Font Selector"]:::ui
        end
        
        subgraph ExtensionCore
            ServiceWorker["Service Worker"]:::core
            ContentScript["Content Script"]:::core
            FontManagement["Font Management"]:::core
            Settings["Settings Storage"]:::storage
            Logger["Logging System"]:::core
        end
        
        subgraph Resources
            FontFiles["Font Files Repository"]:::resource
            subgraph Fonts
                SansKR["Noto Sans KR"]:::font
                SerifKR["Noto Serif KR"]:::font
                Mono["JetBrains Mono"]:::font
                Pretendard["Pretendard Variable"]:::font
            end
        end
        
        subgraph TargetWebsite
            MediumDOM["Medium.com DOM"]:::website
            CodeBlocks["Code Blocks"]:::website
        end
    end
    
    %% Relationships
    Chrome --> ExtensionUI
    Chrome --> TargetWebsite
    
    Popup --> Settings
    FontSelector --> Settings
    
    Settings --> ContentScript
    ServiceWorker --> ContentScript
    FontManagement --> ContentScript
    Logger --> ContentScript
    
    FontFiles --> FontManagement
    Fonts --> FontManagement
    
    ContentScript --> MediumDOM
    ContentScript --> CodeBlocks
    
    %% Styling
    classDef ui fill:#2196F3,stroke:#1565C0,color:white
    classDef core fill:#4CAF50,stroke:#2E7D32,color:white
    classDef resource fill:#FF9800,stroke:#F57C00,color:white
    classDef storage fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef website fill:#795548,stroke:#4E342E,color:white
    classDef font fill:#FF5722,stroke:#D84315,color:white
    
    %% Click Events
    click Popup "https://github.com/radiantbeing/medium-kr-font-extension/blob/main/public/popup.html"
    click ContentScript "https://github.com/radiantbeing/medium-kr-font-extension/blob/main/src/content-script.ts"
    click ServiceWorker "https://github.com/radiantbeing/medium-kr-font-extension/blob/main/src/service-worker.ts"
    click FontManagement "https://github.com/radiantbeing/medium-kr-font-extension/blob/main/src/libs/fonts.ts"
    click Settings "https://github.com/radiantbeing/medium-kr-font-extension/blob/main/src/libs/settings.ts"
    click FontFiles "https://github.com/radiantbeing/medium-kr-font-extension/tree/main/public/fonts/"
    click SansKR "https://github.com/radiantbeing/medium-kr-font-extension/tree/main/public/fonts/NotoSansKR/"
    click SerifKR "https://github.com/radiantbeing/medium-kr-font-extension/tree/main/public/fonts/NotoSerifKR/"
    click Mono "https://github.com/radiantbeing/medium-kr-font-extension/tree/main/public/fonts/JetBrainsMono/"
    click Pretendard "https://github.com/radiantbeing/medium-kr-font-extension/tree/main/public/fonts/PretendardVariable/"
    click Logger "https://github.com/radiantbeing/medium-kr-font-extension/blob/main/src/libs/log.ts"
```
