<?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: abhinav sriharsha</title>
    <description>The latest articles on DEV Community by abhinav sriharsha (@abhinav_sriharsha_73dbc55).</description>
    <link>https://dev.to/abhinav_sriharsha_73dbc55</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%2F3272031%2F615b7a94-9ffa-4974-bbd5-390a2c66682c.png</url>
      <title>DEV Community: abhinav sriharsha</title>
      <link>https://dev.to/abhinav_sriharsha_73dbc55</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abhinav_sriharsha_73dbc55"/>
    <language>en</language>
    <item>
      <title>Beyond Simple RAG: Building an Agentic Workflow with Next.js, Python, and Supabase</title>
      <dc:creator>abhinav sriharsha</dc:creator>
      <pubDate>Wed, 24 Dec 2025 19:51:01 +0000</pubDate>
      <link>https://dev.to/abhinav_sriharsha_73dbc55/beyond-simple-rag-building-an-agentic-workflow-with-nextjs-python-and-supabase-1dm6</link>
      <guid>https://dev.to/abhinav_sriharsha_73dbc55/beyond-simple-rag-building-an-agentic-workflow-with-nextjs-python-and-supabase-1dm6</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhloaw0inrcg1phm6st5l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhloaw0inrcg1phm6st5l.png" alt="The flow of RAG Application" width="800" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Problem: "Chat with PDF" is the new Hello World.&lt;/strong&gt;&lt;br&gt;
Building a basic RAG app is easy today. You upload a 5-page PDF, split it into 1000-character chunks, and it works.&lt;br&gt;
But when I tried this with a &lt;strong&gt;500-page university textbook&lt;/strong&gt;, the standard pipeline fell apart.&lt;/p&gt;

&lt;p&gt;I didn't want a chatbot. I wanted a tutor. So I built &lt;strong&gt;Learneazy.io&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Here is the engineering deep dive into the &lt;strong&gt;3-Layer RAG Pipeline&lt;/strong&gt; and &lt;strong&gt;Generative Flashcard Engine&lt;/strong&gt; I architected to solve this.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Secret Sauce: 3-Layer Semantic Indexing
&lt;/h2&gt;

&lt;p&gt;Most RAG apps treat a document as one giant blob of text. I realized that textbooks have structure (Index -&amp;gt; Chapters -&amp;gt; Content), so I mirrored that structure in my database.&lt;/p&gt;

&lt;p&gt;I built a &lt;strong&gt;Python (Flask)&lt;/strong&gt; microservice using &lt;code&gt;PyMuPDF&lt;/code&gt; to handle the heavy lifting. Instead of simple recursive splitting, it processes every textbook into three distinct layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Layer 1: The "Skeleton" (Table of Contents)&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Purpose:&lt;/strong&gt; Quick, high-level structural queries.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layer 2: The "Container" (Chapter-wise Chunks)&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Purpose:&lt;/strong&gt; Context-aware searches. This ensures that when you ask about "Thermodynamics in Chapter 4," we &lt;em&gt;only&lt;/em&gt; search Chapter 4.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layer 3: The "Deep Dive" (Granular Chunks)&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Purpose:&lt;/strong&gt; Answering specific, deep-dive questions where every nuance matters.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  The Brain: Agentic Routing
&lt;/h2&gt;

&lt;p&gt;A hierarchical index is useless if you don't know &lt;em&gt;which&lt;/em&gt; layer to search.&lt;/p&gt;

&lt;p&gt;I implemented a &lt;strong&gt;LangChain Agent&lt;/strong&gt; equipped with custom tools for each layer. The Agent acts as a router:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;User:&lt;/strong&gt; "How many chapters are there?" → &lt;strong&gt;Agent:&lt;/strong&gt; Calls &lt;em&gt;Index Tool&lt;/em&gt;. (Fast, cheap).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;User:&lt;/strong&gt; "Summarize Chapter 3." → &lt;strong&gt;Agent:&lt;/strong&gt; Calls &lt;em&gt;Chapter Tool&lt;/em&gt;. (High context).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;User:&lt;/strong&gt; "Explain the formula for X." → &lt;strong&gt;Agent:&lt;/strong&gt; Calls &lt;em&gt;Deep Dive Tool&lt;/em&gt;. (High precision).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This routing logic reduced my token usage by ~40% and drastically improved accuracy.&lt;/p&gt;




&lt;h2&gt;
  
  
  Beyond Chat: The Flashcard Engine
&lt;/h2&gt;

&lt;p&gt;This was the hardest technical challenge. I wanted users to be able to say: &lt;em&gt;"Generate 10 flashcards for Chapter 5."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The AI couldn't just "guess." I had to build a specific &lt;strong&gt;Generative Workflow&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Topic Extraction:&lt;/strong&gt; First, the system scans the &lt;em&gt;Chapter Layer&lt;/em&gt; to identify key themes (e.g., "Mitochondria," "Krebs Cycle").&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context Retrieval:&lt;/strong&gt; It performs a targeted vector search in the &lt;em&gt;Deep Dive Layer&lt;/em&gt; specifically for those topics to get the definitions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Synthesis:&lt;/strong&gt; The LLM (Google Gemini) formats these grounded facts into strict Q&amp;amp;A pairs.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The result? Flashcards that are generated from &lt;em&gt;your&lt;/em&gt; specific material, not general internet knowledge.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Stack: Why Microservices?
&lt;/h2&gt;

&lt;p&gt;I split the architecture to optimize for performance:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Frontend:&lt;/strong&gt; &lt;strong&gt;Next.js 16&lt;/strong&gt; (React 19) for a snappy, responsive UI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Processing Service:&lt;/strong&gt; &lt;strong&gt;Python (Flask)&lt;/strong&gt;. Python is simply better at PDF manipulation and chunking logic than Node.js.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Embeddings:&lt;/strong&gt; &lt;strong&gt;Cohere (&lt;code&gt;embed-english-v3.0&lt;/code&gt;)&lt;/strong&gt;. I chose this over OpenAI's embeddings because Cohere's latest model is specifically finetuned for RAG and retrieval quality.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Database:&lt;/strong&gt; &lt;strong&gt;Supabase (PostgreSQL + pgVector)&lt;/strong&gt;. Storing vectors right next to my user data (Auth, Metadata) simplified my backend significantly.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/Abhinav-Sriharsha/Learneazy" rel="noopener noreferrer"&gt;github.com/Abhinav-Sriharsha&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>rag</category>
      <category>supabase</category>
      <category>nextjs</category>
    </item>
  </channel>
</rss>
