Angel Campa
Colour theme

WorkShared infrastructure, then teardown

Ventora Platform

Shared infrastructure for analytics, auth, billing, storage, email, and two AI support widgets, which other products in the estate depended on as private packages instead of each rebuilding its own.

Ran on
Cloudflare Workers
Ran
May 2026 to July 2026
Domain
Shared platform infrastructure
Source
shared-platform-monorepo-ventora-snapshot

Built with

  • TypeScript
  • Python
  • Cloudflare Workers
  • Durable Objects
  • R2
  • Better Auth
  • Stripe
  • PostHog

Hosted services

  • Durable Objects
  • R2
The AI-CS support panel rendered four times side by side under the CAMAudit, CapVeri, GrantPipe and Lextract themes: green, purple, near-black and orange headers, each with a matching send button, escalation pill and message bubbles, all answering the same "How do I get started?" question
The same widget build under four brand themes, captured by a scripted Playwright run against fully mocked Workers: no API key, no network beyond localhost. Brand tokens are data, so adding a product does not fork the client. CAMAudit and CapVeri are the same product under its old and new names, so these four themes correspond to three products.

The decision

Python code in Ventora sent email by posting a signed payload to a small Cloudflare Worker, email-renderer, which rendered the real React Email templates and returned HTML and text. The alternative was a second template set in Python that would have drifted within a month.

Half of Ventora’s consumers were TypeScript and half were Python, and most of the cross-language contract (analytics event names, PII redaction rules) was solved by generating both languages from one JSON schema and byte-comparing the output in the verify gate, so the two runtimes could not drift apart quietly. React Email templates are React, so email rendering used a different solve for the same problem: the Worker above let the Python client call the real templates directly, over an HMAC-signed bridge, keeping both languages rendering from one source.

The parity that mattered on the email path was byte parity of the string that gets signed. The Python client serialized timestamp, nonce, method, path, and body in exactly the key order the Worker used to rebuild the same string, so json.dumps(separators=(",", ":")) and JSON.stringify had to agree byte for byte or the HMAC failed.

An end-to-end test booted the real Worker under wrangler dev and drove the real Python client against it, so that agreement was proven rather than asserted. The cost was a network hop and a Worker kept alive for a single template render, in exchange for a signature scheme proven correct across both languages before it shipped.

Architecture

Everything in the repository except five packages was published as a versioned package and consumed as a private dependency by other products; nothing else here was a deployment target in its own right.

The five exceptions were the deployed Cloudflare Workers. email-renderer let Python render React Email templates without a JS runtime, over the HMAC-signed bridge above. ai-sdr-worker held anonymous marketing-assistant session state in a Durable Object, with a durable outbox and an alarm-driven retry ladder (0s, 30s, 2m, 10m, 1h) so a streaming reply never waited on a lead push to a product’s CRM.

ai-cs-worker served the authenticated in-app support assistant, fetching a signed per-app context from the product and still treating the payload as untrusted, sanitized and length-capped before it reached a prompt. package-registry and python-registry were a private npm registry and a private PEP 503/691 Python index, both implemented from scratch on R2, so every other package in the monorepo had somewhere to publish to and install from without a third-party registry in the loop.

Two widgets, two rules for model output

The hosted AI-CS client, the vanilla-JS build every product embedded on its own marketing pages, rendered every assistant reply through textContent, never innerHTML (packages/ai-cs-worker/src/hosted-client.ts). There was no markdown parser in that path at all, by design: model output landed on a page the widget did not control, so the safest rule was to never interpret it as markup.

@ventora/ai-cs, the React package a product could embed inside its own authenticated app, took the other side of that choice and rendered markdown, through a closed whitelist parser (packages/ai-cs/src/react/markdown.tsx) whose own docstring stated it was “XSS-safe by construction” and never called dangerouslySetInnerHTML. The parser’s behavior under partial input was asserted in the package’s own tests: its inline pattern only recognized a **bold** span once both delimiters had arrived, so a reply captured mid-stream, before the closing ** streamed in, showed literal asterisks for a moment, exactly as the tests expected. One client stripped formatting on purpose, the other rendered it once it could prove it was safe to.

Verification

pnpm verify chained nine steps: a schema check, a metrics check, a secret scan, script tests, lint, typecheck, coverage enforced per file across 19 vitest configs and 6 Python packages, and two smoke suites that installed the built TypeScript and Python artifacts and imported them the way a product would. The in-process Worker E2E tier and the Playwright browser E2E tier were split out as their own commands, run on demand, so the fast local gate stayed fast.

By the numbers

Each figure carries where it came from and when it was measured. Open one to see the command behind it, where the repository recorded a command.

Packages and Workers
20 TypeScript packages, 6 Python packages, 5 deployed Cloudflare Workers
Provenance

Source portfolio/METRICS.md § Scale

Measured

Project lines
92,119 lines across 442 files (lockfiles excluded)
Provenance

Source portfolio/METRICS.md § Scale

Measured

Source code
21,740 TypeScript source lines · 8,039 JavaScript · 4,656 Python
Provenance

Source portfolio/METRICS.md § Source versus test, by package

Measured

Test code
39,822 TypeScript test lines (64.7% of TypeScript) · 3,962 JavaScript · 4,680 Python (50.1% of Python)
Provenance

Source portfolio/METRICS.md § Source versus test, by package

Measured

Test cases declared
2,059 vitest · 448 pytest cases expanding to 472 executed under @pytest.mark.parametrize · 227 node:test
Provenance

Source portfolio/METRICS.md § Scale

Measured

Coverage floor
95% lines, branches, functions, statements, enforced per file across 19 vitest configs and 6 Python packages
Provenance

Source portfolio/METRICS.md § Scale

Measured

Cross-language contract
46 analytics events, 35 redaction field keys, 7 patterns: generated into both TypeScript and Python and byte-compared in the gate
Provenance

Source portfolio/METRICS.md § Scale

Measured

Zero-runtime-dependency packages
18 TypeScript packages
Provenance

Source portfolio/METRICS.md § Scale

Measured

Verification gate
pnpm verify chained nine steps, ending with two consumer harnesses that installed the built artifacts and imported them the way a product would
Provenance

Source README.md § Worth reading: A gate you can actually run

Measured

Screens

Support widget showing the question "How do I get started?" and a reply about uploading a file to extract and export key facts, with Copy, Retry, and Talk to a person options
The authenticated in-app support assistant, served from @ventora/ai-cs-worker, in its answered state on desktop.
Grid of ten labeled email templates: welcome, password-reset, email-verification, trial-ending, trial-expired, payment-receipt, payment-failed, lead-magnet-delivery, nurture-step, and internal-error-fallback, each with its own heading and colored CTA button
Rendered by @ventora/email-templates and reached from Python through the @ventora/email-renderer Worker, over an HMAC-signed HTTP bridge that let the Python client call the real React Email templates directly.
Read the repositoryshared-platform-monorepo-ventora-snapshot

Its portfolio/ directory holds the architecture, metrics and testing documents these figures were taken from.