Confidential - AI Knowledge System with RAG
A secure, AI-enabled personal knowledge system that stores, retrieves, and answers questions over markdown notes using Retrieval-Augmented Generation (RAG). Combines vector search with an LLM to deliver grounded, cited answers from a private knowledge base.
The problem
Build a minimal, secure knowledge system allowing the user to ask natural language questions and receive grounded answers sourced from their own private markdown files.
What I built
Built a Next.js App Router application with Firebase Auth, implemented a full RAG pipeline using pgvector on Neon Postgres with Prisma ORM, integrated OpenAI API for grounded Q&A, and deployed on Vercel with optimised caching.
Outcome
- Semantic vector search across a private markdown knowledge base via pgvector
- Grounded AI answers with live citation links to source documents
- Secure access behind Firebase authentication with session cookies
- Fast retrieval and response with Neon Postgres and Vercel edge deployment
Stack
How I think about this work
Deep-dives covering the same problems this project ran into.
Multi-Tenant Architecture with Supabase: Doing It Right with RLS
How to structure a multi-tenant SaaS on Supabase using Row Level Security for tenant isolation - schema design, the JWT claims approach, and the pitfalls that cause cross-tenant data leaks.
Supabase and Next.js Server Actions: The Pattern That Avoids Redundant Fetches
A practical pattern for combining Supabase with Next.js Server Actions and the App Router - where to create the client, how to handle auth cookies correctly, and how to avoid re-fetching data the server already has.
Running into something similar?
Start with a fixed-scope audit of your Supabase/Postgres app. If there is nothing worth fixing, I will tell you that too.