# omkarcloud/alibaba-scraper architecture

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

- Interactive diagram: https://gitdiagram.com/omkarcloud/alibaba-scraper
- Repository: https://github.com/omkarcloud/alibaba-scraper

## Overview

Alibaba Scraper exposes a local JSON API for product, supplier, discovery, and image-search data. The main workflow is an HTTP request routed through endpoint schemas to a domain operation, which resolves references as needed, fetches Alibaba data, and normalizes it into stable response objects. Search, product, supplier, and discovery are distinct domain stages; browser-backed fetching and browser lifecycle management form an internal transport layer. The source excerpts do not show every endpoint implementation or every runtime call, so unsampled links are omitted.

Main entry points: [`routes.py`](https://github.com/omkarcloud/alibaba-scraper/blob/master/routes.py) (Endpoint routes), [`alibaba/fetch.py`](https://github.com/omkarcloud/alibaba-scraper/blob/master/alibaba/fetch.py) (Alibaba transport), [`alibaba/product.py`](https://github.com/omkarcloud/alibaba-scraper/blob/master/alibaba/product.py) (Product details and reviews), [`alibaba/search.py`](https://github.com/omkarcloud/alibaba-scraper/blob/master/alibaba/search.py) (Product and image search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API routing"]
  node_routes["Endpoint routes<br/>[routes.py]"]
  node_schemas["Request schemas<br/>[schemas.py]"]
end

subgraph group_domain["Alibaba data domains"]
  node_product["Product details and reviews<br/>[product.py]"]
  node_search["Product and image search<br/>[search.py]"]
  node_supplier["Supplier operations<br/>[supplier.py]"]
  node_discovery["Discovery endpoints<br/>[discovery.py]"]
end

subgraph group_transport["Fetch and browsers"]
  node_fetch["Alibaba transport<br/>[fetch.py]"]
  node_browser_client["Browser box client<br/>[browser_client.py]"]
  node_worker_inprocess["In-process browser worker<br/>[inprocess.py]"]
  node_lifecycle["Browser lifecycle manager<br/>[lifecycle.py]"]
  node_worker_settings["Worker settings<br/>[settings.py]"]
  node_egress["Proxy and egress<br/>[egress.py]"]
end

subgraph group_shared["Shared response plumbing"]
  node_glue["Route response glue<br/>[route_glue.py]"]
  node_references["Input reference resolution<br/>[refs.py]"]
  node_parsers["Payload normalization<br/>[parsers.py]"]
end

node_caller(("API caller"))

node_caller -->|"requests"| node_routes
node_routes -->|"validates with"| node_schemas
node_routes -->|"routes to"| node_product
node_routes -->|"routes to"| node_search
node_routes -->|"routes to"| node_supplier
node_routes -->|"routes to"| node_discovery
node_routes -->|"registers through"| node_glue
node_product -->|"fetches pages"| node_fetch
node_product -->|"normalizes with"| node_parsers
node_product -->|"resolves inputs"| node_references
node_search -->|"fetches search data"| node_fetch
node_search -->|"normalizes with"| node_parsers
node_search -->|"resolves inputs"| node_references
node_supplier -->|"fetches store data"| node_fetch
node_supplier -->|"normalizes with"| node_parsers
node_supplier -->|"resolves inputs"| node_references
node_discovery -->|"fetches data"| node_fetch
node_discovery -->|"normalizes with"| node_parsers
node_fetch -->|"uses for gated pages"| node_browser_client
node_fetch -->|"uses sessions"| node_egress
node_browser_client -->|"dispatches locally"| node_worker_inprocess
node_worker_inprocess -->|"manages leases"| node_lifecycle
node_lifecycle -->|"reads policy"| node_worker_settings

click node_routes "https://github.com/omkarcloud/alibaba-scraper/blob/master/routes.py"
click node_schemas "https://github.com/omkarcloud/alibaba-scraper/blob/master/alibaba/schemas.py"
click node_glue "https://github.com/omkarcloud/alibaba-scraper/blob/master/route_glue.py"
click node_product "https://github.com/omkarcloud/alibaba-scraper/blob/master/alibaba/product.py"
click node_search "https://github.com/omkarcloud/alibaba-scraper/blob/master/alibaba/search.py"
click node_supplier "https://github.com/omkarcloud/alibaba-scraper/blob/master/alibaba/supplier.py"
click node_discovery "https://github.com/omkarcloud/alibaba-scraper/blob/master/alibaba/discovery.py"
click node_references "https://github.com/omkarcloud/alibaba-scraper/blob/master/alibaba/refs.py"
click node_parsers "https://github.com/omkarcloud/alibaba-scraper/blob/master/alibaba/parsers.py"
click node_fetch "https://github.com/omkarcloud/alibaba-scraper/blob/master/alibaba/fetch.py"
click node_browser_client "https://github.com/omkarcloud/alibaba-scraper/blob/master/browser_client.py"
click node_worker_inprocess "https://github.com/omkarcloud/alibaba-scraper/blob/master/browser_worker/inprocess.py"
click node_lifecycle "https://github.com/omkarcloud/alibaba-scraper/blob/master/browser_worker/lifecycle.py"
click node_worker_settings "https://github.com/omkarcloud/alibaba-scraper/blob/master/browser_worker/settings.py"
click node_egress "https://github.com/omkarcloud/alibaba-scraper/blob/master/egress.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_routes,node_schemas toneBlue
class node_product,node_search,node_supplier,node_discovery toneAmber
class node_fetch,node_browser_client,node_worker_inprocess,node_lifecycle,node_worker_settings,node_egress,node_caller toneMint
class node_glue,node_references,node_parsers toneRose
```

## Components

### API routing

- [Endpoint routes](https://github.com/omkarcloud/alibaba-scraper/blob/master/routes.py): `routes.py`
- [Request schemas](https://github.com/omkarcloud/alibaba-scraper/blob/master/alibaba/schemas.py): `alibaba/schemas.py`

### Alibaba data domains

- [Product details and reviews](https://github.com/omkarcloud/alibaba-scraper/blob/master/alibaba/product.py): `alibaba/product.py`
- [Product and image search](https://github.com/omkarcloud/alibaba-scraper/blob/master/alibaba/search.py): `alibaba/search.py`
- [Supplier operations](https://github.com/omkarcloud/alibaba-scraper/blob/master/alibaba/supplier.py): `alibaba/supplier.py`
- [Discovery endpoints](https://github.com/omkarcloud/alibaba-scraper/blob/master/alibaba/discovery.py): `alibaba/discovery.py`

### Fetch and browsers

- [Alibaba transport](https://github.com/omkarcloud/alibaba-scraper/blob/master/alibaba/fetch.py): `alibaba/fetch.py`
- [Browser box client](https://github.com/omkarcloud/alibaba-scraper/blob/master/browser_client.py): `browser_client.py`
- [In-process browser worker](https://github.com/omkarcloud/alibaba-scraper/blob/master/browser_worker/inprocess.py): `browser_worker/inprocess.py`
- [Browser lifecycle manager](https://github.com/omkarcloud/alibaba-scraper/blob/master/browser_worker/lifecycle.py): `browser_worker/lifecycle.py`
- [Worker settings](https://github.com/omkarcloud/alibaba-scraper/blob/master/browser_worker/settings.py): `browser_worker/settings.py`
- [Proxy and egress](https://github.com/omkarcloud/alibaba-scraper/blob/master/egress.py): `egress.py`

### Shared response plumbing

- [Route response glue](https://github.com/omkarcloud/alibaba-scraper/blob/master/route_glue.py): `route_glue.py`
- [Input reference resolution](https://github.com/omkarcloud/alibaba-scraper/blob/master/alibaba/refs.py): `alibaba/refs.py`
- [Payload normalization](https://github.com/omkarcloud/alibaba-scraper/blob/master/alibaba/parsers.py): `alibaba/parsers.py`

### Other components

- **API caller**

## Connections

- API caller → Endpoint routes: requests (evidence: `README.md`)
- Endpoint routes → Request schemas: validates with (evidence: `routes.py`)
- Endpoint routes → Product details and reviews: routes to (evidence: `routes.py`)
- Endpoint routes → Product and image search: routes to (evidence: `routes.py`)
- Endpoint routes → Supplier operations: routes to (evidence: `routes.py`)
- Endpoint routes → Discovery endpoints: routes to (evidence: `routes.py`)
- Endpoint routes → Route response glue: registers through (evidence: `routes.py`)
- Product details and reviews → Alibaba transport: fetches pages (evidence: `alibaba/product.py`)
- Product details and reviews → Payload normalization: normalizes with (evidence: `alibaba/product.py`)
- Product details and reviews → Input reference resolution: resolves inputs (evidence: `alibaba/product.py`)
- Product and image search → Alibaba transport: fetches search data (evidence: `alibaba/search.py`)
- Product and image search → Payload normalization: normalizes with (evidence: `alibaba/search.py`)
- Product and image search → Input reference resolution: resolves inputs (evidence: `alibaba/search.py`)
- Supplier operations → Alibaba transport: fetches store data (evidence: `alibaba/supplier.py`)
- Supplier operations → Payload normalization: normalizes with (evidence: `alibaba/supplier.py`)
- Supplier operations → Input reference resolution: resolves inputs (evidence: `alibaba/supplier.py`)
- Discovery endpoints → Alibaba transport: fetches data (evidence: `alibaba/discovery.py`)
- Discovery endpoints → Payload normalization: normalizes with (evidence: `alibaba/discovery.py`)
- Alibaba transport → Browser box client: uses for gated pages (evidence: `alibaba/fetch.py`)
- Alibaba transport → Proxy and egress: uses sessions (evidence: `alibaba/fetch.py`)
- Browser box client → In-process browser worker: dispatches locally (evidence: `browser_client.py`)
- In-process browser worker → Browser lifecycle manager: manages leases (evidence: `browser_worker/inprocess.py`)
- Browser lifecycle manager → Worker settings: reads policy (evidence: `browser_worker/lifecycle.py`)
