An embedded Shopify admin app that keeps merchants ahead of stockouts across
every sales channel a product is listed on. It reads live inventory through
the GraphQL Admin API, listens for inventory_levels/update and
products/update webhooks, and raises alerts the moment a variant crosses a
merchant-defined low-stock threshold — with a Channel Health signal on
each row that goes beyond a flat in-stock/out-of-stock flag.
Built as a portfolio project for a Shopify internship application.
- Dashboard — cursor-paginated table of every product variant, its live
inventory quantity, an editable low-stock threshold, and a Channel
Health badge (
Healthy/Watch/Critical/Stale sync) that blends the current stock level, whether it's trending down toward the threshold, and how recently a webhook actually confirmed the number. - Alerts — every threshold breach, with quantity/threshold at the time, when it was raised, and whether it's since been resolved (stock rose back above threshold).
- Sync Log — a running feed of every inventory and product webhook StockPulse has received, so you can watch the automation work end-to-end without needing to trust a black box.
A single quantity-vs-threshold check tells you a product is already in
trouble, but not whether the number itself can be trusted or whether it's
about to be. computeChannelHealth (in
app/lib/inventory-logic.ts) folds in three
signals:
| Signal | What it catches |
|---|---|
| Threshold breach | Quantity at or below the configured threshold → Critical |
| Sync freshness | No inventory webhook observed in 24h → Stale sync (the number on screen might be wrong) |
| Trend | Quantity falling and within 1.5x of threshold, even if not breached yet → Watch |
This is the one piece of business logic in the app that's pure and fully
unit tested — see app/lib/inventory-logic.test.ts.
Placeholders — swap these for real captures from a dev store install.
| Dashboard | Alerts | Sync Log |
|---|---|---|
┌─────────────────┐ OAuth install / embedded load ┌──────────────────┐
│ Shopify Admin │ ───────────────────────────────────────────▶│ StockPulse │
│ (merchant) │◀─────────────────────────────────────────── │ Remix app │
└─────────────────┘ App Bridge session token on every └──────────────────┘
embedded request │
│ GraphQL Admin API
│ (products, variants,
│ inventory quantity)
▼
┌─────────────────┐ inventory_levels/update, products/update ┌──────────────────┐
│ Shopify │ ───────────────────────────────────────────▶│ /webhooks/* │
│ webhook engine │ (HMAC-verified POST) │ route handlers │
└─────────────────┘ └──────────────────┘
│
▼
┌──────────────────┐
│ Prisma / SQLite │
│ (Postgres in │
│ production) │
│ - Session │
│ - ProductThreshold│
│ - StockAlert │
│ - SyncLogEntry │
└──────────────────┘
- Merchant installs from the Shopify App Store (or a dev store install
link). Shopify redirects to
/auth/login?shop=.... @shopify/shopify-app-remix'sauthenticate.adminhandles the OAuth handshake, exchanges the authorization code for an access token, and stores the resulting session viaPrismaSessionStorage(theSessiontable).- The app is then rendered embedded in Shopify Admin via App Bridge, which
attaches a session token to every subsequent request so
authenticate.admin(request)can re-verify the merchant on each route load without a full re-auth.
shopify.app.tomldeclares subscriptions forinventory_levels/updateandproducts/updatepointing at/webhooks/inventory_levels/updateand/webhooks/products/update.- Shopify's CLI registers these with the Admin API when you run
npm run dev/npm run deploy. - Incoming webhook POSTs are HMAC-verified by
authenticate.webhookbefore any handler code runs. webhooks.inventory_levels.update.tsxresolves the payload'sinventory_item_idto a product/variant via GraphQL, writes aSyncLogEntry, and — if a threshold is configured for that variant and the new quantity breaches it — writes aStockAlert(or resolves an open one if stock has recovered).webhooks.products.update.tsxkeeps cached titles onProductThresholdrows in sync with renames and logs the event.
- Remix via the official Shopify App Template
- Shopify App Bridge for the embedded admin shell
- Polaris for UI
- GraphQL Admin API for product/inventory reads
- Prisma + SQLite locally, swappable to Postgres
via
DATABASE_URL - Vitest for unit tests
- TypeScript throughout
- Node.js 20.19+ or 22.12+
- A Shopify Partners account
- A development store (create one from the Partners dashboard)
- Shopify CLI (installed as a
dev dependency; invoked via
npm run dev)
npm install
npx prisma migrate deploycp .env.example .envRun shopify app dev once and it will prompt you to log in, create (or
select) an app in your Partners org, and it fills in SHOPIFY_API_KEY,
SHOPIFY_APP_URL, and updates shopify.app.toml's client_id for you. You
generally don't need to hand-edit .env beyond that — it exists so
SHOPIFY_API_SECRET and a future DATABASE_URL never get hardcoded into
source.
npm run devThe CLI opens a tunnel, prints an install link for your dev store, and hot-reloads on changes. Approve the OAuth scopes on install; the dashboard should load with your dev store's real products.
npm testLocal dev uses SQLite (prisma/schema.prisma, datasource db { provider = "sqlite" }). For production, switch the provider to "postgresql", set
DATABASE_URL in your deployment environment, and run
npx prisma migrate deploy.
app/
routes/
app._index.tsx # Dashboard: products, inventory, thresholds, Channel Health
app.alerts.tsx # Alerts tab
app.sync-log.tsx # Sync Log tab
webhooks.inventory_levels.update.tsx # Threshold check + alert + sync log on stock change
webhooks.products.update.tsx # Keeps cached titles in sync, logs the event
lib/
inventory-logic.ts # Pure threshold + Channel Health logic (unit tested)
inventory-logic.test.ts
shopify-queries.server.ts # Cursor-paginated products GraphQL query
shopify.server.ts # OAuth/session/webhook config
prisma/
schema.prisma # Session, ProductThreshold, StockAlert, SyncLogEntry
MIT