APIs & setup

Four accounts. One afternoon.

The system depends on four external services. Three are quick free signups, one is a $5/month minimum for Cloudflare, one is pay-as-you-go for the LLM classifier. Total monthly running cost lands somewhere between £60 and £125 once everything is wired together.

How the pieces fit

Hosting, storage, and external data.

Cloudflare runs everything. Neon stores everything. Two external APIs — Companies House and Anthropic — supply the signals. The dashboard reads from Neon; the workers write to Neon. That’s the whole topology.

                    ┌─────────────────────────────┐
                    │       YOUR LAPTOP           │
                    │  wrangler deploy / secrets  │
                    └──────────────┬──────────────┘
                                   │
        ┌──────────────────────────┼──────────────────────────┐
        ▼                          ▼                          ▼
  ┌───────────┐            ┌───────────┐              ┌───────────┐
  │ CLOUDFLARE│◄──reads───►│   NEON    │◄──reads─────►│ DASHBOARD │
  │  Workers  │   writes   │ Postgres  │              │   Pages   │
  └─────┬─────┘            └───────────┘              └───────────┘
        │
        │  fetches
        ▼
  ┌──────────────────────────────────────────┐
  │  COMPANIES HOUSE          ANTHROPIC      │
  │  (filings, charges)       (classifier)   │
  └──────────────────────────────────────────┘
Account 01 · Cloudflare

Where everything runs.

Workers run the five background jobs. Pages hosts the dashboard. Queues pass messages between workers. KV holds the Companies House rate-limit counter. R2 stores the daily finance CSVs.

Plan neededWorkers Paid — $5/month minimum (required for Queues)
API key neededNone — wrangler login handles auth via browser
What it costs at scale~£15–25/month for this workload

Steps

  1. Sign up at the link above.
  2. Add a payment method. Upgrade to Workers Paid ($5/month minimum). The free tier doesn’t support Queues, which the workers depend on.
  3. On your laptop: npm install -g wrangler && wrangler login. A browser tab opens; click authorise.
  4. Done. The deploy guide picks up from here for each of the five workers and the dashboard.
Account 02 · Neon

The Postgres database.

All merchants, signals, invoices and exposure snapshots live here. Workers write; the dashboard reads. Neon is serverless Postgres — cheap to start, branchable for safe schema changes, scales when you need it.

Plan neededFree tier for dev. ~£20–40/month for production with always-on compute.
API key neededA connection stringpostgres://...
Used byEvery worker (5x) and the dashboard. Six places total.

Steps

  1. Sign up. Verify email.
  2. Create project. Name it redbrain-risk. Region: eu-west-2 (London) — closest to Cloudflare’s London edge.
  3. Once created, click Dashboard → Connection details.
  4. Copy the pooled connection string — the one with -pooler in the hostname. Save it somewhere safe.
  5. This is your DATABASE_URL. You’ll paste it into Cloudflare six times during deploy.
Account 03 · Companies House

UK company data, free.

Filings, charges, officer changes, gazette notices, accounts overdue flags. The most reliable signal in the whole system — it’s the official register, and merchants can’t hide from it.

CostFree.
API key neededREST API key
Rate limit600 requests per 5 minutes — honoured in code with KV-backed soft cap at 580
Used byCompanies House worker only

Steps

  1. Sign up. Verify email.
  2. Manage Applications → Create an application. Name it “Redbrain Risk View”.
  3. Create new key. Type: REST (not “stream”).
  4. Copy the key. This is your CH_API_KEY.
Account 04 · Anthropic

The LLM classifier.

Claude Haiku reads each scraped news article and answers: which merchants are mentioned, how severe is the distress signal, what kind. Cheap and fast at scale. The system would work without it — you’d just lose press signals.

CostPay-as-you-go. ~£20 of credit lasts months at low volume. £20–60/month at production volume.
API key neededA standard API key
ModelClaude Haiku 4.5 — cheapest fast model
Used byClassifier worker only

Steps

  1. Sign up.
  2. Settings → Billing. Add £20 of credit. (Auto top-up optional; manual is safer.)
  3. Settings → API keys → Create Key.
  4. Copy it — you can only see it once. This is your ANTHROPIC_API_KEY.
The cheat sheet

What goes where.

Four secrets, six places. Once you have the keys, deploy is mostly copy-paste.

Secret Used by How to set it
DATABASE_URL All 5 workers + dashboard wrangler secret put (workers)
wrangler pages secret put (dashboard)
CH_API_KEY Companies House worker only wrangler secret put in workers/companies-house/
ANTHROPIC_API_KEY Classifier worker only wrangler secret put in workers/classifier/
DASHBOARD_PASSWORD Dashboard only wrangler pages secret put
Total cost

About £60–125 a month.

Variable component is the LLM classifier — scales with article volume. Everything else is roughly fixed.

Cloudflare
£15–25/mo
Workers + Pages + Queues + KV + R2
Neon Postgres
£0–40/mo
Free tier for dev; paid tier for always-on production
Companies House
£0/mo
Free, government-provided
Anthropic (Haiku)
£20–60/mo
Scales with news article volume
Order of operations

How to actually do this.

Don’t try to do everything in one sitting. The signups can be done over a cuppa. The deploy needs a focused afternoon.

  1. 1

    Sign up for all four accounts.

    About 30 minutes. Have card details ready for Cloudflare and Anthropic. Save the four keys/strings in a password manager or local notes file.

  2. 2

    Run the schema and seed against Neon.

    Either via psql on your laptop, or paste into the Neon SQL editor in your browser. Five minutes. Populates 11 sample merchants so the dashboard has data on day one.

  3. 3

    Run wrangler login.

    Browser tab opens. Click authorise. Now your laptop can deploy to Cloudflare.

  4. 4

    Deploy each of the five workers.

    Roughly 10 minutes per worker. For each: cd workers/<name>, npm install, wrangler secret put DATABASE_URL, wrangler deploy. The Companies House worker also takes CH_API_KEY; the classifier also takes ANTHROPIC_API_KEY.

  5. 5

    Deploy the dashboard.

    cd dashboard, npm install, npm run pages:deploy. Set DATABASE_URL and DASHBOARD_PASSWORD. Redeploy once more so the env vars take effect.

  6. 6

    Open the dashboard URL.

    Log in with your password. You should see all 11 seeded merchants on the finance view. Wait ~6 hours for the first Companies House sync, ~30 minutes for the first news scrape.

DEPLOY.md in the repo has the exact commands. This page is the why; DEPLOY.md is the how.