<?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 Banasree Ghosh on Medium]]></title>
        <description><![CDATA[Stories by Banasree Ghosh on Medium]]></description>
        <link>https://medium.com/@banasree.mani?source=rss-2995df7f3791------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*xB0-EdgVxO6yZMDB.jpg</url>
            <title>Stories by Banasree Ghosh on Medium</title>
            <link>https://medium.com/@banasree.mani?source=rss-2995df7f3791------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 22:58:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@banasree.mani/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[Building a Production-Ready RAG System End-to-End]]></title>
            <link>https://medium.com/@banasree.mani/building-a-production-ready-rag-system-end-to-end-dc5ad6f5b415?source=rss-2995df7f3791------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc5ad6f5b415</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[machine-learning-ai]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[llm-applications]]></category>
            <category><![CDATA[mlops]]></category>
            <dc:creator><![CDATA[Banasree Ghosh]]></dc:creator>
            <pubDate>Sat, 27 Jun 2026 08:21:00 GMT</pubDate>
            <atom:updated>2026-06-27T08:21:00.986Z</atom:updated>
            <content:encoded><![CDATA[<p>A production-ready RAG system needs much more than a working answer. It needs evaluation, observability, feedback loops, guardrails, deployment strategy, prompt management, and operational discipline.</p><p>In this project, I built and deployed an end-to-end RAG system using FastAPI, Gradio, ChromaDB, Hybrid Search, Cross-Encoder Reranking, Langfuse, Docker, Groq, and Railway.</p><p>The goal was not just to build a chatbot.</p><p>The goal was to build a measurable, observable, and deployable AI application.</p><h3>What I Built</h3><p>The application is a Pet Care RAG Assistant.</p><p>A user can ask pet-care questions such as: <em>Can dogs eat chocolate?</em></p><p>or <em>How often should I bathe my dog?</em></p><p>The system retrieves relevant knowledge from a curated pet-care knowledge base, ranks the best context, sends it to an LLM, and returns a grounded answer with source context.</p><p>But the important part is not just the answer.</p><p>The important part is the production architecture around the answer.</p><p>The system includes:</p><ul><li>FastAPI backend</li><li>Gradio user interface</li><li>Chroma vector database</li><li>Hybrid Search using vector retrieval and BM25</li><li>Cross-Encoder Reranking</li><li>Guardrails for out-of-scope and unsafe questions</li><li>Evaluation metrics such as MRR and nDCG</li><li>LLM-as-a-judge answer evaluation</li><li>Feedback API</li><li>Feedback analytics dashboard</li><li>Langfuse tracing</li><li>Dynamic prompt management</li><li>Groq API integration</li><li>Railway deployment</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9kQq8Tf-_pAeTykQ3b-Vvw.png" /><figcaption>Gradio UI</figcaption></figure><h3>Architecture Overvie</h3><p>The high-level flow looks like this:</p><pre>User<br>  ↓<br>Gradio UI<br>  ↓<br>FastAPI API<br>  ↓<br>Guardrails<br>  ↓<br>Hybrid Retrieval<br>  ↓<br>Reranker<br>  ↓<br>Prompt Management<br>  ↓<br>LLM via Groq<br>  ↓<br>Answer + Sources<br>  ↓<br>Feedback + Evaluation + Observability</pre><p>The system is split into three deployable services:</p><pre>pet-rag-api<br>pet-rag-ui<br>pet-rag-evaluator</pre><p>The API service exposes:</p><pre>/ask<br>/feedback<br>/health<br>/docs<br>/metrics/retrieval<br>/metrics/answers<br>/feedback/summary</pre><p>The UI service lets users ask questions and submit feedback.</p><p>The evaluator service provides retrieval, answer-quality, and feedback analytics dashboards.</p><h3>Why Vector Search Alone Was Not Enough</h3><p>The first version used vector search only.</p><p>Vector search is powerful because it understands semantic similarity. But it can miss exact terms, especially in specialized domains.</p><p>For example, a user may ask: <em>My dog ate chocolate. What should I do?</em></p><p>The knowledge base may contain terms like:</p><pre>methylxanthines<br>theobromine<br>tachycardia<br>seizures<br>emergency veterinary services</pre><p>Vector search may find relevant chunks, but exact keyword matching is also valuable.</p><p>So I added Hybrid Search.</p><p>Hybrid Search combines:</p><pre>Dense retrieval<br>+<br>BM25 keyword retrieval</pre><p>This improved recall because the system could retrieve documents based on both semantic meaning and exact keyword overlap.</p><h3>Adding Cross-Encoder Reranking</h3><p>Hybrid Search retrieves candidate documents.</p><p>But retrieval alone does not guarantee that the best document is ranked first.</p><p>So I added a Cross-Encoder reranker.</p><p>The reranker takes:</p><pre>question + candidate document</pre><p>and scores how relevant the document is to the question.</p><p>The reranker does not replace retrieval. It improves the order of the retrieved documents.</p><p>The flow became:</p><pre>Retrieve top candidate documents<br>        ↓<br>Rerank documents<br>        ↓<br>Send top documents to the LLM</pre><p>This is a common production RAG pattern.</p><p>One important lesson: reranker scores are not always intuitive. They are often raw logits, not percentages. A negative score does not automatically mean the retrieval is bad. What matters is whether the correct document is ranked above weaker candidates and whether the final answer is grounded in the right context.</p><h3>Guardrails</h3><p>A production RAG system should not answer every question.</p><p>For a pet-care assistant, questions about programming, stock trading, or unrelated topics should be rejected or handled safely.</p><p>So I added guardrails before retrieval.</p><p>The system checks whether the question is relevant to pet care and blocks out-of-scope requests.</p><p>Example:</p><pre>User:<br>Write Python code for a stock trading bot.</pre><pre>System:<br>This assistant is designed for pet-care questions.</pre><p>This keeps the application aligned with its intended purpose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*92Lk2pgTL1n-_L4b.png" /><figcaption>Guardrails</figcaption></figure><h3>Evaluation: Stop Vibe-Checking RAG</h3><p>A common mistake in RAG projects is manually testing a few questions and deciding the system is “good enough.”</p><p>That is not production engineering.</p><p>I added an evaluation framework with test questions stored in JSONL format.</p><p>Each test contains:</p><pre>{<br>  &quot;question&quot;: &quot;What symptoms should I watch for if my dog eats chocolate?&quot;,<br>  &quot;keywords&quot;: [&quot;chocolate&quot;, &quot;theobromine&quot;, &quot;tachycardia&quot;, &quot;seizures&quot;],<br>  &quot;reference_answer&quot;: &quot;...&quot;,<br>  &quot;category&quot;: &quot;emergency&quot;<br>}</pre><p>The retrieval evaluation calculates:</p><ul><li>MRR</li><li>nDCG</li><li>Keyword Coverage</li></ul><p>The answer evaluation uses an LLM-as-a-judge to score:</p><ul><li>Accuracy</li><li>Completeness</li><li>Relevance</li></ul><p>This gives a much better view of system quality than manual testing.</p><h3>Evaluation Dashboard</h3><p>I built a Gradio-based evaluation dashboard.</p><p>The dashboard shows:</p><pre>MRR<br>nDCG<br>Keyword Coverage<br>Accuracy<br>Completeness<br>Relevance</pre><p>It also breaks down retrieval quality by category.</p><p>For example:</p><pre>grooming<br>food<br>vaccination<br>behaviour<br>hygiene<br>emergency</pre><p>This is important because a RAG system may perform well overall but fail in specific categories.</p><p>Production AI systems need this type of visibility.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LYdTM6eg1-vmgTrmwQbk9g.png" /><figcaption>Evaluation &amp; Feedback Dashboard</figcaption></figure><h3>Feedback API</h3><p>Evaluation datasets are useful before release.</p><p>But once users start using the system, user feedback becomes extremely valuable.</p><p>I added a feedback API:</p><pre>POST /feedback</pre><p>The feedback payload stores:</p><pre>{<br>  &quot;question&quot;: &quot;...&quot;,<br>  &quot;answer&quot;: &quot;...&quot;,<br>  &quot;rating&quot;: &quot;thumbs_up&quot;,<br>  &quot;comment&quot;: &quot;Helpful answer&quot;,<br>  &quot;trace_id&quot;: &quot;...&quot;<br>}</pre><p>Feedback is stored in a JSONL file for simplicity:</p><pre>feedback/feedback.jsonl</pre><p>This allowed me to build feedback analytics without needing a database in the first version.</p><h3>Feedback Analytics Dashboard</h3><p>The feedback dashboard shows:</p><ul><li>Total feedback</li><li>Helpful count</li><li>Not helpful count</li><li>Positive rate</li><li>Recent feedback</li><li>Top negative questions</li><li>Recent negative feedback</li><li>User comments</li><li>Trace ID correlation</li></ul><p>This is where the system starts looking more like a real AI product.</p><p>For example, if multiple users downvote the same question, that becomes a signal:</p><pre>The answer may be too generic.<br>The retrieval may be weak.<br>The prompt may need adjustment.<br>The knowledge base may be incomplete.</pre><p>User comments make this even more useful.</p><p>A thumbs down tells us that something failed.</p><p>A comment tells us why.</p><h3>Langfuse Observability</h3><p>I integrated Langfuse for LLM observability.</p><p>For every question, I track:</p><ul><li>User input</li><li>Retrieved sources</li><li>Number of retrieved documents</li><li>Reranker scores</li><li>LLM response</li><li>Latency</li><li>Prompt version</li><li>Trace ID</li></ul><p>This is critical for debugging.</p><p>If a user gives negative feedback, I can look at the trace and inspect:</p><pre>Which documents were retrieved?<br>Which prompt version was used?<br>What did the model receive?<br>How long did the response take?<br>Was the answer grounded?</pre><p>Without tracing, debugging RAG is guesswork.</p><p>With tracing, it becomes an engineering workflow.</p><h3>Dynamic Prompt Management</h3><p>Initially, the system prompt was hardcoded.</p><p>That works for prototypes but not for production.</p><p>So I moved prompt management into Langfuse.</p><p>Now the prompt can be updated, versioned, and rolled back without changing code.</p><p>This is important because prompts behave like operational configuration.</p><p>They should be testable, versioned, and observable.</p><p>The application fetches the prompt dynamically:</p><pre>Langfuse prompt<br>    ↓<br>Compile with retrieved context<br>    ↓<br>Send to LLM</pre><p>If Langfuse is unavailable, the system falls back to a local default prompt.</p><p>That makes the application more resilient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lNTymT-D8vTSTRUuE2j11w.png" /><figcaption>Dynamic Prompt</figcaption></figure><h3>Deployment: Railway + Groq</h3><p>Locally, I used Ollama and Llama 3.2.</p><p>But local Ollama is not ideal for public deployment because the server disappears when the laptop is shut down, and hosting local models requires memory and compute.</p><p>For deployment, I used:</p><pre>Railway<br>+<br>Groq API<br>+<br>Llama 3.3 70B</pre><p>This gives a better public demo experience:</p><ul><li>No GPU management</li><li>Faster LLM responses</li><li>Simpler deployment</li><li>Good fit for a portfolio project</li></ul><p>The deployed architecture became:</p><pre>Railway FastAPI Service<br>        ↓<br>Groq API<br>        ↓<br>Llama 3.3 70B</pre><p>The app uses environment variables to switch between local and deployed mode:</p><pre>Local:<br>LLM_PROVIDER=ollama</pre><pre>Production:<br>LLM_PROVIDER=groq</pre><p>This makes the system portable.</p><h3>Railway Deployment Lessons</h3><p>Deploying the system exposed real production issues.</p><p>The first issue was that the vector database was missing in Railway.</p><p>The API worked:</p><pre>/health worked<br>/docs worked</pre><p>but /ask failed because the vector database was not available.</p><p>That was a useful deployment lesson: <em>A deployed API is not the same as a working AI system.</em></p><p>The second issue was memory.</p><p>The full local setup used:</p><ul><li>Chroma</li><li>Hugging Face embeddings</li><li>BM25</li><li>Cross-Encoder reranker</li><li>Langfuse</li><li>FastAPI</li></ul><p>On a low-memory Railway service, this can trigger out-of-memory errors.</p><p>So I added a configuration option:</p><pre>ENABLE_RERANKER=false</pre><p>This allows the Railway deployment to run with a lighter profile while keeping the full reranker-enabled version available locally.</p><p>This is another real production lesson: <em>Production deployment often requires environment-specific configuration.</em></p><h3>What Makes This Production-Ready?</h3><p>This project is not “production-ready” simply because it has a chatbot UI.</p><p>It is production-oriented because it includes:</p><pre>Measurable retrieval quality<br>Observable LLM behavior<br>Prompt versioning<br>User feedback loops<br>Guardrails<br>Deployment configuration<br>Traceability<br>Failure analysis</pre><p>A real AI application must be improved continuously.</p><p>That means every answer should leave behind evidence:</p><pre>What was asked?<br>What was retrieved?<br>What was generated?<br>What did the user think?<br>What should we improve?</pre><p>That is the difference between a demo and an AI system.</p><h3>Key Lessons Learned</h3><h3>1. RAG quality is not only about the LLM</h3><p>The retriever, chunking, ranking, prompt, and knowledge base all matter.</p><h3>2. Vector search alone is not enough</h3><p>Hybrid Search improves recall by combining semantic and keyword retrieval.</p><h3>3. Reranking improves precision</h3><p>But reranker scores must be interpreted carefully.</p><h3>4. Evaluation is mandatory</h3><p>MRR, nDCG, and LLM-as-a-judge are much better than manual vibe checks.</p><h3>5. Feedback is production data</h3><p>User feedback tells you where the system fails in real usage.</p><h3>6. Observability changes everything</h3><p>Langfuse traces make it possible to debug AI behavior systematically.</p><h3>7. Deployment reveals hidden problems</h3><p>Memory, file paths, vector DB availability, and environment variables all matter.</p><h3>Final Architecture</h3><pre>User<br> ↓<br>Gradio UI<br> ↓<br>FastAPI API<br> ↓<br>Guardrails<br> ↓<br>Hybrid Search<br> ↓<br>Optional Reranker<br> ↓<br>Dynamic Prompt<br> ↓<br>Groq LLM<br> ↓<br>Answer + Sources<br> ↓<br>Feedback API<br> ↓<br>Feedback Analytics<br> ↓<br>Langfuse Observability</pre><p>This is the architecture I would expect from a serious production RAG application.</p><h3>What’s Next?</h3><p>The next step is to build on this foundation and move toward a more enterprise-grade AI platform.</p><p>Future improvements include:</p><ul><li>Authentication for admin dashboards</li><li>Prompt A/B testing</li><li>Automated evaluation pipelines</li><li>Retrieval failure analysis</li><li>Model routing</li><li>Cost tracking</li><li>Cloud vector database</li><li>CI/CD deployment</li><li>Kubernetes deployment</li><li>Enterprise AI Gateway pattern</li></ul><p>The bigger lesson is this: <em>Building a RAG app is easy. Operating a RAG system is the real engineering challenge.</em></p><p>This project was a step toward that operational mindset.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc5ad6f5b415" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Toy RAG to Production RAG: Hybrid Search, Reranking and Observability]]></title>
            <link>https://medium.com/@banasree.mani/from-toy-rag-to-production-rag-hybrid-search-reranking-and-observability-6f54a6de01a0?source=rss-2995df7f3791------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f54a6de01a0</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[generative-ai-use-cases]]></category>
            <dc:creator><![CDATA[Banasree Ghosh]]></dc:creator>
            <pubDate>Fri, 19 Jun 2026 19:01:01 GMT</pubDate>
            <atom:updated>2026-06-21T15:56:47.080Z</atom:updated>
            <content:encoded><![CDATA[<p>Building a basic Retrieval-Augmented Generation (RAG) pipeline over a weekend has become trivial. You chunk a few documents, dump them into a vector database, write a basic prompt, and boom — you have a functioning chatbot.</p><p>Then real users arrive.</p><p>Suddenly the system starts returning irrelevant documents, missing obvious answers, hallucinating responses, and providing no visibility into what actually happened behind the scenes.</p><p>The reality is that a basic RAG prototype is not a production system.</p><p>To move past basic “toy” architectures, you must evolve your pipeline. Here is how I hardened a local pet-knowledge base RAG system into a resilient, production-ready system by implementing <strong>Hybrid Search</strong>, <strong>Cross-Encoder Reranking</strong>, an <strong>Evaluation Dashboard</strong>, <strong>User Feedback APIs, and Langfuse</strong> <strong>Observability</strong>.</p><h3>The Initial Architecture</h3><p>The starting point was straightforward:</p><ul><li>FastAPI backend</li><li>Ollama running Llama 3.2 locally</li><li>LangChain orchestration</li><li>Chroma vector database</li><li>Gradio user interface</li></ul><p>The flow looked like this:</p><p>User Question → Vector Search → Top K Chunks → LLM → Answer</p><p>This worked surprisingly well for straightforward questions.</p><p>The problems appeared when users asked questions using different terminology than the documents contained.</p><h3>Why Vector Search Alone Fails</h3><p>Vector databases are excellent at semantic similarity. If a user asks: “What vaccines does my puppy need?” the embedding model can often retrieve documents discussing: “Puppy vaccination schedules” even if the wording differs. However, vector search has limitations. Consider these queries:</p><ul><li>“Dog names”</li><li>“Parvo”</li><li>“Rabies booster”</li><li>“Pet first aid”</li></ul><p>These contain highly specific keywords.</p><p>Sometimes semantic search retrieves conceptually similar content while completely missing the exact document containing the answer.</p><p>In practice, semantic search and keyword search solve different problems. Vector Search excels at meaning. Keyword Search excels at exact terminology. Production systems typically need both.</p><h3>Hybrid Search: Combining BM25 and Embeddings</h3><p>To improve retrieval quality, I implemented Hybrid Search.</p><p>The idea is simple.</p><p>First retrieve documents using embeddings:</p><pre>vector_docs = vectorstore.similarity_search(query, k=20)</pre><p>Then apply BM25 scoring over the candidate documents:</p><pre>bm25 = BM25Okapi(tokenized_docs)<br>scores = bm25.get_scores(query.split())</pre><p>Finally combine both approaches.</p><p>Instead of relying exclusively on semantic similarity, the retriever now considers both:</p><ul><li>Semantic relevance</li><li>Exact keyword relevance</li></ul><p>The new flow became:</p><pre>User Question<br>↓<br>Vector Search<br>↓<br>BM25 Keyword Search<br>↓<br>Combined Results</pre><p>This immediately improved retrieval performance, particularly for questions containing domain-specific terminology.</p><h3>Cross-Encoder Reranking</h3><p>Even after Hybrid Search, another problem remained. Suppose the retriever returns 20 documents. Not all of them are equally useful. Traditional retrieval systems rank documents independently. <strong>A Cross-Encoder</strong> takes a different approach. It evaluates: (Query, Document) as a pair. Instead of asking: “How similar is this document?” it asks: “How relevant is this document to this specific question?”</p><p>I used:</p><pre>cross-encoder/ms-marco-MiniLM-L-6-v2</pre><p>This model was trained on Microsoft’s MS MARCO dataset containing millions of real-world search queries.</p><p>Example:</p><pre>score = reranker.predict([<br>    [query, document]<br>])</pre><p>The documents are then <strong>sorted by score</strong>.</p><p>The final pipeline became:</p><pre>User Question<br>↓<br>Vector Search<br>↓<br>BM25 Search<br>↓<br>Cross-Encoder Reranker<br>↓<br>Top 5 Documents<br>↓<br>LLM</pre><p>The improvement was immediately visible. The most relevant chunks consistently appeared at the top of the context window.</p><h3>Measuring Retrieval Quality</h3><p>Many teams evaluate RAG systems using intuition.</p><p>They ask a few questions and decide whether the answers “feel good.”</p><p>This approach does not scale.</p><p>I implemented a retrieval evaluation framework using Information Retrieval metrics.</p><h3>Mean Reciprocal Rank (MRR)</h3><p>Measures how quickly the correct answer appears. A score of 1.0 means the relevant document was ranked first.</p><h3>Normalized Discounted Cumulative Gain (nDCG)</h3><p>Measures overall ranking quality. Higher scores indicate that relevant documents appear earlier in the results.</p><h3>Keyword Coverage</h3><p>Measures how many expected keywords were found in retrieved documents.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5ovXRryHGtxkM-gyki7gDA.png" /></figure><p>Example output:</p><ul><li>MRR: 0.67</li><li>nDCG: 0.68</li><li>Coverage: 72.5%</li></ul><p>These metrics provide objective evidence of retrieval performance.</p><h3>LLM-as-a-Judge Answer Evaluation</h3><p>Retrieval quality is only half the story.</p><p>The generated answer also needs evaluation.</p><p>For answer assessment I implemented an LLM-as-a-Judge framework.</p><p>Each generated answer is compared against a reference answer.</p><p>The judge model scores:</p><ul><li>Accuracy</li><li>Completeness</li><li>Relevance</li></ul><p>Example:</p><p>Accuracy: 4.0/5<br>Completeness: 3.0/5<br>Relevance: 4.8/5</p><p>This creates a repeatable evaluation process instead of relying on subjective opinions.</p><h3>Building an Evaluation Dashboard</h3><p>Metrics hidden in logs are not useful.</p><p>To make results visible, I built a dedicated Gradio Evaluation Dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*If7NqZqqpfbVoweMFFZfwg.png" /></figure><p>The dashboard displays:</p><h3>Retrieval Metrics</h3><ul><li>MRR</li><li>nDCG</li><li>Keyword Coverage</li></ul><h3>Category Breakdown</h3><ul><li>Grooming</li><li>Nutrition</li><li>Vaccination</li><li>Behaviour</li><li>Hygiene</li><li>Emergency Care</li></ul><h3>Answer Metrics</h3><ul><li>Accuracy</li><li>Completeness</li><li>Relevance</li></ul><p>This immediately highlighted weak knowledge areas and retrieval gaps.</p><p>Instead of guessing where problems existed, the data showed exactly which categories needed improvement.</p><h3>Capturing Real User Feedback</h3><p>Offline evaluation is valuable.</p><p>Real users are better.</p><p>I added feedback controls directly into the chat interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ISRpvb6C7U6lNG6J5u81cw.png" /></figure><p>Users can select:</p><p>👍 Helpful</p><p>or</p><p>👎 Not Helpful</p><p>Feedback is stored through a FastAPI endpoint:</p><pre>POST /feedback</pre><p>Each record includes:</p><ul><li>Question</li><li>Answer</li><li>Rating</li><li>Timestamp</li></ul><p>Example:</p><pre>{<br>  &quot;question&quot;: &quot;...&quot;,<br>  &quot;answer&quot;: &quot;...&quot;,<br>  &quot;rating&quot;: &quot;positive&quot;<br>}</pre><p>This creates a continuous feedback loop.</p><p>Over time, real-world user signals become more valuable than synthetic test datasets.</p><h3>Adding Observability with Langfuse</h3><p>One of the biggest gaps in early RAG systems is visibility.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PXVA2V_VeQAdnV5U8tzCCA.png" /><figcaption>Langfuse Dashboard</figcaption></figure><p>When a user complains about a bad answer, developers often have no idea:</p><ul><li>Which documents were retrieved?</li><li>What context was sent?</li><li>How long did retrieval take?</li><li>Which prompt version was used?</li></ul><p>I integrated Langfuse to solve this problem.</p><p>Each request now creates a trace containing:</p><ul><li>User question</li><li>Retrieved documents</li><li>Reranker scores</li><li>LLM response</li><li>Latency metrics</li></ul><p>Example metadata:</p><pre>{<br>  &quot;retrieved_doc_count&quot;: 5,<br>  &quot;sources&quot;: [...],<br>  &quot;reranker_scores&quot;: [...]<br>}</pre><p>For the first time, every answer became fully explainable.</p><p>Instead of debugging blindly, I could inspect the entire execution path.</p><h3>The Final Architecture</h3><p>The final production-oriented flow looks like this:</p><pre>User Question<br>↓<br>Guardrails<br>↓<br>Hybrid Search<br>(Vector + BM25)<br>↓<br>Cross-Encoder Reranker<br>↓<br>LLM<br>↓<br>Answer<br>↓<br>Feedback API<br>↓<br>Langfuse Tracing<br>↓<br>Evaluation Dashboard</pre><p>This architecture is dramatically more reliable than a basic vector-search demo.</p><h3>Final Thoughts</h3><p>A simple RAG prototype can often be built in a weekend.</p><p>Building a production-ready RAG system requires much more.</p><p>The biggest lesson from this project was that retrieval quality, observability, evaluation, and user feedback matter just as much as the language model itself. The LLM is only one component of the system. The surrounding engineering determines whether users trust the answers. Moving from toy RAG to production RAG is not about changing models.It is about building the systems that make those models measurable, observable, and continuously improvable.</p><h3>What’s Next?</h3><p>In this article, we transformed a basic RAG application into a production-oriented system by introducing Hybrid Search, Cross-Encoder Reranking, Evaluation Dashboards, User Feedback Analytics, Dynamic Prompt Management, and Langfuse Observability.</p><p>However, building a production-ready AI application doesn’t stop here.</p><p>In the next article, we’ll take the platform one step further and explore:</p><ul><li>Trace-to-Feedback Correlation</li><li>Retrieval Failure Analysis</li><li>Prompt Versioning and A/B Testing</li><li>Langfuse Experiments and Evaluation Workflows</li><li>AI Application Monitoring and Operational Analytics</li><li>Deployment Strategies using Railway, Azure, and Cloud LLM Providers</li></ul><p>We’ll also discuss how production AI teams use observability and user feedback to continuously improve retrieval quality, prompts, and answer accuracy over time.</p><p>The goal is not simply to build a chatbot, but to build an AI system that can be measured, monitored, improved, and operated reliably in production.</p><p>Stay tuned for the next part in the series: <strong>“Operating RAG in Production: Feedback Loops, Experiments, and Continuous Improvement.”</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f54a6de01a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Encoding vs Encryption vs Hashing: The Difference Every Engineer Should Understand]]></title>
            <link>https://medium.com/@banasree.mani/encoding-vs-encryption-vs-hashing-the-difference-every-engineer-should-understand-db569c4b71c7?source=rss-2995df7f3791------2</link>
            <guid isPermaLink="false">https://medium.com/p/db569c4b71c7</guid>
            <category><![CDATA[fintech]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <dc:creator><![CDATA[Banasree Ghosh]]></dc:creator>
            <pubDate>Sun, 07 Jun 2026 02:21:00 GMT</pubDate>
            <atom:updated>2026-06-07T02:21:00.611Z</atom:updated>
            <content:encoded><![CDATA[<h3>Encoding, Encryption, and Hashing: Three Concepts Developers Confuse All the Time</h3><p>While working on post-quantum cryptography (PQC) projects for digital identity, KYC, and payment systems, I was surprised by how often people use the terms <strong>encoding</strong>, <strong>encryption</strong>, and <strong>hashing</strong> interchangeably.</p><p>They all transform data.</p><p>They all make information look different from its original form.</p><p>And they all appear throughout modern software systems.</p><p>But they solve completely different problems.</p><p>Let’s use a banking example.</p><p>Suppose we have the following payment instruction:</p><pre>Pay USD 10,000 from Account A to Account B</pre><p>There are three very different things we can do with this information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*KMsrzR7NvmBHEyCqKmVmBg.png" /><figcaption>Three different transformations. Three completely different purposes.</figcaption></figure><h3>Encoding: Making Data Transportable</h3><p>Encoding is not security.</p><p>Its purpose is simply to convert data into a format that can be safely transmitted or stored.</p><p>For example, a payment message may be encoded using Base64:</p><pre>UGF5IFVTRCAxMCwwMDAgZnJvbSBBY2NvdW50IEEgdG8gQWNjb3VudCBC</pre><p>The message now looks unreadable to most humans.</p><p>But it is not protected.</p><p>Anyone can decode it back to:</p><pre>Pay USD 10,000 from Account A to Account B</pre><p>No secret key is required.</p><p>Encoding is used everywhere:</p><ul><li>JWT tokens</li><li>Email attachments</li><li>Binary files over HTTP</li><li>ISO 20022 payload transport</li></ul><p>Encoding answers the question:</p><p><em>How do I make data easier to transmit or store?</em></p><p>Not: <em>How do I secure it?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*N3Q8xS2Q9wDQU96jEBOWGg.png" /><figcaption>Encoding is designed for transport and compatibility, not security.</figcaption></figure><h3>Encryption: Keeping Information Secret</h3><p>Encryption protects confidentiality.</p><p>Unlike encoding, encryption requires a key.</p><p>A payment message might be encrypted using AES:</p><pre>8F2A7C9D4B3E...</pre><p>Without the encryption key, the original message should remain unreadable.</p><p>Encryption is what protects:</p><ul><li>Online banking sessions</li><li>Payment instructions</li><li>Customer data</li><li>API communications</li><li>Digital identities</li></ul><p>There are two major types of encryption.</p><h3>Symmetric Encryption (AES)</h3><p>AES is the most widely used encryption algorithm today.</p><p>The same key is used to:</p><ul><li>encrypt data</li><li>decrypt data</li></ul><p>Example:</p><pre>Message<br>   ↓<br>AES Encryption + Secret Key<br>   ↓<br>Cipher Text<br>   ↓<br>AES Decryption + Same Secret Key<br>   ↓<br>Original Message</pre><p>AES is fast and efficient.</p><p>That is why it is commonly used for:</p><ul><li>TLS sessions</li><li>database encryption</li><li>file encryption</li><li>payment systems</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*yLoi3Nup2e2gA5FcNqb1IQ.png" /><figcaption>AES uses the same key for encryption and decryption. This is how most data is protected in transit and at rest.</figcaption></figure><h3>Asymmetric Encryption (RSA)</h3><p>RSA uses two keys:</p><ul><li>Public Key</li><li>Private Key</li></ul><p>The public key encrypts.</p><p>The private key decrypts.</p><pre>Message<br>   ↓<br>Encrypt with Public Key<br>   ↓<br>Cipher Text<br>   ↓<br>Decrypt with Private Key<br>   ↓<br>Original Message</pre><p>RSA solved a major problem:</p><p><em>How do two parties communicate securely without first sharing a secre key?</em></p><p>For decades RSA became the foundation of:</p><ul><li>HTTPS</li><li>PKI</li><li>Digital Certificates</li><li>Secure Email</li></ul><p>The challenge is that RSA is vulnerable to sufficiently powerful quantum computers, which is one of the reasons post-quantum cryptography has become so important.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*Lensat3qNPD5Rl0YKHux_Q.png" /><figcaption>RSA solved the key-sharing problem by introducing public and private keys.</figcaption></figure><h3>Hashing: Verifying Without Revealing</h3><p>Hashing solves a different problem.</p><p>A hash function transforms data into a fixed-length fingerprint.</p><p>Example:</p><pre>Pay USD 10,000 from Account A to Account B</pre><p>might become:</p><pre>7d9f6e5b89d2a3f8...</pre><p>A good hash function is designed to be one-way.</p><p>You can generate the hash from the original message.</p><p>But you cannot realistically recover the original message from the hash.</p><p>Hashing is commonly used for:</p><ul><li>Password storage</li><li>Digital signatures</li><li>Blockchain transactions</li><li>File integrity verification</li></ul><p>Hashing answers the question: <em>Has this data changed?</em></p><h3>Why Salt Matters</h3><p>A common mistake is storing hashes directly.</p><p>Consider two users who both use the same password:</p><pre>Welcome123!</pre><p>Without salt, both users produce exactly the same hash.</p><p>An attacker immediately learns they share the same password.</p><p>To prevent this, systems add a random value called a salt.</p><p>Example:</p><pre>User 1:<br>Welcome123! + X7A9</pre><pre>User 2:<br>Welcome123! + M2K4</pre><p>Now both users generate completely different hashes.</p><p>Salt does not make hashing stronger.</p><p>It makes large-scale attacks significantly harder.</p><p>Modern password storage should always use:</p><ul><li>salt</li><li>strong hashing algorithms</li><li>key stretching algorithms such as bcrypt, Argon2, or PBKDF2</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*Did_obvlSxLCW-QRanIQXg.png" /><figcaption>A salt ensures two identical passwords generate different hashes, making attacks significantly harder.</figcaption></figure><h3>Where This Appeared in My PQC Project</h3><p>While working on post-quantum identity and KYC systems, all three concepts appeared repeatedly.</p><p>Identity credentials were encoded so they could be exchanged between systems.</p><p>Sensitive customer information was encrypted to protect confidentiality.</p><p>Digital signatures relied on hashing to verify that credentials had not been modified.</p><p>As we introduced post-quantum cryptography, the biggest changes affected algorithms such as RSA and ECC.</p><p>Encoding remained unchanged.</p><p>Hashing largely remained unchanged.</p><p>But public-key encryption and digital signatures required migration to quantum-resistant algorithms.</p><p>This is an important distinction because many discussions about quantum threats focus on “encryption” generally, when the reality is much more specific.</p><p>The biggest impact of quantum computing is on public-key cryptography, not on Base64 encoding or salted password hashes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YTLOeof30DuBph2Smr4uuQ.png" /><figcaption>A modern banking application typically uses encoding, encryption, hashing, and digital signatures simultaneously.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*LM5T7Zb-UA2Dog5Y0kZQAA.png" /><figcaption>Quantum computing poses the greatest threat to public-key cryptography such as RSA and ECC. Symmetric encryption like AES and modern hash functions remain much more resilient, although larger key sizes (such as AES-256) are recommended in a post-quantum world. Encoding techniques such as Base64 are unaffected.</figcaption></figure><h3>The Simple Test</h3><p>Whenever you encounter transformed data, ask three questions:</p><p><strong>Can anyone reverse it?</strong></p><p>If yes, it is probably encoding.</p><p><strong>Can only someone with the correct key reverse it?</strong></p><p>It is encryption.</p><p><strong>Can nobody realistically reverse it?</strong></p><p>It is hashing.</p><p>That simple test eliminates most confusion.</p><h3>Final Thought</h3><p>Encoding, encryption, and hashing often appear together inside the same application.</p><p>But they solve fundamentally different problems.</p><p>Encoding makes data transportable.</p><p>Encryption makes data secret.</p><p>Hashing makes data verifiable.</p><p>Understanding that distinction is one of the first steps toward understanding modern cybersecurity — and why post-quantum cryptography matters.</p><p>One of the most surprising things about post-quantum cryptography is that AES is not being replaced. Most migration effort focuses on replacing public-key algorithms such as RSA and ECC, while AES largely survives with larger key sizes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db569c4b71c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Vibe-Checking Your RAG: Programmatic Evaluation with IR Metrics and LLM-as-a-Judge]]></title>
            <link>https://medium.com/@banasree.mani/stop-vibe-checking-your-rag-programmatic-evaluation-with-ir-metrics-and-llm-as-a-judge-1d5e9d2138c1?source=rss-2995df7f3791------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d5e9d2138c1</guid>
            <category><![CDATA[llm-evaluation]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[gradio]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[llama-3]]></category>
            <dc:creator><![CDATA[Banasree Ghosh]]></dc:creator>
            <pubDate>Fri, 05 Jun 2026 22:08:50 GMT</pubDate>
            <atom:updated>2026-06-05T22:28:05.190Z</atom:updated>
            <content:encoded><![CDATA[<p>A deep dive into quantifying retrieval and generation accuracy using MRR, nDCG, Recall, and automated LLM grading rubrics.</p><p>In my <a href="https://medium.com/@banasree.mani/beyond-the-tutorial-how-i-built-a-smarter-rag-pipeline-with-chroma-hugging-face-and-llama-3-2-577bdffbf91c">previous article,</a> we looked at how changing your chunking strategy — shifting from blind character splitting to structured, semantic document parsing — radically cleans up the data layout inside your vector database. We even wired up a sleek Gradio dashboard to view our chat history side-by-side with our retrieved chunks from ChromaDB.</p><p>But looking at a few examples in a UI and saying, <em>“Yeah, the answers look pretty good,”</em> is what engineers call a <strong>vibe check</strong>.</p><p>Vibe checks do not scale. When you change an embedding model, tweak a prompt, or modify your chunk sizes, you cannot manually read through hundreds of historical queries to see if your system got better or worse. You need programmatic, repeatable, and mathematically sound <strong>RAG Evaluation Metrics</strong>.</p><p>If you treat a RAG system as a single black box, debugging it is impossible. To truly measure performance, you must isolate and evaluate its two independent halves: <strong>The Retriever</strong> and <strong>The Generator</strong>.</p><p><strong>Part 1: Evaluating the Retriever (The Classic IR Metrics)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_IyBsASGFtJ00TfWYKjwlQ.png" /></figure><p>The retriever’s job is simple: given a user query, find the most relevant chunks in ChromaDB and rank them optimally. To test this deterministically, you need a <strong>Golden Test Set</strong> — a curated list of 100 to 200 real or synthetic user queries where you already <em>know</em> exactly which source documents (Ground Truth) should be pulled.</p><p>With a test set in place, you can track four core Information Retrieval (IR) metrics.</p><p>With my evaluation dashboard running over 150 test queries, I captured a fascinating data disconnect. While my final answers were struggling (scoring around ~2.5/5), the <strong>Retrieval Layer</strong> was actually performing surprisingly well:</p><ul><li><strong>Mean Reciprocal Rank (MRR):</strong> 0.7551</li><li><strong>Normalized DCG (nDCG):</strong> 0.7679</li><li><strong>Keyword Coverage:</strong> 87.6%</li></ul><p>An MRR of <strong>0.755</strong> means that for the vast majority of questions, ChromaDB and my Hugging Face embedding model successfully found the highly relevant source chunks and pushed them right to the top slot (Position 1 or 2).</p><h4>Breaking Down the Performance by Query Type</h4><p>The real insights surfaced when I grouped the retrieval metrics by the <em>type</em> of question being asked:</p><ul><li><strong>The Wins (Direct Facts &amp; Numerical Categories):</strong> The retriever excelled here, scoring close to a <strong>0.90 MRR</strong>. When a user asked for a strict data point (e.g., vaccine timelines, specific bath temperatures), vector similarity easily matched the query to the correct atomic document chunk.</li><li><strong>The Fails (Spanning &amp; Holistic Queries):</strong> For queries requiring information scattered across multiple documents, MRR plummeted to a low <strong>0.43</strong>. Because a basic top-k retrieval fetches chunks independently, it struggled to surface all components of multi-part or open-ended questions in the top spots.</li></ul><h3>1. Recall@K: Did We Even Catch the Fish?</h3><p>Recall measures the system’s ability to find <strong>all</strong> the relevant documents in the database. Out of all the ground-truth chunks that <em>should</em> have been retrieved, how many made it into your top K results?</p><pre>               Relevant Chunks Retrieved in Top K<br>Recall@K = -------------------------------------<br>               Total Existing Ground Truth Chunks<br><br></pre><p><strong>When to care:</strong> When the cost of missing information is catastrophic (e.g., missing a symptom in an emergency medical triage dataset).</p><h3>2. Precision@K: How Much Garbage Did We Bring Back?</h3><p>Precision measures the cleanliness of your context window. Out of the K chunks you pulled and passed to Llama 3.2, how many were actually relevant?</p><pre>               Relevant Chunks Retrieved in Top K<br>Precision@K = -------------------------------------<br>                               K</pre><p><strong>When to care:</strong> When you are managing strict LLM context costs or trying to prevent “context distraction,” where irrelevant noise causes the model to lose track of key facts.</p><p><strong>3. Mean Reciprocal Rank (MRR): Did the Best Hit Land on Top?</strong></p><p>Precision and Recall are order-unaware; they do not care if the most important document is at position 1 or position 10. MRR fixes this by looking strictly at the position (rank) of the <strong>first</strong> relevant chunk returned.</p><pre>                         1<br>   MRR = -------------------------------------<br>            Rank of First Relevant Chunk</pre><p>If the best chunk is at Position 1, the score is 1.0. If it gets buried at Position 5, the score drops to 1/5 = 0.2.</p><ul><li><strong>The Pro:</strong> Excellent for fast, single-answer search scenarios.</li><li><strong>The Con:</strong> It completely ignores what happens after the first relevant document. If your query requires synthesizing facts from three different chunks, MRR won’t tell you if chunks 2 and 3 were dropped.</li></ul><p><strong>4. Normalized Discounted Cumulative Gain (nDCG): Graded Relevance Ranking</strong></p><p>Unlike binary metrics, nDCG allows you to assign a <em>graded score</em> of relevance to chunks (e.g., 3 = Perfect Match, 1 = Barely Relevant, 0 = Waste of Space). It applies a logarithmic discount based on position, heavily penalizing your system if highly relevant documents are pushed to the bottom of the stack.</p><pre>DCG_K = Σ (from i=1 to K) [ (2^rel_i - 1) / log_2(i + 1) ]<br><br>nDCG_K = DCG_K / Ideal DCG_K</pre><p>An nDCG score ranges from 0 to 1, where 1 means your retriever ranked every single chunk in absolute, perfect order of utility.</p><p><strong>Part 2: Evaluating the Generator (LLM-as-a-Judge)</strong></p><p>Even if your retriever gets a perfect 1.0 nDCG, the final answer can still fail if the LLM hallucinates, misinterprets the data, or ignores the prompt.</p><p>Because text generation lacks a single mathematical “correct” answer, token-overlap metrics like BLEU or ROUGE are effectively obsolete — they penalize an LLM for using synonyms, even if the answer is factually flawless. Instead, the industry has shifted to the <strong>LLM-as-a-Judge</strong> paradigm, using powerful, instruction-tuned models (like GPT-4o, Claude 3.5 Sonnet, or heavily quantized local experts) to evaluate outputs against a structured rubric.</p><p>By evaluating the generation layer, we complete the <strong>RAG Triad</strong>:</p><pre>                  [ User Query ]<br>                     /      \<br>    Context         /        \     Answer<br>    Relevance      /          \    Relevance<br>                  v            v<br>    [ Retrieved Context ] ---&gt; [ Generated Answer ]<br>                   Faithfulness</pre><h3>Metric 1: Faithfulness (Groundedness)</h3><ul><li><strong>What it asks:</strong> Is the LLM making things up? Every single sentence in the generated answer must be explicitly supported by a fact inside the retrieved chunks.</li><li><strong>The Judge Protocol:</strong> The judge model breaks the generated answer down into individual claims. It then scans the retrieved chunks line-by-line and labels each claim as Grounded or Not Grounded. Your final score is the fraction of verified sentences.</li></ul><h3>Metric 2: Answer Relevance</h3><ul><li><strong>What it asks:</strong> Did the LLM actually answer the user’s specific question, or did it dodge it with off-topic text?</li><li><strong>The Judge Protocol:</strong> The judge compares the generated answer <em>only</em> against the original user query, ignoring the retrieved context entirely. It penalizes conversational fluff, verbose hedging, and responses that fail to address the core problem.</li></ul><p><strong>The Evaluation Workflow: Code Implementation</strong></p><p>To make this operational, I automated this flow using open-source evaluation patterns. Here is how you can set up a basic programmatic evaluator that compares the generated output to the reference ground truth using a structured JSON schema:</p><pre>import os<br>import sys<br>import math<br>from pydantic import BaseModel, Field<br>from litellm import completion<br>from dotenv import load_dotenv<br>import json<br><br># client = OpenAI(api_key=os.environ.file(&quot;OPENAI_API_KEY&quot;))<br><br>def evaluate_generation(query, retrieved_context, generated_answer, ground_truth):<br>    evaluation_prompt = f&quot;&quot;&quot;<br>    You are an expert AI Quality Assurance Judge. Evaluate the following RAG system outputs.<br>    <br>    [User Query]: {query}<br>    [Retrieved Context]: {retrieved_context}<br>    [Generated Answer]: {generated_answer}<br>    [Ground Truth Answer]: {ground_truth}<br>    <br>    Provide your evaluation in strict JSON format matching this schema:<br>    {{<br>        &quot;faithfulness&quot;: 0.0 to 1.0,<br>        &quot;answer_relevance&quot;: 0.0 to 1.0,<br>        &quot;critique&quot;: &quot;Detailed explanation of why scores were given&quot;<br>    }}<br>    &quot;&quot;&quot;<br>    <br>    response = client.chat.completions.create(<br>        model= &quot;ollama/llama3.2&quot;  #gpt-4o&quot;,<br>        response_format={ &quot;type&quot;: &quot;json_object&quot; },<br>        messages=[{&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: evaluation_prompt}],<br>        temperature=0.0 # Force deterministic evaluation<br>    )<br>    <br>    return json.loads(response.choices[0].message.content)<br><br></pre><p><strong>Real-World Baseline: Testing Llama 3.2 on the 50-Question Benchmark</strong></p><p>To establish a strict performance baseline, I ran the automated evaluation framework against my 50-question golden test dataset using a local, quantized <strong>Llama 3.2 (3B-Instruct)</strong> model.</p><p>The results were a reality check for out-of-the-box local RAG setups:</p><ul><li><strong>Accuracy:</strong> 2.64 / 5</li><li><strong>Completeness:</strong> 2.50 / 5</li><li><strong>Relevance:</strong> 3.60 / 5</li></ul><p>Looking closely at the categorical breakdown, the model performed best on <strong>Food</strong> and <strong>Vaccination</strong> topics but took a massive hit in <strong>Hygiene</strong> and <strong>Behavior</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2uCW9QdkAiHNwg4Fjw0QWA.png" /></figure><p><strong>Diagnosing the Low Scores: Why did it struggle?</strong></p><ul><li><strong>The “Completeness” Bottle-neck (2.50/5):</strong> This score was hit hardest because of our naive retrieval layer. When a user question required synthesizing information from multiple distinct concepts, a simple top-k similarity search often missed chunks 2 or 3. Llama 3.2 only received half the picture, leading to an incomplete response.</li><li><strong>The 3B Parameter Reasoning Gap:</strong> While Llama 3.2 is incredibly articulate for its size, a 3-billion parameter model naturally struggles to extract and cross-reference granular, multi-step instructions (like the precise chemical contact times needed to neutralize Parvovirus vs. Toxoplasmosis in the hygiene module) when mixed with surrounding context noise.</li><li><strong>Relevance held the line (3.60/5):</strong> The higher relevance score proves the system <em>was</em> finding the correct general domain documents, but it simply couldn’t cleanly translate that raw context into precise, comprehensive answers without better retrieval guardrails.</li></ul><h3>What I Learned: The Pitfalls of Automated Judges</h3><p>Implementing this evaluation framework taught me two critical lessons about moving away from human “vibe checks”:</p><ul><li><strong>The Cost of the Judge Layer:</strong> While running local evaluations on your retriever (nDCG/Recall) is practically free and instant, running hundreds of production queries through an “LLM-as-a-Judge” can get expensive and slow if you use massive commercial models. For local iteration, I found success fine-tuning a smaller, quantized model explicitly prompted for classification tasks.</li><li><strong>The “Lenient Judge” Bias:</strong> LLMs can sometimes be overly forgiving judges. If your generated answer sounds highly professional and grammatically flawless, an LLM judge might give it a high <em>Answer Relevance</em> score, even if it subtly missed a specific edge-case constraint. To counter this, your judge prompts must enforce a strict, binary evaluation rubric rather than relying on loose, open-ended grading.</li></ul><h3>The RAG Paradox: Great Search, Poor Synthesis</h3><p>This exact experiment highlighted the most common trap in production RAG systems: <strong>The Retrieval Paradox</strong>.</p><p>Looking at my metrics, my retriever achieved a strong <strong>0.76 nDCG</strong>, successfully delivering the right facts to the context window. Yet, my generation accuracy remained stuck at a poor <strong>2.64/5</strong>.</p><p>This proves that my system’s bottleneck wasn’t a search failure — it was a <strong>context-handling failure</strong>. Passing a massive wall of text to a smaller local model like Llama 3.2 (3B) causes it to lose focus. It proves that simply stuffing more documents into a prompt doesn’t guarantee a better answer. You have to ensure that <em>only</em> the absolute highest-quality, re-ranked context gets through.</p><h3>Summary: Designing Your Guardrails</h3><p>When deploying production-grade RAG pipelines, these metrics serve as your development gates.</p><p>If you notice your <strong>Recall@K</strong> is low, it means you need to rethink your chunking boundary sizes or implement a hybrid dense/sparse keyword search. If your <strong>Faithfulness</strong> drops, your retrieval is likely fine, but you need to engineering a stricter system prompt for Llama 3.2 (e.g., <em>“Answer the question using ONLY the provided text. If the answer is not present, say ‘I do not know’”</em>).</p><p>By tracking retrieval and generation metrics independently, you stop guessing and start engineering.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d5e9d2138c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond the Tutorial: How I Built a Smarter RAG Pipeline with Chroma, Hugging Face, and Llama 3.2]]></title>
            <link>https://medium.com/@banasree.mani/beyond-the-tutorial-how-i-built-a-smarter-rag-pipeline-with-chroma-hugging-face-and-llama-3-2-577bdffbf91c?source=rss-2995df7f3791------2</link>
            <guid isPermaLink="false">https://medium.com/p/577bdffbf91c</guid>
            <category><![CDATA[vector-database]]></category>
            <category><![CDATA[llmops]]></category>
            <category><![CDATA[open-source-model]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Banasree Ghosh]]></dc:creator>
            <pubDate>Sun, 31 May 2026 19:51:00 GMT</pubDate>
            <atom:updated>2026-05-31T19:51:00.524Z</atom:updated>
            <content:encoded><![CDATA[<p>Building a basic Retrieval-Augmented Generation (RAG) system has become the “Hello World” of the LLM era. If you follow any standard tutorial, the formula is deceptively simple: load text, throw it into a default text splitter, push it to a vector database, and pass it to a large language model.</p><p>But when I sat down to build a specialized RAG project handling highly structured domains — such as medical triage, pet grooming mechanics, and emergency protocols — I quickly ran into a brick wall. The default setup was breaking my data, confusing the embeddings, and causing the LLM to hallucinate.</p><p><strong>UI Implementation: Bringing it to Life with Gradio</strong></p><p>To turn this local pipeline into an interactive application, I built a sleek, functional user dashboard using <strong>Gradio</strong>. Instead of a basic, generic chat interface, I customized the layout to serve as a visual debugging tool for my RAG retrieval:</p><ul><li><strong>Dual-Window Interface:</strong> The screen is split cleanly down the middle using Gradio’s Blocks layout.</li><li><strong>The Left Panel (Chat &amp; Continuity):</strong> Handles the main conversational thread, rendering smooth markdown responses from Llama 3.2 and maintaining complete session history so users can ask follow-up questions naturally.</li><li><strong>The Right Panel (Live Context Viewer):</strong> This side window acts as the “source of truth.” The moment a query is submitted, this panel instantly updates to display the exact raw articles, tables, and metadata extracted from ChromaDB.</li></ul><p>This setup completely removes the mystery from the RAG process. By pinning the retrieved source documents right next to the conversation, I can instantly verify if a bad response is caused by a failure in vector matching or a failure in the LLM’s synthesis logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ruU2FNVOS8uzSmWSFH0xbw.png" /></figure><p>But having a beautiful interface didn’t matter if the data inside the side window was broken. That brings us to the hidden bottleneck of any production RAG system: <strong>The Chunking Showdown.</strong></p><p>Here is a deep dive into how I engineered around these issues using an open-source local stack consisting of <strong>ChromaDB</strong>, <strong>Hugging Face Embeddings</strong>, and <strong>Llama 3.2</strong>, with a specific focus on the unsung hero of RAG: <strong>Chunking Strategy.</strong></p><p><strong>The Stack: Lightweight, Sovereign, and Local</strong></p><p>I chose this specific stack to prove that you don’t need expensive enterprise APIs or massive computing footprints to build a high-performance RAG pipeline:</p><ul><li><strong>Vector Database:</strong> <strong>ChromaDB</strong> — Lightweight, highly performant, and runs perfectly in-memory or as a local persistent client. It handles filtering metadata like a charm.</li><li><strong>Embeddings Engine:</strong> <strong>Hugging Face Sentence Transformers</strong> (e.g., all-MiniLM-L6-v2 or bge-small-en-v1.5) — Runs locally on a CPU or consumer GPU, converting raw text into dense, 384- or 768-dimensional vector spaces.</li><li><strong>LLM:</strong> <strong>Llama 3.2 (3B-Instruct)</strong> — Meta’s lightweight powerhouse. With a native 128k context window and knowledge distillation from larger models, it is incredibly efficient at processing retrieved context directly on consumer hardware.</li></ul><p><strong>The Hidden Bottleneck: The Chunking Showdown</strong></p><p>The ultimate quality of an LLM’s response is strictly bound to the quality of the context retrieved. If you give your vector database fractured data, it will return fractured search results.</p><p>During development, I stress-tested my system against two vastly different chunking philosophies. Choosing between them changes your entire application’s behavior.</p><h4>Strategy 1: Naive Fixed-Size Sliders (RecursiveCharacterTextSplitter)</h4><p>This is the standard approach most developers reach for first. You define a hard character count and an overlap size, forcing the system to slice documents at structural points like paragraphs, sentences, or spaces.</p><pre>from langchain_text_splitters import RecursiveCharacterTextSplitter<br><br>text_splitter = RecursiveCharacterTextSplitter(<br>    chunk_size=500, <br>    chunk_overlap=200<br>)<br>chunks = text_splitter.split_documents(docs)</pre><h4>Pros</h4><ul><li><strong>Extremely Easy to Implement:</strong> Works right out of the box with virtually zero knowledge of the underlying data format.</li><li><strong>Uniform Vector Sizes:</strong> Ensures every chunk maps onto a clean, uniform slice of vector space, which makes cosine similarity math highly predictable.</li><li><strong>No Stranded Context:</strong> The overlap ensures that if a critical concept spans a boundary, it appears in both chunks.</li></ul><h4>Cons</h4><ul><li><strong>Context Fragmentation:</strong> Slicing an informational guide at exactly 500 characters breaks apart interconnected tables, conditional statements, and multi-step instructions.</li><li><strong>The “Orphaned Text” Problem:</strong> If an article starts with vital metadata (e.g., target_species: feline, danger_level: high) and gets chopped into five chunks, Chunks 2 through 5 are injected into ChromaDB completely naked. If a user queries a symptom found in Chunk 4, the database will retrieve it, but Llama 3.2 will have no idea whether the treatment applies to a cat, a dog, or a human.</li></ul><p><strong>Strategy 2: Semantic Document-Level Grouping (No Splitting)</strong></p><pre># Intentionally bypassing character counters to keep context whole<br>documents = raw_text.split(&quot;\n---\n&quot;)</pre><h4>Pros</h4><ul><li><strong>Contextual Preservation:</strong> Every single chunk contains the complete operational picture. The symptoms, the diagnosis, the treatment steps, and the safety precautions remain bound together.</li><li><strong>Metadata Integration:</strong> Allows for flawless mapping of structured tags (like categories, species, or keywords) directly into ChromaDB’s native metadata engine.</li><li><strong>Maximized Retrieval Coherence:</strong> When Chroma hits a match, it pulls the complete document, giving Llama 3.2 the pristine formatting (tables, bullet points) it needs to synthesize an accurate response.</li></ul><h4>Cons</h4><ul><li><strong>Token-Heavy Payloads:</strong> Pushing larger chunks into the LLM context means you consume more input tokens per query.</li><li><strong>Vector Dilution:</strong> If a 3,000-character article covers multiple minor sub-points, the core meaning of the embedding vector can become slightly “diluted” compared to a razor-sharp 400-character chunk focused on a single sentence.</li></ul><p><strong>Structural Trade-offs at a Glance</strong></p><pre>| Metric                       | Fixed-Size Recursive Chunking                 | Semantic Whole-Document Chunking         |<br>|------------------------------|-----------------------------------------------|------------------------------------------|<br>| ChromaDB Indexing Speed      | Faster, highly uniform embeddings.            | Slightly slower due to varying lengths.  |<br><br>| Llama 3.2 Context Use        | Low token consumption; highly fragmented.     | Higher token consumption; preserves data. |<br><br>| Handling of Tables/Lists     | Terrible; breaks rows across boundaries.      | Flawless; preserves complete markdown.   |<br><br>| Best Used For                | Long books, essays, unformatted text.         | Reference manuals, specs, QA pairs.     |</pre><p><strong>ChromaDB Indexing Speed</strong>Faster, highly uniform embeddings.Slightly slower due to varying input lengths.</p><p><strong>What I Learned: Engineering for Higher Accuracy</strong></p><p>If you are building a RAG system that handles critical data (like emergency signs or complex operational steps), <strong>do not let character-based text splitters break your content.</strong></p><p>Instead, invest time in structuring your source data with explicit boundaries (---). By parsing these files out into whole, self-contained articles, loading them into ChromaDB with explicit metadata dictionaries, and querying them with native metadata filters, you drastically reduce retrieval noise.</p><p>When you pass a complete, cleanly structured Markdown table straight to <strong>Llama 3.2</strong>, its attention mechanism handles the data beautifully — producing a localized, lightning-fast response that reads like it came from an expert, not a hallucinating chatbot.</p><p><strong>What’s Next?</strong></p><p>Choosing the right chunking strategy is only half the battle. In my next article, I will dive deep into <strong>RAG Evaluation Metrics</strong>, exploring how to quantitatively measure and track your pipeline’s retrieval accuracy using frameworks like Ragas and LlamaIndex Evaluation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=577bdffbf91c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kafka in Production: What Actually Breaks (and How to Fix It)]]></title>
            <link>https://medium.com/@banasree.mani/kafka-in-production-what-actually-breaks-and-how-to-fix-it-acb28c02cf1e?source=rss-2995df7f3791------2</link>
            <guid isPermaLink="false">https://medium.com/p/acb28c02cf1e</guid>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[financial-system]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[event-driven-architecture]]></category>
            <dc:creator><![CDATA[Banasree Ghosh]]></dc:creator>
            <pubDate>Fri, 17 Apr 2026 21:06:01 GMT</pubDate>
            <atom:updated>2026-04-17T21:06:01.251Z</atom:updated>
            <content:encoded><![CDATA[<h4>What building financial microservices taught me about idempotency, partitioning, and real-world failures</h4><p>Kafka looks simple at first — publish events, consume them, scale horizontally. In practice, things start to break the moment you hit real production constraints..</p><p><strong>Apache Kafka</strong> stands out because of its thoughtful design as a <strong>distributed log system</strong>. It stores events durably, allowing you to replay them, decouple services cleanly, and absorb sudden traffic spikes without bringing your entire system down.</p><p>Let’s break it down simply.</p><h4>What Makes Kafka Special?</h4><p>In traditional systems, services communicate directly. If one service slows down or crashes, the whole chain fails with it.</p><p>Kafka changes that equation.</p><p>Services no longer talk to each other directly. Producers send messages to Kafka, and consumers read from it at their own pace. Kafka acts as a reliable buffer in the middle. More importantly, it turns communication into a durable, re-playable log — which fundamentally changes how systems are designed.</p><ul><li><strong>Producers</strong> publish data to topics.</li><li><strong>Consumers</strong> read and process data.</li><li><strong>Kafka</strong> sits in between, handling storage and distribution.</li></ul><p>This decoupling delivers several powerful benefits:</p><ul><li>Services can evolve independently without breaking each other.</li><li>Traffic spikes get absorbed in the buffer instead of overwhelming downstream systems.</li><li>Failures become isolated rather than cascading.</li><li>You can replay historical events for debugging, recovery, or auditing.</li></ul><h4>How Kafka Works Under the Hood</h4><p>When a producer sends a message, Kafka appends it to a <strong>partition</strong> — essentially an append-only log file on disk.</p><ul><li>Multiple partitions make up a <strong>topic</strong> (a category of events, such as “transactions”, “orders”, or “user-activity”).</li><li>These partitions are distributed across multiple servers called <strong>brokers</strong>.</li><li>A collection of brokers forms a <strong>Kafka cluster</strong>.</li></ul><p>Each message includes:</p><ul><li>A <strong>key</strong> (important for ordering and partitioning)</li><li>A <strong>value</strong> (the actual payload)</li><li>A <strong>timestamp</strong></li><li>Optional headers</li></ul><p>The <strong>key</strong> plays a critical role. Messages with the same key always land in the same partition, preserving strict order. Without a key, Kafka distributes messages across partitions for better load balancing.</p><h4>Partitioning: The Make-or-Break Factor for Scaling</h4><p>Poor partitioning is where many systems collapse under load.</p><p><strong>Bad example</strong> (what to avoid): In a financial system, suppose you partition transaction events solely by <strong>accountId</strong>. Everything runs smoothly until a high-volume period hits — like salary credit day or a major sale event. Millions of transactions for popular accounts flood a single partition, creating a hotspot. That partition becomes a bottleneck, slowing down or crashing processing for those accounts.</p><p><strong>Better approach</strong>: Use a <strong>compound key</strong>, such as accountId + hash(userId) or transactionType + hash(transactionId).</p><p>This distributes load evenly across partitions while keeping related events (e.g., all actions for one user or one logical transaction flow) ordered within their partition.</p><h4>Consumers, Offsets, and Consumer Groups</h4><p>Consumers track their progress using <strong>offsets</strong> — think of them as bookmarks in the log.</p><ul><li>Commit offsets too early → risk losing messages on failure.</li><li>Commit too late → risk processing the same message multiple times (duplicates).</li></ul><p>Kafka supports <strong>consumer groups</strong>, where multiple consumers share the workload. Each message goes to exactly one consumer in the group. If a consumer fails, Kafka automatically rebalances the partitions among the remaining healthy ones.</p><h4>Delivery Guarantees in Kafka</h4><p>Kafka offers three semantics:</p><ol><li><strong>At-most-once</strong> — Fastest, but messages can be lost.</li><li><strong>At-least-once</strong> — No loss, but duplicates are possible (most common in practice).</li><li><strong>Exactly-once</strong> — No loss and no duplicates, but more complex and slower to implement. In practice, “exactly-once” is often a system-level property, not something Kafka guarantees on its own.</li></ol><p>In financial systems, most teams start with <strong>at-least-once</strong> because it guarantees no data loss. Then they build application-level safeguards to eliminate duplicates.</p><h4>Handling Duplicates in Financial Transactions (Real-World Microservices Example)</h4><pre>Producers → Kafka → Consumers<br>              ↓<br>      Dedup Store (Redis)<br>              ↓<br>         Ledger Service<br>              ↓<br>         Audit / Replay</pre><p>Duplicates become especially dangerous in payments and banking:</p><ul><li>Double debits or credits</li><li>Incorrect account balances</li><li>Regulatory compliance issues</li><li>Loss of customer trust</li></ul><p>Since Kafka commonly uses at-least-once delivery (due to retries on network issues, broker failures, or consumer crashes), duplicates can occur. In my microservice project for financial transactions, we implemented a robust deduplication strategy across a payment processing pipeline involving multiple services (initiation, validation, ledger update, and notification).</p><p>Here’s how we handled it in practice:</p><ol><li><strong>Idempotency Keys (Primary Defense)</strong> Every incoming transaction request includes a unique <strong>idempotency key</strong> (often a combination of clientGeneratedTxnId + timestamp or a UUID provided by the upstream system).</li></ol><p><strong>Example</strong>: A user initiates a bank transfer of ₹5000 from Account A to Account B. The request carries idempotencyKey = “txn-uuid-98765”.</p><p>Before processing:</p><ul><li>The consumer microservice first checks a fast lookup store (Redis or a dedicated processed_transactions table).</li><li>If the key exists and status = “completed” → skip processing and return success (or cached response).</li><li>If not found → process the transaction (update balances, call external gateways if needed), then store the key with status “completed”.</li></ul><p>This ensures the same transfer is executed only once, even if the message is redelivered multiple times due to retries.</p><ol><li><strong>Deduplication Store</strong></li></ol><p>We used <strong>Redis</strong> (with TTL of 7–30 days for safety) as the primary fast cache for idempotency checks, backed by a PostgreSQL table for long-term auditing.</p><p>Stored fields:</p><ul><li>idempotency_key (unique index)</li><li>transaction_id</li><li>status (pending / completed / failed)</li><li>processed_at timestamp</li><li>result_summary (for quick responses on duplicates)</li></ul><p>On consumer startup or rebalance, we also leveraged Kafka’s state stores (in Kafka Streams) for in-memory deduplication where possible.</p><p><strong>3. Kafka’s Built-in Features (Producer &amp; Consumer Side)</strong></p><ul><li>Enabled enable.idempotence=true on producers (now default in newer Kafka versions) to prevent duplicate writes from producer retries within a partition.</li><li>For critical paths, we used <strong>Kafka Transactions</strong> (with transactional.id) to atomically produce messages to multiple topics and commit offsets together. This helps achieve closer to exactly-once semantics across services.</li><li>On the consumer side, we combined it with the <strong>Idempotent Consumer pattern</strong>: check the store first, process only if needed, then update the store and commit offset — all within a database transaction where feasible.</li></ul><p><strong>4. Event Sourcing as a Safety Net</strong></p><p>We treated the transaction topic as the source of truth. Instead of directly mutating balances, we appended immutable events (e.g., “DebitInitiated”, “CreditApplied”, “TransferCompleted”).</p><p>Current balance is computed by replaying events for an account. This provides:</p><ul><li>Full audit trail for compliance</li><li>Easy recovery after failures</li><li>Natural handling of out-of-order or duplicate events (by ignoring already-applied events via idempotency keys)</li></ul><p>In our project, this layered approach (idempotency key + dedup store + producer idempotence + selective transactions) reduced duplicate processing incidents to near zero, even during high-load periods and simulated failures.</p><h4>Replication and Durability</h4><p>Kafka protects data with replication:</p><ul><li>Each partition has one <strong>leader</strong> and multiple <strong>followers</strong>.</li><li>Followers replicate data from the leader.</li><li>If the leader fails, a follower is promoted automatically.</li></ul><p>Common setup: <strong>3 replicas</strong> per partition (survives one broker failure). You can configure acks=all so the producer waits for all replicas to acknowledge the write — safer, but slightly slower.</p><h4>Real-World Usage</h4><p>Kafka powers critical flows in:</p><ul><li>Ride-sharing apps (real-time location and ride events)</li><li>Streaming platforms (user activity and recommendations)</li><li>Financial systems (transaction processing, fraud detection, ledger updates)</li></ul><p>Many teams treat Kafka as the <strong>source of truth</strong> for events.</p><h4>Trade-offs (Being Honest)</h4><p>Kafka isn’t a silver bullet:</p><ul><li>It excels at high throughput but isn’t optimized for ultra-low latency request-response.</li><li>Strict ordering is guaranteed only within a single partition.</li><li>Exactly-once semantics add complexity and some performance overhead.</li><li>Running and monitoring a Kafka cluster requires operational maturity.</li></ul><h4>Final Thought</h4><p>Kafka shines because it <strong>decouples</strong> services, creating flexible and resilient architectures. Traffic spikes get buffered, failures stay isolated, and events remain re-playable.</p><p>For systems like payments, analytics, or real-time pipelines, the investment pays off. In financial microservices especially, remember this key principle:</p><p><strong>Kafka often gives you at-least-once delivery. It’s your responsibility to turn it into exactly-once using strong idempotency and deduplication patterns.</strong></p><p>If you’re building event-driven financial systems, start with idempotency keys early — it saves a lot of headaches later.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=acb28c02cf1e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Most Tokenization Platforms Fail (And It’s Not What You Think)]]></title>
            <link>https://medium.com/@banasree.mani/why-most-tokenization-platforms-fail-and-its-not-what-you-think-a416191d23c9?source=rss-2995df7f3791------2</link>
            <guid isPermaLink="false">https://medium.com/p/a416191d23c9</guid>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[fintech]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Banasree Ghosh]]></dc:creator>
            <pubDate>Fri, 03 Apr 2026 21:26:01 GMT</pubDate>
            <atom:updated>2026-04-03T21:26:01.247Z</atom:updated>
            <content:encoded><![CDATA[<h4>Notes from building a real system</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2q7pz6BWgf03tA7qSe4s3w.png" /></figure><p>Tokenization didn’t fail.</p><p>It just never really started.</p><p>That might sound harsh. But if you look past the announcements, the funding rounds, and the polished dashboards, you’ll notice something uncomfortable:</p><p>Most tokenization platforms are not used.</p><p>They exist.<br> They launch.<br> They demo well.</p><p>And then they quietly fade into inactivity.</p><p>No users. No liquidity. No real flow of value.</p><h3>The uncomfortable truth</h3><p>The industry likes to blame:</p><ul><li>Regulation</li><li>Market cycles</li><li>User education</li><li>Timing</li></ul><p>But after building a real system in this space, the pattern looks much simpler: <em>Most tokenization platforms fail because they were never designed to be used.</em></p><p>They were designed to be shown.</p><h3>The real problem: building for the wrong moment</h3><p>Many platforms optimize for the launch.</p><ul><li>Clean UI</li><li>Token minting</li><li>Marketplace screens</li><li>A few demo transactions</li></ul><p>Everything works — as long as nothing unexpected happens.</p><p>But real systems don’t live in demos.</p><p>They live in:</p><ul><li>Partial failures</li><li>Edge cases</li><li>Users doing things you didn’t expect</li><li>Load you didn’t simulate</li></ul><p>And that’s where most platforms start to break.</p><h3>Tokens are easy. Systems are hard.</h3><p>Creating a token is trivial now. You can mint an asset in minutes. That’s not the challenge.</p><p>The challenge is everything around it:</p><ul><li>Who owns it legally?</li><li>How does it move?</li><li>What happens if a transaction fails halfway?</li><li>Can someone exit easily?</li></ul><p>Most platforms answer the first question: <em>“Can we create the asset?”</em></p><p>Very few answer the second: <em>“Can this system survive real usage?”</em></p><h3>Liquidity is not a feature</h3><p>This is where many projects collapse. They assume liquidity will appear after launch. It doesn’t. Liquidity is not something you add later.<br> It is something you design from the beginning.</p><p>If users cannot:</p><ul><li>Buy easily</li><li>Trade quickly</li><li>Exit reliably</li></ul><p>then they won’t enter at all. And once that happens, the system becomes static. Assets sit still. Users stop returning.</p><p>The platform slowly becomes a catalogue instead of a market.</p><h3>The onboarding myth</h3><p>There’s a quiet assumption in many teams: <em>“Users will learn.”</em></p><p>In practice, they don’t.</p><p>If the first experience requires:</p><ul><li>Wallet setup</li><li>Crypto purchase</li><li>Network understanding</li><li>Multiple confirmations</li></ul><p>most users will drop off immediately. Not because they can’t learn. But because they don’t need to.</p><p>There are easier alternatives.</p><h3>Infrastructure decisions are not neutral</h3><p>Early choices feel reversible.</p><p>They’re not.</p><p>The chain you choose, the way you structure transactions, how you handle state — all of it shapes the system long before scale arrives.</p><p>And when scale does arrive, those decisions surface as:</p><ul><li>High costs</li><li>Slow interactions</li><li>Unpredictable behaviour</li></ul><p>By then, you’re no longer building.</p><p>You’re firefighting.</p><h3>The biggest mistake: confusing blockchain with product</h3><p>This is probably the most common issue.</p><p>Teams focus on:</p><ul><li>The chain</li><li>The token</li><li>The mechanics</li></ul><p>But users don’t care about any of that.</p><p>They care about:</p><ul><li>Speed</li><li>Reliability</li><li>Simplicity</li></ul><p>The blockchain is part of the system.</p><p>It is not the product.</p><h3>What we did differently</h3><p>We didn’t start with the token.</p><p>We started with the experience.</p><p>That changed everything.</p><h3>We assumed failure from day one</h3><p>Instead of asking “what happens when everything works?”, we asked:</p><ul><li>What happens when a transaction partially succeeds?</li><li>What happens when the system crashes mid-process?</li></ul><p>This led to designs that could recover — not just execute.</p><h3>We reduced friction, not explained it</h3><p>We didn’t try to educate users into complexity.</p><p>We removed it.</p><p>Users can enter, interact, and move assets without needing to understand how the system works underneath.</p><p>That wasn’t an afterthought.</p><p>It was the goal.</p><h3>We treated liquidity as a core system property</h3><p>Buy, swap, transfer — these are not features.</p><p>They are the system.</p><p>If assets don’t move, the platform doesn’t work.</p><p>So we designed for movement, not just creation.</p><h3>We treated the backend as the real product</h3><p>The UI creates expectation.</p><p>The backend delivers reality.</p><p>We focused on:</p><ul><li>Real-time processing</li><li>Event-driven architecture</li><li>Systems that hold up under load</li></ul><p>Because reliability is invisible — until it’s gone.</p><h3>We used the ledger where it matters</h3><p>Not everything belongs on-chain.</p><p>Trying to put everything there creates friction, not trust.</p><p>Instead, we separated concerns:</p><ul><li>Ownership → on-chain</li><li>High-volume logic → off-chain</li></ul><p>This made the system faster, cheaper, and more usable.</p><h3>The result</h3><p>What we built is not perfect. But it works.</p><p>Users can:</p><ul><li>Enter easily</li><li>Interact quickly</li><li>Move assets without friction</li></ul><p>And most importantly <em>they come back.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*Ix3yJGPxz7G3LIgYYvoRFw.jpeg" /><figcaption>Image from debutinfotech website</figcaption></figure><h3>A better way to evaluate tokenization platforms</h3><p>If you want to understand whether a platform will survive, don’t look at the demo.</p><p>Ask simpler questions:</p><ul><li>Can a new user complete a transaction in under a minute?</li><li>Are costs predictable?</li><li>Can users exit as easily as they enter?</li><li>Does the system behave well under stress?</li></ul><p>If the answer is unclear, the outcome usually is too.</p><h3>Final thought</h3><p>Tokenization doesn’t need more ideas.</p><p>It needs fewer illusions.</p><p>The next generation of platforms won’t win because they sound better. They’ll win because they quietly work — day after day — without asking the user to think about how.</p><p>And that’s a much harder problem than launching a token.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a416191d23c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Hidden Complexity Behind a “Simple” Token Swap]]></title>
            <link>https://medium.com/coinmonks/the-hidden-complexity-behind-a-simple-token-swap-f3e5850f75ce?source=rss-2995df7f3791------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3e5850f75ce</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[fintech]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Banasree Ghosh]]></dc:creator>
            <pubDate>Tue, 31 Mar 2026 13:11:01 GMT</pubDate>
            <atom:updated>2026-04-06T05:35:03.839Z</atom:updated>
            <content:encoded><![CDATA[<h4>Notes from building a real-world token swap system on Hedera</h4><p>From the outside, a token swap looks almost too simple to think about.</p><p>You enter an amount, press a button, and a different balance appears on the screen. It feels clean, immediate, almost effortless. That is exactly how it should feel for the user.</p><p>But while working on a tokenized platform built on Hedera for renewable energy assets, I was reminded of something that good systems often hide very well: <em>simplicity on the surface is usually paid for by complexity underneath.</em></p><p>A swap is never just a swap.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*Usnm3-VmjaoQfWVzAjVQ0A.png" /><figcaption>Swap Flow</figcaption></figure><h3>The illusion we design for</h3><p>When a user swaps 50 EPC tokens into a yield token, the expectation is straightforward:</p><ul><li>“I had this”</li><li>“Now I have that”</li></ul><p>No one thinks about what happens in between.</p><p>And honestly, they shouldn’t have to.</p><p>But for the system, that “in between” is where everything lives.</p><p>Behind that single action, we have to:</p><ul><li>Verify that the user actually owns those tokens</li><li>Identify <em>which</em> tokens (because these are NFTs, not just numbers)</li><li>Lock them so they can’t be used twice</li><li>Calculate the value being exchanged</li><li>Execute transfers on the ledger</li><li>Update internal state</li><li>Handle the possibility that something fails halfway</li></ul><p>What looks like one step is actually a sequence that has to behave like one step.</p><p>That distinction matters.</p><h3>When tokens are not just numbers</h3><p>One of the first things that changes your thinking is this:</p><p>EPC tokens are NFTs.</p><p>That means:</p><ul><li>Each one has a serial number</li><li>Each one is tracked individually</li><li>Each one must be handled explicitly</li></ul><p>So when a user says “swap 50 tokens”, the system is not dealing with a balance.</p><p>It is dealing with 50 distinct items.</p><p>It has to:</p><ul><li>Select 50 serials</li><li>Track them</li><li>Move them</li><li>And later prove what happened to each one</li></ul><p>This alone turns a simple financial operation into something closer to inventory management.</p><h3>The moment reality steps in</h3><p>In the early version, we tried to keep things elegant.</p><p>One swap → one transaction.</p><p>That idea works beautifully in theory.</p><p>Until the system tells you otherwise.</p><p>At around a dozen NFT transfers, we started hitting a limit:</p><pre>BATCH_SIZE_LIMIT_EXCEEDED</pre><p>No warning. Just a boundary.</p><p>And at that point, you realise something important:</p><p>The system is not what you imagined.<br> It is what the constraints allow.</p><h3>One action, multiple steps</h3><p>We had to rethink the swap.</p><p>Instead of one transaction, it became many.</p><p>A swap of 50 EPC tokens turned into:</p><ul><li>5 transactions × 10 NFTs each</li></ul><p>But the user still expects one outcome.</p><p>So now the system has to do something subtle: <em>Take multiple independent operations and make them behave like a single, reliable action.</em></p><p>This is where things stop being purely “blockchain” and start becoming a distributed systems problem.</p><h3>The uncomfortable questions</h3><p>Once you break a swap into parts, questions start appearing:</p><ul><li>What if the third transaction fails?</li><li>What if the system crashes halfway through?</li><li>What if tokens are locked but never transferred?</li></ul><p>At that point, you’re no longer asking “did the swap work?”</p><p>You’re asking: <em>what is the correct state of the system now?</em></p><p>And there isn’t always an obvious answer.</p><h3>The architecture we ended up with</h3><p>To handle this, we had to be very deliberate.</p><p>Not just about success — but about failure.</p><h3>1. Lock before doing anything</h3><p>Before a swap begins:</p><ul><li>The system selects EPC serials</li><li>Marks them as <strong>LOCKED</strong></li></ul><p>This prevents double-use and gives us control over the process.</p><h3>2. Process in safe chunks</h3><p>Instead of pushing everything at once:</p><ul><li>We process NFTs in batches</li><li>Each batch becomes its own transaction</li></ul><p>This respects the limits of the ledger while keeping the system stable.</p><h3>3. Accept that failure will happen</h3><p>If something goes wrong:</p><ul><li>We unlock the serials</li><li>Restore their previous state</li><li>Return a clear failure response</li></ul><p>The goal is not to avoid failure.</p><p>The goal is to recover cleanly.</p><h3>4. Only commit at the very end</h3><p>Only when all parts succeed:</p><ul><li>EPC tokens are marked as <strong>REDEEMED</strong></li><li>Yield tokens are credited</li><li>The swap is marked <strong>COMPLETED</strong></li></ul><p>Until then, nothing is final.</p><h3>What actually happens when you click “Swap”</h3><pre>User → API → Validation → Inventory Lock → Chunked Ledger Transfers → Reconciliation → Final State</pre><p>That entire chain exists behind one button.</p><p>The system absorbs the complexity so the user doesn’t have to.</p><h3>What this really is</h3><p>It’s tempting to think of this as a financial operation.</p><p>It’s not.</p><p>It’s coordination.</p><p>Between:</p><ul><li>A blockchain that enforces rules</li><li>An application that orchestrates behaviour</li><li>A database that tracks intent and outcome</li></ul><p>Each one has a different idea of truth.</p><p>And your job is to make them agree — or at least behave as if they do.</p><h3>What we learned</h3><p>A few things became very clear while building this:</p><ul><li><strong>Constraints are not problems — they define the design</strong></li><li><strong>Handling identity (NFTs) is fundamentally harder than handling balances</strong></li><li><strong>Atomicity is often something you simulate, not something you get for free</strong></li><li><strong>Good systems hide complexity, but they don’t remove it</strong></li></ul><h3>Final thought</h3><p>When a user clicks “Swap”, they see: <em>Done.</em></p><p>What they don’t see is everything that had to go right for that word to be true.</p><p>And that’s the work.</p><p>Not making systems simple — <br> but making them <em>feel</em> simple, while quietly holding everything together underneath.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3e5850f75ce" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/the-hidden-complexity-behind-a-simple-token-swap-f3e5850f75ce">The Hidden Complexity Behind a “Simple” Token Swap</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Metric Is Just a Number Trying to Look Like Truth]]></title>
            <link>https://medium.com/@banasree.mani/a-metric-is-just-a-number-trying-to-look-like-truth-f09784fb506e?source=rss-2995df7f3791------2</link>
            <guid isPermaLink="false">https://medium.com/p/f09784fb506e</guid>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[grafana-prometheus]]></category>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[system-architecture]]></category>
            <category><![CDATA[metrics]]></category>
            <dc:creator><![CDATA[Banasree Ghosh]]></dc:creator>
            <pubDate>Sun, 29 Mar 2026 12:06:00 GMT</pubDate>
            <atom:updated>2026-03-29T12:06:00.534Z</atom:updated>
            <content:encoded><![CDATA[<h4>The hidden complexity of business metrics in distributed systems</h4><p>And for a while, I believed it.</p><p>I added custom metrics to a microservice — total balance, total customers, daily transactions. The dashboard looked clean. The numbers looked precise. Everything felt… under control.</p><p>Until the numbers started disagreeing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*lSvL1kyei3zGjuhndGbTJQ.gif" /><figcaption>Custom metrics</figcaption></figure><h3>The Illusion: Measuring Means Understanding</h3><p>The system wasn’t small.</p><p>It had:</p><ul><li>Spring Boot services</li><li>Kafka streaming events</li><li>MongoDB storing state</li><li>Micrometer exposing metrics</li><li>Prometheus scraping everything</li></ul><p>It felt modern. Observable. Professional.</p><p>The request itself was simple <em>“Can we show total balance and daily transactions?” </em>It felt like a trivial addition.</p><p>Add a few counters.<br>Expose a few gauges.<br>Draw a graph.</p><p>Done. Except it isn’t. Because the moment you define a metric like:</p><ul><li>total_balance</li><li>daily_transactions</li></ul><p>you are no longer just measuring the system. You are defining a <strong>contract of interpretation</strong>.</p><h3>Distributed Systems Don’t Have a Single “Now”</h3><p>The first issue appeared almost immediately.</p><p>We tried to answer a simple question: <em>What is the current total balance?</em></p><p>And it turned out that the answer depended on where you looked.</p><ul><li>MongoDB reflected persisted state</li><li>Kafka reflected in-flight events</li><li>Metrics reflected aggregated state at scrape time</li></ul><p>Each of these was correct — within its own context.</p><p>But they were not consistent with each other. Because in a distributed system: <em>There is no single “now” There are only multiple timelines</em></p><ul><li><strong>Event time</strong> (when the transaction actually happened)</li><li><strong>Processing time</strong> (when the system handled it)</li><li><strong>Observation time</strong> (when Prometheus scraped it)</li></ul><p>Most metrics collapse these into one number. That’s where the illusion begins.</p><h3>When Metrics Drift from Reality</h3><p>At one point we observed:</p><ul><li>MongoDB showed one balance</li><li>The metric showed another</li><li>Logs suggested a third</li></ul><p>Nothing was broken. But the system had multiple valid states at different stages of convergence. The metric was simply picking one — and presenting it as <em>the truth</em>.</p><h3>What You Measure Becomes System Truth</h3><p>Once a number appears on a dashboard:</p><ul><li>it is trusted</li><li>it is discussed</li><li>it is used for decisions</li></ul><p>Even if the definition behind it is incomplete. A metric is rarely “wrong”. But it is very often <strong>underspecified</strong>. And in distributed systems, underspecified metrics are dangerous.</p><h3>Real-Time Is a Trade-Off, Not a Guarantee</h3><p>We often say “real-time metrics”.</p><p>But in practice:</p><ul><li>Kafka delivers events asynchronously</li><li>MongoDB updates are eventually consistent</li><li>Prometheus scrapes at intervals</li></ul><p>So what we actually have is: <em>Near-real-time, eventually consistent, sampled observations</em></p><p>Which means:</p><ul><li>events can arrive late</li><li>retries can duplicate signals</li><li>aggregation can lag</li></ul><p>“Real-time” is an approximation.</p><h3>The Real Engineering Problems Behind Metrics</h3><h3>1. Consistency vs Latency</h3><p>You must choose:</p><ul><li>low-latency metrics (fast, but slightly stale or inconsistent)</li><li>strongly consistent metrics (accurate, but delayed)</li></ul><p>There is no free option here.</p><h3>2. Idempotency and Duplicate Events</h3><p>Kafka retries are expected. But unless your aggregation is idempotent:</p><ul><li>one transaction → multiple counts</li><li>metrics drift over time</li></ul><p>Metrics systems typically track <strong>occurrence</strong>, not <strong>intent</strong>.</p><h3>3. Event Time vs Processing Time</h3><p>“Daily transactions” is not a trivial definition.</p><p>You need to decide:</p><ul><li>group by event timestamp?</li><li>or processing timestamp?</li></ul><p>Late-arriving events will break one of these models.</p><h3>4. Cardinality Explosion</h3><p>Metrics that start simple:</p><ul><li>per user</li><li>per account</li><li>per transaction type</li></ul><p>Quickly lead to:</p><ul><li>high cardinality label sets</li><li>memory pressure in Prometheus</li><li>degraded query performance</li></ul><h3>What I Realized: Metrics Are an Interpretation Layer</h3><p>I initially thought I was exposing system state. In reality, I was building a <strong>projection</strong> of the system. A layer that tries to answer human questions:</p><ul><li>“What is the balance?”</li><li>“How many transactions today?”</li></ul><p>Using:</p><ul><li>asynchronous events</li><li>distributed state</li><li>eventual consistency</li></ul><p>And compressing all of that into a single number.</p><h3>So What Actually Works? (Practical Approach)</h3><p>After going through this, I stopped treating metrics as “facts” and started treating them as <strong>defined views</strong>.</p><p>Here are the patterns that worked.</p><h3>1. Make Metric Definitions Explicit</h3><p>Every metric must answer:</p><ul><li>What data sources does it use?</li><li>Does it include pending or only settled state?</li><li>What time reference does it use?</li></ul><p>Example:</p><pre>total_balance = sum(settled balances in MongoDB, excluding pending Kafka events, updated every scrape interval)</pre><p>If you cannot define it clearly, do not expose it.</p><h3>2. Separate Operational Metrics from Business Metrics</h3><p>Do not mix:</p><ul><li>system-level metrics (latency, throughput)</li><li>business-level metrics (balances, transactions)</li></ul><p>Business metrics require:</p><ul><li>stronger semantics</li><li>clearer definitions</li><li>controlled aggregation pipelines</li></ul><h3>3. Use Stream Processing for Deterministic Aggregation</h3><p>Instead of aggregating ad hoc inside services:</p><ul><li>use a streaming layer (e.g., Kafka Streams)</li><li>define aggregation explicitly</li><li>maintain state stores</li></ul><p>This allows:</p><ul><li>controlled windowing</li><li>reproducible results</li><li>replayability</li></ul><h3>4. Design for Idempotency</h3><p>Every aggregation should be:</p><ul><li>replay-safe</li><li>duplicate-tolerant</li></ul><p>Techniques:</p><ul><li>transaction IDs</li><li>deduplication stores</li><li>exactly-once processing (where feasible)</li></ul><h3>5. Treat Time as a First-Class Concern</h3><p>Decide explicitly:</p><ul><li>event-time vs processing-time</li><li>windowing strategy</li><li>handling of late events</li></ul><p>Do not leave this implicit.</p><h3>6. Avoid “Total” Without Context</h3><p>“Total” is one of the most misleading words in distributed systems.</p><p>Always qualify it:</p><ul><li>total (settled)</li><li>total (including pending)</li><li>total (as of last aggregation window)</li></ul><h3>7. Build Observability Around Discrepancy</h3><p>Instead of hiding inconsistencies:</p><ul><li>expose lag between systems</li><li>show reconciliation gaps</li><li>track divergence metrics</li></ul><p>This makes the system more trustworthy, not less.</p><h3>Implementation Example: Deterministic Metrics with Kafka Streams</h3><p>One of the biggest shifts we made was moving business metric aggregation out of application services and into a <strong>stream processing layer</strong>.</p><p>Instead of incrementing counters inside services, we treated metrics as <strong>stateful stream transformations</strong>.</p><pre>{<br>  &quot;transactionId&quot;: &quot;tx01234&quot;,<br>  &quot;accountId&quot;: &quot;1001&quot;,<br>  &quot;type&quot;: &quot;DEBIT&quot;,<br>  &quot;amount&quot;: 1000,<br>  &quot;timestamp&quot;: 1720000000000<br>}</pre><h3>Step 1: Ensure Idempotency</h3><p>Before aggregation, we deduplicate events using a transaction ID.</p><pre>KStream&lt;String, Transaction&gt; transactions = builder.stream(&quot;transactions&quot;);<br><br>KStream&lt;String, Transaction&gt; uniqueTransactions =<br>    transactions.transform(() -&gt; new DeduplicationTransformer(&quot;txn-store&quot;));</pre><p>This prevents retries from corrupting metrics.</p><h3>Step 2: Define Event-Time Semantics</h3><p>We explicitly use <strong>event time</strong>, not processing time:</p><pre>Consumed.with(Serdes.String(), transactionSerde)<br>        .withTimestampExtractor((record, partitionTime) -&gt; record.value().getTimestamp());</pre><h3>Step 3: Windowed Aggregation</h3><p>Instead of “global totals”, we define <strong>time-bounded truth</strong>:</p><pre>KTable&lt;Windowed&lt;String&gt;, Double&gt; balanceByAccount =<br>    uniqueTransactions<br>        .groupBy((key, txn) -&gt; txn.getAccountId())<br>        .windowedBy(TimeWindows.ofSizeWithNoGrace(Duration.ofMinutes(30)))<br>        .aggregate(<br>            () -&gt; 0.0,<br>            (accountId, txn, currentBalance) -&gt; {<br>                if (txn.getType().equals(&quot;DEBIT&quot;)) {<br>                    return currentBalance - txn.getAmount();<br>                } else {<br>                    return currentBalance + txn.getAmount();<br>                }<br>            },<br>            Materialized.as(&quot;balance-store&quot;)<br>        );</pre><p>Now, the metric is no longer ambiguous. It is “Balance per account within a 30-minute event-time window”</p><h3>Step 4: Emit Metric Events (Not Just Prometheus Gauges)</h3><p>Instead of exposing only scraped metrics, we <strong>publish results as events</strong>:</p><pre>balanceByAccount.toStream()<br>    .map((windowedKey, balance) -&gt; KeyValue.pair(<br>        windowedKey.key(),<br>        new BalanceSnapshot(windowedKey.window().start(), balance)<br>    ))<br>    .to(&quot;balance-metrics&quot;);</pre><p>This enables:</p><ul><li>replayability</li><li>auditability</li><li>reconciliation</li></ul><h3>Step 5: Prometheus as a Consumer, Not Source of Truth</h3><p>Prometheus should scrape <strong>derived state</strong>, not raw truth.</p><ul><li>Kafka Streams = source of truth</li><li>Prometheus = observation layer</li></ul><p>This separation prevents metric drift.</p><h3>Key Outcome</h3><p>We moved from: “metrics as side-effects” to “metrics as deterministic data products”. That shift alone removed most inconsistencies.</p><h3>Final Thought</h3><p>Systems are precise. Metrics are interpretations. And the more complex the system becomes, the more that interpretation matters.</p><p>I started with: <em>“Let’s add a few metrics.”</em></p><p>I ended with: <em>“What exactly are we claiming this number represents?”</em></p><p>Because in distributed systems a <em>metric is not the truth. It is a carefully constructed version of it. </em>And unless that construction is explicit, the number on the dashboard is just:</p><p>A number… trying to look like truth.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f09784fb506e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Banking Needs Post-Quantum Cryptography (PQC)]]></title>
            <link>https://medium.com/@banasree.mani/why-banking-needs-post-quantum-cryptography-pqc-002aed2ffbd1?source=rss-2995df7f3791------2</link>
            <guid isPermaLink="false">https://medium.com/p/002aed2ffbd1</guid>
            <category><![CDATA[payments]]></category>
            <category><![CDATA[fintech]]></category>
            <category><![CDATA[post-quantum-cryptography]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <dc:creator><![CDATA[Banasree Ghosh]]></dc:creator>
            <pubDate>Wed, 25 Mar 2026 16:59:23 GMT</pubDate>
            <atom:updated>2026-03-27T21:04:21.446Z</atom:updated>
            <content:encoded><![CDATA[<h4>While working on <a href="https://www.bis.org/publ/othp80.pdf">Tourbillon</a>, <a href="https://www.bis.org/publ/bisih_fusse.pdf">FuSSE</a>, and post-quantum identity and KYC architecture, I started thinking about something that seems obvious now: in banking, security is never just about now.</h4><p>Banks have always trusted mathematics the way kingdoms once trusted walls. Not physical walls, obviously, but mathematical ones — built on things like prime factorization and elliptic curves. And like all walls, they look strongest… just before they become irrelevant. For a long time, that worked extremely well.</p><p>That’s what makes digital banking possible in the first place. Payments move, identities are verified, contracts are protected, and sensitive data can be exchanged across networks because the underlying cryptography is assumed to hold.</p><p>The problem is not that today’s cryptography is poorly designed. It isn’t. RSA and ECC are some of the most important engineering achievements in modern computing.</p><p>The problem is that they were built on an assumption that no machine would exist in practice that could break them at scale. And that assumption is starting to matter much more than people realize. Post-quantum computing does not argue. It simply waits.</p><p><strong>The issue is not only ‘when quantum arrives’</strong></p><p>A lot of discussion around post-quantum cryptography gets framed in a very dramatic way that quantum computers are coming, so we need new algorithms.</p><p>That is true, but I think it misses the real issue. The real issue is time.</p><p>If a bank encrypts sensitive data today, that data may still matter years from now. In banking, information often has a very long life. Transaction histories, identity records, KYC data, contracts, internal communications, payment instructions — these are not disposable. Some of them remain sensitive for a decade or more.</p><p>That means the question is not just whether something is secure today.</p><p>The real question is whether it will still be secure at the point in the future when an attacker is finally able to break it.</p><p>That is where the risk becomes uncomfortable.</p><p><strong>Secure now does not mean secure later</strong></p><p>Imagine a bank encrypts sensitive transaction or customer data in 2026. An attacker may not be able to do anything useful with it at that moment. So instead of trying to decrypt it immediately, they simply collect it and store it. Then, in 2032, a quantum computer arrives — running algorithms like Shor’s algorithm. And suddenly, yesterday’s secrets become today’s headlines.</p><p>No breach is visible. No alarm goes off. The system appears secure.</p><p>But if stronger quantum capabilities become available later, that same data could suddenly become readable.</p><p>So in effect, the attacker does not need to break the bank today. They only need to preserve access to encrypted information until the technology catches up. That is the logic behind what people call <strong>harvest now, decrypt later</strong>.</p><p>And for banking, that is a serious problem, because so much high-value data remains sensitive long after it is first created.</p><p><strong>Why this matters so much in banking</strong></p><p>In many industries, some data loses value quickly. But in banking, that is often not the case.</p><p>Account relationships matter for years. Identity records matter for years. Payment histories, contracts, treasury instructions, compliance evidence, onboarding documents — all of this can remain important well beyond the present moment.</p><p>So even if quantum attacks are not operationally practical at scale today, banks still have to think ahead. If the shelf life of the data is longer than the shelf life of the cryptography protecting it, there is already a problem.</p><p>That is why this is not just a future technology discussion. It is a present-day architecture and risk discussion.</p><p><strong>What PQC actually means</strong></p><p>Post-quantum cryptography is sometimes misunderstood as “better cryptography.” I do not think that is the right way to describe it.</p><p>It is not really about elegance, and in many cases it is not about efficiency either. Some PQC schemes have larger keys, larger signatures, and more implementation overhead than the classical cryptography engineers are used to. But that is not the point. The point is that the threat model has changed.</p><p>PQC is about using cryptographic algorithms that are designed to remain secure even if attackers eventually have access to quantum capabilities that would undermine RSA or ECC.</p><p>So this is not about replacing something beautiful with something even more beautiful. It is more practical than that. It is about adapting before the assumptions underneath the old system stop being true.</p><p><strong>The shift is bigger than algorithms</strong></p><p>What I think is changing here is not just the cryptography stack. It is how we think about security in financial systems.</p><p>For a long time, it was enough to ask, is this secure? Now we have to ask something more difficult, how long is this secure for? Every encrypted message, every identity proof, every transaction carries a hidden question:</p><p>“Will this still be secure in 10 years?”</p><p>That is a very different way of thinking.</p><p>If you are designing systems in banking, you are no longer just choosing protocols and algorithms in the abstract. You are making a judgement about how long data, identities, transactions, and instructions can remain trustworthy under changing computational realities.</p><p>That makes security a time-bound design problem, not just a static technical decision.</p><p><strong>Final Thought</strong></p><p>Banks do not need PQC because current systems are suddenly useless. That would be the wrong conclusion. They need PQC because financial infrastructure has long memory, and cryptography has entered a period where its future lifetime can no longer be taken for granted. That is the part that matters.</p><p>The real risk is not weak security. The real risk is security that looks strong now, but is quietly ageing against a future it was never designed for.</p><p>And in banking, that kind of risk has a habit of showing up late — and mattering all at once. We encrypted everything perfectly… for a world that is already disappearing.</p><p>“The only thing worse than weak security is beautifully outdated security.”</p><p>PQC is not urgent because systems are broken.<br>It is urgent because <strong>time is undefeated</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=002aed2ffbd1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>