Supabase database changes (e.g., new document embeddings inserted) trigger Edge Functions that route events through EventBridge to invoke ECS Cloud Assistant commands, which batch-manage vector data and indexes in OSS (insert, rebuild, similarity search), then email a processing report with index statistics via Resend.
When a Supabase table receives new document embeddings or updates, developers need an automated pipeline to sync these vectors into Alibaba Cloud OSS for high-performance similarity search. This workflow triggers ECS-based batch processing via EventBridge and delivers a completion report with index metrics through Resend.
supabase/functions/sync-vectors/index.ts to listen for INSERT events on your embeddings table. Format the payload as {"action": "sync", "vectors": [...]} and POST it to the EventBridge PutEvents endpoint.{"source": ["supabase.edge"]}. Route to an ECS Cloud Assistant target using the RunCommand API. Set CommandType=RunShellScript and pass the payload via Parameters.``bash curl -X POST "https://<bucket>.oss-<region>.aliyuncs.com/?vector&action=CreateVectorIndex" \ -H "x-oss-vector-dimension: 1536" \ -H "x-oss-vector-distance-metric: Cosine" \ -H "x-oss-vector-format: float32" ``
InsertVectors action, ensuring each record includes a primary key. Immediately run a validation query:``bash curl -X POST "https://<bucket>.oss-<region>.aliyuncs.com/?vector&action=QueryVectors" \ -d '{"topK": 5, "vector": [0.1, 0.2, ...]}' ``
TotalVectors and IndexSize from the OSS response. Trigger a Resend API call:``bash curl -X POST https://api.resend.com/emails \ -H "Authorization: Bearer $RESEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{"from":"[email protected]","to":["[email protected]"],"subject":"Vector Sync Complete","html":"<p>Inserted $COUNT vectors. Index size: $SIZE MB.</p>"}' ``
Supabase acts as the event source, pushing database changes to an Edge Function. The function publishes structured events to Alibaba Cloud EventBridge, which routes them to an ECS Cloud Assistant command. The ECS instance executes a shell script that interacts directly with the OSS Vector API to manage indexes and run similarity queries. Finally, the script calls the Resend API to deliver a formatted processing report to stakeholders.
pg_net configuredAliyunECSFullAccess, AliyunOSSFullAccess, and AliyunEventBridgeFullAccess attached to the ECS instancedimension matching your embedding modelcurl installed on target ECS instancesdimension parameter doesn't exactly match your embedding model (e.g., 768 vs 1536).Timeout in the RunCommand API call.429 Too Many Requests. Implement exponential backoff or batch notifications.Q: How does the system automatically rebuild OSS vector indexes when Supabase data changes and send a notification? A: The pipeline automatically rebuilds vector indexes in OSS whenever Supabase database changes occur. These events are routed through EventBridge to trigger ECS batch jobs, after which a processing report with index statistics is emailed via Resend.