<?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: Elyass</title>
    <description>The latest articles on DEV Community by Elyass (@elyass_43b15fee1a28f165db).</description>
    <link>https://dev.to/elyass_43b15fee1a28f165db</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4120496%2F6b2b5fdf-7a7a-4a83-a942-14293cd6abce.png</url>
      <title>DEV Community: Elyass</title>
      <link>https://dev.to/elyass_43b15fee1a28f165db</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/elyass_43b15fee1a28f165db"/>
    <language>en</language>
    <item>
      <title>How I Built a PDF Chat API in One Day with FastAPI, Gemini, and Qdrant</title>
      <dc:creator>Elyass</dc:creator>
      <pubDate>Fri, 11 Sep 2026 08:07:01 +0000</pubDate>
      <link>https://dev.to/elyass_43b15fee1a28f165db/how-i-built-a-pdf-chat-api-in-one-day-with-fastapi-gemini-and-qdrant-1j94</link>
      <guid>https://dev.to/elyass_43b15fee1a28f165db/how-i-built-a-pdf-chat-api-in-one-day-with-fastapi-gemini-and-qdrant-1j94</guid>
      <description>&lt;p&gt;Have you ever wanted to just &lt;em&gt;talk&lt;/em&gt; to a PDF instead of reading through 50 pages?&lt;/p&gt;

&lt;p&gt;I built a full PDF Chat API in one day — upload any PDF, ask questions in natural language, and get AI-powered answers. Here's how I did it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Upload any PDF document&lt;/li&gt;
&lt;li&gt;Ask questions about its content in natural language&lt;/li&gt;
&lt;li&gt;Get accurate answers powered by RAG (Retrieval Augmented Generation)&lt;/li&gt;
&lt;li&gt;Clean web UI included — no frontend framework needed&lt;/li&gt;
&lt;li&gt;REST API with authentication for easy integration&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tech Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;FastAPI&lt;/strong&gt; — REST API backend&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Google Gemini&lt;/strong&gt; — embeddings (&lt;code&gt;gemini-embedding-001&lt;/code&gt;) + chat (&lt;code&gt;gemini-2.5-flash&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Qdrant&lt;/strong&gt; — vector database for semantic search&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LangChain&lt;/strong&gt; — RAG pipeline orchestration&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pure HTML/CSS&lt;/strong&gt; — no React, no framework&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;p&gt;The architecture is classic RAG in two phases:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ingestion (upload):&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Extract text from PDF&lt;/li&gt;
&lt;li&gt;Split into chunks (1000 chars, 200 overlap)&lt;/li&gt;
&lt;li&gt;Generate embeddings with Gemini&lt;/li&gt;
&lt;li&gt;Store in Qdrant&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Query (chat):&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Embed the user's question&lt;/li&gt;
&lt;li&gt;Search Qdrant for the 4 most relevant chunks&lt;/li&gt;
&lt;li&gt;Send chunks + question to Gemini&lt;/li&gt;
&lt;li&gt;Return the answer&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The code
&lt;/h2&gt;

&lt;p&gt;The core is surprisingly simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;chain&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;context&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;vector_store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;as_retriever&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;search_kwargs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;k&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;}),&lt;/span&gt; 
     &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;question&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;RunnablePassthrough&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;
    &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;prompt&lt;/span&gt;
    &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;llm&lt;/span&gt;
    &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;StrOutputParser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's the entire RAG chain — retrieve relevant context, inject into prompt, generate answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Gemini embeddings produce 3072-dimensional vectors (not 768 like older models)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;grpcio&lt;/code&gt; on Windows can be a pain — pin to version 1.62.2&lt;/li&gt;
&lt;li&gt;Qdrant Cloud free tier is genuinely useful for side projects&lt;/li&gt;
&lt;li&gt;Building a clean UI in pure HTML/CSS takes less time than setting up React&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it yourself
&lt;/h2&gt;

&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjll3vttcnu9fiuq7dfor.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjll3vttcnu9fiuq7dfor.png" alt=" " width="800" height="380"&gt;&lt;/a&gt; get the packaged version ready to deploy:&lt;br&gt;
👉 &lt;a href="https://elyassdigital.gumroad.com/l/zcgjmmz" rel="noopener noreferrer"&gt;https://elyassdigital.gumroad.com/l/zcgjmmz&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Multi-user support with separate collections per user&lt;/li&gt;
&lt;li&gt;Docker deployment guide&lt;/li&gt;
&lt;li&gt;Support for other document types (Word, Excel)&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Built this as a side project — happy to answer questions in the comments!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>rag</category>
      <category>python</category>
      <category>fastapi</category>
    </item>
  </channel>
</rss>
