npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kaizen403/realtime-semantic-search

v0.1.1

Published

Library-first realtime RAG engine with pgvector and streaming generation.

Readme

Realtime RAG (TypeScript)

Library-first, realtime RAG engine built for production. This is infrastructure, not a chatbot.

You get:

  • Realtime ingestion and updates
  • pgvector-powered retrieval
  • Streaming generation
  • Pluggable embeddings and LLMs
  • Prisma-friendly store
  • Postgres-native LISTEN/NOTIFY
  • Node or Bun runtime

Install

npm install realtime-rag @prisma/client

Project layout

realtime-rag/
├─ src/
│  ├─ index.ts
│  ├─ rag/
│  │  ├─ createRAG.ts
│  │  ├─ RAG.ts
│  │  └─ types.ts
│  ├─ ingestion/
│  │  ├─ chunk.ts
│  │  ├─ embed.ts
│  │  └─ ingest.ts
│  ├─ retrieval/
│  │  └─ retrieve.ts
│  ├─ generation/
│  │  └─ stream.ts
│  ├─ stores/
│  │  ├─ pgvector.ts
│  │  └─ memory.ts
│  ├─ realtime/
│  │  └─ postgres.ts
│  ├─ adapters/
│  │  ├─ langchain.ts
│  │  └─ vercel-ai.ts
│  └─ utils/
│     └─ hash.ts
├─ prisma/
│  └─ schema.prisma
├─ tsup.config.ts
├─ package.json
└─ README.md

Core interfaces

export interface Embedder {
  embed(texts: string[]): Promise<number[][]>
}

export interface LLM {
  stream(prompt: string): AsyncIterable<string>
}

export interface VectorStore {
  upsert(vectors: StoredVector[]): Promise<void>
  query(vector: number[], k: number): Promise<StoredVector[]>
  delete(ids: string[]): Promise<void>
}

Quickstart

import { createRAG, memoryStore } from "realtime-rag"

const rag = createRAG({
  embedder,
  llm,
  store: memoryStore()
})

await rag.add({ id: "doc-1", text: "Hello world" })

for await (const token of rag.ask("What is hello?")) {
  process.stdout.write(token)
}

Prisma + pgvector schema

model Embedding {
  id        String   @id
  content   String
  embedding Unsupported("vector(1536)")
  metadata  Json?
  updatedAt DateTime @updatedAt
}

Enable pgvector:

CREATE EXTENSION IF NOT EXISTS vector;
CREATE INDEX embedding_idx ON "Embedding"
USING ivfflat (embedding vector_cosine_ops);

pgvector store

import { PrismaClient } from "@prisma/client"
import { createRAG, pgVectorStore } from "realtime-rag"

const prisma = new PrismaClient()

const rag = createRAG({
  embedder,
  llm,
  store: pgVectorStore(prisma)
})

Realtime sync (Postgres)

import { Client } from "pg"
import { postgresRealtime } from "realtime-rag"

const client = new Client({ connectionString: process.env.DATABASE_URL })
await client.connect()

const realtime = postgresRealtime(client, { channel: "rag_updates" })

Build

npm run build

License

MIT