Skip to content

feat(sync)!: migrate backend from Cloudflare Workers to Supabase#147

Closed
vscarpenter wants to merge 1 commit intomainfrom
feature/supabase-migration
Closed

feat(sync)!: migrate backend from Cloudflare Workers to Supabase#147
vscarpenter wants to merge 1 commit intomainfrom
feature/supabase-migration

Conversation

@vscarpenter
Copy link
Owner

Summary

  • Complete backend migration from Cloudflare Workers (D1/KV/custom OIDC) to Supabase (Auth + Postgres + Realtime + PostgREST)
  • Net deletion of ~22,500 lines — removes entire worker/ directory, custom OAuth handshake, token manager, vector clocks, health monitor, and all associated tests
  • Adds 5 new modules: Supabase client singleton, sync client, realtime listener, auth dialog, and OAuth buttons
  • MCP server updated to query Supabase directly via service role key instead of custom JWT auth

What Changed

Replaced

Before (Cloudflare) After (Supabase)
Custom OIDC OAuth flow Supabase Auth (Google/Apple)
D1 database + KV storage Supabase Postgres with RLS
Polling-based sync Supabase Realtime (WebSocket)
Custom API client + JWT Supabase SDK direct calls
Vector clocks for conflicts Last-write-wins (server updated_at)

Removed

  • worker/ — entire Cloudflare Worker backend (~150 files)
  • Custom OAuth handshake modules (lib/sync/oauth-handshake/)
  • Token manager, health monitor, vector clocks, API client
  • All tests for removed modules

Added

  • lib/supabase.ts — Supabase client singleton
  • lib/sync/supabase-sync-client.ts — CRUD operations via Supabase SDK
  • lib/sync/realtime-listener.ts — WebSocket subscription manager
  • components/sync/supabase-auth-dialog.tsx — Auth UI
  • components/sync/supabase-oauth-buttons.tsx — Google/Apple OAuth buttons

Verification

  • Sync tested locally — 47 tasks successfully pushed with E2E encryption
  • All encrypted blobs have valid nonce + checksum fields
  • Zero conflicts in conflict_log
  • RLS enabled on all 5 tables (profiles, encrypted_tasks, devices, sync_metadata, conflict_log)

Test plan

  • Local sync push verified (47 tasks encrypted and synced)
  • Supabase database integrity verified via SQL queries
  • Multi-device sync with realtime updates
  • OAuth sign-in flow (Google/Apple)
  • MCP server queries with new Supabase config
  • Build passes (bun run build)

Breaking Changes

Sync backend changed from Cloudflare Workers to Supabase. Users must:

  1. Re-authenticate via Supabase Auth
  2. Set NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY env vars

🤖 Generated with Claude Code

Replace the entire Cloudflare Worker sync backend with Supabase
(Auth + Postgres + Realtime + PostgREST). This is a complete
architectural migration that simplifies the stack significantly.

Key changes:
- Auth: Supabase Auth with Google/Apple OAuth (replaces custom OIDC)
- Database: Supabase Postgres with RLS (replaces D1/KV)
- Realtime: Supabase Realtime WebSocket (replaces polling)
- Sync: Direct Supabase SDK calls (replaces custom API client)
- MCP Server: Supabase service role queries (replaces JWT auth)

Removed:
- Entire worker/ directory (Cloudflare Worker backend)
- Custom OAuth handshake, token manager, vector clocks
- Health monitor, custom API client, config migration
- All associated tests for removed modules

Added:
- lib/supabase.ts - Supabase client singleton
- lib/sync/supabase-sync-client.ts - Sync CRUD via Supabase SDK
- lib/sync/realtime-listener.ts - Realtime subscription manager
- components/sync/supabase-auth-dialog.tsx - Auth UI
- components/sync/supabase-oauth-buttons.tsx - OAuth provider buttons

BREAKING CHANGE: Sync backend changed from Cloudflare Workers to
Supabase. Users must re-authenticate and configure Supabase env vars.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@vscarpenter vscarpenter closed this Mar 1, 2026
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.

1 participant