Skip to content

AT1: the CRM on Workers - #2

Merged
ruehowl merged 1 commit into
mainfrom
at/1-the-crm-on-workers
Oct 28, 2026
Merged

ruehowl merged 1 commit into
mainfrom
at/1-the-crm-on-workers

Conversation

@ruehowl

@ruehowl ruehowl commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Marmelab's Atomic CRM (marmelab/atomic-crm at 9eb8349, MIT) running on one Cloudflare Worker.

apps/web: the React-Admin app, its FakeRest demo, and its six Supabase edge functions.

  • App: Vite builds it into the Worker's Static Assets.
  • Edge functions: they become the Worker's own routes, at the paths supabase.functions.invoke already calls (/functions/v1/<name>). The code is nearly verbatim:
    • Deno.env and Deno.serve come from a two-function shim.
    • The jsr:/npm: imports are npm packages.
    • Two pieces held a Postgres pool for the life of the process: Kysely in merge_contacts, and @supabase/server's middleware in the MCP server. Both now open a client per request through the Hyperdrive binding. A Worker may not reuse a socket another request opened, and I confirmed the pooled version hangs on the second request.
  • Calling the functions: the Supabase client's fetch sends function calls to the page's own origin.
  • Build config: the build inlines the project's URL and publishable key from the rendered wrangler config, so the bundle and the Worker always name the same project.
  • Inbound email: it answers 503 until configured, instead of failing the whole Worker at load.
  • Size: 561 KiB compressed in the dry run.

tests/web:

  • Upstream's 33 test files (433 tests, plus upstream's one skip) run in Chromium, with the 14 Storybook stories they render.
  • Its 5 edge-function test files.
  • The port's own tests: the routes, the functions' fetch, the build's project, the wrangler render, and the MCP server's Postgres.
  • Every direct dependency is pinned to the version upstream's lockfile resolves. With newer patch versions, upstream's own tests fail, and they pass on its lockfile.

Checked locally:

  • pnpm typecheck, lint, test and build are green.
  • Under wrangler dev, against a stand-in Supabase and a local Postgres:
    • the SPA, including deep links;
    • CORS preflight;
    • 401 for a signed-out caller;
    • a password reset through the admin client;
    • Postmark's 503 when unconfigured;
    • the MCP server's OAuth challenge, its metadata, and repeated tool calls against Postgres.

Every departure from upstream is listed in specs/epics/atomic-crm/IMPLEMENTATION-STATUS.md.


Generated by Claude Code

apps/web is Marmelab's Atomic CRM — the React-Admin single-page app, its
FakeRest demo and its six Supabase edge functions — on one Cloudflare
Worker. Vite builds the app into the Worker's Static Assets; the edge
functions are the Worker's own routes at the paths supabase.functions.invoke
calls (/functions/v1/<name>), nearly verbatim: Deno.env and Deno.serve come
from a two-function shim, the jsr:/npm: imports are npm packages, and the
two that held a Postgres pool for the life of the process (Kysely in
merge_contacts, @supabase/server's middleware in the MCP server) open a
client per request through the Hyperdrive binding, since a Worker may not
reuse a socket another request opened. The Supabase client's fetch sends
function calls to the page's own origin; the build inlines the project's URL
and publishable key from the rendered wrangler config, so the bundle and the
Worker name the same project. Inbound email answers 503 until it is
configured instead of failing the Worker at load.

tests/web runs upstream's 33 test files in Chromium with the Storybook
stories they render, its edge-function tests, and the port's own: the
routes, the functions' fetch, the build's project, the wrangler render and
the MCP server's Postgres. Every direct dependency is pinned to the version
upstream's lockfile resolves.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019PcpNVpFBcbeiX3EHdXfmn
@ruehowl
ruehowl merged commit 3c2b35a into main Oct 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants