Engineering notes
Keeping a RAG portfolio assistant in sync with Supabase
How this portfolio connects Supabase, Gemini embeddings, Pinecone, and Groq, including content updates, stale vectors, and cache limitations.
By Vincent Teo · Updated
What happens after an edit
After a successful project save, a Next.js server action schedules a sync with after(). The visitor-facing save response does not have to wait for embedding requests. The backend webhook checks a shared secret before reading the content tables and generating new vectors.
Each knowledge entry has an ID derived from its category and question. Editing the answer updates the existing vector. Renaming a project can change its generated question and therefore its ID. The sync removes IDs absent from the new content set, so deleted or renamed entries do not remain indefinitely in retrieval results.
The route refuses to sync an empty content set, and a failed Supabase read aborts before cleanup. These checks matter because deleting every vector after a failed read would turn a temporary content error into an empty knowledge base.
Keep the retrieval units useful
Short portfolio entries are embedded as complete records using Gemini. Longer case studies are separated into their named sections, each carrying a link to the corresponding heading. That gives a question about limitations a more specific source than one vector representing the entire project.
At question time, the backend embeds the query, asks Pinecone for nearby entries, applies a similarity threshold, and sends the retrieved context to Groq. The widget streams the answer and displays supporting links. A source link helps a visitor inspect the evidence; it does not prove that every generated claim is supported.
Tradeoffs I would measure next
The current sync re-embeds the content on each run. This is easy to follow for a small portfolio, but a growing knowledge base would benefit from comparing content hashes and updating only changed entries. Concurrent sync jobs also deserve explicit coordination before scaling the service.
Answers use an in-memory cache, which is cleared by the process handling a successful sync. A deployment with multiple workers would need shared invalidation or versioned cache keys to keep every worker current. The update process is also not a transactional switch between complete index versions; an interrupted sync can require a retry.
The useful next measurements are sync duration, embedding requests per edit, retrieval quality after an update, and the time until changed content appears in an answer. These are proposed measurements, not published benchmark results.