<?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 Shubham Bhama on Medium]]></title>
        <description><![CDATA[Stories by Shubham Bhama on Medium]]></description>
        <link>https://medium.com/@shubhambhama?source=rss-999277334716------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Fpy0xtJoaYhOuhgpN_4IGQ.jpeg</url>
            <title>Stories by Shubham Bhama on Medium</title>
            <link>https://medium.com/@shubhambhama?source=rss-999277334716------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 17:24:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shubhambhama/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 Scalable E-Commerce Price Tracking System]]></title>
            <link>https://medium.com/@shubhambhama/building-a-scalable-e-commerce-price-tracking-system-63a78f621541?source=rss-999277334716------2</link>
            <guid isPermaLink="false">https://medium.com/p/63a78f621541</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[price-tracking]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[ecommerce]]></category>
            <dc:creator><![CDATA[Shubham Bhama]]></dc:creator>
            <pubDate>Wed, 11 Feb 2026 14:35:01 GMT</pubDate>
            <atom:updated>2026-02-11T14:35:01.795Z</atom:updated>
            <content:encoded><![CDATA[<p><em>What does it really take to monitor prices across Amazon, Flipkart, and other major retailers—every single day, for hundreds of thousands of products?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*MVWOoJXB6P0uGwTQ13X0NA.png" /></figure><p>I remember the first time I missed a flash sale on Amazon. It was a laptop I had been wanting for a long time. The price dropped by 30% during a lightning deal, but by the time I found out, it was too late. That annoying moment made me think: what if there was a way to automatically keep track of prices and let you know when deals are about to end?</p><p>That’s how this project got going. PriceHistory started out as a simple weekend hack, but it grew into a full-fledged price-tracking platform. Artificial Intelligence. In this article, I&#39;ll explain how we designed the system, why we chose certain technologies, and what we learned along the way.</p><p>If you want to make distributed systems, scrape the web on a large scale, or set up real-time alerting platforms, this is the one for you.</p><h3>System Architecture</h3><p>Before diving into the details, let me show you the big picture. Here’s how all the pieces fit together:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*PYHaspEO6ViH1k4VQM-4xg.png" /><figcaption>Pricehistory.ai System Design</figcaption></figure><p>The system follows a <strong>microservices architecture</strong> where each service has a single responsibility. This design allows us to scale individual components independently based on load. Let me break down each layer and explain why we built it this way.</p><h3>The Frontend — Next.js</h3><p>Next.js is a React-based framework that lets you render on the server side. It is used to build the frontend. When someone comes to our <a href="https://pricehistory.ai/">site</a>, they can paste in any product link from Amazon, Flipkart, Myntra, Nykaa, or Reliance Digital. The frontend then uses REST APIs to talk to our backend.</p><p>Why use Next.js?</p><ol><li>Server-side rendering (SSR) makes SEO better. When Google looks at our product pages, it sees fully rendered HTML instead of empty React placeholders.</li><li>API routes let us add simple backend logic to the frontend repo when we need to.</li><li>Image optimization works well with product images, which speeds up website loading times.</li></ol><h3>The API Gateway—FastAPI</h3><p>All requests from the frontend go through the API Gateway first. In a way, it’s the front door to our whole backend. This is where all requests go.</p><p>The API Gateway takes care of:</p><ol><li>Request routing: sends requests to the correct microservice</li><li>Authentication checks the validity of user sessions and JWT tokens.</li><li>Rate limitation stops abuse and keeps services downstream safe.</li><li>Error handling—gives consistent responses to errors</li></ol><p>Why use FastAPI?</p><ol><li>Speed: FastAPI is one of the quickest Python frameworks out there, along with Node.js and Go.</li><li>Automatic documentation: It makes interactive API docs on its own.</li><li>Type hints—Python’s type annotations function perfectly, which cuts down on issues.</li><li>Support for async: The gateway can handle thousands of connections at the same time because it doesn’t block I/O.</li></ol><h3>Core Microservices</h3><p>Every important feature is in its service. This division makes it easier to keep the system running and grow.</p><h4>User Service</h4><p>Takes care of anything that has to do with users:</p><ol><li>Signing up and logging in</li><li>Managing profiles</li><li>Choices for notifications</li><li>Making a JWT token</li></ol><p>The data of users is safely saved via password hashing that is typical in the industry.</p><h4>Product Catalog Service</h4><p>This is the<strong> heart of the system.</strong> The Product Catalog manages:</p><ol><li>Product information (name, images, descriptions)</li><li>Current prices</li><li>Price history data</li><li>Product metadata</li></ol><p>The service implements a <strong>cache-first architecture</strong> using Redis. When a user requests a product, we first check the cache. If the data is fresh, we return it immediately. This drastically reduces database load and improves response times.</p><h4>Scheduler Service</h4><p>The scheduler is the <strong>brains</strong> behind automated price monitoring. It runs continuously in the background, deciding:</p><ol><li>Which products need to be scraped</li><li>When to scrape them</li><li>With what priority</li></ol><p>Products are prioritised based on users&#39; interests. A product with many alert subscribers gets checked more frequently than one with fewer subscribers. The scheduler uses a weighted algorithm to balance scraping resources.</p><h4>Alerting Service—The Smart Deal Scorer</h4><p>The alerting service starts working when the price goes down. But here’s the catch: not every decline in price is worth an alarm. At first, users said they were getting too many reminders for little changes.</p><p>That’s why we established the<strong> Deal Quality Score (DQS) </strong>methodology. DQS doesn’t just use simple percentage thresholds to figure out how “good” a bargain is; it uses statistics to do so:</p><ol><li><strong>Historical Position</strong>: How close is the current price to the lowest price ever?</li><li><strong>Statistical Significance</strong>: Is this decline in price a meaningful signal or just noise?</li><li><strong>Momentum</strong>: Is the price going down quickly (flash sale)?</li></ol><p>The outcome is a smart score that puts deals into groups:</p><ol><li><strong>LOOT DEAL</strong>—Great, but there may be a mistake in the price.</li><li><strong>HOT DEAL</strong>—A crucial, unusual price.</li><li><strong>GOOD DEAL</strong>—Something to think about</li><li><strong>Normal change</strong>—no need for an alert</li></ol><p>This cut down on “alert fatigue” a lot. Users now pay attention to notifications because they believe that every alert is a real chance.</p><h4>Notification Service</h4><p>When notifications go off, they need to get to users right away. We picked Telegram as our main way to send notifications because:</p><ol><li><strong>Instant delivery</strong>—messages arrive within seconds</li><li><strong>Rich formatting</strong>—we can send product images, prices, and charts</li><li><strong>No app installation</strong>—most users already have Telegram</li><li><strong>Reliable API</strong>—Easy to integrate and highly stable</li></ol><h3>The Scraping Pipeline</h3><p>This is when things become complicated. One of the trickiest things about the system is scraping a lot of e-commerce sites.</p><h4>How It Works</h4><ol><li><strong>Orchestrator</strong> receives scraping requests and identifies the platform (Amazon, Flipkart, etc.)</li><li><strong>Message Queue</strong> distributes jobs to available workers</li><li><strong>Workers</strong> execute scraping using <strong>headless browsers</strong></li><li><strong>Data Processor</strong> cleans and normalizes the scraped data</li><li><strong>Batch Writer</strong> efficiently writes results to the database</li></ol><p>We use <strong>Playwright</strong> for browser automation because it handles modern websites better than older tools. It also has built-in capabilities to navigate common anti-bot measures.</p><h3>Message Queue—Apache Kafka</h3><p>Why use a message queue? Imagine this scenario: a user submits a product URL. If we scraped it synchronously, they would wait 30–35 seconds for the scraper to finish. That’s terrible UX.</p><p>Instead, we immediately acknowledge the request, push a job to the queue, and return a job ID. The user can then poll for status updates while the job processes in the background.</p><p><strong>Why Kafka?</strong></p><ol><li><strong>High throughput</strong>—Handles massive message volumes</li><li><strong>Durability</strong>—Messages survive system restarts</li><li><strong>Scalability</strong>—Adding more consumers is seamless</li><li><strong>Ordering guarantees</strong>—Messages are processed in order</li></ol><h3>Database—PostgreSQL + TimescaleDB</h3><p>We use PostgreSQL with the TimescaleDB module for our database layer. TimescaleDB is made just for time-series data, which is great for pricing history.</p><p>Why use TimescaleDB?</p><ol><li><strong>Automatic partitioning—Time-based</strong> data is organized efficiently</li><li><strong>Compression</strong>—Historical data is compressed significantly, saving storage</li><li><strong>Fast queries</strong>—Aggregations over time ranges are optimized.</li><li><strong>SQL compatibility</strong>—works with standard PostgreSQL tools</li></ol><h3>Caching—Redis</h3><p>In our architecture, Redis has many uses:</p><ol><li><strong>Application cache:</strong> Data about products and API answers</li><li><strong>Task broker: </strong>a queue for background tasks</li><li><strong>Session storage:</strong> user sessions for endpoints that require authentication</li><li><strong>Rate limiting</strong>—keeping track of how many requests are made</li></ol><h4>Why use Redis?</h4><ol><li><strong>In-memory</strong>—Microsecond response times</li><li><strong>Versatile data structures</strong>—lists, sets, hashes out of the box</li><li><strong>Pub/Sub</strong>—Real-time messaging capabilities</li></ol><h3>The Batch Write Pattern—Handling Scale</h3><p>One of our biggest wins was implementing the <strong>batch write architecture</strong>. When you’re scraping hundreds of thousands of products daily, that’s hundreds of thousands of database writes. Each write creates overhead that adds up fast.</p><p><strong>Our solution:</strong> Instead of writing each price update immediately, we push them to a queue. A separate service reads from this queue and writes to the database in batches.</p><p>The results were dramatic:</p><ul><li>Database operations reduced by 100x</li><li>Read latency improved significantly</li><li>Lock contention became nearly zero</li></ul><p>This pattern—decoupling reads from writes—applies to any high-volume system.</p><h3>Lessons Learned Along the Way</h3><p>Building this system taught us several valuable lessons:</p><p><strong>1. Start with the hardest problem.</strong> For us, that was reliable data extraction. Without accurate prices, nothing else matters.</p><p><strong>2. Monitoring is not optional.</strong> We added logging, health checks, and alerting early. When something breaks at 3 AM, you want to know immediately.</p><p><strong>3. Users hate notification spam.</strong> The DQS system transformed user engagement. Quality over quantity.</p><p><strong>4. Scaling is not just about code.</strong> Database optimization, caching strategies, and architectural patterns matter more than micro-optimization.</p><p><strong>5. Distributed systems are challenging.</strong> What starts as a simple script becomes a complex distributed system. Plan for this from day one.</p><h3>What’s Next?</h3><p>The system continues to evolve. We’re exploring:</p><ul><li><strong>Machine learning</strong> for price prediction</li><li><strong>Cross-platform comparison</strong> to find the best deal across retailers</li><li><strong>Personalized recommendations</strong> based on user behavior</li></ul><h3>Want to Learn These Technologies?</h3><p>If this architecture interested you and you want to dive deeper, here are some excellent courses:</p><h4>System Design</h4><ul><li><a href="https://www.educative.io/courses/grokking-modern-system-design-interview-for-engineers-managers"><strong>Grokking System Design Interview</strong></a> (Educative)—Covers distributed systems, scaling, and real-world architecture patterns</li></ul><h4>Web Scraping</h4><ul><li><a href="https://www.udemy.com/course/web-scraping-in-python-master-class/"><strong>Web Scraping in Python</strong></a> (Udemy)—Covers Selenium, BeautifulSoup, and handling anti-bot measures</li></ul><h4>FastAPI</h4><ul><li><a href="https://www.udemy.com/course/fastapi-the-complete-course/"><strong>FastAPI—The Complete Course</strong></a> (Udemy)—Build APIs with Python’s fastest framework</li></ul><h4>Apache Kafka</h4><ul><li><a href="https://www.udemy.com/course/apache-kafka/"><strong>Apache Kafka for Beginners</strong></a> (Udemy) — Learn message streaming from scratch</li></ul><h4>Docker &amp; Containers</h4><ul><li><a href="https://www.udemy.com/course/docker-mastery/"><strong>Docker Mastery</strong></a> (Udemy)—Complete Docker guide including Docker Compose</li></ul><h4>PostgreSQL &amp; Time-Series Data</h4><ul><li><a href="https://www.udemy.com/course/the-complete-python-postgresql-developer-course/"><strong>PostgreSQL Bootcamp</strong></a> (Udemy)—Database fundamentals with PostgreSQL</li></ul><h4>Redis</h4><ul><li><a href="https://www.udemy.com/course/redis-the-complete-developers-guide-p/"><strong>Redis: The Complete Developer’s Guide</strong></a> (Udemy) — Caching, data structures, and patterns</li></ul><h3>Conclusion</h3><p>Building <a href="https://pricehistory.ai/">PriceHistory.AI</a> has been an incredible journey. What started as a personal frustration—missing deals—evolved into a comprehensive price tracking platform serving thousands of users.</p><p>The architecture we’ve discussed isn’t just theory. It has undergone rigorous testing, lives in production, and manages hundreds of thousands of products daily. Each component exists because we faced a real problem and needed a real solution.</p><p>If there’s one takeaway from this article, it’s this: <strong>excellent architecture emerges from solving real problems</strong>. We didn’t start with microservices and Kafka because they’re trendy. We began with a basic script and refined the system as we encountered scaling challenges.</p><p>Whether you’re building a price tracker, a social network, or any other web application—the patterns are universal. Separate concerns. Cache aggressively. Queue what you can. Batch what you must. And you should always monitor everything.</p><p>I hope this deep dive into our architecture inspires you to build something of your own. Start small, solve real problems, and let the complexity grow organically.</p><p>Happy coding, and may you never miss a deal again! 🛒📉</p><p><em>If you found this article helpful, please give it a clap </em>👏<em> and follow it for more in-depth explorations of system design, web development, and Android/iOS development. Drop a comment </em>💬<em> if you have questions—I’d love to hear from you!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63a78f621541" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Price Tracking System: A Technical Deep Dive]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@shubhambhama/price-tracking-system-a-technical-deep-dive-47b8fa44cfea?source=rss-999277334716------2"><img src="https://cdn-images-1.medium.com/max/640/1*BwjQhywcUPMSLpdqmeH-_Q.png" width="640"></a></p><p class="medium-feed-snippet">Learn how we built a price tracking system that monitors 100,000+ products daily. Discover the engineering challenges and solutions</p><p class="medium-feed-link"><a href="https://medium.com/@shubhambhama/price-tracking-system-a-technical-deep-dive-47b8fa44cfea?source=rss-999277334716------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@shubhambhama/price-tracking-system-a-technical-deep-dive-47b8fa44cfea?source=rss-999277334716------2</link>
            <guid isPermaLink="false">https://medium.com/p/47b8fa44cfea</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[Shubham Bhama]]></dc:creator>
            <pubDate>Mon, 09 Feb 2026 14:33:59 GMT</pubDate>
            <atom:updated>2026-02-09T14:33:59.650Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[LangChain vs LangGraph vs LangFlow vs LangSmith: Which AI Tool Should You Choose in 2025?]]></title>
            <link>https://medium.com/@shubhambhama/langchain-family-668b73c25ca6?source=rss-999277334716------2</link>
            <guid isPermaLink="false">https://medium.com/p/668b73c25ca6</guid>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[ai-development]]></category>
            <category><![CDATA[langgraph]]></category>
            <category><![CDATA[langsmith]]></category>
            <category><![CDATA[langflow]]></category>
            <dc:creator><![CDATA[Shubham Bhama]]></dc:creator>
            <pubDate>Sun, 20 Jul 2025 06:21:19 GMT</pubDate>
            <atom:updated>2025-07-20T06:21:19.788Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Have you ever tried explaining Large Language Models to a cat? Probably not — and neither have I. But if I were to explain them to someone curious about AI, I’d start with these four powerful tools. They simplify AI development, transforming it from something that feels like rocket science into a more approachable, modular experience — like building with intelligent LEGO blocks.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1STqW_J4oy76UqBz" /></figure><h3>Meet the Brains Behind the Bots 🧠</h3><p>Picture this: You’re at a party (remember those?), and someone asks you about AI development. Instead of mumbling something about “training neural networks” and awkwardly shuffling away, you can now confidently say, “Oh, I just use the Lang-family tools!”</p><p>The LangChain ecosystem isn’t just one tool — it’s like the <strong>Avengers of AI development</strong>. Each member has their own superpower:</p><ul><li><strong>LangChain</strong> is Iron Man — the brilliant, modular genius</li><li><strong>LangGraph</strong> is Captain America — the strategic coordinator</li><li><strong>LangFlow</strong> is Spider-Man — young, visual, and surprisingly powerful</li><li><strong>LangSmith</strong> is Nick Fury — always watching, always monitoring</li></ul><p><em>But wait, are you wondering which one you should start with? Keep reading, because I’m about to break down each superhero’s origin story!</em></p><h3>Meet LangChain: The Foundation Hero 🦸‍♂️</h3><h4>What is LangChain, Really?</h4><p>LangChain is like that friend who always has the right tool for every job. It’s an <strong>open-source framework designed to make building LLM applications as easy as ordering pizza online</strong> (and arguably more satisfying).</p><p><strong>Fun fact:</strong> The name “LangChain” comes from “Language” + “Chain” — because it literally chains together different AI components like a digital assembly line</p><h4>Why Should You Care?</h4><p>Remember when you had to write 500 lines of code just to get a chatbot to say “Hello”? LangChain said, “Not on my watch!” Here’s what makes it special:</p><p>🔗 <strong>Unified Interface:</strong> Work with OpenAI today, switch to Claude tomorrow, no headaches<br>🧩 <strong>Pre-built Components:</strong> Like having a toolbox that never runs out of the right screwdriver<br>💭<strong> Memory &amp; Context: </strong>Your AI can finally remember what you talked about 5 minutes ago</p><h4>LangChain in Action (The “Aha!” Moment)</h4><pre>from langchain.llms import OpenAI<br>from langchain import PromptTemplate, LLMChain<br><br># Create a joke generator<br>llm = OpenAI(temperature=0.9)  # Higher temperature = more creative<br><br>prompt = PromptTemplate(<br>    input_variables=[&quot;topic&quot;],<br>    template=&quot;Tell me a funny joke about {topic}&quot;<br>)<br><br>chain = LLMChain(llm=llm, prompt=prompt)<br>result = chain.run(&quot;programmers&quot;)<br><br># Output: &quot;Why do programmers prefer dark mode? <br># Because light attracts bugs!&quot;</pre><p><em>See how clean that is? No more wrestling with API endpoints or managing conversation history manually!</em></p><h3>Enter LangGraph: The Master Strategist 🕸️</h3><h4>What Makes LangGraph Different?</h4><p>If LangChain is like having a really smart assistant, <strong>LangGraph is like having a team of specialists who can work together.</strong> Think of it as the difference between a solo guitar performance and a full symphony orchestra.</p><p>LangGraph specializes in <strong>stateful, </strong><a href="https://medium.com/@shubhambhama/build-ai-agents-with-kotlin-jetbrains-koog-cf7080509300"><strong>multi-agent workflows</strong></a>. In human terms: your AI agents can now have persistent memory, make complex decisions, and work together without stepping on each other’s digital toes.</p><h4>The “Why” Behind LangGraph</h4><p>Traditional AI applications are like following a recipe — step 1, step 2, step 3, done. But real-world problems are messier. Sometimes you need to:</p><ul><li>Go back and revise earlier decisions</li><li>Have multiple AI agents collaborate</li><li>Handle unpredictable user interactions</li><li>Maintain context over long conversations</li></ul><p><strong>That’s where LangGraph shines</strong>. It turns your AI from a simple question-answering machine into a sophisticated problem-solving partner.</p><h4>Real-World Example: The AI Research Team</h4><p>Imagine you’re building an AI that can write research reports. With LangGraph, you can create:</p><p>🔍 Research Agent: Finds and gathers information<br>✍️ Writer Agent: Creates the actual content<br>📊 Chart Agent: Generates visualisations<br>🎯 Supervisor Agent: Coordinates everything</p><pre>from langgraph.graph import StateGraph<br>from langchain.agents import initialize_agent<br><br># Create your research dream team<br>research_agent = create_agent(llm, [search_tool], &quot;You&#39;re a research specialist...&quot;)<br>writer_agent = create_agent(llm, [writing_tool], &quot;You&#39;re a content writer...&quot;)<br>chart_agent = create_agent(llm, [chart_tool], &quot;You&#39;re a data visualization expert...&quot;)<br><br># Build the workflow graph<br>workflow = StateGraph(AgentState)<br>workflow.add_node(&quot;researcher&quot;, research_agent)<br>workflow.add_node(&quot;writer&quot;, writer_agent) <br>workflow.add_node(&quot;chart_generator&quot;, chart_agent)<br><br># Define how they work together<br>workflow.add_edge(&quot;researcher&quot;, &quot;writer&quot;)<br>workflow.add_edge(&quot;writer&quot;, &quot;chart_generator&quot;)</pre><p><em>The magic? Each agent maintains its own state and can communicate with others. It’s like having a WhatsApp group for your AI agents!</em></p><h3>LangFlow: The Visual Virtuoso 🎨</h3><h4>The “No-Code” Revolution</h4><p><strong>What if I told you that you could build AI applications by dragging and dropping components like you’re designing a poster</strong>? That’s exactly what LangFlow does.</p><p>LangFlow is the <strong>visual, drag-and-drop interface for AI development</strong>. It’s perfect for those moments when you want to prototype quickly or when you need to explain your AI workflow to someone who speaks in PowerPoint, not Python.</p><h4>Who Is LangFlow For?</h4><p>👩‍💼 Product Managers: “I want to see how the AI workflow actually works!”<br>🎓 Educators: “Let me show my students how AI components connect…”<br>⚡ Rapid Prototypers: “I need to test this idea in 10 minutes, not 10 hours!”<br>🤝 Team Collaborators: “Let’s design this together on a shared canvas!”</p><p>Here’s what’s beautiful about LangFlow: Everything you build visually generates real, production-ready code behind the scenes. It’s not just pretty pictures — it’s functional AI applications.</p><p>The typical LangFlow workflow:</p><ol><li><strong>Drag</strong> components (LLMs, databases, tools) onto a canvas</li><li><strong>Connect</strong> them with visual flows</li><li><strong>Configure</strong> each component’s settings</li><li><strong>Test</strong> in the integrated playground</li><li><strong>Deploy</strong> as an API endpoint automatically</li></ol><p><em>Think of it as the Canva of AI development — powerful enough for pros, simple enough for beginners.</em></p><h4>Building Your First LangFlow App</h4><p>Let’s say you want to create a PDF summariser:</p><ol><li>Drag a <strong>File Loader</strong> component</li><li>Connect it to a <strong>Text Splitter</strong></li><li>Link that to an <strong>LLM</strong> (like GPT-4)</li><li>Add a <strong>Summarisation Chain</strong></li><li>Connect to an <strong>Output</strong> component</li></ol><p>Boom! You’ve just built a document summarizer without writing a single line of code</p><h3>LangSmith: The All-Seeing Eye 👁️</h3><h4>The Problem LangSmith Solves</h4><p>Picture this scenario: Your AI chatbot is working great in testing, but in production, users are complaining it’s slow and sometimes gives weird answers. <strong>Where do you even start debugging?</strong></p><p>Traditional software debugging is hard enough, but AI applications are like trying to debug a dream — everything is probabilistic and non-deterministic</p><h4>What LangSmith Actually Does</h4><p>LangSmith is your <strong>AI application’s personal detective</strong></p><p>🔍 Traces every step: See exactly what your AI is thinking at each moment<br>📊 Monitors performance: Track costs, latency, and quality metrics<br>🧪 Helps with testing: Create datasets and run evaluations<br>👥 Enables collaboration: Share insights across your team</p><h3>The “$500 OpenAI Bill” Story (Yeah… That Happened to Me)</h3><p>Let me tell you a story — because I’ve been there. I once got slapped with a surprise $500 OpenAI bill. Why? My app was making way more API calls than I ever intended. And the worst part? I had no real visibility into what was going on under the hood. It was a wake-up call. That experience taught me just how important it is to have proper monitoring and controls in place when working with powerful APIs like OpenAI’s.</p><p>With LangSmith, you can:</p><ul><li>Set up cost alerts before bills explode</li><li>See which parts of your app are expensive</li><li>Identify performance bottlenecks</li><li>Catch failures before users do</li></ul><h4>LangSmith in Practice</h4><pre>import os<br>from langsmith import Client<br><br># Set up LangSmith tracing<br>os.environ[&quot;LANGSMITH_TRACING&quot;] = &quot;true&quot;<br>os.environ[&quot;LANGSMITH_API_KEY&quot;] = &quot;your-api-key&quot;<br><br># Your existing LangChain code automatically gets traced!<br>def rag_pipeline(question):<br>    docs = retriever(question)<br>    system_message = f&quot;Answer using: {docs}&quot;<br>    return llm.invoke([<br>        {&quot;role&quot;: &quot;system&quot;, &quot;content&quot;: system_message},<br>        {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: question}<br>    ])<br><br># Every call is now automatically logged and monitored<br>result = rag_pipeline(&quot;What&#39;s the weather like?&quot;)</pre><p><em>The beautiful part? LangSmith integrates seamlessly with your existing LangChain code. Just add a few environment variables, and suddenly you have superpowers!</em></p><h3>The Great Comparison: When to Use What? 🤔</h3><p>“But wait,” you might be thinking, “which tool should I actually use for my project?”</p><h4>Choose LangChain when:</h4><ul><li>You’re building traditional AI workflows</li><li>You want maximum flexibility and control</li><li>You’re comfortable with code</li><li>You need extensive integrations</li></ul><h4>Choose LangGraph when:</h4><ul><li>You need multi-agent systems</li><li>Your workflow has loops and complex decision-making</li><li>You want stateful applications</li><li>Agents need to collaborate and remember context</li></ul><h4>Choose LangFlow when:</h4><ul><li>You want to prototype quickly</li><li>You need to collaborate with non-technical team members</li><li>Visual workflows help you think better</li><li>You want to deploy without writing backend code</li></ul><h4>Choose LangSmith when:</h4><ul><li>You’re running AI applications in production</li><li>You need to debug and optimise performance</li><li>Cost monitoring is important</li><li>You want to evaluate AI quality over time</li></ul><p><em>Pro tip: You don’t have to choose just one! These tools work beautifully together. Many teams including myself use LangFlow for prototyping, LangGraph for complex workflows, and LangSmith for monitoring everything.</em></p><h3>Common Pitfalls (And How to Dodge Them) ⚠️</h3><p><strong>Every superhero has their kryptonite</strong>, and AI development tools are no exception. Here are the most common mistakes I see beginners make:</p><h4>Mistake #1: “Let AI Do Everything”</h4><p><strong>The Problem:</strong> Expecting AI to magically solve complex problems without proper prompt engineering.</p><p><strong>The Fix:</strong> Start simple, be specific with your prompts, and gradually add complexity</p><h4>Mistake #2: “Ignoring Cost Monitoring”</h4><p><strong>The Problem: </strong>Not tracking API usage until the bill arrives.</p><p><strong>The Fix: </strong>Set up LangSmith monitoring from day one, not after your first expensive surprise.</p><h4>Mistake #3: “Reinventing the Wheel”</h4><p><strong>The Problem:</strong> Building everything from scratch instead of using pre-built components.</p><p><strong>The Fix:</strong> Check the LangChain documentation first — there’s probably already a component for what you need</p><h4>Mistake #4: “No Testing Strategy”</h4><p><strong>The Problem:</strong> Not testing your AI applications systematically.</p><p><strong>The Fix:</strong> Use LangSmith to create evaluation datasets and regularly test your app’s performance</p><p>The AI development space is still young, which means there’s huge opportunity for creative developers to build the next big thing. <strong>Whether you’re a seasoned developer or just starting out</strong>, these tools lower the barrier to entry significantly.</p><h3>Conclusion</h3><p>That’s a wrap, folks! 🎉 We’ve just taken a wild ride through the awesome <a href="https://python.langchain.com/docs/introduction/?_gl=1*2ih3fp*_gcl_au*MTQyMDU5Njk2LjE3NTE0NzY4OTA.*_ga*NTA2NDU3NjUuMTc1MTQ3Njg5MA..*_ga_47WX3HKKY2*czE3NTI5NDkyNTQkbzYkZzEkdDE3NTI5NDkyNTYkajU4JGwwJGgw">LangChain</a> world — from clever chains to <a href="https://langchain-ai.github.io/langgraph/concepts/why-langgraph/">plotting graphs</a>, drag-and-drop flows, and all-seeing <a href="https://docs.smith.langchain.com/?_gl=1*i2n50h*_gcl_au*MTQyMDU5Njk2LjE3NTE0NzY4OTA.*_ga*NTA2NDU3NjUuMTc1MTQ3Njg5MA..*_ga_47WX3HKKY2*czE3NTI5NDkyNTQkbzYkZzEkdDE3NTI5NDkzMTAkajQkbDAkaDA.">monitors</a>. No matter if you’re an LLM newbie or already have AI bots named after your pets, there’s something here for everyone.</p><p>So, what’s next?</p><ul><li>Got a question, a tip, or a wild AI story? Drop a comment below, or share your experiments — I LOVE seeing fellow makers in action!</li><li>Let’s connect on <a href="https://www.linkedin.com/in/shubhambhama/">LinkedIn</a>!</li></ul><p>If this made you smile, helped you out, or just filled your head with ideas, tap that 👏 button.</p><p>Thanks a bunch for hanging out with me — and remember: every big AI adventure starts with a single (Lang)Chain.</p><p>Happy tinkering! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=668b73c25ca6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Everything new in Kotlin 2.2.0]]></title>
            <link>https://medium.com/@shubhambhama/everything-new-in-kotlin-2-2-0-8f4a6cf27466?source=rss-999277334716------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f4a6cf27466</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[technews]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Shubham Bhama]]></dc:creator>
            <pubDate>Sat, 12 Jul 2025 09:55:20 GMT</pubDate>
            <atom:updated>2025-07-12T09:55:20.706Z</atom:updated>
            <content:encoded><![CDATA[<p>Kotlin 2.2.0 is here, and it’s not just a point-release — it’s a rocket-fuel upgrade for JVM, Android, Multiplatform, and beyond. From context parameters that streamline your constructors to guard conditions that declutter your when expressions, this release brings power, polish, and a dash of Kotlin wit. Buckle up: we’re about to explore every headline feature, real-world use case, and quick tip you need to supercharge your codebase today.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*nIsby377yeSPROI1E6KkLA.png" /></figure><p>Before we dive into all the cool new features, here are a few questions to get you thinking:</p><ul><li>Ever wish you could pass dependencies to your functions without dragging them everywhere?</li><li>How many times have you typed Status.APPROVED and thought, “Can’t Kotlin just figure it out?”</li><li>Wouldn’t it be great if your when expressions could handle those tricky cases without a mess of if statements?</li><li>Have you ever tried encoding with Base64 and wondered if you picked the right version?</li></ul><p>Let’s jump in and see what Kotlin 2.2.0 can do!</p><h3>Table of Contents</h3><ol><li><a href="#0042">Why This Release Matters</a></li><li><a href="#a210">Language Sweet Spots</a><br>• Context Parameters (Preview)<br>• Guard Conditions (Stable)<br>• Context-Sensitive Resolution (Preview)<br>• Non-Local break/continue (Stable)<br>• Multi-Dollar Interpolation (Stable)</li><li><a href="#8384">Standard-Library Upgrades</a><br>• Base64 API (Stable)<br>• HexFormat API (Stable)</li><li><a href="#b3af">JVM &amp; Tooling Goodies</a><br>• K2 Compiler Highlights<br>• Unified Warning Management<br>• Default-Method Generation Changes</li><li><a href="#80ac">Native, JS, Wasm &amp; Multiplatform Tweaks</a></li></ol><h3>1. Why This Release Matters</h3><p>Kotlin 2.2.0 lands only a year after 2.1 but introduces more language evolution than some full-digit releases. JetBrains calls it “game-changing,” and early benchmarks show <strong>compilation up to 2× faster with K2</strong> plus cleaner cross-platform libraries. If you write Android apps, server-side code, or KMP libraries, the payoff is immediate: less boilerplate, clearer control flow, and snappier builds.</p><h3>2. Language Sweet Spots</h3><h4>2.1 Context Parameters — Dependency Injection</h4><p>What they do: Declare implicit dependencies right in the function signature:</p><pre>context(logger: Logger, userRepo: UserRepository)<br>fun createUser(name: String) { logger.info(&quot;Hi, $name&quot;) }</pre><p><em>Why you care</em></p><ul><li>Removes constructor/parameter clutter.</li><li>Plays nicely with IDE “with(…) { }” scaffolding.</li><li>Replaces experimental context receivers</li></ul><p><em>How to enable</em><br>Add -Xcontext-parameters to your Gradle freeCompilerArgs</p><blockquote><em>Gotchas: </em>Only functions &amp; property accessors, not classes.</blockquote><h4>2.2 Guard Conditions — &quot;when&quot; Gets Street Smarts</h4><p>Tired of nesting if inside when? Now combine them:</p><pre>when (response) {<br>    is Failure if response.code == 503 -&gt; showToast(&quot;Maintenance&quot;)<br>    is Failure -&gt; showToast(&quot;Error&quot;)<br>}</pre><p>This feature just graduated to <strong>stable</strong>, so no flags needed. It boosts readability and “fail-fast” patterns</p><h4>2.3 Context-Sensitive Resolution — Drop the Prefix</h4><p>Inside obvious scopes, you can omit enum-type qualifiers:</p><pre>val status: Status = APPROVED // instead of Status.APPROVED</pre><p>Enable with -Xcontext-sensitive-resolution. IDE hints are still catching up</p><h4>2.4 Non-Local break and continue – Escape Inline Lambdas Gracefully</h4><p>Inline higher-order loops can now break or continue the outer loop directly—no more flag variables.</p><pre>items.forEach {<br>    if (it.bad) continue // skips outer loop iteration<br>    if (it.stop) break   // breaks outer loop<br>}</pre><h4>2.5 Multi-Dollar Interpolation — $$$ in Your Strings</h4><p>Need literal dollar signs <em>and</em> string templates? Prefix with extra $ characters:</p><pre>println($$&quot;Total: $$${price}&quot;) // prints: Total: $42</pre><p>Enabled by -Xmulti-dollar-interpolation; now stable</p><h3>3. Standard-Library Upgrades</h3><h4><strong>Base64 API (Stable)</strong></h4><ul><li>Offers four alphabets: Default, UrlSafe, Mime, and Pem.</li><li>Supports customizable padding.</li><li>Now production-ready for encoding/decoding needs in networking, JWTs, email attachments, and more.</li></ul><pre>val encoded = Base64.Default.encode(&quot;data&quot;.encodeToByteArray())</pre><h4><strong>HexFormat API (Stable)</strong></h4><ul><li>Provides a builder-style DSL for formatting bytes and numbers as hexadecimal.</li><li>Lets you easily set upper/lower case, byte separators (like :, -), and grouping.</li><li>Great for MAC addresses, color codes, and binary dumps.</li></ul><pre>val mac = byteArrayOf(0x00, 0x1B, 0x63, 0x84.toByte(), 0x45, 0xE6.toByte())<br>val fmt = HexFormat { upperCase = true; bytes.byteSeparator = &quot;:&quot; }<br>println(mac.toHexString(fmt))  // 00:1B:63:84:45:E6</pre><h3>4. JVM &amp; Tooling Goodies</h3><h4>4.1 K2 Compiler (Beta)</h4><ul><li>Unified frontend for JVM/JS/Wasm/Native.</li><li>Up to 94% faster incremental analysis</li><li>Available in IntelliJ IDEA 2025.1 — opt-in per project</li></ul><h4>4.2 Unified Warning Management</h4><p>New flag -XWarning-level lets you tune diagnostics without full -Werror lockdown</p><h4>4.3 Default-Method Generation</h4><p>-jvm-default now defaults to enable in Kotlin 2.2, simplifying Java-interop</p><h3>5. Native, JS, Wasm &amp; Multiplatform Tweaks</h3><ul><li><strong>LLVM 19</strong> for Kotlin/Native brings smaller iOS binaries</li><li><strong>Separated Wasm build infra</strong>; wasmJs target no longer tangled with JS</li><li>New passCliArgumentsToMainFunction() DSL for Kotlin/JS removes drop(2) hacks</li><li>Multi-platform library format unified under K2 for smoother publishing</li></ul><h3><strong>Conclusion</strong></h3><p>And that’s a wrap! We’ve journeyed through everything new in <a href="https://kotlinlang.org/docs/whatsnew22.html">Kotlin 2.2.0 </a>— from context parameters and guard conditions to the latest Base64 and HexFormat APIs. Whether you’re a seasoned Kotlin developer or just dipping your toes into the JVM waters, this release offers something to spark your creativity and boost your productivity.</p><p>But this isn’t just about reading release notes or copying code samples. It’s about building, experimenting, and sharing what you create. I’ve put together a complete, runnable project on GitHub so you can dive right in, see these features in action, and use them as a foundation for your own apps.</p><h4>Ready to take the next step?</h4><ul><li>⭐️ <a href="https://github.com/shubhambhama/Everything-new-in-Kotlin-2.2.0">Check out the full project on GitHub</a> — clone it, run it, and make it your own!</li><li>💬 Have questions or want to show off what you’ve built? Drop a comment below or connect with me.</li><li>🔗 <a href="https://www.linkedin.com/in/shubhambhama/">Let’s connect on LinkedIn!</a> I love meeting fellow Kotlin enthusiasts, sharing ideas, and learning together.</li></ul><p>If you find it useful, please don’t forget to hit the 👏 button.</p><p>Thanks for following along and happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f4a6cf27466" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build AI Agents with Kotlin & JetBrains Koog]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@shubhambhama/build-ai-agents-with-kotlin-jetbrains-koog-cf7080509300?source=rss-999277334716------2"><img src="https://cdn-images-1.medium.com/max/1024/0*1oz6VqTeKBbeQzvi.png" width="1024"></a></p><p class="medium-feed-snippet">Build AI agents natively in Kotlin with JetBrains Koog&#x200A;&#x2014;&#x200A;an open-source framework unveiled at KotlinConf 2025 for JVM-based AI power.</p><p class="medium-feed-link"><a href="https://medium.com/@shubhambhama/build-ai-agents-with-kotlin-jetbrains-koog-cf7080509300?source=rss-999277334716------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@shubhambhama/build-ai-agents-with-kotlin-jetbrains-koog-cf7080509300?source=rss-999277334716------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf7080509300</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[jetbrains]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Shubham Bhama]]></dc:creator>
            <pubDate>Tue, 01 Jul 2025 08:45:42 GMT</pubDate>
            <atom:updated>2025-07-12T09:59:34.058Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Build Production-Ready UI Fast with Figma, Cursor AI, and MCP]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@shubhambhama/connect-figma-to-cursor-ai-with-mcp-in-5-minutes-0c4794537fa3?source=rss-999277334716------2"><img src="https://cdn-images-1.medium.com/max/2600/1*PnVaWy9b0VXukxl_Qw_EOA.png" width="3120"></a></p><p class="medium-feed-snippet">Figma&#x2019;s MCP bridges design and code, letting tools like Cursor turn designs into clean, production-ready UI with true design intent.</p><p class="medium-feed-link"><a href="https://medium.com/@shubhambhama/connect-figma-to-cursor-ai-with-mcp-in-5-minutes-0c4794537fa3?source=rss-999277334716------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@shubhambhama/connect-figma-to-cursor-ai-with-mcp-in-5-minutes-0c4794537fa3?source=rss-999277334716------2</link>
            <guid isPermaLink="false">https://medium.com/p/0c4794537fa3</guid>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[figma]]></category>
            <category><![CDATA[vscode]]></category>
            <dc:creator><![CDATA[Shubham Bhama]]></dc:creator>
            <pubDate>Mon, 23 Jun 2025 09:20:12 GMT</pubDate>
            <atom:updated>2025-07-12T10:01:15.995Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Building a Cryptocurrency Price Tracker with Jetpack Compose]]></title>
            <link>https://medium.com/@shubhambhama/building-a-cryptocurrency-price-tracker-with-jetpack-compose-4e0d6857b50d?source=rss-999277334716------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e0d6857b50d</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[jetpack]]></category>
            <category><![CDATA[jetpack-navigation]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <dc:creator><![CDATA[Shubham Bhama]]></dc:creator>
            <pubDate>Mon, 17 Apr 2023 09:20:47 GMT</pubDate>
            <atom:updated>2023-04-21T07:35:44.796Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we will be discussing a project built using Jetpack Compose, a modern toolkit for building Android UIs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pR_mRAUd6kPem40B" /></figure><p>Our project will be a cryptocurrency price tracker displaying the current prices of Bitcoin, Ethereum, Litecoin, and other cryptocurrencies. Additionally, it will also display the price trends using custom line and bar charts. Users can also save and view their favorite cryptocurrencies on a separate screen.</p><p><a href="https://youtube.com/shorts/7pHTki9jmIQ">Building a Cryptocurrency Price Tracker with Jetpack Compose</a></p><p>The project follows the MVVM (Model-View-ViewModel) architecture, a popular architecture pattern for building robust and scalable Android apps. We will also use popular libraries such as Retrofit, Room, Pager and Lottie Animation to help us build the app.</p><h3><strong>Setting up the Project</strong></h3><p>Before diving into the project’s implementation, let’s set up our Android Studio project with Jetpack Compose. To create a new Jetpack Compose project, follow these steps:</p><ol><li>Open Android Studio and click on “Create New Project.”</li><li>Select “Empty Compose Activity” and click “Next.”</li><li>Give your project a name and select your desired location for the project.</li><li>Choose your desired language (Kotlin or Java) and click “Finish.”</li></ol><p>Once you have set up your project, you can start implementing the features of the cryptocurrency price tracker app.</p><h3>Displaying Current Prices for Cryptocurrencies</h3><p>To display the current prices for cryptocurrencies, we will be using the Retrofit library. Retrofit is a type-safe HTTP client for Android and Java, simplifying communication with APIs. We will create a Retrofit interface defining the endpoints for fetching the data.</p><pre>interface CryptoApi {<br>    @GET(&quot;coins/markets?vs_currency=usd&amp;order=market_cap_desc&amp;sparkline=true&quot;)<br>    suspend fun getAllCrypto(<br>            @Query(&quot;page&quot;) page: Int = 1,<br>            @Query(&quot;per_page&quot;) pageSize: Int = 20<br>    ): Response&lt;List&lt;CryptoApiResponse&gt;&gt;<br>}</pre><p>We will also create a data class called CryptoApiResponse that will represent a single cryptocurrency price.</p><pre>data class CryptoApiResponse(<br>    val id: String, // The unique identifier of the cryptocurrency.<br>    val symbol: String, // The ticker symbol of the cryptocurrency.<br>    val name: String, <br>    val image: String, <br>    val current_price: Double, // The current price of the cryptocurrency.<br>    val market_cap: Long,  // The market capitalization of the cryptocurrency.<br>    val total_volume: Double, // The total trading volume of the cryptocurrency.<br>    val high_24h: Double, // The highest price of the cryptocurrency in the last 24 hours.<br>    val low_24h: Double, // The lowest price of the cryptocurrency in the last 24 hours.<br>    val price_change_24h: Double, // The price change of the cryptocurrency in the last 24 hours.<br>    val price_change_percentage_24h: Double, // The percentage price change of the cryptocurrency in the last 24 hours.<br>    val total_supply: Double, // The total supply of the cryptocurrency.<br>    val sparkline_in_7d: LineData // The price trend of the cryptocurrency over the last 7 days.<br>)</pre><p>Next, we will create a ViewModel that will fetch the data from the API using Retrofit and expose it to the UI using LiveData.</p><p>Here, Network object sets up a retrofit instance with a base URL, GsonConverterFactory, and an okHttpClient that handles timeouts.</p><p>The createRepository function returns a CryptoRepoImplementation instance that implements the CryptoRepository interface and uses CryptoApi, CryptoDatabase, and ApiMapper instances to handle API calls.</p><pre>object Network {<br>    private const val timeOut = 20L<br>    private const val BASE_URL = &quot;https://api.coingecko.com/api/v3/&quot;<br><br>    private val okHttpClient by lazy {<br>        OkHttpClient.Builder().apply {<br>            readTimeout(timeout = timeOut, TimeUnit.SECONDS)<br>            connectTimeout(timeout = timeOut, TimeUnit.SECONDS)<br>        }.build()<br>    }<br><br>    private val retrofit = Retrofit.Builder().client(okHttpClient).baseUrl(BASE_URL)<br>            .addConverterFactory(GsonConverterFactory.create()).build()<br><br>    fun createRepository(context: Context): CryptoRepository {<br>        val db = CryptoDatabase.getInstance(context)<br>        return CryptoRepoImplementation(cryptoApi = retrofit.create(CryptoApi::class.java),<br>                dao = db.cryptoDao(), apiMapper = ApiMapper())<br>    }<br>}</pre><p>The HomeScreenViewModel class defines a cryptoRepository property that creates a repository using Network.createRepository.</p><p>The getAllCryptos function returns a Pager object that retrieves crypto data from the repository using cryptoRepository.getCryptoPages.</p><p>The cryptoLiveData property retrieves and emits crypto data from the repository using liveData and cryptoRepository.getCryptoData.</p><pre>class HomeScreenViewModel(context: Context) : ViewModel() {<br>    private val cryptoRepository: CryptoRepository = Network.createRepository(context)<br><br>    fun getAllCryptos(pageSize: Int = 20) = Pager(<br>            config = PagingConfig(pageSize = pageSize, initialLoadSize = pageSize)) {<br>        PageNumSource { pageNum, pageSize -&gt;<br>            cryptoRepository.getCryptoPages(pageNum, pageSize)<br>        }<br>    }.flow.cachedIn(viewModelScope)<br><br>    val cryptoLiveData = liveData(Dispatchers.IO) {<br>        emitSource(cryptoRepository.getCryptoData())<br>    }<br>}</pre><p>In the UI layer, we will use Jetpack Compose to display the list of cryptocurrency prices.</p><pre>@Composable<br>fun HomeScreen(interactionsEvent: (InteractionsEvent) -&gt; Unit = {}) {<br>    val viewModel: HomeScreenViewModel = viewModel(<br>            factory = HomeScreenViewModelFactory(LocalContext.current)<br>    )<br>    val listScrollState = rememberLazyListState()<br>    val pagingItems = viewModel.getAllCryptos().collectAsLazyPagingItems()<br>    val cryptos = viewModel.cryptoLiveData.observeAsState(emptyList())<br>    Scaffold { paddingValue -&gt;<br>        Column(modifier = Modifier<br>                .fillMaxSize()<br>                .padding(paddingValue)) {<br>            Header()<br>            CryptoList(pagingItems = pagingItems, cryptos = cryptos.value,<br>                    listScrollState = listScrollState, interactionsEvent)<br>        }<br>    }<br>}</pre><h3>Displaying Price Trends using Custom Line Chart</h3><p>To display the price trends, we will be using custom Composable functions: LineChart. This will take a list of data points and render them as a chart.</p><p>Here’s the code for LineChart:</p><pre>@Composable<br>fun LineChart(modifier: Modifier = Modifier,<br>              lineColors: List&lt;Color&gt; = listOf(MaterialTheme.colors.primary,<br>                      MaterialTheme.colors.primary),<br>              lineWidth: Float = 4f,<br>              yAxis: List&lt;Float&gt;,<br>              shouldAnimate: Boolean = true,<br>              shouldDrawLiveDot: Boolean = true,<br>              animationKey: Any? = Unit,<br>              customXTarget: Int = 0) {<br>    val x = remember {<br>        Animatable(0f)<br>    }<br>    // To determine the x-bounds of the chart and to calculate the horizontal scaling factor for the chart.<br>    val xTarget = if (customXTarget &gt; 0) customXTarget.toFloat() else (yAxis.size - 1).toFloat()<br>    LaunchedEffect(animationKey) {<br>        x.animateTo(targetValue = xTarget,<br>                animationSpec = tween(durationMillis = if (shouldAnimate) 500 else 0,<br>                        easing = LinearEasing))<br>    }<br>    val infiniteTransition = rememberInfiniteTransition()<br>    // This is used to control the size of the live dot that is drawn on the chart.<br>    val radius by infiniteTransition.animateFloat(initialValue = 7f, targetValue = 15f,<br>            animationSpec = infiniteRepeatable(<br>                    animation = tween(500, easing = LinearEasing),<br>                    repeatMode = RepeatMode.Reverse<br>            ))<br><br>    // This is used to control the opacity of the live dot that is drawn on the chart.<br>    val opacity by infiniteTransition.animateFloat(initialValue = 0.7f, targetValue = 1f,<br>            animationSpec = infiniteRepeatable(animation = tween(500, easing = LinearEasing),<br>                    repeatMode = RepeatMode.Reverse))<br><br>    Canvas(modifier = modifier.padding(8.dp)) {<br>        val path = Path()<br>        val xBounds = Pair(0f, xTarget)<br>        val yBounds = getBounds(yAxis)<br><br>        // Scaling factor to map the x-axis values of the chart data to the width of the canvas.<br>        val scaleX = size.width / (xBounds.second - xBounds.first)<br>        // Scaling factor to map the y-axis values of the chart data to the height of the canvas.<br>        val scaleY = size.height / (yBounds.second - yBounds.first)<br>        // Amount to translate the y-coordinates of the chart data to account for the height of the canvas<br>        val yMove = yBounds.first * scaleY<br>        // The range of x-axis values to include in the chart<br>        val interval = (0..min(yAxis.size - 1, x .value.toInt()))<br>        // The last x-axis value in the interval range.<br>        val last = interval.last()<br><br>        interval.forEach { value -&gt;<br>            val xPoint = value * scaleX<br>            val yPoint = size.height - (yAxis[value] * scaleY) + yMove<br>            if (value == 0) {<br>                path.moveTo(0f, yPoint)<br>                return@forEach<br>            }<br>            path.lineTo(xPoint, yPoint)<br>        }<br><br>        // Responsible for drawing the actual line chart on the canvas.<br>        drawPath(path = path, brush = Brush.linearGradient(lineColors),<br>                style = Stroke(width = lineWidth))<br>        if (shouldDrawLiveDot) {<br>            drawCircle(lineColors.first(), radius,<br>                    Offset(last * scaleX, size.height - (yAxis[last] * scaleY) + yMove), opacity)<br>        }<br>    }<br>}</pre><h3>Conclusion</h3><p>In this article, we have discussed how to build a cryptocurrency price tracker app using Jetpack Compose. We used Retrofit to fetch the data from an API, and created custom Composable functions to display price trends using line charts.</p><p><strong>Project Link:</strong></p><p><a href="https://github.com/shubhambhama/jetpack-compose-crypto">shubhambhama/jetpack-compose-crypto (github.com)</a></p><p>If you find it useful, please don’t forget to hit the 👏 button.</p><p>Happy Coding :) See you next time till then be you be happy.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e0d6857b50d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>