Case Study

Distributed Inventory Sync Platform

Built a fault-tolerant, distributed workflow platform on Temporal.io that synchronizes 100K+ automotive parts from Pinnacle inventory systems to Shopify and WooCommerce storefronts, paired with an edge-deployed Shopify dashboard app on Cloudflare Workers for configuration, monitoring, and client onboarding.

Role
Founder & Solutions Architect
Company
Codex
Duration
2024 - Present
Stack
Temporal.io, TypeScript, Cloudflare Workers, Shopify
100K+
Products synced across storefronts
6
Active clients onboarded
900MB+
Datasets processed per sync
4h
Automated sync cycles

The Challenge

Australian automotive parts recyclers manage massive inventories of salvaged parts - often tens of thousands of items per yard - tracked in Pinnacle, a legacy inventory management system used across the industry. These businesses needed their inventory visible on e-commerce platforms like Shopify and WooCommerce to reach online buyers, but there was no reliable bridge between the two worlds.

The Pinnacle API returns enormous datasets (900MB+ per client) that change constantly as parts are added, sold, priced, and scrapped. A naive sync approach - pulling everything and pushing everything - was far too slow, too error-prone, and would hammer destination platform rate limits. The system needed to be intelligent about what changed, resilient to crashes and API failures, and configurable per client without requiring code changes.

Beyond the sync engine itself, clients needed a way to configure their own sync settings - field mappings, pricing rules, image preferences, and filtering logic - without touching code or calling me directly. The onboarding experience had to be self-service, and the monitoring had to be real-time.

Key Constraints


System Architecture

DISTRIBUTED INVENTORY SYNC PLATFORM - END-TO-END ARCHITECTURE Pinnacle API Automotive Parts Inventory / 900MB+ Datasets JSON Stream Temporal Workflow Engine TypeScript / Durable Workflow Orchestration / Single Task Queue fullSyncOrchestrator mainSync delete update create Temporal Schedules Every 4 hours per client File-Based Exchange Bypasses 4MB gRPC limit SHA256 Hash-Based Change Detection Diff analysis: categorize as add / update / delete / skip Destination Adapter Pattern Interface-based abstraction / Per-client business rules Shopify GraphQL API Bulk mutations / Rate limit handling PRIMARY DESTINATION WooCommerce REST API Batch operations / WordPress hosting SECONDARY DESTINATION Shopify Dashboard App Remix v2 / Shopify Polaris Setup Wizard Field Mapping Pricing Rules Analytics Versioned Config / Sync Controls config Cloudflare Edge Workers D1 (SQLite) Durable Objects (State Machine) Safety & Reliability Deletion threshold (50%) Health checks / Retries Idempotency / Soft-delete ACTIVE CLIENTS AutoPlus Fairfield Sunshine Coast Narrandera Toyrolla Temporal-powered durable sync engine with Shopify embedded dashboard for self-service configuration File-based data exchange (900MB+) / SHA256 change detection / continueAsNew at 40K events 6 ACTIVE CLIENTS / 100K+ PRODUCTS / AUTOMATED 4-HOUR SYNC CYCLES

The Solution

I designed and built a two-part production system: a Temporal.io-powered workflow engine that handles the heavy lifting of inventory synchronization, and a Shopify Remix dashboard app deployed on Cloudflare Workers that serves as the control plane for configuration, monitoring, and client onboarding. The architecture prioritizes durability, fault tolerance, and operational simplicity - syncs survive crashes, deploys, and infrastructure failures without losing a single item.


1. Temporal Workflow Architecture

I chose Temporal.io as the orchestration layer because the core problem is inherently long-running, failure-prone, and stateful. A single sync cycle can take hours when processing 900MB of inventory data against platform rate limits, and the system needs to pick up exactly where it left off after any failure - whether it's a network timeout, a worker crash, or a deployment rolling out.

Workflow Hierarchy

The system uses a hierarchical workflow design. At the top sits the fullSyncOrchestrator, which coordinates the entire sync lifecycle for a client. It spawns a mainSync child workflow to fetch and analyze data from Pinnacle, then sequentially executes delete, update, and create child workflows to apply changes to the destination platform. This sequential ordering is deliberate - deletes run first to free up product slots, updates modify existing listings, and creates add new inventory last.

continueAsNew Strategy

Temporal workflows accumulate event history as they execute, and workflows that exceed the history limit get terminated. I implemented a continueAsNew strategy at 40,000 history events. When a child workflow approaches this threshold during batch processing (creating or updating thousands of products), it checkpoints its progress, signals its state to the orchestrator, and continues as a fresh workflow execution. This allows single sync operations to process tens of thousands of products without hitting Temporal's history limits.

File-Based Data Exchange

Temporal's gRPC transport has a hard 4MB payload limit, and a single client's inventory data can exceed 900MB. I solved this by implementing a file-based data exchange pattern: activities write large datasets to shared filesystem paths, and downstream activities read from those paths. The workflow passes only the file path reference (a few bytes) through Temporal's gRPC layer. A stale file cleanup mechanism runs at the end of each sync to prevent disk space accumulation.

Single Task Queue Design

All client workflows share a single Temporal task queue, which simplifies operations and allows horizontal scaling by adding more workers. Client isolation is maintained at the data level - each workflow carries its client configuration and operates on its own dataset. Temporal schedules trigger syncs every 4 hours per client, staggered to avoid thundering herd effects.


2. Destination Adapter Pattern

I designed the sync engine around an interface-based adapter pattern that abstracts away the destination platform entirely. The core workflow logic - fetch data, detect changes, apply mutations - doesn't know or care whether it's talking to Shopify or WooCommerce. Each destination is just an implementation of the adapter interface.

Adapter Interface

The adapter interface defines a clean contract: methods for fetching existing products, creating new ones, updating existing ones, archiving (soft-deleting) products, and querying product counts. The Shopify adapter implements these using GraphQL bulk mutations and the Admin API. The WooCommerce adapter uses the REST API with batch endpoints. Adding a new platform - say BigCommerce or Magento - means implementing this interface and nothing else. The orchestrator, change detection, and all business logic remain untouched.

Per-Client Business Rules

Each client has a unique configuration that controls every aspect of how their inventory appears on the storefront. This includes tiered pricing rules (e.g., "$10-50 add 30%, $50+ add 25%"), product filtering by category or condition, tag generation from Pinnacle metadata, image selection logic (Part images vs Vehicle images), freight data enrichment for shipping dimensions, and SEO template generation. All of these rules are loaded from the dashboard app's configuration API at sync time, meaning clients can change their rules between syncs without any code deployment.


3. Hash-Based Change Detection

The most critical optimization in the system is the SHA256-based change detection pipeline. Rather than comparing every field of every product on every sync (which would be absurdly slow at 900MB+ datasets), I compute a hash of each product's relevant fields and compare it to the previously stored hash.

How It Works

During the analysis phase, the mainSync workflow streams the full Pinnacle dataset through a JSONStream parser (avoiding loading the entire 900MB into memory) and computes a SHA256 hash for each part. These hashes are compared against the previously stored hash map from the last successful sync. The result is four categorized lists: parts to add (new hashes not seen before), parts to update (existing parts whose hash changed), parts to delete (previously synced parts no longer in the Pinnacle feed), and parts to skip (hash unchanged, no action needed).

Two Hashing Modes

I maintain two hashing modes for backward compatibility with clients who were onboarded before a schema change. The legacy mode hashes a subset of fields; the current mode hashes the full product payload. The hashing mode is stored per-client in their configuration, and the system transparently supports both without any code branching in the core sync logic.

Efficiency Gains

In practice, this means that on a typical 4-hour sync cycle, only 2-5% of products have actually changed. Instead of pushing 15,000 API calls to Shopify, the system might only need 300-500. This dramatically reduces sync time, avoids rate limit pressure, and makes the system viable for the frequency of syncs clients need.

Temporal Workflow Execution Pipeline

TEMPORAL WORKFLOW EXECUTION PIPELINE Temporal Schedule (every 4h) Triggers per-client sync workflow fullSyncOrchestrator Parent workflow / Coordinates child workflows sequentially Health Check Activity Verify Pinnacle API availability mainSync (Child Workflow) Fetch Pinnacle data / SHA256 hash comparison / Produce change lists Writes add/update/delete lists to filesystem File-Based Data Exchange 900MB+ streamed via JSONStream File paths passed through gRPC Delete Workflow Soft-delete (archive) products Safety threshold: blocks if >50% deletes Update Workflow Modify existing product listings Pricing / Images / Tags / Metadata Create Workflow Add new products to storefront Full product creation with images continueAsNew at 40K history events continueAsNew at 40K events continueAsNew at 40K events RELIABILITY FEATURES Activity Retries Exponential backoff per activity Idempotency Keys Prevent duplicate activity runs Non-Blocking Callbacks Status reporting to dashboard Stale File Cleanup Auto-purge after sync completion Sequential child workflow execution: delete first (free slots) -> update (modify existing) -> create (add new) Each child workflow independently supports continueAsNew for unbounded batch sizes

4. Shopify Dashboard App

I built the control plane as a Shopify Remix embedded app, deployed on Cloudflare Workers at the edge. The dashboard serves two audiences: clients who use it to configure their sync settings and monitor sync health, and the Temporal workers which call its internal APIs to fetch configuration and report sync status.

Cloudflare Workers + D1 + Durable Objects

The app runs on Cloudflare Workers for edge-deployed performance with zero cold starts. Cloudflare D1 (SQLite at the edge) stores client configurations, sync history, error logs, and idempotency keys. I used Cloudflare Durable Objects to implement a serialized state machine for the setup wizard - ensuring that concurrent requests during the onboarding flow don't create race conditions or partial configurations. Drizzle ORM provides type-safe database access with migration support.

3-Step Setup Wizard

I designed a guided onboarding flow that takes a new client from zero to their first sync in about 5 minutes. Step 1 collects their Pinnacle API credentials and validates the connection. Step 2 presents the visual field mapping builder and tiered pricing configuration. Step 3 shows a review summary and launches the first sync. The Durable Object backing the wizard ensures atomic state transitions - you can't skip steps or submit a half-configured setup.

Visual Field Mapping & Tiered Pricing

The field mapping builder lets clients drag and map Pinnacle fields to their Shopify product fields, with template support for generating titles, descriptions, and URL handles from multiple source fields. The tiered pricing interface allows rules like "$0-10 add 50%", "$10-50 add 30%", "$50-200 add 25%", "$200+ add 20%" - each client sets their own margin strategy. Configurations are versioned, and new versions are activated atomically so a sync never runs against a half-updated config.

Dashboard Analytics

The dashboard home shows hero stats (total synced products, last sync time, error count), a 7-run stacked bar chart showing adds/updates/deletes per sync, a chronological error log with stack traces, and a recent activity feed. Internal APIs allow the Temporal workers to push sync status updates in real-time, so the dashboard reflects the current state of any running sync.


5. Reliability & Safety Engineering

When you're managing a client's entire product catalogue programmatically, safety isn't optional. A bug that accidentally deletes 10,000 products from a Shopify store would be catastrophic for the business. I built multiple layers of protection into the system.

Deletion Safety Threshold

If the change detection analysis determines that more than 50% of a client's products should be deleted, the sync aborts and raises an alert. This catches scenarios like a Pinnacle API returning an empty or partial dataset - which would otherwise look like "every product was removed" and trigger mass deletion. The threshold is configurable per client.

Health Checks

Before any sync begins, the orchestrator runs a health check activity against the Pinnacle API. If the API is down or returning errors, the sync is skipped rather than running with stale or empty data. This prevents the deletion threshold scenario from even being reached in most failure cases.

Activity Retries with Exponential Backoff

Every Temporal activity (API calls to Pinnacle, Shopify, WooCommerce) is configured with retry policies using exponential backoff. Transient failures - rate limits, network timeouts, 502 errors - are retried automatically without human intervention. The retry policy is tuned per activity type: read operations retry aggressively, write operations retry conservatively.

Idempotency Keys

The dashboard maintains an idempotency keys table that prevents duplicate Temporal activity runs. If a worker crashes mid-activity and retries, the idempotency key ensures the operation isn't executed twice. This is especially critical for create and delete operations where duplicates would corrupt the product catalogue.

Soft-Delete Semantics

Products are never hard-deleted from destination platforms. Instead, the delete workflow archives them (draft/hidden status), preserving the product data and allowing recovery. This gives clients a safety net - if a part was incorrectly flagged for deletion, it can be restored without re-creating all its metadata, images, and URL history.


Tech Stack

Temporal.io TypeScript Node.js Cloudflare Workers Cloudflare D1 Durable Objects Shopify GraphQL API WooCommerce REST API Remix v2 Shopify Polaris Drizzle ORM JSONStream GitHub Actions Docker Winston Zod

The Outcome

100K+ Products Synced

Synchronized over 100,000 automotive parts across multiple Shopify and WooCommerce storefronts, keeping inventory accurate and up to date.

6 Clients Onboarded

Six active automotive recycler clients running in production, each with unique configurations, pricing rules, and destination platforms.

Zero Data Loss

Temporal's durable execution guarantees mean zero products lost to crashes, deploys, or infrastructure failures. Every sync completes or resumes exactly where it left off.

5-Minute Onboarding

New clients go from zero to their first sync in about 5 minutes through the guided setup wizard - no code changes or manual configuration required.

Automated 4h Sync Cycles

Fully automated sync cycles every 4 hours via Temporal schedules. Clients wake up to fresh inventory on their storefronts without lifting a finger.

Fault-Tolerant by Design

System survives worker crashes, network outages, and rolling deployments. Temporal's event sourcing means workflows pick up exactly where they stopped.

Need distributed sync infrastructure?

I design and build fault-tolerant data synchronization platforms using Temporal workflows and modern edge infrastructure.

Let's Talk