Production RAG, line by line
Ingestion
What the demo Worker does with a PDF's text after the router calls upload(): it validates the upload, claims the file name, checks the limits of the visitor's demo account (their row in the demos table, which owns their files, chunks and questions), cuts each page into chunks, stores the chunks in D1, embeds them with bge-m3 on Workers AI and indexes the vectors in Vectorize, then tells Joel about an account's first upload and replies.
200 of 200 lines explained (100%)
Stages, in the order they run
- INGEST 1 Validate the upload 27 of 27 lines explained (100%)
- INGEST 2 Claim the file name 14 of 14 lines explained (100%)
- INGEST 3 Check the limits 22 of 22 lines explained (100%)
- INGEST 4 Chunk each page 56 of 56 lines explained (100%)
- INGEST 5 Store the chunks 32 of 32 lines explained (100%)
- INGEST 6 Embed and index 17 of 17 lines explained (100%)
- INGEST 7 Notify and reply 32 of 32 lines explained (100%)
- In the browser
- runs in the visitor's browser, on the demo page
- Ingestion
- runs when a PDF's text is uploaded
- Query time
- runs when the Worker answers a question or a search_documents call from the MCP server, and in the request handling every route shares, in the Worker and in the site's functions, which uploads and removals pass through too
- MCP request
- runs on a request to the MCP server or its OAuth endpoints
- Site request
- runs on a site request that is not a question, an upload, an MCP call or the cron: a page load, a session read, the demo page's /api/grants calls, an admin read, a file's removal
- Scheduled
- runs in the Worker's daily cron job
- Eval run
- runs when the eval harness runs on a developer's machine
- MCP host
- runs in an MCP host outside the Worker: the search loop example, on a developer's machine (npm run search) or in its test
- Module load
- runs once, when the module is loaded
- Type only
- erased by the TypeScript compiler; never runs
- Never runs
- a comment, a licence or markup with no behaviour of its own
Pinned to joelstevick-demo-rag-pipeline at 6a9c6c7.