# ducdev/aliexscrape architecture

> Architecture diagram of the GitHub repository ducdev/aliexscrape, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ducdev/aliexscrape
- Repository: https://github.com/ducdev/aliexscrape

## Overview

aliexscrape is a small AliExpress product scraper. Its main workflow accepts a product ID through either the JavaScript API or CLI, fetches the product page, extracts product and variation details, fetches and cleans the description, and returns JSON. These stages are implemented in index.js rather than separate modules; the source excerpt shows the requests and parsing flow. The CLI delegates to the same API.

Main entry points: [`index.js`](https://github.com/ducdev/aliexscrape/blob/master/index.js) (Scraper API), [`cli.js`](https://github.com/ducdev/aliexscrape/blob/master/cli.js) (CLI entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_api_user(("API caller"))
node_cli_user(("CLI user"))
node_cli["CLI entry<br/>[cli.js]"]
node_scraper["Scraper API<br/>[index.js]"]
node_product_page["Product page"]
node_extract["Product extraction<br/>[index.js]"]
node_description_fetch["Description fetch<br/>[index.js]"]
node_description_source["Description source"]
node_description_clean["Description cleanup<br/>[index.js]"]
node_json_result["JSON result"]

node_api_user -->|"calls with ID"| node_scraper
node_cli_user -->|"runs scrape"| node_cli
node_cli -->|"calls"| node_scraper
node_scraper -->|"requests page"| node_product_page
node_product_page -->|"returns HTML"| node_extract
node_extract -->|"requests description"| node_description_fetch
node_description_fetch -->|"fetches source"| node_description_source
node_description_source -->|"returns content"| node_description_clean
node_description_clean -->|"serializes data"| node_json_result
node_scraper -->|"returns result"| node_json_result

click node_cli "https://github.com/ducdev/aliexscrape/blob/master/cli.js"
click node_scraper "https://github.com/ducdev/aliexscrape/blob/master/index.js"
click node_extract "https://github.com/ducdev/aliexscrape/blob/master/index.js"
click node_description_fetch "https://github.com/ducdev/aliexscrape/blob/master/index.js"
click node_description_clean "https://github.com/ducdev/aliexscrape/blob/master/index.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api_user,node_scraper toneMint
class node_cli_user toneBlue
class node_cli,node_extract,node_description_fetch,node_description_clean toneTeal
class node_product_page,node_description_source,node_json_result toneIndigo
```

## Components

### Other components

- **API caller**
- **CLI user**
- [CLI entry](https://github.com/ducdev/aliexscrape/blob/master/cli.js): `cli.js`
- [Scraper API](https://github.com/ducdev/aliexscrape/blob/master/index.js): `index.js`
- **Product page**
- [Product extraction](https://github.com/ducdev/aliexscrape/blob/master/index.js): `index.js`
- [Description fetch](https://github.com/ducdev/aliexscrape/blob/master/index.js): `index.js`
- **Description source**
- [Description cleanup](https://github.com/ducdev/aliexscrape/blob/master/index.js): `index.js`
- **JSON result**

## Connections

- API caller → Scraper API: calls with ID (evidence: `README.md`)
- CLI user → CLI entry: runs scrape (evidence: `README.md`)
- CLI entry → Scraper API: calls (evidence: `cli.js`)
- Scraper API → Product page: requests page (evidence: `index.js`)
- Product page → Product extraction: returns HTML (evidence: `index.js`)
- Product extraction → Description fetch: requests description (evidence: `index.js`)
- Description fetch → Description source: fetches source (evidence: `index.js`)
- Description source → Description cleanup: returns content (evidence: `index.js`)
- Description cleanup → JSON result: serializes data (evidence: `index.js`)
- Scraper API → JSON result: returns result (evidence: `README.md`)
