惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
罗磊的独立博客
T
Tailwind CSS Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
V
V2EX
美团技术团队
阮一峰的网络日志
阮一峰的网络日志
酷 壳 – CoolShell
酷 壳 – CoolShell
月光博客
月光博客
量子位
MyScale Blog
MyScale Blog
G
Google Developers Blog
M
MIT News - Artificial intelligence
L
LangChain Blog
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
有赞技术团队
有赞技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
DataBreaches.Net
云风的 BLOG
云风的 BLOG
B
Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
We just launched on the Shopify App Store - here's the ar...
Nventory · 2026-05-27 · via DEV Community

Nventory

Hey dev.to - we just launched Nventory on the Shopify App Store and I wanted to share the technical decisions behind what we built and why.
Not a feature list. The actual architectural thinking.

The problem we kept seeing
Every multichannel seller we talked to had the same story.
Running Shopify alongside Amazon, Flipkart, or eBay. Inventory going out of sync during high-traffic periods. Oversells during flash sales. Marketplace accounts flagged for cancellations that came from nowhere.
All traceable back to one architectural decision most inventory tools make — polling.
javascript// What most inventory tools are doing under the hood
setInterval(async () => {
const stock = await getSourceOfTruth();
await syncToAllChannels(stock);
}, 15 * 60 * 1000);

// The problem
const windowsPerDay = (24 * 60) / 15; // 96
// 96 times per day where channels disagree about stock
// At flash sale velocity: catastrophic
96 windows per day where channels show different stock. At normal velocity — manageable. At flash sale velocity — every window is an oversell waiting to happen.

The architectural decision we made
We built Nventory on event-driven propagation from day one.
javascript// Every stock mutation fires an immediate event
orderEventBus.on('order.confirmed', async ({ sku, qty, channel, orderId }) => {
// Idempotency — retries don't corrupt counts
if (await idempotencyStore.exists(orderId)) return;

// Optimistic locking — concurrent orders resolve safely
const result = await inventory.decrementWithLock(sku, qty);

if (!result.success) {
// Stock unavailable — pause listings across every channel immediately
await pauseListingsAcrossChannels(sku);
throw new InsufficientStockError(sku);
}

// Propagate immediately — milliseconds not minutes
await Promise.all(
connectedChannels
.filter(ch => ch.id !== channel)
.map(ch => ch.updateInventory(sku, result.newQty))
);

await Promise.all([
idempotencyStore.mark(orderId),
auditLog.record({
sku, qty, channel, orderId,
result, timestamp: Date.now()
})
]);
});
Three decisions worth explaining:
Idempotency keys — at volume, retries are inevitable. Without idempotency, retries create duplicate decrements that corrupt stock counts silently. Every mutation gets a key. Every retry checks it first.
Optimistic locking — concurrent orders from different channels hitting the same SKU simultaneously need to resolve against the same stock count. Without locking, race conditions produce oversells even with event-driven sync.
Dead letter queue — failed propagations that get silently dropped create invisible discrepancies. Every failure goes to DLQ with exponential backoff retry. Nothing gets lost.

The Shopify integration layer
Connecting to Shopify correctly required a few specific decisions:
javascript// Shopify webhook handler — every relevant event
app.post('/webhooks/shopify', async (req, res) => {
const hmac = req.headers['x-shopify-hmac-sha256'];

// Verify webhook authenticity
if (!verifyShopifyHmac(req.body, hmac)) {
return res.status(401).send('Unauthorized');
}

const { topic, shop } = parseWebhookHeaders(req.headers);

switch(topic) {
case 'orders/create':
await orderEventBus.emit('order.confirmed', parseOrder(req.body));
break;
case 'inventory_levels/update':
await inventoryEventBus.emit('inventory.updated', parseInventoryLevel(req.body));
break;
case 'products/update':
await productEventBus.emit('product.updated', parseProduct(req.body));
break;
}

res.status(200).send('OK');
});

// GraphQL inventory update — using Shopify's preferred API
async function updateShopifyInventory(inventoryItemId, locationId, qty) {
const mutation =
mutation inventorySetQuantities($input: InventorySetQuantitiesInput!) {
inventorySetQuantities(input: $input) {
inventoryAdjustmentGroup {
reason
changes {
name
delta
}
}
userErrors {
field
message
}
}
}
;

return shopifyGraphQL(mutation, {
input: {
reason: "correction",
setQuantities: [{
inventoryItemId,
locationId,
quantity: qty
}]
}
});
}
Webhook reliability — Shopify webhooks occasionally fail or arrive out of order. We built a reconciliation layer that periodically verifies channel state matches our source of truth and corrects any drift.
GraphQL over REST — Shopify's GraphQL API is significantly more efficient for bulk inventory operations. Fewer API calls, better rate limit management, cleaner error handling.
Multi-location support — Shopify's inventory model is location-aware. Every inventory operation needs to specify location explicitly. Our routing engine determines the correct location per operation based on the seller's fulfilment rules.

What we built on top
The sync architecture is the foundation. On top of it:
AI automation — sellers describe workflows in plain English, the system builds trigger-condition-action logic automatically using an LLM that understands our event model.
javascript// Plain English → workflow
const workflow = await automationBuilder.fromDescription(
"When stock drops below 10 units on any SKU, send a Slack notification to the warehouse team"
);

// Generates:
// trigger: inventory.level.changed
// condition: newQty < 10
// action: slack.send({ channel: '#warehouse', message: Low stock: ${sku} })
Smart order routing every order evaluated against proximity, cost, speed, and stock availability across FBA, 3PLs, and owned locations simultaneously.

Multi-carrier shipping - real-time rate comparison across 100+ carriers per order. Optimal carrier selected automatically based on seller's routing rules.

Honest reflections after launch
The hardest part wasn't the sync architecture it was the edge cases.
Shopify making automatic inventory adjustments for returns that need to reconcile with our source of truth. Channel APIs going down mid-propagation. Sellers with inconsistent SKU mapping across platforms. Variant-level inventory that doesn't map cleanly to marketplace catalog structures.

The DLQ and reconciliation layer ended up being as important as the core sync engine. The happy path is straightforward. The unhappy paths are where reliability is actually built.

Worth exploring
If you're building for multichannel sellers or working on Shopify integrations would love technical feedback on the architecture.