# lemon0417/comicsscroller architecture

> Architecture diagram of the GitHub repository lemon0417/comicsscroller, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lemon0417/comicsscroller
- Repository: https://github.com/lemon0417/comicsscroller

## Overview

##### Project type and purpose
- ComicsScroller is a Chrome extension (an open-source tool) that:
- Injects a React/Redux-powered UI into comic websites to load entire chapters
- Auto-appends the next chapter when you scroll
- Manages subscriptions and notifies on updates
- Key tech: React, Redux, redux-observable (RxJS), Webpack, Jest

##### File structure
- Top-level build & config:
- webpack.config.dev.js / prod.js / bg.js – three build targets (dev server, production extension, background script)
- server.js + bin/dev – local Express‐based dev server for hot-reload of content pages
- .babelrc, postcss.config.js – transpilation & CSS
- src/
- css/ – raw styles
- js/
– component/ – presentational React components (ComicCard, ComicImage, Loading, etc.)
– container/ – Redux-connected “smart” components, each with its own reducers and epics
– epics/ – root RxJS middleware orchestration
– reducers/ – global & popup reducers
– store/ – configureStore & configurePopStore setups for reader vs. popup contexts
– background.js – long-lived background script handling subscriptions, notifications
– index.jsx, popup.jsx – entry points for the reader page & popup UI
- views/ – server‐side EJS templates for dev rendering of reader/popup/background
- package.json scripts: build & test pipelines
- Coverage/ tests/ mocks for Jest

##### Architecture at a glance
- Three extension contexts (bundles):
A. Content/Reader page (React app injected into comic sites)
B. Popup UI (subscription manager)
C. Background script (persistent event handlers + storage)
- Flux pattern everywhere:
- React view layer
- Redux store per context
- Epics (redux-observable) as middleware for async flows (fetching images, polling updates)

##### Components
a. Main components
1. Browser (Chrome host environment)
2. Extension Contexts:
- Content Script / Reader App
- Popup App
- Background Script
3. Redux Stores (one per context)
4. Remote Websites (comicbus.com, sfacg.com, dm5.com)
5. Chrome Storage / Notifications API
6. Dev Server & Webpack (development-time only)
b. Relationships & interactions
- Reader App ↔ Remote Website (HTTP fetch, parse HTML, extract image URLs via epics)
- Reader App → Redux Store → UI Components (ComicImage, ChapterList, etc.)
- Reader App → Background Script (chrome.runtime.sendMessage) to record “last chapter viewed”
- Background Script ↔ Chrome Storage (persist subscriptions, last‐read state)
- Background Script → Notification API (push “comic updated” alerts)
- Popup App ↔ Background Script (message passing) to manage subscriptions and display status
- Dev Server + Webpack → Bundles loaded into the above contexts during development
c. Architectural patterns & principles
- Separation of concerns: Presentational vs. Container components
- Middleware for side-effects: redux-observable / RxJS
- Multi‐context stores: isolate state per extension page
- Message passing as the only cross‐context communication channel
d. Key technologies & frameworks
- React 16+ for UI
- Redux for state management
- redux-observable & RxJS for asynchronous operations
- Webpack for bundling (three configs)
- Babel + Flow for static typing
- Jest for unit tests / coverage

##### Diagramming recommendations
- Green for Background Script
- Gray for external services (Comic Sites, Chrome Storage/API)
- Orange for Dev tools (Webpack, Dev Server)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Entities
    Browser["Chrome Browser"]:::external
    subgraph "External Services" 
        RemoteSites["Comic Websites (comicbus.com, sfacg.com, dm5.com)"]:::external
        ChromeAPIs["Chrome Storage / Notifications API"]:::external
    end

    %% Dev Tools
    subgraph "Development Tools" 
        DevServer["Dev Server (server.js / bin/dev)"]:::dev
        Webpack["Webpack (config.dev.js / prod.js / bg.js)"]:::dev
    end

    %% Reader Context
    subgraph "Reader App Context" 
        direction TB
        ReaderEntry["Entry Point\nindex.jsx"]:::ui
        ContainerApp["Container App\nsrc/js/container/App/index.jsx"]:::ui
        ReaderEpics["Epics\nsrc/js/epics/index.js"]:::ui
        ReaderStore["Reader Store\nconfigureStore.js"]:::ui
        subgraph "Presentational Components"
            ComicImage["ComicImage"]:::ui
            ComicCard["ComicCard"]:::ui
            Loading["Loading"]:::ui
        end
        ReaderEntry -->|boots| ReaderStore
        ReaderStore -->|uses| ReaderEpics
        ReaderStore -->|connects| ContainerApp
        ContainerApp -->|renders| ComicImage
        ContainerApp -->|renders| ComicCard
        ContainerApp -->|renders| Loading
        ContainerApp -->|"fetchChapter()"| RemoteSites
        RemoteSites -->|"image URLs"| ReaderEpics
        ReaderEpics -->|dispatch| ReaderStore
        ContainerApp -->|"chrome.runtime.sendMessage"| BackgroundScript
    end

    %% Popup Context
    subgraph "Popup App Context"
        direction TB
        PopupEntry["Entry Point\npopup.jsx"]:::ui
        PopupContainer["Container PopUpApp\nsrc/js/container/PopUpApp/index.jsx"]:::ui
        PopupStore["Popup Store\nconfigurePopStore.js"]:::ui
        PopupReducer["Popup Reducer\nsrc/js/reducers/popup.js"]:::ui
        PopupEntry -->|boots| PopupStore
        PopupStore -->|uses| PopupReducer
        PopupStore -->|connects| PopupContainer
        PopupContainer -->|"message passing"| BackgroundScript
    end

    %% Background Context
    subgraph "Background Script Context"
        direction TB
        BackgroundScript["Background Script\nbackground.js"]:::background
        BackgroundScript -->|persist| ChromeAPIs
        BackgroundScript -->|notify| ChromeAPIs
        BackgroundScript -->|"message passing"| PopupContainer
        BackgroundScript -->|"message passing"| ContainerApp
    end

    %% Dev Tools Connections
    DevServer -.->|hot reload| ReaderEntry
    DevServer -.->|hot reload| PopupEntry
    Webpack -.->|bundle reader/popup| ReaderEntry
    Webpack -.->|bundle bg| BackgroundScript

    %% Browser loading
    Browser -->|injects ReaderApp| ReaderEntry
    Browser -->|opens Popup UI| PopupEntry
    Browser -->|runs Background| BackgroundScript

    %% Click Events
    click ReaderEntry "https://github.com/lemon0417/comicsscroller/blob/master/src/js/index.jsx"
    click ContainerApp "https://github.com/lemon0417/comicsscroller/blob/master/src/js/container/App/index.jsx"
    click ReaderEpics "https://github.com/lemon0417/comicsscroller/blob/master/src/js/epics/index.js"
    click ReaderStore "https://github.com/lemon0417/comicsscroller/blob/master/src/js/store/configureStore.js"
    click ComicImage "https://github.com/lemon0417/comicsscroller/blob/master/src/js/component/ComicImage/index.jsx"
    click ComicCard "https://github.com/lemon0417/comicsscroller/blob/master/src/js/component/ComicCard/index.jsx"
    click Loading "https://github.com/lemon0417/comicsscroller/blob/master/src/js/component/Loading/index.jsx"
    click PopupEntry "https://github.com/lemon0417/comicsscroller/blob/master/src/js/popup.jsx"
    click PopupContainer "https://github.com/lemon0417/comicsscroller/blob/master/src/js/container/PopUpApp/index.jsx"
    click PopupStore "https://github.com/lemon0417/comicsscroller/blob/master/src/js/store/configurePopStore.js"
    click PopupReducer "https://github.com/lemon0417/comicsscroller/blob/master/src/js/reducers/popup.js"
    click BackgroundScript "https://github.com/lemon0417/comicsscroller/blob/master/src/js/background.js"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366D6,stroke-width:1px
    classDef background fill:#DFF2BF,stroke:#4F8A10,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#888,stroke-width:1px
    classDef dev fill:#FFE0B2,stroke:#FF9800,stroke-width:1px
```
