Bhaskar Pandey
View résumé
Menu
Back to all projects

Private Knowledge Platform

BrainVault

A sturdy filing cabinet of glowing notes beside a compact blue index wall, joined by a thin bridge, with a small padlock gate between them and the outside.
The notes stay in the cabinet, and the searchable index can be rebuilt from them.

A second brain that keeps my notes as plain files, finds them by meaning, and refuses to guess when privacy is on the line.

What It Is

BrainVault is my personal knowledge system. It takes in what I know, organizes it, and lets me search and retrieve it later by meaning, not just by keyword. People call this kind of tool a second brain. I am the sole architect and implementer, and the repository is private, so there is no public source link.

The system has two halves on purpose. The first half is a local vault, a folder of human-readable notes kept locally. The vault is the source of truth. The second half is Supabase, a hosted Postgres database, which acts as the place where search happens. The database is a sync target. It holds a searchable copy, not the original.

Think of the vault as a filing cabinet at home, and Supabase as a fast card index kept in another room. If the index breaks, I rebuild it from the cabinet. If I lost the cabinet, the index would not save me, which is exactly why the cabinet is the boss.

Why It Exists

A personal knowledge pile has four jobs to do. Things must come in, get organized, be searchable and be retrievable. I wanted one system that handled all four over a personal corpus, which is just a word for the full body of text you have collected.

I also wanted the notes to outlive the tooling. If a search layer gets retired or a vendor changes, plain files in a folder still work. That is the reason for the dual design: the notes stay usable even if the search layer is rebuilt.

The third reason is privacy. The system needed a hard line between private and public material, and that line had to hold even when software made a mistake.

How It Works, Part One: From Notes to Searchable Vectors

The first stage is the sync pipeline. It watches the vault for new and changed notes. When a note appears or changes, the pipeline picks it up.

Next, the pipeline cleans the note before it turns into numbers. Notes carry operational frontmatter, which is a block of bookkeeping fields at the top of a file, like the label on a folder. I strip that block before embedding, so the metadata never pollutes the vector space. If the label were included, notes would look alike because their labels match, not because their ideas do.

Then comes the embedding. An embedding turns a piece of text into a long list of numbers that captures its meaning. Texts with similar meaning get similar lists, the way two nearby pins on a map are near each other. I use OpenAI embeddings with the text-embedding-3-small model at 1536 dimensions, which means every note becomes a list of 1536 numbers.

Finally, the pipeline routes each note to the correct table based on its domain tag. A domain tag says what area a note belongs to. The vectors land in Supabase, in Postgres with the pgvector extension. pgvector is an add-on that lets Postgres store these number lists and find the closest ones to a question. That is how a search by meaning works: embed the question, then ask pgvector for the nearest notes.

A note card moving along a belt through a cleaning station, a number-making machine, and into a map of glowing points sorted into bins.
A note is cleaned, turned into numbers, and filed by domain so it can be found by meaning.

How It Works, Part Two: Putting Things In and Getting Answers Out

Notes arrive through several capture channels. Every one of them goes through a single edge-function front door. An edge function is a small piece of server code that runs close to the user. Because all channels use the same door, every input inherits the same LLM extraction and data-domain safety rules. An LLM, or large language model, is an AI program trained on huge amounts of text that can read and write. Extraction means pulling out the key facts from raw input. A data domain is a labeled area, such as private or public, that decides how a piece of data may be used. No channel gets to reimplement them, and no channel gets to skip them.

For retrieval, an edge function exposes the corpus to AI clients as tools. This uses MCP, the Model Context Protocol, an open standard that lets an AI assistant call tools in a program. I authored and deployed a remote MCP server in TypeScript on Supabase Edge Functions. It has 11 tools. They cover semantic search and fetching, thought capture, note editing, review and statistics.

The server sits behind OAuth 2.1, run through Supabase's OAuth server. OAuth is the standard way an app asks permission to act for you. It gives clients a registration step and a consent screen, so each client is approved before it connects. On top of that, database row-level security (RLS) limits what each client can read and write. RLS is a rule inside the database that decides, row by row, who may touch what. This setup replaced an earlier shared-key login.

There is also a chat bot. It answers questions with domain filters applied, and its answers come from the vault, not from model memory. A model's memory can be wrong or stale. The vault is what I actually wrote.

Several different doors all leading into one gatehouse, then a half-ring of small tool drawers behind a consent turnstile.
Every input uses one front door, and clients reach the notes through approved tools.

What Keeps It Careful

Data governance is fail-closed. Fail-closed means that when the system is unsure, it chooses the safe answer. The privacy domain is an explicit caller parameter. A model never infers it. It defaults to private. And it is never auto-promoted to public. Nothing becomes public unless a caller says so on purpose.

I hardened the deployment too. Internal APIs are bound to loopback, which means they only listen to the machine they run on. A Cloudflare Tunnel is the sole public ingress, so there is exactly one way in. If the auth secret is missing, the system fails hard instead of starting in an insecure state. A silent insecure start is worse than a loud crash. A guard also blocks mass deletion, so one bad command cannot wipe out the notes.

One more safeguard is about change. I benchmarked local Qwen vision and embedding models against hosted providers. Qwen is a family of AI models, and local means they run on my own computer instead of in someone else's cloud. A vision model reads images. A hosted provider runs the model for you, for a fee. I also centralized all model identifiers in one configuration module. When a provider retires a model, I change one file, not five places, so the pipeline cannot break in five places at once.

What I Built It With

The stack is Supabase with Postgres, pgvector and edge functions; OpenAI embeddings; a Cloudflare Tunnel for the single public entry; and a TypeScript MCP server secured with OAuth 2.1. The local vault is plain notes on disk.

The vault stays human-readable, and the retrieval layer is the part I can rebuild from it.

Where It Stands Today

BrainVault is shipped and in daily use as my own knowledge system.

The repository is private, so I am not showing screenshots or sample notes. What I can show is the design: a local source of truth, a rebuildable search layer, a single front door for capture, and a privacy rule that fails closed.

Glossary

pgvector
A Postgres add-on that stores embedding vectors and finds the ones closest in meaning to a question.
MCP
Model Context Protocol, an open standard that lets an AI assistant call tools exposed by a program.
OAuth 2.1
The standard way an app asks permission to act for you, with client registration and a consent screen.
row-level security
A database rule that decides, row by row, which client may read or write which data.
LLM
Large language model, an AI program trained on huge amounts of text that can read and write.
Qwen
A family of AI models; the local Qwen models I tested run on my own computer.
embedding
A long list of numbers that captures the meaning of a piece of text, so similar texts get similar lists.
Supabase Edge Functions
Small pieces of server code hosted by Supabase that run close to the user.
Cloudflare Tunnel
A service that gives a private machine one safe public entrance without opening its ports.
fail-closed
When the system is unsure, it picks the safe answer, such as private instead of public.

Key Facts

  • pgvector retrieval
  • Fail-closed privacy domain
  • Private repository, no public source link

Back to all projects