feat: implement data replication plugin for external database sync #96
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #72
/claim #72
Purpose
Implement a comprehensive data replication plugin for StarbaseDB that enables users to pull data from external databases (PostgreSQL, MySQL, etc.) into the internal SQLite database with configurable sync intervals and incremental updates.
This addresses the request for creating a "pull mechanism" to replicate data from external sources like Supabase PostgreSQL into StarbaseDB's edge-close SQLite replica.
Screencast.from.2025-07-23.13-11-42.mp4
Tasks
Verify
🔍 Code Review Checklist
plugins/data-replication/index.ts
🧪 Testing Steps
npm run build && npx wrangler deploy
curl -X GET https://starbasedb.mavrickrishi.workers.dev/data-replication/status -H "Authorization: Bearer ABC123"
📊 Performance Verification
Before
GitHub Issue #72 Request:
StarbaseDB Plugin Ecosystem:
After
✅ Complete Data Replication System:
🔌 New Plugin Added
🚀 Live Deployment
📡 7 New API Endpoints
POST /data-replication/configure
- Set up replicationPOST /data-replication/start/:name
- Start specific replicationPOST /data-replication/stop/:name
- Stop specific replicationPOST /data-replication/sync/:name
- Manual sync triggerGET /data-replication/status
- View all configurationsGET /data-replication/logs
- Sync operation logsDELETE /data-replication/configure/:name
- Remove config💾 Database Schema
Two new internal tables created:
tmp_replication_configs
- Store replication settingstmp_replication_logs
- Track sync operations and performance🔄 Working Demo
🎯 Issue Requirements Met
✅ Pull mechanism for external databases
✅ Configurable sync intervals
✅ Table-specific replication
✅ Incremental updates via tracking columns
✅ Supabase PostgreSQL support
✅ Edge-close SQLite replica creation
✅ wrangler.toml configuration support