<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Akshyansu Pritam on Medium]]></title>
        <description><![CDATA[Stories by Akshyansu Pritam on Medium]]></description>
        <link>https://medium.com/@akshyansupritam7?source=rss-1002af93f6bc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*783xrJeWus4H_yHZ</url>
            <title>Stories by Akshyansu Pritam on Medium</title>
            <link>https://medium.com/@akshyansupritam7?source=rss-1002af93f6bc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 09:19:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akshyansupritam7/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From PDFs to Cited Answers: A Local RAG Pipeline with RAGFlow]]></title>
            <link>https://medium.com/@akshyansupritam7/from-pdfs-to-cited-answers-a-local-rag-pipeline-with-ragflow-9f4841b38c87?source=rss-1002af93f6bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f4841b38c87</guid>
            <category><![CDATA[ollama]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai-engineering]]></category>
            <dc:creator><![CDATA[Akshyansu Pritam]]></dc:creator>
            <pubDate>Sat, 17 Oct 2026 17:35:37 GMT</pubDate>
            <atom:updated>2026-10-17T17:35:37.567Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>From messy internal documents to cited answers — without sending your data to a cloud LLM.</strong></p><p>HR policies live in PDFs. SLAs sit in spreadsheets. Access rules are buried in scanned memos. When someone asks “How many vacation days do I accrue each month?” or “What’s the SEV-1 first response time?”, the usual options are bad:</p><ul><li>Dig through folders manually</li><li>Ask a colleague who may or may not remember</li><li>Paste text into a public LLM and hope it doesn’t invent an answer</li></ul><p>I wanted something better: a local Retrieval-Augmented Generation (RAG) system that:</p><ol><li>Ingests real internal documents</li><li>Retrieves the right chunks when asked a question</li><li>Generates an answer only from that context</li><li>Shows citations so you can verify the source</li><li>Refuses to answer when the knowledge base doesn’t contain the information</li></ol><p>This article walks through the stack I built around open-source RAGFlow, with Elasticsearch for retrieval, Ollama for local embeddings and chat, and a thin Python + Streamlit layer for bootstrap and demos.</p><h3><strong>What is RAG (in one minute)?</strong></h3><p>RAG doesn’t “train” the model on your documents. It does something simpler and more controllable:</p><ol><li>Ingest — split documents into chunks and store them (usually with vector embeddings)</li><li>Retrieve — for each question, find the most relevant chunks</li><li>Generate — send the question <em>plus</em> those chunks to an LLM and ask it to answer from that context.</li></ol><p>If retrieval is weak, generation will be weak.</p><p>If retrieval is strong and the model is constrained to the context, answers become grounded — and you can show <em>where</em> they came from.</p><h3><strong>High-level flow :</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WuA93D__wE2vAmvbME2YbA.png" /><figcaption><strong>High Level Diagram of the RAGFLOW</strong></figcaption></figure><p>In short:</p><ul><li>Documents go in once (ingest → chunk → embed → index)</li><li>Questions go through retrieve → generate every time</li><li>The client sees a final answer, ideally with citations</li></ul><h3><strong>Detailed system architecture :</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*LjvktMxXbZO8YHgkZ3yIYw.png" /><figcaption><strong>End-To-End Flow</strong></figcaption></figure><h3><strong>Here’s what each layer does :</strong></h3><h4>1.Clients :</h4><p>Two ways to talk to the system:</p><ul><li>Streamlit UI — chat interface with expandable citations</li><li>Python CLI — start the stack, bootstrap the KB, ask questions from the terminal</li></ul><p>Both authenticate with a Bearer API key.</p><h4>2.Gateway :</h4><p>nginx sits on port 80 and proxies:</p><ul><li>the UI / API surface</li><li>backend calls into the RAGFlow service</li></ul><h4>3.RAGFlow API :</h4><p>RAGFlow’s Quart API (port 9380) owns:</p><ul><li>auth and API tokens</li><li>datasets and document upload</li><li>chat sessions</li><li>retrieval and answer generation</li></ul><p>Inside it, a dialog/chat path does async chat with citation handling, and search is hybrid: keyword (BM25-style) + vector similarity.</p><p>BM25 =&gt; helps in word to word search.</p><p>vector =&gt; helps in sematic search.</p><h4>4.Data stores :</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*lKH3wzMOudtZpY2tUpZiZQ.png" /></figure><h4>5.Ingest workers :</h4><p>When documents are uploaded and parsing is triggered:</p><ol><li>A task executor picks work from Redis.</li><li>DeepDOC + chunkers parse PDFs, Office files, and even scanned content and others which we have uploaded.</li><li>Chunks are embedded via the configured embedding model.</li><li>Chunks are indexed into Elasticsearch.</li></ol><h4>6.Models (local) :</h4><p>Chat and embeddings run on Ollama on the host.</p><p>Docker containers can’t always reach localhost:11434 cleanly, so a small Ollama proxy listens on :11435 and forwards traffic to host Ollama on :11434.</p><p>RAGFlow is configured to use that proxy URL (e.g. via host.docker.internal).</p><p>Typical models in this setup:</p><ul><li>Chat: e.g. qwen2.5-coder:14b</li><li>Embeddings: e.g. nomic-embed-text</li></ul><h4>7. Final response</h4><p>The dialog path returns:</p><ul><li>the answer</li><li>citations (document name, page/position, similarity, chunk text)</li><li>behavior for empty / unreliable cases when nothing relevant was retrieved</li></ul><p>That last part matters as much as “getting an answer.”</p><h3>The ingest path (documents → searchable knowledge)</h3><p>This is the offline (or “setup”) pipeline:</p><ol><li>Client uploads documents into a dataset.</li><li>Files land in MinIO.</li><li>Parse jobs are enqueued in Redis.</li><li>Workers pull files, run DeepDOC parsing and chunking.</li><li>Each chunk is embedded through Ollama.</li><li>Chunks + vectors are written to Elasticsearch.</li></ol><p>Until parsing finishes, the knowledge base isn’t fully query-able. Bootstrap waits for document status to reach “done” before creating the chat assistant.</p><p>For demos I use a small internal-style corpus (“northwind” KB), including things like:</p><ul><li>HR leave policy (PDF)</li><li>Engineering access policy (PDF)</li><li>Support SLA matrix (Excel)</li><li>Onboarding deck (PPTX)</li><li>A scanned facilities memo (PDF)</li></ul><p>That mix forces the pipeline to handle more than plain text files.</p><h3>The query path (question → cited answer)</h3><p>When a user asks a question:</p><ol><li>The UI or CLI sends the question to RAGFlow’s chat API with the API key.</li><li>The query is embedded.</li><li>Hybrid search runs against Elasticsearch (keyword + vector).</li><li>Top chunks are assembled as context.</li><li>The chat model generates an answer from question + context.</li><li>The response includes the answer and citation metadata.</li><li>The UI shows expandable sources (document, page, similarity, chunk text).</li></ol><p>A similarity floor (for example ~0.35) helps filter weak matches. For questions outside the KB — like “What is the CEO’s favorite sandwich?” — the system should return an empty or “I don’t know” style response rather than inventing a witty answer.</p><p>That refusal behavior is the difference between a demo chatbot and something you’d actually trust for internal Q&amp;A.</p><h3>The glue layer: making it runnable end-to-end</h3><p>RAGFlow is the engine. Around it I added a thin Python project so “spin up and try it” is one path, not ten manual UI clicks.</p><h4>Bootstrap</h4><p>A bootstrap command roughly:</p><ol><li>Ensures the Ollama proxy is up.</li><li>Pulls the embedding model if needed.</li><li>Waits until RAGFlow is healthy.</li><li>Registers/logs in an admin user.</li><li>Creates an API token.</li><li>Registers Ollama chat + embed models in RAGFlow.</li><li>Creates a dataset and uploads the sample corpus.</li><li>Triggers parse and waits until documents are done.</li><li>Creates a chat assistant bound to that dataset.</li><li>Optionally runs a smoke test: one known question + one unknown question</li></ol><h4>Streamlit UI</h4><p>The Streamlit app:</p><ul><li>loads settings from .env.</li><li>chats against the configured chat ID.</li><li>shows answers and expandable citations.</li></ul><h3>Why these technology choices?</h3><p>RAGFlow — full ingest/retrieve/chat orchestration, including DeepDOC for harder document layouts, instead of hand-rolling every piece.</p><p>Elasticsearch — solid hybrid retrieval (keyword + vectors), which usually beats “vectors only” on policy-style docs with exact terms (SEV-1, accrual rates, named owners).</p><p>Ollama (local) — private by default; no document text leaving the machine for the LLM call; no per-token cloud bill for demos.</p><p>Docker Compose — MySQL, Redis, MinIO, ES, API, and nginx as one stack.</p><p>Streamlit + CLI — fast demo surface and automation without building a full product frontend first.</p><h3>What “good” looks like in a demo :</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wnoXlsbHk9Zs3spCbFzLig.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Etak4bwORfdPKf9cFUITw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*35eTH8_4zJ6uMTlb2THnWg.png" /></figure><h3>Lessons learned :</h3><ol><li>Retrieval quality beats model size for internal KB Q&amp;A. Hybrid search helps.</li><li>Citations are the product, not a nice-to-have. Without them, users can’t trust the answer.</li><li>Refuse is a feature. Empty responses on out-of-scope questions build more trust than fluent hallucination.</li><li>Local LLMs need plumbing. Docker → host Ollama via a proxy is a real-world detail, not a footnote.</li><li>Bootstrap saves hours. Automating register → models → dataset → parse → chat turns a platform into a reproducible project.</li></ol><blockquote>Explore this project : <a href="https://github.com/Akshyansu3479">https://github.com/Akshyansu3479</a></blockquote><h3>THANK YOU FOR READING IT…!!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f4841b38c87" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Scalable URL Shortener on AWS: My Journey]]></title>
            <link>https://medium.com/@akshyansupritam7/building-a-scalable-url-shortener-on-aws-my-journey-82f957e88576?source=rss-1002af93f6bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/82f957e88576</guid>
            <category><![CDATA[url-shorteners]]></category>
            <category><![CDATA[availability]]></category>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[mern-stack]]></category>
            <dc:creator><![CDATA[Akshyansu Pritam]]></dc:creator>
            <pubDate>Thu, 19 Sep 2024 19:14:00 GMT</pubDate>
            <atom:updated>2024-09-19T19:23:05.908Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction:</h3><p>In this project, I created a <strong>MERN stack website</strong> with a URL shortener service. The application allows users to generate short URLs and handles redirection to the original URLs.</p><p>The backend processes include URL validation, generating a unique short ID, storing data in MongoDB, and handling redirection requests.</p><p>To ensure the application is <strong>scalable</strong> and <strong>highly available</strong>, I hosted the backend on <strong>AWS</strong> using<strong> EC2</strong>, <strong>PM2</strong>, <strong>Load Balancers</strong>, <strong>Auto Scaling Groups</strong>, and various other AWS services.</p><p>This guide explains the steps I followed, the challenges I faced, and the solutions I implemented to create a robust URL shortening service.</p><h3>Architecture:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-V2xX7bOcOlrW0ui2bvIqg.png" /></figure><h3>Steps Taken:</h3><ol><li><strong>Setting Up the Backend on EC2:</strong></li></ol><p>I hosted the backend on an <strong>EC2 instance</strong> to handle the server-side logic. Using <strong>PM2</strong>, a process manager for Node.js applications, I ensured that my server would run as a daemon, staying online 24/7, even in case of crashes.</p><pre>Install PM2: npm i pm2<br>Start Server with PM2: pm2 start app.js --watch<br></pre><p>2. <strong>CORS Issue and Solution:</strong></p><p>While testing on a single EC2 instance, I faced a <strong>CORS error</strong>. After 8 hours of debugging, I realized the issue was due to my college’s Wi-Fi (FortiGuard firewall) dropping headers, including CORS-related ones. This experience taught me that firewalls can interfere with headers, leading to such errors.</p><p>3. <strong>Setting Up a Load Balancer:</strong></p><p>To distribute traffic across multiple EC2 instances, I created an <strong>Elastic Load Balancer (ELB)</strong>.</p><p>Key Considerations:</p><ul><li>Ensure the <strong>EC2</strong> and <strong>Load Balancer</strong> are in the same <strong>VPC</strong>.</li><li>Use the same <strong>Security Group</strong> for both EC2 and the Load Balancer.</li><li>Create a <strong>Target Group</strong> for EC2 instances.</li><li>Set the <strong>protocol</strong> to HTTP/HTTPS and the <strong>port</strong> to 8080.</li><li><strong>Health checks</strong> were configured to ensure that only healthy instances receive traffic.</li><li>The <strong>Listener</strong> was configured to forward all traffic on port 81 to the EC2 instances.</li></ul><p>4. <strong>Auto Scaling Group Setup:</strong></p><p>To make my application scalable, I created an <strong>Auto Scaling Group (ASG)</strong> that would automatically adjust the number of EC2 instances based on traffic load.</p><p>Steps:</p><p><strong>Launch Template</strong>: Created an <strong>Amazon Machine Image (AMI)</strong> to launch EC2 instances.</p><ul><li>Instance type: <strong>t2.micro</strong>.</li><li>User data script to start the server on boot:</li></ul><pre>#!/bin/bash<br>sudo su -<br>curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash<br>source ~/.nvm/nvm.sh<br>nvm install node<br>sudo yum update -y<br>sudo yum install git -y<br>git clone https://github.com/Akshyansu3479/URL-Shortener.git<br>cd URL-Shortener/server<br>npm install<br>npm install pm2 -g<br>pm2 start index.js --watch</pre><ul><li><strong>Scaling Policy</strong>: Configured based on <strong>CPU utilization</strong>, ensuring the application could handle varying levels of traffic dynamically.</li></ul><h3>AWS Services and Their Importance:</h3><ol><li><strong>EC2 (Elastic Compute Cloud):</strong></li></ol><ul><li><strong>Purpose</strong>: Host the backend server.</li><li><strong>Why EC2</strong>: Provides scalable compute capacity for running Node.js servers and handling client requests.</li><li><strong>How it helps</strong>: EC2 allows the application to scale up/down based on traffic.</li></ul><p>2. <strong>PM2 (Process Manager for Node.js):</strong></p><ul><li><strong>Purpose</strong>: Ensure the Node.js server remains online 24/7.</li><li><strong>Why PM2</strong>: Automatically restarts the application in case of crashes.</li><li><strong>How it helps</strong>: PM2 ensures high availability, especially for a URL shortener where uptime is critical.</li></ul><p>3. <strong>Elastic Load Balancer (ELB):</strong></p><ul><li><strong>Purpose</strong>: Distribute incoming traffic across EC2 instances.</li><li><strong>Why ELB</strong>: Ensures no single instance is overwhelmed by traffic.</li><li><strong>How it helps</strong>: ELB routes traffic to healthy instances, ensuring availability even during instance failure or high traffic.</li></ul><p>4. <strong>Target Group:</strong></p><ul><li><strong>Purpose</strong>: Define which EC2 instances receive traffic.</li><li><strong>Why Target Group</strong>: Monitors the health of EC2 instances.</li><li><strong>How it helps</strong>: Routes traffic only to healthy instances, preventing downtime.</li></ul><p>5. <strong>Auto Scaling Group (ASG):</strong></p><ul><li><strong>Purpose</strong>: Automatically adjust the number of EC2 instances based on traffic.</li><li><strong>Why ASG</strong>: Ensures cost-effectiveness by scaling up during high traffic and scaling down when not needed.</li><li><strong>How it helps</strong>: Dynamically handles traffic spikes and scales down during quiet periods.</li></ul><p>6. <strong>Launch Template:</strong></p><ul><li><strong>Purpose</strong>: Automate the process of launching new EC2 instances with predefined configurations.</li><li><strong>Why Launch Template</strong>: Ensures consistent instance setup.</li><li><strong>How it helps</strong>: Automates scaling by creating new instances with the correct configuration.</li></ul><p>7. <strong>VPC (Virtual Private Cloud):</strong></p><ul><li><strong>Purpose</strong>: Provide a secure and isolated network for the application.</li><li><strong>Why VPC</strong>: Ensures secure communication between AWS services.</li><li><strong>How it helps</strong>: Facilitates efficient scaling and security.</li></ul><p>8. <strong>Security Groups:</strong></p><ul><li><strong>Purpose</strong>: Control inbound and outbound traffic for instances.</li><li><strong>Why Security Groups</strong>: Ensures only authorized traffic reaches EC2 instances.</li><li><strong>How it helps</strong>: Enhances security by allowing only necessary ports and protocols.</li></ul><p>9. <strong>Scaling Policy (CPU Utilization-Based):</strong></p><ul><li><strong>Purpose</strong>: Adjust EC2 instances based on CPU usage.</li><li><strong>Why Scaling Policy</strong>: Ensure the application can handle traffic spikes.</li><li><strong>How it helps</strong>: Dynamically scales resources based on CPU usage.</li></ul><p>10. <strong>MongoDB (NoSQL Database):</strong></p><ul><li><strong>Purpose</strong>: Store URLs with unique short IDs.</li><li><strong>Why MongoDB</strong>: Flexible schema design for handling dynamic data.</li><li><strong>How it helps</strong>: Scales efficiently as the number of URLs grows.</li></ul><p>11. <strong>Rate Limiting with Redis:</strong></p><ul><li><strong>Purpose</strong>: Prevent abuse by limiting the number of requests.</li><li><strong>Why Redis</strong>: Fast in-memory data store for real-time rate limiting.</li><li><strong>How it helps</strong>: Controls traffic load while maintaining performance.</li></ul><p>12. <strong>Amazon Machine Image (AMI):</strong></p><ul><li><strong>Purpose</strong>: Provide a pre-configured virtual machine template.</li><li><strong>Why AMI</strong>: Ensures consistency in launching new EC2 instances.</li><li><strong>How it helps</strong>: Simplifies scaling by ensuring each new instance is properly configured.</li></ul><h3>Handling Traffic and Scaling</h3><h4><strong>Traffic Handling:</strong></h4><p>The <strong>Load Balancer</strong> distributes incoming traffic across multiple EC2 instances, preventing any single instance from being overwhelmed.</p><p>With the <strong>Auto Scaling Group</strong> in place, the system can respond to traffic spikes by automatically adding more instances.</p><p><strong>Rate limiting</strong> with Redis helps control abusive requests and ensures traffic is managed efficiently.</p><h4>Scalability:</h4><p>The combination of the <strong>Auto Scaling Group</strong> and the <strong>Load Balancer</strong> ensures that the application can dynamically scale based on traffic load.</p><p>Instances are automatically launched or terminated based on CPU utilization, ensuring both high performance and cost-effectiveness.</p><p><strong>This architecture ensures that the URL shortener can handle increasing traffic while remaining cost-effective and responsive. I hope you enjoyed this journey of building a scalable solution using AWS!</strong></p><h3><strong>Thank You for taking the time to read my article! I hope you found it helpful and insightful.</strong></h3><h3><strong>Feel free to share your thoughts or ask any questions in the comments. Your support and feedback mean a lot to me!</strong></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82f957e88576" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>