Repo of the Day
ygwyg/merchant
Published: Dec 2, 2026
Open repository ↗The backend for selling things on the internet
Summary
ygwyg/merchant is a TypeScript, API-first commerce backend for Cloudflare Workers, with Stripe handling payments. It provides product and variant management, inventory, carts and checkout, customers, orders, refunds, image storage, and real-time updates. It also exposes OAuth 2.0 and Universal Commerce Protocol (UCP) endpoints for platform integrations and agent-to-commerce flows.
What it is useful for
Use Merchant when an application needs a commerce backend rather than a complete storefront. Engineers can create products such as a “T-Shirt,” attach priced variants with SKUs, adjust stock, accept cart checkouts, and then manage orders, tracking, and refunds.
The REST API distinguishes public keys (pk_...), which can create carts and check out, from admin keys (sk_...), which provide full access. This separation can support a customer-facing store while keeping catalog, inventory, customer, and fulfillment operations behind administrative credentials.
It also fits integrations that need event delivery or delegated access:
- Outbound webhooks can report events such as
order.created,order.shipped,inventory.low, and refunds. Payloads use HMAC-SHA256 signatures. - WebSockets provide live cart, order, and inventory updates.
- OAuth 2.0 with PKCE lets platforms act for customers with scopes for checkout, orders, and addresses.
- UCP endpoints let AI agents discover products and create Stripe-backed checkout sessions.
How engineers can use it
The README documents a straightforward local start:
git clone https://github.com/ygwyg/merchant
cd merchant && npm install
npx tsx scripts/init.ts
npm run dev
The initialization script creates API keys. Optional demo data can be added with:
npx tsx scripts/seed.ts http://localhost:8787 sk_your_admin_key
Connect Stripe through the documented setup endpoint:
curl -X POST http://localhost:8787/v1/setup/stripe \
-H "Authorization: Bearer sk_your_admin_key" \
-H "Content-Type: application/json" \
-d '{"stripe_secret_key":"sk_test_..."}'
A typical workflow is to create a product, add a variant such as TEE-BLK-M for 2,999 cents, adjust its inventory, create a cart, add two units, and request checkout. The checkout response returns a Stripe URL. A test-order endpoint is also documented for workflows that need to skip Stripe.
The admin interface and example storefront can be started separately:
cd admin && npm install && npm run dev
cd example && npm run dev
For deployment, the README documents wrangler deploy followed by npx tsx scripts/init.ts --remote; Durable Objects and R2 are automatically provisioned.
Documented caveats include that ordered products or variants cannot be deleted, a single Durable Object handles most stores, and D1 migrations do not re-import historical orders. API keys and OAuth tokens must also be regenerated during that migration.