Structured Data Extraction from E-commerce Storefronts Using Specialized Agentic Architecture

shopify · E-commerce · 2025 · source Agentic: yes · promotional bias: low · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: E-commerce storefront understanding and structured extraction

Shopify needed to extract structured shop-level information from millions of highly customized merchant storefronts, including fraud signals, merchant profiles, and tax-related category codes, while reducing cost enough to cover all shops rather than a small subset.

Constraints:

Architecture

Shopify evolved from a single-shot GPT-5 approach to a DSPy-built agentic architecture, then to three specialized ReAct sub-agents for fraud, merchant profile, and merchant category code extraction. A Flink batch job processes shops, calls a Kubernetes-hosted LLM API agent layer, and the agents call a self-hosted Qwen-3-9B model on a separate GPU cluster, enabling cheaper frequent coverage across all shops.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  flink_batch_job["Flink batch job"] --> kubernetes_llm_api["Kubernetes LLM API"]
  kubernetes_llm_api --> fraud_sub_agent["Fraud sub-agent"]
  kubernetes_llm_api --> profile_sub_agent["Profile sub-agent"]
  kubernetes_llm_api --> mcc_sub_agent["MCC sub-agent"]
  fraud_sub_agent --> qwen_gpu_service["Qwen GPU service"]
  profile_sub_agent --> qwen_gpu_service
  mcc_sub_agent --> qwen_gpu_service
  store_snapshots["Store snapshots"] --> kubernetes_llm_api
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Flink batch job Batch scheduler that selects shops and calls the agent layer. Kubernetes LLM API
Kubernetes LLM API Production agent layer that crawls pages, strips HTML, and coordinates sub-agents. Flink batch job, Fraud sub-agent, Profile sub-agent, MCC sub-agent, Qwen GPU service
Fraud sub-agent Specialized ReAct agent for fraud signals and fraud-specific tools. Kubernetes LLM API, Qwen GPU service
Profile sub-agent Specialized ReAct agent for merchant profile information. Kubernetes LLM API, Qwen GPU service
MCC sub-agent Specialized ReAct agent for merchant category code classification. Kubernetes LLM API, Qwen GPU service
Qwen GPU service Self-hosted Qwen-3-9B model on a separate GPU cluster. Kubernetes LLM API, Fraud sub-agent, Profile sub-agent, MCC sub-agent
Store snapshots Replayable snapshots used to run agents and compare labels for optimization. Kubernetes LLM API

Data flow

A Flink batch job selects shops and calls the Kubernetes LLM API. The agent layer crawls pages, strips HTML, and runs three specialized ReAct sub-agents for fraud, profile, and MCC extraction. Those agents call the self-hosted Qwen model on a separate GPU cluster. Outputs are produced from store snapshots and replayed store runs for quality optimization.

3 supporting quotes
“Um the batch job runs on Flink. Then Flink calls the agent layer, which runs on our production platform, essentially Kubernetes.”transcript, stated
“Qwen itself, the actual LLM, is hosted on a separate cluster where we have GPUs.”transcript, stated
“This wasn't just cost, right? This was both cost as well as control, right? So, we wanted specific control over which hardware is used for which step”transcript, stated

Why this architecture

Shopify split the system into specialized agents and separate compute layers because monolithic GPT calls were expensive, less controllable, and hit quality ceilings. Specialized sub-agents could use task-specific tools independently, while self-hosted Qwen and separated GPU infrastructure reduced cost enough for all-shop coverage.

3 supporting quotes
“monolithic agents did not perform as well as specialized agents.”transcript, stated
“we moved from GPT-5 to Qwen, now it's much much cheaper, like 75 times cheaper”transcript, stated
“don't focus on one thing, focus on the entire architecture because not no single thing is going to get you the entire way.”transcript, stated

Models used: GPT-5 · GPT-4 · Qwen-3-9B · DSPy ReAct agents

Scale

Alternatives considered (roads not taken)

Single-shot GPT-5 extraction

Rejected because: It was too expensive for millions of merchants and could not cover frequently changing stores.

“sent it in one big corpus, sent it as a single shot. We sent it to GPT-5”transcript, stated
“as pages change, as merchants adapt, as merchants evolve.”transcript, stated

One monolithic agent

Rejected because: The team found monolithic agents did not perform as well as specialized agents and created cross-quality coupling.

“monolithic agents did not perform as well as specialized agents.”transcript, stated
“I can make a change to the profile agent without having any sort of like ramifications on the on quality on the fraud agent or the MCC agent”transcript, stated

Run all agent work on GPU hardware

Rejected because: Crawling, HTML stripping, and orchestration do not need GPUs, so Shopify split agent infrastructure from model inference.

“the agent layer is doing a bunch of tasks that are not that don't really need a GPU”transcript, stated

Patterns

multi-agent-orchestration (agent architecture)

Shopify split storefront extraction into fraud, profile, and MCC ReAct sub-agents with separate tools and optimization paths.

“in our in this case three agents. One agent that was specifically looking at fraud signals.”transcript, stated
“specialized agents. went from single shot to an agentic architecture to now multiple agents and sub-agents”transcript, stated

model-routing (model operations)

The architecture routes generation calls from the Kubernetes agent layer to a separate self-hosted Qwen GPU service.

“the agent for its LLM generate calls calls another service that hosted on GPU cluster somewhere else”transcript, stated

cost-aware-routing (cost optimization)

Shopify moved from GPT-5 to self-hosted Qwen and split CPU/GPU work to reduce cost by about 75x.

“because we moved from GPT-5 to Qwen, now it's much much cheaper, like 75 times cheaper”transcript, stated

batch-offline-processing (processing architecture)

The storefront extraction system runs as a Flink batch job over shop snapshots rather than a synchronous per-user request flow.

“this whole thing runs as a batch job for us. Um the batch job runs on Flink.”transcript, stated

eval-driven-development (optimization)

The team used replayed stores and human labels to optimize and compare sub-agent quality.

“let the agent run on that snapshot”transcript, stated
“labels. Humans did it like our our fraud”transcript, stated

Tradeoffs

Self-host Qwen for extraction.

Chose Qwen-3-9B on Shopify GPU infrastructure over GPT-5 API calls.

Rationale: The self-hosted model reduced cost enough for all-shop coverage while improving quality in the agentic architecture.

“we moved from GPT-5 to our own self-hosted Qwen.”transcript, stated
“At the same time, our quality goes up like close to 2x the quality at orders of magnitude lower the cost.”transcript, stated

Separate agent layer from GPU inference.

Chose Kubernetes agent layer plus separate GPU cluster over Run the full pipeline on GPU infrastructure.

Rationale: Crawling, HTML stripping, and orchestration are CPU/platform tasks, while only model generation needs GPU inference.

“the agent layer is doing a bunch of tasks that are not that don't really need a GPU”transcript, stated
“we wanted specific control over which hardware is used for which step along the way”transcript, stated

Use specialized sub-agents.

Chose Fraud, profile, and MCC agents over Single monolithic agent.

Rationale: Specialization allowed task-specific tools, independent optimization, and better quality than monolithic extraction.

“we have three sub-agents each running there.”transcript, stated
“monolithic agents did not perform as well as specialized agents.”transcript, stated

Gotchas (what bit them)

Single-shot frontier calls do not scale across changing storefronts.

Root cause: Millions of merchants and page changes make repeated GPT-5 calls too expensive.

Resolution: Use a batch pipeline, self-hosted Qwen, and specialized agents to cover all shops more frequently.

“do we really want to make millions and millions of calls at some regular basis to recompute these things as as page as pages change”transcript, stated
“what that enabled us is now I can run this this solution not on a subset of shops because I was worried of cost, but I can run it on all Shopify shops”transcript, stated

Monolithic agents couple unrelated quality changes.

Root cause: One agent handling fraud, profile, and tax objectives cannot isolate tools or optimization changes by task.

Resolution: Use separate ReAct sub-agents so each can be optimized and tooled independently.

“certain agents I wanted to give them the ability to have specialized tools that I did not want other agents to have”transcript, stated
“if I optimize the fraud agent”transcript, stated

Evaluation

Shopify compared single-shot, agentic, sub-agent, and optimized architectures against quality and cost metrics, using replayed stores and human labels for agent optimization.

Metrics: Approximate cost reduction: 75x after moving from GPT-5 to Qwen. · Quality improvement: close to 2x. · Prior subset coverage: 13% of shops at about $5 million. · Batch volume: about 150K shops daily.

3 supporting quotes
“we went from single shot to an agent and then from an agent to sub-agents”transcript, stated
“now it's much much cheaper, like 75 times cheaper”transcript, stated
“quality goes up like close to 2x the quality”transcript, stated

Outcomes

The source describes millions of merchants, about 150K shops processed daily, and prior costs of about $5 million for only 13% of shops.

“I can run it on all Shopify shops, and I can run it more frequently”transcript, stated
“we have a Flink batch job that takes about 150K shops daily.”transcript, stated