Business systems

E-commerce back office

Purchase costs, target margins and competitor prices for a 1,150-product online shop, in one read-only dashboard.

See the demo

When
Sep 2026 – present
Status
Live for one shop; AI monitoring paused
Source
Private source
Stack
  • PostgreSQL
  • PL/pgSQL
  • Supabase
  • Cloudflare Workers
  • JavaScript

Problem and idea

A dropshipping shop sells products it never holds. Supplier costs change, competitors change their prices, and the shop platform has no view of margins. The owner needed to see, for each product, what it costs, what it should sell for and what others charge, without any tool touching the live shop.

The idea: let PostgreSQL own the rules. Workers, both AI agents and a plain price refresher, can only call validated database functions. Every observation is kept, and the dashboard only reads.

How it works

  1. Catalogue and costsImported snapshots, read-only towards the shop
  2. PostgreSQLAppend-only ledger, validating functions, row-level security
  3. WorkersAI agents find and judge offers; a Cloudflare Worker re-reads verified prices every 30 minutes
  4. DashboardStatic site behind sign-in: margins and competitor prices

Demo

Dashboard overview with counts of loaded products, calculated margins and products with negative margin.
Overview after sign-in.
Price table: purchase cost, product margin, target margin, calculated price and lowest competitor price for each product.
Prices and margins. Each row shows the purchase cost, the margin at the calculated price, the target margin and the lowest verified competitor price, with its source and check time.
Monitoring panel showing the status of exact and equivalent product monitoring groups.
Competitor monitoring. The queue adapts to whichever workers are running, and paused groups are taken over without errors.

Synthetic data. These screenshots were rendered from the real dashboard code, with every request answered by a local mock containing invented products, sellers, prices and links. The shop’s name is replaced with “Exempelbutiken”.

What I built

  • The data model and 41 versioned migrations, with the domain logic in validating PL/pgSQL functions in a private schema.
  • Margin calculation in whole öre, editable margin targets and a preview of every price change before it is saved.
  • Competitor price monitoring: exact matches by EAN, judged equivalent products, seller coverage and an adaptive work queue.
  • A Cloudflare Worker that re-reads verified offers from the page’s structured data, with sites that earn or lose automatic refresh.
  • A versioned contract for the AI workers, published by migration, with rollback scripts for each version.

Stack

  • PostgreSQL 17
  • PL/pgSQL
  • Supabase Auth
  • Row-level security
  • pg_cron
  • Cloudflare Workers
  • Browser Rendering
  • Hyperdrive
  • Cloudflare Pages
  • JavaScript
  • Python
  • GitHub Actions

Quality evidence

  • About 3,800 lines of SQL tests across the migrations, run in CI.
  • 92 JavaScript test cases for the dashboard and the price refresher.
  • Three CI workflows: SQL tests, dashboard checks and deploy, and the price refresher.
  • A deployment log of verified checkpoints that the workers read before they act.

Current limits

  • Shop catalogue and supplier costs are imported by hand; there is no live supplier API.
  • Finding new competitor offers depends on AI scheduled tasks, which are paused right now. The refresher only re-reads offers that were already verified.
  • Competitor prices exclude shipping, and the margin excludes payment fees and overhead.