Skip to main content

Live Demo

A single-page semantic search app over Hacker News, showcasing Rivestack pgvector in action.

Try the demo

Search 30 days of HN stories and comments with natural language.

Source code

Full source code — backend, frontend, and Kubernetes deployment.

What it does

Type a question, get semantically relevant Hacker News posts and comments — with real-time performance stats on every query.
  • ~4,000 stories and ~40,000 chunks indexed from the last 30 days of HN
  • HNSW index for fast cosine similarity search
  • Performance stats displayed on every query: vector query time, embedding time, chunks searched, index type
  • Daily cron job keeps a rolling 30-day window of fresh data

Architecture

User query → OpenAI embedding → pgvector HNSW search → ranked results
ComponentStack
DatabaseRivestack PostgreSQL + pgvector
BackendPython, FastAPI, SQLAlchemy, asyncpg
EmbeddingsOpenAI text-embedding-3-small (1536 dims)
FrontendVue 3, Vite, Tailwind CSS v4, shadcn-vue
DeploymentKubernetes, Helm, GitHub Actions CI/CD

Performance

Typical query performance on a shared Rivestack instance:
MetricTime
Vector query (pgvector)~12ms
OpenAI embedding~150ms
Total API response~180ms
These numbers are from a shared Rivestack instance. Dedicated instances deliver significantly faster performance.

Run it yourself

1. Create a Rivestack database

Sign up at app.rivestack.io and create a database. pgvector is enabled by default on the initial appdb database. For new databases, add it through the dashboard or Terraform.

2. Clone and configure

git clone https://github.com/Rivestack/rag-starter.git
cd rag-starter
cp .env.example backend/.env
Edit backend/.env with your Rivestack DATABASE_URL and an OPENAI_API_KEY.

3. Run with Docker Compose

docker compose up

4. Load data

curl -X POST http://localhost:8000/api/ingest/initial
This fetches 30 days of HN stories, generates embeddings, and stores them in your Rivestack database. The first load runs in the background and takes a few minutes. Open http://localhost:8080 and start searching.