# Supabase pgvector tutorial: code and run outputs

Run: 2026-11-01 to 2026-11-02, one MacBook, Docker Desktop, Ollama `nomic-embed-text` (768 dims) on the host.
Self-hosted Supabase (compose project `kb-supabase`), Postgres 17.6, pgvector 0.8.2.
Not run: hosted Supabase (supabase.com dashboard). No Python crawl step was re-run: `chunks.jsonl` comes from an earlier ingest run (52 docs pages, 304 chunks).

Images (digests read from the local Docker engine):
supabase/postgres:17.6.1.136 sha256:f371b5f3f2ac0a05703f33d6e6134515fb2498cab708fb948a0aeb7481467c00
supabase/studio:2026.10.12-sha-3699278 sha256:948770ec467f00e6ae34c35018ef7cb23d7b30eb806b42c2cc0d7bcfdcf8a7a8
postgrest/postgrest:v14.18 sha256:c7cd7e265a85b05248abf53f4473fcec7e327c282d0bd0cf60f1551996d09fcf
supabase/edge-runtime:v1.77.4 sha256:ad45164b7548bf5820ed7be714789c17ac2865edce79a09cfb4c3756c3d365a8
supabase/supavisor:2.9.13 sha256:07f1a6098ffc04b80263bca4eb5c3e7bd2e03dfd1fc465aa108d7329000a1a4e
envoyproxy/envoy:v1.39.1 sha256:57e14a549d7bd43c8d3f6d03e8cfa653e037d4b38e133acd9b54f38c524401b4
supabase/gotrue:v2.197.0, supabase/realtime:v2.143.3, supabase/storage-api:v1.81.0, supabase/postgres-meta:v0.100.0, darthsim/imgproxy:v3.31.4

## Run order
1. `docker/README.md` (start the stack)
2. Enable `vector` in Studio (Database > Extensions) or run `schema.sql`
3. `python load.py chunks.jsonl` (needs the full `chunks.jsonl`, 3 sample rows in `chunks.sample.jsonl`)
4. `python query.py "question"` (psycopg) or `--rest` (supabase-py); `node query.mjs "question"`
5. Edge Function: copy `functions/kb-query` to the stack's `volumes/functions/`
6. `python answer.py "question"` (top 5 chunks to local Ollama `gemma4:26b`, answer with citations)
7. `python measure.py` (writes `measure.md`, `explain.out`)

Env vars: DATABASE_URL, SUPABASE_URL, SUPABASE_ANON_KEY (never commit them). `ingest.py` provides `embed_query`.

## Notes
- The full `chunks.jsonl` (about 3 MB, 304 rows with 768-float embeddings) is not published. `chunks.sample.jsonl` has 3 rows. `ingest.py` produces the full file (crawl with `webcr`, chunk by headings, embed with Ollama).
- `out/edge-logs.out` holds the first (cold) Edge Function calls, `out/edge-logs-warm.out` warm ones.
- Latencies in `measure.md` were re-measured on 2026-11-02 after the stack was restarted; `out/*.out` files from the first session are the same functions and data.
- The code folder is meant to be published next to the post at assets.webcrawlerapi.com; until then it exists only in the repo.
