Building a searchable photo library on the Neon backend with TanStack
Atlas is a TanStack Start app on Vercel that stores private photos in Neon Object Storage, metadata and vectors in Lakebase Postgres, identity in Managed Better Auth, and ranks CLIP embeddings with the Lakebase Search `lakebase_ann` index. The build covers a declarative `neon.ts` config, uploads via aws4fetch that write bytes before inserting the Postgres row, presigned GET URLs for a private bucket, and a Drizzle schema using a pgvector custom type. Every query is scoped to an owner ID taken from a JWKS-verified JWT. Face search runs exact scans over 1024-d descriptors with Chinese Whispers clustering. Because all of these primitives branch with copy-on-write, one Neon branch gives a preview environment with production data, objects, users and search indexes.
Related posts
- Lakebase Search: the retrieval primitive for agents on Neon
Neon mediumAdept
Lakebase Search adds vector and BM25 search to Lakebase Postgres through two extensions, lakebase_vector and lakebase_text, so agents can query operational data without a separate search system. lakebase_vector keeps its durable index in object storage, caches hot pages in NVMe and RAM, and combines hierarchical IVF with RaBitQ quantization. That design lets compute scale to zero and reconnect without rebuilding the index, and it stays compatible with pgvector types, operators and query syntax. lakebase_text adds a BM25 index over standard tsvector with top-K pushdown, and TypeScript Neon Functions, Object Storage triggers and AI Gateway embeddings round out an ingest-to-hybrid-search pipeline that agents can call in a search-evaluate-retry loop.
- Neon Docs search is now built on Neon
Neon mediumAdept
Neon's docs search now runs entirely on its own stack: Lakebase Postgres with the lakebase_vector (pgvector-compatible ANN) and lakebase_text (BM25) extensions, a Hono API on Neon Functions, and Neon AI Gateway for embeddings and reranking. Pages are ingested as markdown via a GitHub Action, chunked by heading, embedded and stored with tsvectors in one table. To fit search-as-you-type latency budgets, full hybrid results (ANN plus BM25 merged with reciprocal rank fusion, then an LLM rerank) are precomputed for common queries and cached, while unseen queries fall back to BM25 only. Cache hits take 1.9 ms and BM25 misses 8.6 ms at p50 on the server, and top-5 hit rate rose from 80% to 94% on 171 real queries.
- Implementing semantic image search with Amazon Titan and Supabase Vector
Supabase mediumAdeptSemantic image search can be built in Python by generating 1024-dimensional embeddings for images with the Amazon Titan multimodal embedding model (amazon.titan-embed-image-v1) via Amazon Bedrock, then storing and querying them in Supabase Vector (Postgres with pgvector) using the vecs client. The walkthrough covers Poetry project setup, base64-encoding images for the Bedrock API, upserting embeddings with metadata into a vecs collection and creating an index. A text query is embedded with the same model and matched against image vectors with a metadata filter, and the top result is displayed with matplotlib. The same approach supports reverse image search.
- Lakebase Search: vector and BM25 on Neon
Neon mediumAdept
Neon's Lakebase Search adds two Postgres extensions, lakebase_vector (IVF partitioning plus RaBitQ quantization, pgvector-compatible) and lakebase_text (a BM25-native index with Block-Max WAND top-K pushdown), designed for Neon's separated compute and object-storage tiers. HNSW's dependent random reads serialize into tens-of-millisecond round trips on object storage, so the new indexes map clusters and postings to contiguous blocks fetched in parallel. RaBitQ's ~32x compression fits a 100M-vector index in under 10GB versus ~300GB for HNSW, with builds 50–100x faster, and indexes persist on object storage so scale-to-zero and copy-on-write branching work without rebuilds. Hybrid search runs as plain SQL in one transaction, and lakebase_ann_prewarm() is available to avoid cold-cache latency.
- Semantic search using OpenAI, pg_embedding and Neon
Neon mediumAdept
A YC idea-matcher app implements semantic search by embedding ~4,400 YCombinator company descriptions with OpenAI's text-embedding-ada-002 (1536 dimensions) and storing them as real[] columns in Neon Postgres via the pg_embedding extension. Queries embed the user's idea and order rows by cosine distance (<=>) to return the top five matches from a Next.js edge function, which is colocated with the database region and uses the Neon serverless driver, Upstash rate limiting and Zod validation. The full ingestion script and API route are shown. Sequential scan is fine for this small dataset, but larger tables need an HNSW index. pg_embedding has since been deprecated in favor of pgvector.