How it works & how to rebuild it

Architecture, data flow, and a step-by-step deploy guide.

DashboardPlain descriptionData sources

The big picture

The whole thing is one file — a single Cloudflare Worker (server-side JavaScript). It has no build step, no framework, and no dependencies. When someone visits the page, the Worker fetches data from eight public APIs, runs a transparent scoring model, and returns a finished HTML dashboard.

Three stages, every page load:
  1. Ingest — fetch eight external feeds in parallel. Each one can fail on its own without breaking the others.
  2. Model — combine the data into a 10-component risk score, each component capped and labelled.
  3. Render — build the HTML dashboard and send it back.

The data sources

Eight external feeds, all free, plus a CSV the operator can upload. Full detail including endpoints and signup links is on the data sources page.

SourceProvidesKey?
UN ComtradeTrade flows by HS codeNo
World Bank WITSImport tariff ratesNo
GDELTDisruption newsNo
IMF PortWatchPort disruptionNo
US EIAFeedstock pricesFree key
NOAA / NWSGulf Coast weatherNo
ECB / FrankfurterUSD FX ratesNo
FREDDemand & logistics stressFree key

The risk model

The score is plain arithmetic — ten components, each with a hard cap, added together and clamped to 0–100. No machine learning, no opinion. Every component is tagged by where its data came from, so the score always explains itself. One component (chemical demand) can be negative, which stops the tool overstating risk when the market is soft.

The honesty rule

Every value the tool shows is labelled: measured (official statistics), signal (news monitoring — attention, not proof), user (uploaded data), or sample (a placeholder used only when a live feed fails). Mixing hard facts with noisy sentiment is the trap that kills supply dashboards — the labelling is what avoids it.

How to rebuild and deploy it

You need a free Cloudflare account. No terminal required.

1. Cloudflare dashboard → Workers & Pages → Create → Create Worker.
2. Choose "Start with Hello World!", give it a name, click Deploy. This makes a placeholder.
3. Click "Edit code". Delete the placeholder code entirely.
4. Paste in the full contents of worker.js. Click Deploy.
5. Done — you have a live URL. The dashboard is at /, this page at /explain.

Optional setup (all in the Worker's Settings tab)

Changing the commodity

The default is propylene glycol (HS code 290532). Add ?hs=CODE to any URL, or set the HS_CODE variable, to track a different traded good.

Where the source code lives

The complete tool is the single worker.js file plus a short README and a sample CSV. Anyone with that file can paste it into their own Cloudflare account and have an identical, independent copy running in minutes. Nothing is locked to the original deployment.