Build Pinecone

KINDAreplaces $20/mosaves $240/yrback to the verdict

0%0 of 16 items done

Saved on this device only. Tick prerequisites first, then work the phases in order · do not start one until the checks above it pass.

Semantic search over your own documents with pgvector in the Postgres you already run: chunked documents with embeddings, cosine search with an HNSW index, hybrid ranking with full-text so exact identifiers still win, a localhost search page, and backups that are just pg_dump.

estimated effort one sittingthe files for this build are in the project pack

DatabasePostgres 16 with pgvectorEmbeddingsA provider behind an interfaceRuntimeNode 22

Before step 1

Everything below is assumed from the first step. Tick each one when you actually have it, not when you plan to.

  1. installfree

    Why Everything in this build runs on it: the server, the scripts, the tests.

    Get it Download the LTS installer from nodejs.org, or install with your package manager (brew install node, or nvm install 22). Restart the terminal afterwards. open ↗

    Verify node --version prints v22 or higher

  2. installfree

    Why Every step below is a command you type or a file you edit.

    Get it VS Code (code.visualstudio.com), Cursor or Zed. Open a folder for the project and use the editor's built-in terminal. open ↗

    Verify You can open a folder and run a command in its terminal

  3. installfree

    Why History for your code, and the way most hosts deploy.

    Get it Install from git-scm.com or with your package manager, then run git init in the project folder once it exists. open ↗

    Verify git --version prints a version

  4. installfree

    Why The whole store.

    Get it Docker: docker run -d -e POSTGRES_PASSWORD=pw -p 5432:5432 pgvector/pgvector:pg16. Or install pgvector on an existing Postgres. open ↗

    Verify CREATE EXTENSION vector; succeeds

  5. API keypay per use, or free locally

    Why Phase 1 embeds chunks.

    Get it OpenAI: platform.openai.com/api-keys. Local: install Ollama and ollama pull nomic-embed-text. open ↗

  6. have readyfree

    Why Markdown, PDFs converted to text, or a folder of notes.

    Get it A folder of files.

Data model

Create these before the first phase that stores anything. Changing a table later is the expensive kind of change.

- documents: id, source, title, url, updated_at
- chunks: id, document_id, position, text, embedding vector(N), token_count
Chunks, not documents, carry the vectors: a 40-page PDF as one vector matches nothing well.

Environment variables

These go in a .env file the app reads at startup. The pack's .env.example is this table as a file · copy it, never commit the filled-in version.

VariableNeededExampleWhere the value comes from
DATABASE_URLsecretrequiredpostgres://postgres:pw@localhost:5432/searchYour Postgres.
EMBED_PROVIDERrequiredopenaiopenai or ollama.
OPENAI_API_KEYsecretoptionalsk-...For the openai provider.
EMBED_MODELrequiredtext-embedding-3-smallModel name; dimension must match the column.
DOCS_DIRrequired./docsWhere the ingester reads.

The build, in order

  1. Store and embed

    Chunks with vectors, idempotent on document hash, provider swappable.

    1. documents (id, source, title, url, updated_at, hash), chunks (id, document_id, position, text, embedding vector(N), token_count). N matches EMBED_MODEL's dimension.

      Files schema.sql

      terminal
      mkdir semantic && cd semantic && git init && npm init -y && npm pkg set type=module && npm install pg@8
      mkdir -p docs && cp .env.example .env
    done when · tick each as it passes
  2. Search

    Top-k by cosine with an HNSW index actually used.

    1. terminal
      CREATE INDEX ON chunks USING hnsw (embedding vector_cosine_ops);
    2. terminal
      EXPLAIN ANALYZE SELECT ... ORDER BY embedding <=> $1 LIMIT 10;
    done when · tick each as it passes
  3. Hybrid

    Exact identifiers win: fuse vector and full-text ranks.

    done when · tick each as it passes
  4. A page

    Localhost search with highlighted passages and source links.

    done when · tick each as it passes
  5. Operate

    Migrations, pg_dump, reindex.

    1. Files README.md

    done when · tick each as it passes
what this build does not replace
after v1, if you want it

Need the files? The project pack on the verdict page hands your agent the whole brief · more databases.