# ndgigliotti/shopify-spy architecture

> Architecture diagram of the GitHub repository ndgigliotti/shopify-spy, 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/ndgigliotti/shopify-spy
- Repository: https://github.com/ndgigliotti/shopify-spy

## Overview

Shopify Spy is a Python library and CLI for collecting product and collection data from ecommerce stores. A user supplies store URLs and scrape options; the API hands the run to its runner, which detects or uses a platform adapter, fetches store data, and yields items with per-store results and failure diagnostics. Users can write results in several formats, including a unified tabular schema. The README documents platform coverage, images, collections, and network politeness; sampled source and the source index support the main call relationships, but not every adapter’s internals.

Main entry points: [`shopify_spy/_runner.py`](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_runner.py) (Run orchestration), [`shopify_spy/_session.py`](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_session.py) (Store request session), [`shopify_spy/_export.py`](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_export.py) (File exporters), [`shopify_spy/_api.py`](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_api.py) (Scrape API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and orchestration"]
  node_api["Scrape API<br/>[_api.py]"]
  node_cli["Command line<br/>[cli.py]"]
  node_runner["Run orchestration<br/>[_runner.py]"]
  node_detect["Platform detection<br/>[_detect.py]"]
end

subgraph group_platforms["Store adapters"]
  node_shopify["Shopify adapter<br/>[_shopify.py]"]
  node_woocommerce["WooCommerce adapter<br/>[_woocommerce.py]"]
  node_magento["Magento adapter<br/>[_magento.py]"]
  node_bigcommerce["BigCommerce adapter<br/>[_bigcommerce.py]"]
  node_squarespace["Squarespace adapter<br/>[_squarespace.py]"]
  node_generic["Generic adapter<br/>[_generic.py]"]
  node_sitemap["Sitemap discovery<br/>[_sitemap.py]"]
  node_jsonld["JSON-LD parsing<br/>[_jsonld.py]"]
  node_microdata["Microdata parsing<br/>[_microdata.py]"]
end

subgraph group_network["Request handling"]
  node_session["Store request session<br/>[_session.py]"]
  node_policy["Politeness and retries<br/>[_policy.py]"]
  node_fetch["HTTP transport<br/>[_fetch.py]"]
end

subgraph group_results["Results and output"]
  node_results["Run results<br/>[_results.py]"]
  node_summary["Product summaries<br/>[_summary.py]"]
  node_flatten["Unified row schema<br/>[_flatten.py]"]
  node_export["File exporters<br/>[_export.py]"]
  node_xlsx["Excel writer<br/>[_xlsx.py]"]
end

node_user(("CLI or library user"))
node_store(("Ecommerce stores"))
node_output["JSON, CSV, XLSX, XML"]

node_user -->|"runs command"| node_cli
node_user -->|"calls library"| node_api
node_cli -->|"invokes scrape"| node_api
node_api -->|"starts run"| node_runner
node_runner -->|"detects platform"| node_detect
node_runner -->|"dispatches"| node_shopify
node_runner -->|"dispatches"| node_woocommerce
node_runner -->|"dispatches"| node_magento
node_runner -->|"dispatches"| node_bigcommerce
node_runner -->|"dispatches"| node_squarespace
node_runner -->|"dispatches"| node_generic
node_runner -->|"creates sessions"| node_session
node_runner -->|"records status"| node_results
node_detect -->|"probes store"| node_store
node_shopify -->|"requests data"| node_session
node_woocommerce -->|"requests data"| node_session
node_magento -->|"requests data"| node_session
node_bigcommerce -->|"requests data"| node_session
node_squarespace -->|"requests data"| node_session
node_generic -->|"discovers pages"| node_sitemap
node_generic -->|"parses products"| node_jsonld
node_jsonld -->|"parses markup"| node_microdata
node_session -->|"applies policies"| node_policy
node_session -->|"sends requests"| node_fetch
node_session -->|"fetches pages"| node_store
node_runner -->|"yields items"| node_results
node_cli -->|"writes items"| node_export
node_api -->|"exposes writer"| node_export
node_export -->|"flattens rows"| node_flatten
node_export -->|"writes workbook"| node_xlsx
node_flatten -->|"summarizes fields"| node_summary
node_results -->|"writes formats"| node_output
node_export -->|"exports files"| node_output

click node_api "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_api.py"
click node_cli "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/cli.py"
click node_runner "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_runner.py"
click node_detect "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_detect.py"
click node_shopify "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_shopify.py"
click node_woocommerce "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_woocommerce.py"
click node_magento "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_magento.py"
click node_bigcommerce "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_bigcommerce.py"
click node_squarespace "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_squarespace.py"
click node_generic "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_generic.py"
click node_sitemap "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_sitemap.py"
click node_jsonld "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_jsonld.py"
click node_microdata "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_microdata.py"
click node_session "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_session.py"
click node_policy "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_policy.py"
click node_fetch "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_fetch.py"
click node_results "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_results.py"
click node_summary "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_summary.py"
click node_flatten "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_flatten.py"
click node_export "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_export.py"
click node_xlsx "https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_xlsx.py"

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,node_cli,node_runner,node_detect,node_user toneBlue
class node_shopify,node_woocommerce,node_magento,node_bigcommerce,node_squarespace,node_generic,node_sitemap,node_jsonld,node_microdata toneAmber
class node_session,node_policy,node_fetch toneMint
class node_results,node_summary,node_flatten,node_export,node_xlsx toneRose
class node_store,node_output toneIndigo
```

## Components

### Entry and orchestration

- [Scrape API](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_api.py): `shopify_spy/_api.py`
- [Command line](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/cli.py): `shopify_spy/cli.py`
- [Run orchestration](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_runner.py): `shopify_spy/_runner.py`
- [Platform detection](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_detect.py): `shopify_spy/_detect.py`

### Store adapters

- [Shopify adapter](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_shopify.py): `shopify_spy/_shopify.py`
- [WooCommerce adapter](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_woocommerce.py): `shopify_spy/_woocommerce.py`
- [Magento adapter](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_magento.py): `shopify_spy/_magento.py`
- [BigCommerce adapter](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_bigcommerce.py): `shopify_spy/_bigcommerce.py`
- [Squarespace adapter](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_squarespace.py): `shopify_spy/_squarespace.py`
- [Generic adapter](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_generic.py): `shopify_spy/_generic.py`
- [Sitemap discovery](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_sitemap.py): `shopify_spy/_sitemap.py`
- [JSON-LD parsing](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_jsonld.py): `shopify_spy/_jsonld.py`
- [Microdata parsing](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_microdata.py): `shopify_spy/_microdata.py`

### Request handling

- [Store request session](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_session.py): `shopify_spy/_session.py`
- [Politeness and retries](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_policy.py): `shopify_spy/_policy.py`
- [HTTP transport](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_fetch.py): `shopify_spy/_fetch.py`

### Results and output

- [Run results](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_results.py): `shopify_spy/_results.py`
- [Product summaries](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_summary.py): `shopify_spy/_summary.py`
- [Unified row schema](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_flatten.py): `shopify_spy/_flatten.py`
- [File exporters](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_export.py): `shopify_spy/_export.py`
- [Excel writer](https://github.com/ndgigliotti/shopify-spy/blob/master/shopify_spy/_xlsx.py): `shopify_spy/_xlsx.py`

### Other components

- **CLI or library user**
- **Ecommerce stores**
- **JSON, CSV, XLSX, XML**

## Connections

- CLI or library user → Command line: runs command (evidence: `README.md`)
- CLI or library user → Scrape API: calls library (evidence: `README.md`)
- Command line → Scrape API: invokes scrape (evidence: `shopify_spy/cli.py`)
- Scrape API → Run orchestration: starts run (evidence: `shopify_spy/_api.py`)
- Run orchestration → Platform detection: detects platform (evidence: `shopify_spy/_runner.py`)
- Run orchestration → Shopify adapter: dispatches (evidence: `shopify_spy/_runner.py`)
- Run orchestration → WooCommerce adapter: dispatches (evidence: `shopify_spy/_runner.py`)
- Run orchestration → Magento adapter: dispatches (evidence: `shopify_spy/_runner.py`)
- Run orchestration → BigCommerce adapter: dispatches (evidence: `shopify_spy/_runner.py`)
- Run orchestration → Squarespace adapter: dispatches (evidence: `shopify_spy/_runner.py`)
- Run orchestration → Generic adapter: dispatches (evidence: `shopify_spy/_runner.py`)
- Run orchestration → Store request session: creates sessions (evidence: `shopify_spy/_runner.py`)
- Run orchestration → Run results: records status (evidence: `shopify_spy/_runner.py`)
- Platform detection → Ecommerce stores: probes store (evidence: `shopify_spy/_detect.py`)
- Shopify adapter → Store request session: requests data (evidence: `shopify_spy/_shopify.py`)
- WooCommerce adapter → Store request session: requests data (evidence: `shopify_spy/_woocommerce.py`)
- Magento adapter → Store request session: requests data (evidence: `shopify_spy/_magento.py`)
- BigCommerce adapter → Store request session: requests data (evidence: `shopify_spy/_bigcommerce.py`)
- Squarespace adapter → Store request session: requests data (evidence: `shopify_spy/_squarespace.py`)
- Generic adapter → Sitemap discovery: discovers pages (evidence: `shopify_spy/_generic.py`)
- Generic adapter → JSON-LD parsing: parses products (evidence: `shopify_spy/_generic.py`)
- JSON-LD parsing → Microdata parsing: parses markup (evidence: `shopify_spy/_jsonld.py`)
- Store request session → Politeness and retries: applies policies (evidence: `shopify_spy/_session.py`)
- Store request session → HTTP transport: sends requests (evidence: `shopify_spy/_session.py`)
- Store request session → Ecommerce stores: fetches pages (evidence: `README.md`)
- Run orchestration → Run results: yields items (evidence: `README.md`)
- Command line → File exporters: writes items (evidence: `shopify_spy/cli.py`)
- Scrape API → File exporters: exposes writer (evidence: `shopify_spy/__init__.py`)
- File exporters → Unified row schema: flattens rows (evidence: `shopify_spy/_export.py`)
- File exporters → Excel writer: writes workbook (evidence: `shopify_spy/_export.py`)
- Unified row schema → Product summaries: summarizes fields (evidence: `shopify_spy/_flatten.py`)
- Run results → JSON, CSV, XLSX, XML: writes formats (evidence: `README.md`)
- File exporters → JSON, CSV, XLSX, XML: exports files (evidence: `README.md`)
