← all repositories
RafalWilinski/cloudflare-rag

A RAG stack that never leaves Cloudflare's orbit

It's a reference app showing how to run an entire PDF Q&A pipeline—OCR, hybrid search, inference, and rate limiting—entirely inside Cloudflare's ecosystem.

602 stars TypeScript RAG · Search
cloudflare-rag
Not currently ranked — collecting fresh signals.
star history

What it does

This is a fullstack “chat with your PDFs” application built entirely on Cloudflare’s stack. It ingests documents, runs OCR inside a Worker, indexes content across both a D1 SQL database and the Vectorize vector store, then answers questions by streaming responses back through Pages and Workers. Every stage—search, ranking, model inference, and rate limiting—stays inside Cloudflare’s network.

The interesting bit

The search layer uses a hybrid approach: it rewrites a single user query into five variants, runs BM25 full-text search over D1 and dense vector retrieval over Vectorize in parallel, then merges the results with Reciprocal Rank Fusion. That’s a lot of orchestration for an edge deployment, and it all happens before the LLM even sees a prompt.

Key highlights

  • Hybrid retrieval combines D1 full-text search and Vectorize dense search, merged via Reciprocal Rank Fusion.
  • LLM provider switching and fallbacks (OpenAI, Groq, Anthropic, or Workers AI) are handled through Cloudflare AI Gateway.
  • OCR runs natively inside a Worker using unpdf, so documents never leave the edge for preprocessing.
  • Per-IP rate limiting is enforced with Cloudflare KV.
  • Responses are streamed to the UI using Server-Sent Events.

Caveats

  • The README presents this as a reference example, not a turn-key product, and setup involves manual configuration of D1, KV, and other primitives.
  • It is unclear from the README how text is chunked or how embeddings are generated; those mechanics appear to live in the code rather than the docs.

Verdict

Developers already paying for Cloudflare who want a blueprint for edge-native RAG should clone this. If you’re looking for a managed, batteries-included PDF chat product, this is just the architecture diagram come to life.

Frequently asked

What is RafalWilinski/cloudflare-rag?
It's a reference app showing how to run an entire PDF Q&A pipeline—OCR, hybrid search, inference, and rate limiting—entirely inside Cloudflare's ecosystem.
Is cloudflare-rag open source?
Yes — RafalWilinski/cloudflare-rag is an open-source project tracked on heatdrop.
What language is cloudflare-rag written in?
RafalWilinski/cloudflare-rag is primarily written in TypeScript.
How popular is cloudflare-rag?
RafalWilinski/cloudflare-rag has 602 stars on GitHub.
Where can I find cloudflare-rag?
RafalWilinski/cloudflare-rag is on GitHub at https://github.com/RafalWilinski/cloudflare-rag.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.