# 0xissam/aliexpress-links-scraper architecture

> Architecture diagram of the GitHub repository 0xissam/aliexpress-links-scraper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/0xissam/aliexpress-links-scraper
- Repository: https://github.com/0xissam/aliexpress-links-scraper

## Overview

##### Project Type and Purpose
- Type: Chrome browser extension (client-side tool).
- Purpose: Provide a small popup UI that, on user request, scrapes product links from an active AliExpress page and copies them to the clipboard.

##### File Structure
- Top‐level directory “Aliexpress Links Scraper” holds:
- manifest.json – metadata, permissions, entry points
- popup.html, popup.css – UI layer
- popup.js – main logic
- No backend or external servers—everything runs in the user’s browser.

##### Pull Insights from README
- Defines three link‐count options (50, 100, 500).

##### Main Components & Their Roles
A. manifest.json
- User interaction trigger.
C. Popup UI (popup.html + popup.css)
- Renders radio buttons and “Copy” button.
D. Popup Script (popup.js)
- Listens for UI events.
- Invokes chrome.tabs.executeScript or chrome.scripting.executeScript to inject or run scraping code in the context of the active tab.
- Receives scraped links (via callback or message).
- Uses Clipboard API or chrome.clipboard to copy results.
- Sends a success notification back to the UI.
E. Content‐injected Script (may be inline in popup.js or separate)
- Runs in the page’s DOM context.
- Queries document for product link elements.
- Extracts hrefs up to the user‐selected count.
- Returns array of links to popup.js.
F. Active Tab / AliExpress Web Page
- The runtime environment whose DOM is scraped.
G. Clipboard (OS clipboard service)
- Final data sink for links.

##### Data Flow & Interactions
2. popup.js attaches event handlers to radio buttons + “Copy”.
3. On “Copy” click → popup.js calls chrome.tabs.executeScript / chrome.scripting.executeScript in the active tab.
4. Content script runs, scrapes DOM, and returns results to popup.js.
5. popup.js writes links to the clipboard.
6. popup.js updates the popup UI with a success message.

##### Architectural Patterns & Principles
- Single-page popup UI for minimal surface area.
- Separation of concerns: manifest → config, popup.html/css → view, popup.js → controller/logic, injected script → model (DOM scraping).
- Message‐passing via Chrome’s extension API to bridge popup and page contexts.
- No persistent storage or backend—fully client-side.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Components
    M["manifest.json"]:::script
    Icon["Browser Toolbar / Extension Icon"]:::external
    subgraph "Popup UI"
        popupHTML["popup.html"]:::ui
        popupCSS["popup.css"]:::ui
    end
    popupJS["popup.js"]:::script
    contentScript["Content Script"]:::script
    activeTab["Active Tab DOM (AliExpress Page)"]:::external
    clipboard["Clipboard (OS)"]:::external

    %% Data Flow
    M -->|"loads popup.html entryPoint"| Icon
    Icon -->|"user click"| popupHTML
    popupHTML -->|"UI event"| popupJS
    popupJS -->|"chrome.scripting.executeScript"| contentScript
    contentScript -->|"returns links"| popupJS
    popupJS -->|"writes links"| clipboard
    popupJS -->|"update success"| popupHTML

    %% Click Events
    click M "https://github.com/0xissam/aliexpress-links-scraper/blob/main/Aliexpress Links Scraper/manifest.json"
    click Icon "https://github.com/0xissam/aliexpress-links-scraper/tree/main/Aliexpress Links Scraper/images/"
    click popupHTML "https://github.com/0xissam/aliexpress-links-scraper/blob/main/Aliexpress Links Scraper/popup.html"
    click popupCSS "https://github.com/0xissam/aliexpress-links-scraper/blob/main/Aliexpress Links Scraper/popup.css"
    click popupJS "https://github.com/0xissam/aliexpress-links-scraper/blob/main/Aliexpress Links Scraper/popup.js"

    %% Styles
    classDef ui fill:#f9f,stroke:#333,stroke-width:2
    classDef script fill:#bbf,stroke:#333,stroke-width:2
    classDef external fill:#bfb,stroke:#333,stroke-width:2
```
