# enrych/toppings architecture

> Architecture diagram of the GitHub repository enrych/toppings, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/enrych/toppings
- Repository: https://github.com/enrych/toppings

## Overview

##### Detailed Component Breakdown

Browser Extension:
- Background Service
- Context Management
- Store
- Content Scripts
- Playlist Handler
- Shorts Handler
- Watch Page Handler
- Popup Interface
- Options Interface

Backend Service:
- Cloudflare Worker
- Playlist Route
- Duration Parser
- YouTube API Integration

Website:
- Next.js Pages
- Landing
- Greetings
- Farewell
- Shared Components

##### Important Elements

- Communication patterns between background scripts and content scripts
- API endpoints and their purposes
- Storage mechanisms and state management
- Browser extension entry points (content script injection points)

##### Technical Details to Highlight

- TypeScript usage across all components
- React components in the extension UI
- Cloudflare Workers for serverless backend
- Next.js for the marketing website
- Localization support system

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Browser Extension"
        BG["Background Service"]
        CM["Context Management"]:::bgService
        ST["Store"]:::bgService
        
        subgraph "Content Scripts"
            PH["Playlist Handler"]:::contentScript
            SH["Shorts Handler"]:::contentScript
            WH["Watch Page Handler"]:::contentScript
        end
        
        subgraph "User Interface"
            POP["Popup Interface"]:::ui
            OPT["Options Interface"]:::ui
            LOC["Localization System"]:::ui
        end
        
        BG --> CM
        BG --> ST
        CM <--> PH
        CM <--> SH
        CM <--> WH
    end
    
    subgraph "Backend Service"
        CFW["Cloudflare Worker"]:::backend
        PR["Playlist Route"]:::backend
        DP["Duration Parser"]:::backend
        YTAPI["YouTube API"]:::external
        
        CFW --> PR
        PR --> DP
        PR <--> YTAPI
    end
    
    subgraph "Marketing Website"
        NJS["Next.js App"]:::website
        LP["Landing Page"]:::website
        GP["Greetings Page"]:::website
        FP["Farewell Page"]:::website
        
        subgraph "Shared Components"
            NAV["Navbar"]:::website
            FTR["Footer"]:::website
            CTA["Call To Action"]:::website
        end
        
        NJS --> LP
        NJS --> GP
        NJS --> FP
        NJS --> NAV
        NJS --> FTR
        NJS --> CTA
    end
    
    PH <--> CFW
    SH <--> CFW
    WH <--> CFW
    
    %% Click Events
    click BG "https://github.com/enrych/toppings/blob/main/web-ext/src/background/index.ts"
    click CM "https://github.com/enrych/toppings/blob/main/web-ext/src/background/context.ts"
    click ST "https://github.com/enrych/toppings/blob/main/web-ext/src/background/store.ts"
    click PH "https://github.com/enrych/toppings/blob/main/web-ext/src/content_scripts/pages/playlist.tsx"
    click SH "https://github.com/enrych/toppings/blob/main/web-ext/src/content_scripts/pages/shorts.tsx"
    click WH "https://github.com/enrych/toppings/blob/main/web-ext/src/content_scripts/pages/watch.tsx"
    click POP "https://github.com/enrych/toppings/blob/main/web-ext/src/popup/App.tsx"
    click OPT "https://github.com/enrych/toppings/blob/main/web-ext/src/options/App.tsx"
    click LOC "https://github.com/enrych/toppings/blob/main/web-ext/src/_locales/en/messages.json"
    click CFW "https://github.com/enrych/toppings/blob/main/backend/src/index.ts"
    click PR "https://github.com/enrych/toppings/blob/main/backend/src/routes/playlist.ts"
    click DP "https://github.com/enrych/toppings/blob/main/backend/src/lib/parseDuration.ts"
    click LP "https://github.com/enrych/toppings/blob/main/website/app/page.tsx"
    click GP "https://github.com/enrych/toppings/blob/main/website/app/greetings/page.tsx"
    click FP "https://github.com/enrych/toppings/blob/main/website/app/farewell/page.tsx"
    click NAV "https://github.com/enrych/toppings/blob/main/website/components/Navbar.tsx"
    click FTR "https://github.com/enrych/toppings/blob/main/website/components/Footer.tsx"
    click CTA "https://github.com/enrych/toppings/blob/main/website/components/CallToAction.tsx"
    
    %% Styling
    classDef bgService fill:#2196F3,color:white
    classDef contentScript fill:#42A5F5,color:white
    classDef ui fill:#64B5F6,color:white
    classDef backend fill:#4CAF50,color:white
    classDef external fill:#9C27B0,color:white
    classDef website fill:#FF9800,color:white
    
    %% Legend
    subgraph Legend
        L1["Background Service"]:::bgService
        L2["Content Script"]:::contentScript
        L3["UI Component"]:::ui
        L4["Backend Service"]:::backend
        L5["External Service"]:::external
        L6["Website Component"]:::website
    end
```
