Distributed RAG Web Scraper
A system that visits websites, cleans the pages, stores them, and answers questions about them with sources. Many workers share the job, and it keeps going when one of them fails.
In short. Scraping a few pages is easy. Doing it across many sites means workers crash, sites fail, and pages repeat or change. Here, workers take jobs from a queue, retry failures and set aside jobs that keep failing. The system stores the pages and answers questions about them with numbered sources.
- TypeScript
- Node.js
- Express
- React
- PostgreSQL
- Prisma
- RabbitMQ
- Qdrant
- Docker
- Turbo
Demo video
Watch it work
A recording of the web dashboard: searching and asking questions about pages that were already collected, then crawling new pages live and watching them get cleaned, split up and stored. Click a chapter to jump to it.
Core flow
Safety and limits
Core flow
Safety and limits
Core flow
How it flows
Follow a crawl, then a question
Pick what happens:
What came out
The worker logs show a Chromium crawl, then 10 chunks embedded locally and stored in Qdrant.
Click any box to see what that step does.
- Problem
- Collecting web pages at scale breaks in ordinary ways: workers crash, sites fail, and pages repeat or change.
- Approach
- Workers pick jobs from a queue, retry failures, set aside jobs that keep failing, and a monitor restarts stuck jobs.
- Result
- A recording on this page walks through searching, asking a question that comes back with its sources, and crawling new pages live. About 180 automated tests cover the crawler, the queue, the search and the vector database.
- Limits
- The tests were counted, not run for this page. Answering questions needs an outside AI service key. It was developed in a private repository, so the public history is a snapshot.
- Try it
- Watch the demo ↓
01What it is
Collecting lots of web pages breaks in ordinary ways: workers crash, sites go down, and pages repeat or change. This project visits websites, cleans the pages, stores them and answers questions about them. It is built to keep working when parts of it fail.
Built in one week during the Onramp program, it comes with an API, background workers and a web dashboard, and runs with Docker. Once pages are collected, you can search them by words or by meaning, or ask a question and get an answer with numbered sources.
- Failed jobs are tried again with growing waits, and jobs that keep failing are set aside for review
- Respects each site's rules, goes slowly enough not to overload it, and blocks unsafe web addresses
- Finds duplicate pages, keeps old versions of changed pages, and searches by meaning with a vector database
- Answers questions only from the pages it collected, with numbered sources, and says so when they don't cover something
- Turns page text into searchable form with a model that runs on your own machine; only the final answer step needs an outside AI service
- A web dashboard shows jobs, pages, search, questions and the health of each worker
- Around 180 automated tests cover the crawler, the queue and the search
- Built in one week during the Onramp program, right after the RAG session, while the team's main project was paused
- Developed in a private repository and published afterwards, so the public history is a snapshot
02What happens to each page
- Check the web address: only http and https are allowed, unsafe addresses are blocked, and pages that are not real content (such as Wikipedia's special pages) are skipped.
- Read the site's robots.txt rules and wait between requests to the same site (one second by default, longer if the site asks) so it is not overloaded.
- Download the page safely, with a 10-second time limit and a 10 MB size limit.
- Pull out the title, description, links and text, and strip menus, sidebars, ads and cookie banners.
- Organise the text into headings, paragraphs and lists, and note the language, author, dates and reading time where they can be found.
- Throw away pages that are too short, list-only or near-empty.
- Skip duplicates (each page gets a fingerprint of its cleaned text, checked in the database so two workers never store the same page) and keep a history of how a page changed.
- Cut the text into pieces of about 150 words that end on sentence boundaries and overlap by 30 words, then turn each piece into 384 numbers that capture its meaning (embeddings). A small model that runs on your own machine does this step.
- Save the pieces in a vector database (Qdrant) so they can be searched by meaning, and record them in PostgreSQL too.
- Queue up the links found on the page that stay on the same site, up to 50, one level shallower.
03Searching and asking questions
- Search by words: a case-insensitive text match on the stored pages, newest first. It is a plain match, not a ranked search engine.
- Search by meaning: the question is turned into numbers with the same local model and matched against the stored pieces. Results are scored pieces of text, each with its heading, up to 500 per search.
- Ask a question: by default the 25 closest pieces are fetched. Boilerplate text is dropped, and at most 3 pieces per page are kept, so one page cannot crowd out the others.
- The AI is told to answer only from those pieces, to combine details from several of them, and to cite sources as [1], [2]. It is told to say it does not have enough information only when the pieces hold nothing relevant.
- The answer comes back with its sources: the text, the page link, the page title and a similarity score.
- The AI model is a setting. It defaults to gpt-4o-mini and can point at any compatible provider. If the service answers with a rate-limit or server error, the call is tried again, up to 4 tries in all.
04When things go wrong
- Timeouts, network errors, server errors and rate-limit replies are tried again, waiting longer each time with a little randomness, never more than 30 seconds (up to 5 tries).
- Jobs that keep failing, or can never work (a missing page, a bad address, something that is not a web page), are set aside in a separate queue to review.
- Every worker reports in every 30 seconds. If one goes quiet for 90 seconds, it is marked offline.
- A job stuck for over 10 minutes is put back in the queue, up to 3 times.
- If a worker dies, the queue hands its unfinished jobs to the others, and duplicate pages are never stored twice.
05How it is built
- One repository with three apps (the API, the background worker and the dashboard) and shared packages for the database, the queue, the crawler, the search and question answering, and the vector database.
- The API has 9 endpoints: crawl, ask, search, pages, jobs, workers, websites, health and a reset that is switched off unless enabled.
- The dashboard has 8 views: dashboard, crawl jobs, job detail, pages, page detail with its versions, search, ask and workers.
- PostgreSQL keeps six kinds of records: websites, crawl jobs, pages, page versions, chunks and workers.
- Docker Compose runs PostgreSQL, RabbitMQ, Qdrant, the API and two workers. Both workers take jobs from the same queue, one job at a time each, so the work is shared fairly.
06Automated tests
| Part | Test files | Tests |
|---|---|---|
| Crawler | 9 | 140 |
| Queue | 1 | 18 |
| Search (RAG) | 3 | 19 |
| Vector database | 1 | 3 |
| Total | 14 | about 180 |
These numbers come from counting the tests in the code.
07Pictures

08Good to know
~180 automated tests
From the project's GitHub repository
- There are no screenshots. The demo video on this page is the way to see the dashboard.
- Answering questions needs an AI service key. Crawling, cleaning, embedding and searching run on your own machine.
- Chunk sizes are counted in words, not exact tokens. A note in the code lists exact token counting as a to-do.
- It was developed in a private repository and published afterwards, so the public history is a snapshot.