Event-Driven Microservices

A serverless event-driven architecture using Vercel Functions, Cloudflare Workers, and Supabase Realtime.

Vercel Function

Event producer endpoint at /api/events

POST events with type and payload

Validates with EVENT_SECRET

Stores in Supabase events table

Cloudflare Worker

Event consumer at /events/process

Polls for pending events

Processes via event handlers

Updates event status

Supabase Realtime

Event bus with PostgreSQL + Realtime

events table for event storage

notifications table for alerts

Realtime subscriptions

Event Handlers

Built-in handlers for common events

user.created → Welcome email

order.placed → Inventory update

payment.succeeded → Receipt

Quick Test

Test the event pipeline by sending a POST request to the Vercel Function endpoint.

curl -X POST https://your-app.vercel.app/api/events \
  -H "Authorization: Bearer YOUR_EVENT_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "user.created",
    "payload": { "userId": "123", "email": "test@example.com" },
    "source": "test"
  }'