<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Edwin</title>
    <description>The latest articles on DEV Community by Edwin (@edwin_93a122d31bc978aa64a).</description>
    <link>https://dev.to/edwin_93a122d31bc978aa64a</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1836348%2F6b0be2a8-69e2-4b25-8af6-4eee50814a0f.png</url>
      <title>DEV Community: Edwin</title>
      <link>https://dev.to/edwin_93a122d31bc978aa64a</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/edwin_93a122d31bc978aa64a"/>
    <language>en</language>
    <item>
      <title>How I bypassed Vercel Serverless timeouts to build a decoupled document ingestion pipeline</title>
      <dc:creator>Edwin</dc:creator>
      <pubDate>Sat, 30 May 2026 20:17:55 +0000</pubDate>
      <link>https://dev.to/edwin_93a122d31bc978aa64a/how-i-bypassed-vercel-serverless-timeouts-to-build-a-decoupled-document-ingestion-pipeline-2p0j</link>
      <guid>https://dev.to/edwin_93a122d31bc978aa64a/how-i-bypassed-vercel-serverless-timeouts-to-build-a-decoupled-document-ingestion-pipeline-2p0j</guid>
      <description>&lt;p&gt;If you’ve ever tried to build an asynchronous document processing or RAG pipeline using Next.js API routes hosted on Vercel, you know that even with max duration configuration adjustments, keeping intensive computing tasks entirely inline on serverless routes can get messy.&lt;/p&gt;

&lt;p&gt;When a user uploads large PDFs or batch data sources, parsing the text layers, chunking them semantically, and running batch embedding requests consumes serious time. Relying on synchronous, API-facing function execution windows for deep I/O tasks often leaves you managing brittle state.&lt;/p&gt;

&lt;p&gt;To make my application, I spent my time decoupling my stack into a clean, asynchronous background processing worker architecture. Here is a breakdown of how the data flows.&lt;/p&gt;

&lt;p&gt;The Stack Architecture&lt;br&gt;
Ingress Layer (Next.js): The API endpoints strictly handle incoming request validation, file storage organization, and API idempotency keys (managed via Upstash Redis).&lt;/p&gt;

&lt;p&gt;The Worker Queue (BullMQ + TCP Redis): Instead of processing files inline, the Next.js route enqueues the task into a BullMQ background line. Because BullMQ requires a persistent, low-latency binary TCP connection, this Redis instance is hosted directly on Railway alongside our workers.&lt;/p&gt;

&lt;p&gt;Persistent Worker Instance: A standalone Node.js background process running on Railway listens to the BullMQ stream. Because it runs on a dedicated server environment, it completely removes the headache of managing serverless execution constraints. It streams files from Cloudflare R2, runs semantic paragraph chunking, and processes text embeddings in parallel batches.&lt;/p&gt;

&lt;p&gt;Concurrency and Data Privacy Safety&lt;br&gt;
Handling high-volume API requests means designing for deep multi-tenant safety. To prevent concurrent race conditions across quota meters during multi-file processing, the platform utilizes a Postgres SELECT FOR UPDATE block inside an explicit database transaction to lock and update user tokens safely at the database layer.&lt;/p&gt;

&lt;p&gt;Furthermore, to solve data privacy and compliance hurdles for teams that do not want third-party database lock in, I implemented a strict Stateless Pass-Through Mode. By sending a passthrough: true flag to the endpoint, the background worker processes the document, generates the raw 1,536 dimension float arrays using OpenAI, streams the payload back via an asynchronous webhook, and instantly flushes the server RAM. Zero data retention.&lt;/p&gt;

&lt;p&gt;Open Beta &amp;amp; Feedback&lt;br&gt;
I've packaged this entire decoupled pipeline layout into a developer utility called ContextFlow AI.&lt;/p&gt;

&lt;p&gt;The public beta is completely live, open, and free to try. You can check out the landing page, read the documentation, and inspect the JSON payload schemas directly at &lt;a href="https://usecontextflow.com" rel="noopener noreferrer"&gt;https://usecontextflow.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'd love to get your thoughts on the webhook event schemas or how you are structuring background queues for your own AI applications!&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>typescript</category>
      <category>architecture</category>
      <category>backend</category>
    </item>
  </channel>
</rss>
