# hamachi25/pixiv-infinite-scroll architecture

> Architecture diagram of the GitHub repository hamachi25/pixiv-infinite-scroll, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hamachi25/pixiv-infinite-scroll
- Repository: https://github.com/hamachi25/pixiv-infinite-scroll

## Overview

##### Main Components
- Content Script Injection:
- “content” entry point (src/entrypoints/content). This part is responsible for modifying or extending the Pixiv pages. It includes components for various features like following lists, grid illustrations, novels, and profile popups.
- Options Page:
- “options” entry point (src/entrypoints/options) that provides users a settings interface. Note the components that handle tag/user mute sections and UI elements like Add, Delete, Import/Export buttons.
- Popup Interface:
- Main World Injection:
- “main-world.content” component (src/entrypoints/main-world.content) which potentially enables running scripts in the same execution context as the page.
- Supporting Modules:
- Shared utilities and libraries (e.g., messaging, storage, data fetching in “fetch” folders, and utility functions for URL generation and style injection).
- “locales” folder—marked for translation support—and “types” folder for type definitions.
- Build and Deployment:
- Build and CI/CD configuration components, such as GitHub workflows (.github directory), Husky pre-commit hooks, linting configurations (eslint, commitlint), and package management files (package.json, pnpm-lock.yaml).

##### Relationships and Interactions
- Data Flow:
- Messaging or communication flows between the different entry points (content scripts may communicate with the popup or options page if needed).
- Configuration and Build:
- That the build process (using pnpm with commands for dev, build, and zip) compiles/transpiles and bundles the various entry points separately.
- Localization:
- A block for “locales” to indicate that the UI is internationalized.

##### Architectural Patterns and Design Principles
- The project follows a modular structure by separating different functionalities into distinct entry points.
- The UI layer is component-based (React) with clear separation of concerns (UI components, feature pages, utilities).
- There is an emphasis on maintainability with isolated concerns for fetching, data transformation, and messaging.
- The integration with browser extension APIs (as seen from the extension’s installation instructions and build outputs, such as the .output folder) is a core design element.

## Diagram (Mermaid)

```mermaid
flowchart TD
    EXT["Pixiv Infinite Scroll Extension"]:::blue

    %% Main Entry Points
    EXT --> CS_Inj
    EXT --> OP_Inj
    EXT --> PU_Inj
    EXT --> MW
    EXT --> BUILD

    %% Content Script (Infinite Scroll UI)
    subgraph "Content Script (Infinite Scroll UI)"
        CS_Inj["Content Script Injection"]:::blue
        CS_App["Content UI App (App.tsx)"]:::blue
        CS_Pages["Content Pages (/pages)"]:::blue
        CS_Following["Following Feature"]:::blue
        CS_Grid["Grid Illustrations Feature"]:::blue
        CS_Novel["Novel Feature"]:::blue
        CS_Profile["Profile Popup Feature"]:::blue
        CS_UI["Shared UI (Icons & UI)"]:::blue
        CS_Fetch["Data Fetching Modules"]:::green
        CS_Utils["Utility Functions"]:::green
    end

    CS_Inj --> CS_App
    CS_App --> CS_Pages
    CS_App --> CS_Fetch
    CS_App --> CS_Utils
    CS_App --> CS_UI
    CS_App --> CS_Following
    CS_App --> CS_Grid
    CS_App --> CS_Novel
    CS_App --> CS_Profile

    %% Options Page (Settings)
    subgraph "Options Page (Settings)"
        OP_Inj["Options Page"]:::blue
        OP_App["Options App (App.tsx)"]:::blue
        OP_Comp["Options Components"]:::blue
    end

    OP_Inj --> OP_App
    OP_App --> OP_Comp

    %% Popup UI
    subgraph "Popup UI"
        PU_Inj["Popup Interface"]:::blue
        PU_App["Popup UI App (App.tsx)"]:::blue
        PU_Comp["Popup Components"]:::blue
    end

    PU_Inj --> PU_App
    PU_App --> PU_Comp

    %% Separate Entry Points and Supporting Modules
    MW["Main-World Script Injection"]:::blue
    BUILD["Build & Deployment (CI/CD, Config)"]:::orange

    LOC["Localization Module"]:::green
    TYP["Shared Type Definitions"]:::green
    SUPUTIL["Supporting Utilities"]:::green

    %% Interactions and Data Flow
    CS_Fetch -->|"updatesUI"| CS_UI
    OP_App -->|"configUpdate"| CS_App
    PU_App -->|"userAction"| CS_App

    LOC --- CS_App
    LOC --- OP_App
    LOC --- PU_App

    TYP --- CS_App
    TYP --- OP_App
    TYP --- PU_App

    SUPUTIL --- CS_App
    SUPUTIL --- OP_App
    SUPUTIL --- PU_App

    BUILD -->|"buildsBundle"| CS_Inj
    BUILD -->|"buildsBundle"| OP_Inj
    BUILD -->|"buildsBundle"| PU_Inj
    BUILD -->|"buildsBundle"| MW

    %% Styles
    classDef blue fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px,color:#0D47A1;
    classDef green fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px,color:#2E7D32;
    classDef orange fill:#FFE0B2,stroke:#EF6C00,stroke-width:2px,color:#EF6C00;

    %% Click Events
    click CS_Inj "https://github.com/hamachi25/pixiv-infinite-scroll/tree/main/src/entrypoints/content"
    click CS_App "https://github.com/hamachi25/pixiv-infinite-scroll/blob/main/src/entrypoints/content/App.tsx"
    click CS_Pages "https://github.com/hamachi25/pixiv-infinite-scroll/tree/main/src/entrypoints/content/pages"
    click CS_Following "https://github.com/hamachi25/pixiv-infinite-scroll/tree/main/src/entrypoints/content/components/features/Following"
    click CS_Grid "https://github.com/hamachi25/pixiv-infinite-scroll/tree/main/src/entrypoints/content/components/features/GridIllusts"
    click CS_Novel "https://github.com/hamachi25/pixiv-infinite-scroll/tree/main/src/entrypoints/content/components/features/Novel"
    click CS_Profile "https://github.com/hamachi25/pixiv-infinite-scroll/tree/main/src/entrypoints/content/components/features/ProfilePopup"
    click CS_UI "https://github.com/hamachi25/pixiv-infinite-scroll/tree/main/src/entrypoints/content/components/ui"
    click CS_Fetch "https://github.com/hamachi25/pixiv-infinite-scroll/tree/main/src/entrypoints/content/fetch"
    click CS_Utils "https://github.com/hamachi25/pixiv-infinite-scroll/tree/main/src/entrypoints/content/utils"
    click MW "https://github.com/hamachi25/pixiv-infinite-scroll/blob/main/src/entrypoints/main-world.content/index.ts"
    click OP_Inj "https://github.com/hamachi25/pixiv-infinite-scroll/tree/main/src/entrypoints/options"
    click OP_App "https://github.com/hamachi25/pixiv-infinite-scroll/blob/main/src/entrypoints/options/App.tsx"
    click OP_Comp "https://github.com/hamachi25/pixiv-infinite-scroll/tree/main/src/entrypoints/options/components"
    click PU_Inj "https://github.com/hamachi25/pixiv-infinite-scroll/tree/main/src/entrypoints/popup"
    click PU_App "https://github.com/hamachi25/pixiv-infinite-scroll/blob/main/src/entrypoints/popup/App.tsx"
    click PU_Comp "https://github.com/hamachi25/pixiv-infinite-scroll/tree/main/src/entrypoints/popup/components"
    click LOC "https://github.com/hamachi25/pixiv-infinite-scroll/tree/main/src/locales"
    click TYP "https://github.com/hamachi25/pixiv-infinite-scroll/tree/main/src/types"
    click SUPUTIL "https://github.com/hamachi25/pixiv-infinite-scroll/tree/main/src/utils"
    click BUILD "https://github.com/hamachi25/pixiv-infinite-scroll/blob/main/package.json"
```
