Recorded against the local stack: docker Postgres, seed_local.py with real figures from a Shopify development store, the API and the built dashboard. Full video.
Multi-tenant analytics hub: external APIs are synced, normalised, stored in PostgreSQL, served by a backend and shown on a dashboard.
There are sixteen connectors. Shopify Admin GraphQL is verified against a real development store. Fifteen more (table below) ran against stand-in servers written from the vendors' documentation. The dashboard never calls a vendor API to render a page; it reads snapshots the sync wrote. A monthly PowerPoint report, built by an n8n workflow for each tenant, puts the sources side by side.
| Source | Built and tested against |
|---|---|
| Shopify | a real development store |
| Google Analytics 4 | a stand-in server (sources) |
| Meta Ads | a stand-in server (sources) |
| Meta ad creatives | a stand-in server (sources) |
| Search Console | a stand-in server (sources) |
| Google Ads, TikTok Ads, Google Business Profile, Square, QuickBooks Online, Shopmonkey, Salesforce | a stand-in server each (sources) |
| Harvest (time, budgets), Microsoft Graph (SharePoint, Teams, Excel) | a stand-in server each (how) |
| Autotask PSA (tickets, technician time) | a stand-in server only: written from the vendor's public documentation and tested against a stand-in server, never a live database (sources) |
| NinjaOne (RMM: devices, active alerts) | a stand-in server only: written from the vendor's public documentation and tested against a stand-in server, never a live tenant (sources) |
| ConnectWise Manage (PSA: tickets, technician time) | a stand-in server only: written from third party descriptions of the API (not ConnectWise's own pages: its documentation needs a login that refuses a free email address) and tested against a stand-in server, never a live tenant (sources) |
| A fulfilment partner's order API (outbound) | a stand-in server (contract) |
| n8n | a real n8n 2.44.6 container, seven runs read node by node |
The dashboard front end is on Vercel (https://analytics-hub-pi.vercel.app).
Requirements: Docker (010 needs pgvector), Python 3.13, Node 20+, and psql (or the container's own, second form below). nix develop gives the same tools from a lock file (docs/nix.md).
# 1. Postgres
docker compose up -d --wait # exposes 5433, deliberately not 5432; waits for the healthcheck
# 2. Backend
python -m venv .venv
. .venv/Scripts/activate # Windows, Git Bash. macOS or Linux: . .venv/bin/activate
pip install -r requirements.txt
export DATABASE_URL="postgresql://analytics:[email protected]:5433/analytics"
export CREDENTIAL_KEYS="1:$(python -c 'from app.crypto import generate_key; print(generate_key())')"
export DASHBOARD_ORIGIN="http://localhost:3100"
# migrations, in order, with the psql client
cat migrations/*.sql | psql "$DATABASE_URL" -v ON_ERROR_STOP=1
# or, without psql:
for f in migrations/*.sql; do docker compose exec -T db psql -q -U analytics -d analytics -v ON_ERROR_STOP=1 < "$f"; done
uvicorn app.api.main:app --port 8000
# 3. Dashboard
cd web && npm install && NEXT_PUBLIC_API_BASE=http://127.0.0.1:8000 npm run build
npm start -- -p 3100seed_local.py needs the owner's Shopify development store (a two-line domain and token file); anyone else runs python seed_demo.py (sample figures, same keys). Both drop the public schema and print an admin and a viewer API key; seed_local.py applies 001 to 003, so run the rest after. Build and start the dashboard (not npm run dev, which did not hydrate) and open http://localhost:3100.
app/ holds the connectors, sync runner, API, change detection, monthly report and sms.py and messaging_inbound.py, the signed Twilio STOP and Resend bounce receiver (docs/sms.md). migrations/ holds the SQL in order. Backups: docs/backups.md; metrics: docs/observability.md. deploy/ holds a Caddyfile and four systemd units; deploy/run_units_on_systemd.sh boots a real systemd as PID 1 in a Debian container, installs the units with stand-in executables and checks that the timer fires the service on its own schedule, that it runs as its own user and that a failed backup starts the alert check (docs/deploy.md; nothing has run on a rented server). File by file: docs/layout.md.
Connectors translate and nothing else: each yields CanonicalPoint values, never a vendor's field names. Money is an integer in minor units with its currency beside it. History is accumulated in dated snapshots, not fetched. The tenant boundary is in the database: row level security is enabled and forced on every tenant table and the pool refuses to start as a role that can bypass it. Credentials are AES-256-GCM encrypted with the row bound in, and syncs are leased, not flagged. Each decision and why: docs/architecture.md.
Google Ads, TikTok, Square, QuickBooks, Shopmonkey and Salesforce are written from the vendors' public documentation and ran against stand-in servers. Salesforce adds a lead matcher (docs/salesforce.md). app/report/adspend.py puts Google Ads, Meta and TikTok side by side. Limits: docs/ad-spend.md.
- Meta ad creatives.
scripts/meta_creatives.pywrites a CSV and a JSON file with every ad's copy, destination links, video source and permalink, shareable preview link and post link across campaigns. Built from Meta's pages and run only against a stand-in server. 389 tests, 74 breakages each caught: docs/meta-creatives.md.
app/ai/catalog_copy.py is an LLM copywriter for product meta descriptions that refuses to publish a number it was not given: verify_grounded rejects any row whose figures are not in the product facts. Against a live model it invented nothing with the rule. 30 tests and four mutation guards: docs/catalogue-copy.md.
app/price_watch/ reads competitor pages in Chromium (Playwright). It matches them to the catalogue (an uncertain match waits for a person), reports where a competitor's landed price beats ours without breaking a floor, and syncs person-approved prices to Shopify and Zoho Inventory. Tested against stand-in pages and vendor servers written from the vendors' documentation. Details: docs/price-watch.md.
An hourly n8n workflow pulls ten job data vendors, normalises and dedupes them, archives the raw JSON, embeds each new job into Qdrant and scores a tailored resume and cover letter that refuses any claim the applicant's facts do not hold. A form filler types a field only at 0.95 confidence; the rest go to a review queue, and the answer resumes the run.
Run against stand-ins, real Redis, Qdrant, RabbitMQ, Postgres and n8n (output), with the embeddings and a chat model live (output). Not pointed at a vendor account or an employer's application form. Details, vendors.
app/billing/ is a prepaid wallet with a double-entry ledger in integer minor units under forced row level security: an unbalanced transaction cannot commit and a wallet cannot go below zero. Top-ups, refunds, subscriptions and a signed webhook receiver run through a Stripe provider interface (the official SDK against stripe-mock), with an idempotency key on every money command: docs/billing.md.
-
Ordering portal. Python, FastAPI, asyncpg and Postgres row level security: Stripe bank debit (ACH) and invoices run against stripe-mock, a partner fulfilment connector with signed status events and a hash chained audit log run against a stand-in partner, and a four role access matrix enforced in the API and in the database. 368 tests, 182 breakages each caught: bank debit and invoices, fulfilment, roles.
-
Stripe webhooks: refunds, disputes and cancellations.
POST /api/billing/webhooks/stripechecks theStripe-Signatureheader (the timestamp window and the v1 HMAC over the raw body) before it reads anything, claims each event id once in the same Postgres transaction that applies it, and handlescharge.refunded,charge.dispute.created,charge.dispute.closedandcustomer.subscription.deleted: a refund reverses only the newly refunded part, a dispute holds the disputed credit out of the wallet and a win returns it or a loss writes it off, and a cancellation ends the subscription for good. An event that arrives before the payment it depends on is held and applied when the payment is, one that can never apply is dead-lettered with a notice, and every attempt leaves an append-only audit row. Run against stripe-mock and against events built from Stripe's documented shapes and signed with its scheme, never against a Stripe account. 42 new tests (25 of them seeded worlds of late, repeated and reordered events) and 21 deliberate breakages each caught: receiver, guards.
scripts/monthly_report.py --month 2026-10 --tenant <uuid> turns one month of stored snapshots into a PowerPoint deck: seven slides for a store, up to ten with a website, ads and search. The narrative is a fixed template; a model's text is used only if every figure in it is computed.
The monthly run. POST /api/reports/monthly builds the same deck byte for byte and says whether it was delivered, so a rerun sends nothing. The n8n workflow calls it for each tenant at 13:00 UTC on the first of the month; (output). --drive-folder <id> uploads the deck to Google Drive (detail). Method and limits.
The Reports page in web/ (Next.js App Router, strict TypeScript, Tailwind CSS 4, shadcn/ui) exports a tenant's month as CSV, Excel or PDF through Server Actions with Zod checks. An optional AI summary passes a code guard that refuses any figure not in the data. Tested on real Postgres and a free Neon project (detail): 156 tests, 12 browser tests, 76 deliberate breakages each caught.
app/inventory/ reads Shopify inventory levels per product variant and keeps them as dated snapshots in Postgres for each tenant under forced row level security, beside the order lines sold. It works out a stockout-adjusted forecast: the daily sales velocity of each SKU and variant is the units sold over the days it was on sale, so ten days with an empty shelf do not read as demand falling. From the supplier's lead time and the variation in demand it gives days of cover, a reorder point and safety stock, and a suggested order in whole packs. A dated promotion factor a person enters lifts the forecast. Variants are ranked into ABC classes by sales contribution and labelled an all-time best seller, a rising best seller or a slow mover. Each shortage raises one alert, once. The /inventory page is the inventory dashboard with exception alerts and writes a supplier purchase order draft for each supplier as CSV, Excel or a Google Sheets paste.
Run against the owner's Shopify development store, read only: 38 variants and 28 order lines, with five variants and 25 test orders made for the run and removed after it. Lead times and promotions are supplied as inputs, and the stockout adjustment is shown on a constructed history (the run).
Purchase order tracking. An order is made from the plan's draft and moves through draft, ordered, confirmed, shipped, partly received, received or cancelled by a transition table the database enforces. What is still on order counts as inbound stock, so an order that lands in time raises no shortage and no second order (rules and limits).
Excel model with live formulas. inventory_plan.py workbook, or the page's download, writes Inputs, Plan (supplier lookup, cover, safety stock, reorder point, order and shortage flag as formulas), Classes (COUNTIFS, SUMIFS) and Scenario (before and after the promotion factor). Each computed cell is recalculated in LibreOffice and compared with the Python plan, and a one unit change in an input fails the check (run, how).
A worked example, the formulas, the rule for a day with no snapshot and the limits (seasonality is out of scope): docs/inventory-planning.md.
powerbi/ holds a Power BI report over the same snapshot tables: a five table star schema, 27 DAX measures, two pages and 18 visuals, on sample figures. powerbi/check_model.py runs the measures against 56 figures worked out from the CSV files: all match, and one dollar changed in the data fails six. Details.
A Next.js proxy reads the Host header and rewrites a one label subdomain to an internal route; a key opens a portal only when its tenant's row carries that host's slug. 16 tests, 14 live HTTP checks, 8 breakages caught: docs/portals.md.
E-signatures. A client reads a document's SHA-256 and a versioned consent text, types their full name and signs once; the record links into a hash chained, append only audit log, and verify names the row or byte that changed. 212 tests over 50 seeded worlds and 63 guards, each caught. A tamper-evident record, not a certified e-signature service, not legal advice: docs/esign.md.
app/changes.py loads one day of about 400,000 carriers, finds the few that changed with one hash compare, keeps every change in history and raises each alert once behind a UNIQUE key. Measured on 2026-10-24 (sample data): a 400,200 row day took 9.89 s and raised 2,371 events; the same file again raised 0. Method and limits: docs/change-detection.md.
lakehouse/ is a medallion pipeline over the hub's own daily figures, on open source Spark 4.1 and Delta Lake 4.3 on one machine. The Spark code never ran on Databricks; the same layers written as SQL did, on a Free Edition workspace (run). 68 tests; 24 of 24 breakages caught. Details and limits, runbook.
analytics-engineering/: a dbt Core project (4 marts, 66 tests) run on Postgres and BigQuery's free sandbox, a Cube semantic layer, a local model answering 32 questions with Cube queries (85 of 96 trials right), a reconciliation that catches a planted variance, an OpenMetadata glossary, a Looker Studio report and Slack alerts, on invented data. Results and limits.
msp-powershell/MspAutomation is a PowerShell 7 module: NinjaOne, ConnectWise and Microsoft Graph REST helpers, an alert remediation runbook that opens a ticket only when the alert did not clear, ticket auto-triage, patch orchestration (an approval policy, maintenance windows per client tier, success proved from the pending list and the history, a ticket only on failure), user onboarding and offboarding through Graph with a completion report that counts only what it read back, rollback for each, inventory drift between NinjaOne and ConnectWise with an optional fix, and a run log with an automation report (success rate, ticket reduction, an estimate of minutes saved that is labelled an assumption, service levels, Prometheus text). 922 Pester tests (seeded random worlds checked against Python oracles that read the same rules files), PSScriptAnalyzer clean, 446 guards broken on purpose. Written from the vendors' public documentation, each page saved with a note of what it leaves unstated, and tested against stand-in servers written from the same pages, never a live tenant. The Windows executor ran for real on a Windows Server 2022 Evaluation machine in the lab below (not under a NinjaOne agent), and that first run found and fixed two defects (docs/msp.md, runbooks).
msp-powershell/lab/ builds a Windows Server 2022 Evaluation machine from one script, on a Windows 11 PC with no administrator rights (QEMU with the Windows Hypervisor Platform, an unattended install from a generated answer file, PowerShell remoting over HTTPS), and promotes it to the domain controller of a new forest. It then builds and reads back Active Directory DNS records and a reverse zone, a DHCP scope authorized in Active Directory with options, an exclusion and a reservation, an OU tree with four GPOs and the domain password and lockout policy (checked on the domain controller after gpupdate /force),
and ten users and four groups from a CSV with a drift check and an undo; then it runs the module's Windows executor and the alert remediation runbook inside it, with a reading of the machine before and after each action. 119 tests read the state back from the machine; the parts that need no Windows run in the Linux CI job. One domain controller and no second machine: no domain member, no replication partner, no DHCP lease, no time source for resync-time, an evaluation licence (docs/windows-lab.md).
Active Directory migration (msp-powershell/lab/guest/AdMigration.Lib.ps1, run in the lab by Invoke-WindowsLab.ps1 -Phase Migration): users and their security group memberships move from a legacy OU into a target OU of the same domain from a YAML or CSV mapping, with the account name and user principal name renamed. A dry run lists every planned move and every conflict (a name or principal name that is taken, a missing target OU or group) and changes nothing; the apply journals each step, and its report counts an account only after reading it back from Active Directory; the undo returns only what the journal names. In the lab, 7 of 10 accounts moved and read back Verified while 3 conflicts were listed and left alone, then 10 of 10 after the conflicts were cleared, and the undo restored 9 and skipped 1 that somebody else had moved. 92 Linux tests against an in-memory directory (40 seeded worlds in which migrating and undoing must leave the directory as it started), 84 deliberate breakages each turn a test red, and 13 more tests read the guest.
Not tested on: a migration between two domains or forests (the lab has one domain), SID history, password migration, replication or Entra ID sync (docs/windows-lab.md).
app/policy_baseline/ reads Conditional Access, Intune compliance and Microsoft Defender for Endpoint policies from Microsoft Graph and reports drift from a baseline file per tenant: MFA for admins, legacy authentication blocked, a compliant device required, a break glass exclusion on every enabled policy that could lock the accounts out, report-only versus enabled, an assigned EDR policy, antivirus settings by definition id. Written from 26 saved Microsoft pages and tested against a stand-in Graph server, never a live tenant: 150 tests, 700 seeded tenants against brute force oracles, 99 guards broken on purpose (docs/msp.md).
python -m pytest tests/ -q # 9,146 passed, 117 skipped, 5 known limits marked
python tests/mutation_check.py # all 300 hand matched guards; edits source, so use a copy
python tests/mutation_check_jobs.py # the job pipeline's guards, run in a temporary copy
python tests/mutation_check_inventory.py # 114 inventory guards, each broken on purpose; use a copy
python tests/mutation_check_fulfillment.py # 182 portal guards (bank debit, invoices, roles, fulfilment); use a copy
python tests/mutation_check_msp.py # the MSP connectors, records, ledger and backlog analysis: every guard broken on purpose; use a copy
pwsh -NoProfile -File msp-powershell/tests/Invoke-Tests.ps1 # 922 Pester tests of the PowerShell module and the lab's pure parts
python tests/mutation_check_msp_powershell.py # 446 module and lab guards, each broken on purpose; use a copy
./msp-powershell/lab/Invoke-WindowsLab.ps1 -Phase All # the Windows lab: builds the VM, then the VM tests (local only, [docs/windows-lab.md](docs/windows-lab.md))
python tests/mutation_check_policy_baseline.py # 62 policy baseline guards, each broken on purpose; use a copy
python live_check.py # against the real store
cd web && npm test # 240 tests, 11 need the S3 stand-in ([docs/web-reports.md](docs/web-reports.md))
cd web && npm run build && npx playwright test # 21 browser tests in Chromium, Firefox and WebKit
cd web && node scripts/mutation_check.mjs # 158 guards broken one at a time; use a copyRun dates, outputs, skips and the 2,779 syntax tree mutants: docs/TESTING.md.
Open items, in the order I would do them: docs/roadmap.md.


