# jonghakseo/chrome-extension-boilerplate-react-vite architecture

> Architecture diagram of the GitHub repository jonghakseo/chrome-extension-boilerplate-react-vite, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jonghakseo/chrome-extension-boilerplate-react-vite
- Repository: https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite

## Overview

##### Main Components
- Chrome Extension Core:
- Pages Layer:
- Under “pages/”, there are folders for different extension entry points: content scripts (pages/content, pages/content-ui, pages/content-runtime), popup, options, new-tab, side-panel, devtools, and devtools-panel. Each is built as its own mini-application that integrates with the extension manifest.
- Shared and Utility Packages:
- The “packages/” directory includes several modules that handle various concerns:
▪ dev-utils – helper utilities like manifest parsing and logging.
▪ env – environment variable management.
▪ hmr – custom hot module reload mechanism for fast development.
▪ i18n – internationalization support.
▪ shared – common React components, hooks, types, and utilities.
▪ storage – abstractions over Chrome extension storage (local/session).
▪ tailwind-config – shared TailwindCSS setup.
▪ tsconfig, ui, vite-config, zipper, and module-manager provide shared configuration, UI merging, build systems, and module management.
- Build & Development Tools:
- Bash scripts provide automation for environment management and version updates.
- The “tests” directory contains end-to-end testing setups with WebdriverIO.

##### Relationships and Data Flow
- The Chrome extension’s Manifest (generated from chrome-extension/manifest.ts) serves as the coordination point dictating which pages (content, popup, options, etc.) are loaded.
- Each “pages” component is bundled separately via Vite with its own configuration (vite.config.mts) and then referenced within the manifest.
- The shared “packages” provide common functionality to be consumed by both the chrome-extension scripts and pages. This modular approach lets these components share types, environment variables, styling (via Tailwind), and HMR behaviors.
- Development and build processes (controlled by Turborepo, pnpm, and rollup configurations) manage building all packages and pages in a coordinated manner.
- Additionally, there are separate testing flows defined under “tests/e2e” that simulate user interactions across these components.

##### Architectural Patterns and Design Principles
- Modular Architecture with separation of concerns:
- Splitting extension-specific code (chrome-extension), runtime pages, and shared libraries (packages) leads to high modularity and reusability.
- Monorepo management:
- Turborepo is used to manage interdependent packages and simplify dependency management.
- Micro-frontend elements:
- Each page (popup, options, new-tab, etc.) functions as an individual mini-application that interacts via the Chrome extension runtime.
- Build and Dev Workflow Separation:
- Dedicated configurations and scripts for development (HMR, vite-dev server) and production builds, with CI workflows to enforce code quality (lint, prettier, etc.).

##### Relevant Technologies and Tools
- Frontend framework: React (for building UI in pages like popup, options, etc.).
- Language: TypeScript.
- Bundler: Vite (with Rollup for production builds).
- Styling: TailwindCSS.
- Automation: Bash scripts, Turborepo, pnpm.
- Testing: WebdriverIO (for E2E tests).
- Others: Prettier, ESLint, custom plugins (HMR, module-manager, i18n).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Aggregator Nodes
    BT["Build & Dev Tools"]
    SPAG["Shared Packages"]
    COREAG["Chrome Extension Core"]
    PAGEAG["Pages Layer"]
    E2E["End-to-End Testing"]

    BT --> SPAG
    BT --> COREAG
    BT --> PAGEAG
    SPAG --> COREAG
    SPAG --> PAGEAG
    COREAG --> PAGEAG
    PAGEAG --> E2E

    %% Subgraph: Shared and Utility Packages
    subgraph "Shared and Utility Packages"
        DEVUTIL["dev-utils"]
        ENV["env"]
        HMR["hmr"]
        I18N["i18n"]
        SHARED["shared"]
        STORAGE["storage"]
        TAILWIND["tailwind-config"]
        TSCONFIG["tsconfig"]
        UI["ui"]
        VITECONFIG["vite-config"]
        ZIPPER["zipper"]
        MODULEMGR["module-manager"]
    end

    %% Subgraph: Chrome Extension Core
    subgraph "Chrome Extension Core"
        CORE["Chrome Extension Core (manifest.ts, background, assets, vite.config.mts)"]
    end

    %% Subgraph: Pages
    subgraph "Pages"
        CONTENT["Content (pages/content)"]
        CONTENTUI["Content UI (pages/content-ui)"]
        CONTENTRUNTIME["Content Runtime (pages/content-runtime)"]
        POPUP["Popup Page (pages/popup)"]
        OPTIONS["Options Page (pages/options)"]
        NEWTAB["New Tab Page (pages/new-tab)"]
        SIDEPANEL["Side Panel Page (pages/side-panel)"]
        DEVTOOLS["Devtools Page (pages/devtools)"]
        DEVTOOLSPANEL["Devtools Panel Page (pages/devtools-panel)"]
    end

    %% Click Events for Aggregator Nodes
    click BT "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/bash-scripts"
    click E2E "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/tests/e2e"

    %% Click Events for Chrome Extension Core
    click CORE "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/chrome-extension"

    %% Click Events for Pages
    click CONTENT "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/pages/content"
    click CONTENTUI "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/pages/content-ui"
    click CONTENTRUNTIME "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/pages/content-runtime"
    click POPUP "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/pages/popup"
    click OPTIONS "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/pages/options"
    click NEWTAB "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/pages/new-tab"
    click SIDEPANEL "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/pages/side-panel"
    click DEVTOOLS "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/pages/devtools"
    click DEVTOOLSPANEL "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/pages/devtools-panel"

    %% Click Events for Shared and Utility Packages
    click DEVUTIL "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/packages/dev-utils"
    click ENV "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/packages/env"
    click HMR "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/packages/hmr"
    click I18N "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/packages/i18n"
    click SHARED "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/packages/shared"
    click STORAGE "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/packages/storage"
    click TAILWIND "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/packages/tailwind-config"
    click TSCONFIG "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/packages/tsconfig"
    click UI "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/packages/ui"
    click VITECONFIG "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/packages/vite-config"
    click ZIPPER "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/packages/zipper"
    click MODULEMGR "https://github.com/jonghakseo/chrome-extension-boilerplate-react-vite/tree/main/packages/module-manager"

    %% Styles
    class BT build
    class SPAG shared
    class COREAG core
    class PAGEAG page
    class E2E e2e

    class DEVUTIL,ENV,HMR,I18N,SHARED,STORAGE,TAILWIND,TSCONFIG,UI,VITECONFIG,ZIPPER,MODULEMGR shared
    class CORE core
    class CONTENT,CONTENTUI,CONTENTRUNTIME,POPUP,OPTIONS,NEWTAB,SIDEPANEL,DEVTOOLS,DEVTOOLSPANEL page

    classDef build fill:#ffeb3b,stroke:#fbc02d,stroke-width:2px;
    classDef shared fill:#bbdefb,stroke:#64b5f6,stroke-width:2px;
    classDef core fill:#c8e6c9,stroke:#66bb6a,stroke-width:2px;
    classDef page fill:#f8bbd0,stroke:#f06292,stroke-width:2px;
    classDef e2e fill:#d1c4e9,stroke:#9575cd,stroke-width:2px;
```
