PenCarrie → WooCommerce Sync
LiveSignature capability
Reverse-engineered an undocumented supplier gateway with no public docs and reconciled ~91,000 SKUs into a live store, idempotently, every night.
What it is
Each night a cron-triggered PHP CLI fetches the full PenCarrie catalogue (~91,000 SKUs, ~80,000 mapped to live WooCommerce products) over a legacy CSV-over-POST gateway, diffs it against the previous night's snapshot, and pushes only the changed stock quantities via batched WooCommerce REST v3 calls. It writes structured JSON telemetry per run and per supplier call and emails the operator on any failure. A stock-shock guard aborts the run if the fresh fetch is under 50% of the prior baseline, preventing a mass zero-out of live inventory. Two modes run: a fast nightly delta and a full baseline reconciliation.
Highlights
- 121 tests / 239 assertions passing; business-logic coverage >=95% (orchestrator and diff engine at 100%).
- Stock-shock guard aborts if the current SKU count drops below 50% of the previous snapshot, protecting live inventory from bad supplier data.
- Reverse-engineered an undocumented gateway: strips stray UTF-8 BOM, rejects conflicting duplicate SKUs, and treats a short 200-OK response as malformed rather than consuming the rate budget.
- Self-enforced 15-minute rate limit via a stamped rate file (the supplier sends no rate-limit headers, only 403 streaks).
- Concurrency-safe via flock; atomic snapshot writes via tmp-file + rename; bounded retry with backoff on 429/5xx.
- Memory-bounded full-sync mode streams SKU batches via a generator instead of materialising 91k rows in memory.
Tech · PHP 8.1+, ext-curl, ext-json, PHPUnit, WooCommerce REST API v3, CSV-over-POST supplier gateway, cron, cPanel/CageFS hosting.