Supabase Vector Chat System: Document Ingestion, Deletion & AI-Powered Q&A on Your Own Knowledge Base
Problem:
A development team building a Lovable app needed a complete backend system for document-based AI chat, one that could handle adding new documents to a vector database, removing outdated ones, and answering user questions against the stored knowledge, all through clean webhook-based API endpoints.
Solution:
Built a three-flow n8n vector database management system backed by Supabase, Flow 1 handles document ingestion: receives a webhook, retrieves the file from Supabase, fetches it via HTTP, extracts text from the PDF, chunks it with a Recursive Character Text Splitter, generates OpenAI embeddings, and stores vectors in the Supabase Vector Store with a Default Data Loader; Flow 2 handles document deletion: receives a webhook, deletes the specified Supabase row, and confirms; Flow 3 handles AI chat: receives a webhook, passes the query to an AI Agent with Postgres Chat Memory and Supabase Vector Store retrieval using OpenAI embeddings to answer questions from stored documents, all responding back to the webhook caller.
Result:
Delivered a complete document-aware AI backend, the Lovable app can add, remove, and chat with documents through three clean API endpoints, with all vector storage, retrieval, and AI processing handled automatically by the n8n backend.
