<?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 Mahitha Pasupuleti on Medium]]></title>
        <description><![CDATA[Stories by Mahitha Pasupuleti on Medium]]></description>
        <link>https://medium.com/@mahithapasupuleti?source=rss-7e42287127ee------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*d_qcCuESTgHIoeRUTs9Wrw.jpeg</url>
            <title>Stories by Mahitha Pasupuleti on Medium</title>
            <link>https://medium.com/@mahithapasupuleti?source=rss-7e42287127ee------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 03:28:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mahithapasupuleti/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[When a Microservice Grows Too Large: How We Applied SOA Internally]]></title>
            <link>https://medium.com/@mahithapasupuleti/when-a-microservice-grows-too-large-how-we-applied-soa-internally-fe3de5ac23ad?source=rss-7e42287127ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe3de5ac23ad</guid>
            <dc:creator><![CDATA[Mahitha Pasupuleti]]></dc:creator>
            <pubDate>Tue, 28 Oct 2025 18:45:31 GMT</pubDate>
            <atom:updated>2025-10-28T20:11:09.948Z</atom:updated>
            <content:encoded><![CDATA[<p>Microservices are supposed to be small, independent, and easy to maintain. But what happens when one of your microservices starts <strong>growing uncontrollably</strong>, handling multiple responsibilities, and becomes difficult to maintain? This is exactly what happened in one of our projects, and how we ended up <strong>applying Service-Oriented Architecture (SOA) principles inside a single microservice</strong> to regain control.</p><blockquote><strong><em>Note:</em></strong><em> The examples used in this article are </em><strong><em>simplified and illustrative</em></strong><em> for understanding purposes — they do not reflect the exact production system.</em></blockquote><h3>The Growing Microservice</h3><p>We had a payment microservice that started simple:</p><ul><li>Validate transactions</li><li>Persist transaction data</li></ul><p>Over time, more responsibilities were added:</p><ul><li>Fraud detection</li><li>Notifications (email, SMS, in-app)</li><li>Reporting and analytics</li><li>Handling complex payment workflows</li></ul><p>What was once a small, focused service became <strong>a large multi-module service</strong>, with tightly coupled code and interdependent modules. Deployments were risky, testing was cumbersome, and any small change could inadvertently break unrelated functionality.</p><p>We had reached a tipping point. The service was too big to manage as-is, but splitting it into multiple microservices immediately was not feasible due to infrastructure and timeline constraints.</p><h3>The Challenge</h3><p>We needed to:</p><ol><li><strong>Make the codebase maintainable</strong></li><li><strong>Decouple responsibilities</strong></li><li><strong>Enable easier testing and deployment</strong></li><li><strong>Prepare for future scaling and eventual microservice decomposition</strong></li></ol><p>Essentially, we needed <strong>modularity without breaking the existing system</strong>.</p><h3>The SOA-Inspired Solution</h3><p>We decided to apply <strong>SOA principles internally</strong>, treating the modules inside the microservice as mini-services.</p><h3>Step 1: Identify Service Modules</h3><p>We broke the monolith into logical modules with clear responsibilities:</p><ul><li>TransactionModule – Transaction validation and persistence</li><li>FraudModule – Risk scoring and fraud detection</li><li>NotificationModule – Sending notifications</li><li>ReportingModule – Aggregating data for dashboards</li></ul><p>Each module became a “service” with a single responsibility.</p><h3>Step 2: Define Interface Contracts</h3><p>Instead of letting modules call each other’s internal code directly, we created <strong>interfaces</strong> for communication.</p><pre>public interface FraudService {<br>    boolean checkFraud(Transaction txn);<br>}<br>public interface NotificationService {<br>    void sendNotification(Transaction txn);<br>}</pre><p>Modules communicated <strong>only through defined interfaces</strong>, reducing tight coupling and improving maintainability.</p><h3>Step 3: Introduce Internal Messaging</h3><p>To further decouple modules, we implemented <strong>event-driven communication</strong>:</p><ul><li>TransactionModule emits a TransactionCompleted event</li><li>NotificationModule consumes it and sends notifications</li><li>ReportingModule consumes it and updates dashboards</li></ul><p>Modules could now react independently to the same events, without knowing each other’s internal details.</p><h3>Step 4: Shared Utilities</h3><p>Cross-cutting concerns like logging, validation, and error handling were centralized into a <strong>Shared Utilities Module</strong> used by all service modules. This reduced duplication and maintained consistency across the microservice.</p><h3>The Outcome</h3><p>Applying SOA internally transformed the large microservice:</p><ul><li><strong>Looser Coupling:</strong> Modules could evolve independently without breaking others</li><li><strong>Improved Maintainability:</strong> Smaller, testable units made code easier to manage</li><li><strong>Reusability:</strong> Modules like FraudModule were later reused in other services</li><li><strong>Future Scalability:</strong> Preparing the microservice for gradual decomposition into independent microservices</li></ul><h3>Lessons Learned</h3><ol><li><strong>SOA principles help even inside a single microservice.</strong></li><li><strong>Defining clear interfaces is key.</strong> They act as contracts between modules.</li><li><strong>Internal events reduce module dependencies.</strong></li><li><strong>Shared utilities improve consistency across modules.</strong></li><li><strong>Modularity makes future scaling and refactoring smoother.</strong></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe3de5ac23ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Factory Design Pattern — When I used it]]></title>
            <link>https://medium.com/@mahithapasupuleti/factory-design-pattern-c9c5a18c9575?source=rss-7e42287127ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9c5a18c9575</guid>
            <dc:creator><![CDATA[Mahitha Pasupuleti]]></dc:creator>
            <pubDate>Tue, 28 Oct 2025 16:29:23 GMT</pubDate>
            <atom:updated>2025-10-28T16:57:58.674Z</atom:updated>
            <content:encoded><![CDATA[<h3>When to Use</h3><p>The <strong>Factory Design Pattern</strong> is useful when:</p><ul><li>You need to <strong>create objects dynamically</strong> based on input or configuration.</li><li>You want to <strong>decouple the client code from concrete implementations</strong>.</li><li>You have <strong>one family of related objects</strong> that share a common interface but differ in specific behavior.</li></ul><p>In short, use a <strong>Factory Pattern</strong> when your system needs flexibility in <strong>object creation</strong> and you want to <strong>avoid repetitive conditional logic</strong>.</p><h3>When It Made Sense</h3><p>I used the Factory Design Pattern in a <strong>backend service</strong> where we needed to support multiple types of transactions — for example:</p><ul><li><strong>Invoice</strong> — standard customer billing document</li><li><strong>Statement</strong> — summary of account activity</li><li><strong>Tax Report</strong> — detailed tax information</li></ul><p>Each document type had its <strong>own template and formatting rules</strong>, but the <strong>overall workflow was the same</strong>:<br> prepare → generate → save/export</p><p>Initially, the code relied on repetitive if-else blocks like:</p><pre>if (type.equals(&quot;INVOICE&quot;)) {<br>    // generate invoice<br>} else if (type.equals(&quot;STATEMENT&quot;)) {<br>    // generate statement<br>} else if (type.equals(&quot;TAX_REPORT&quot;)) {<br>    // generate tax report<br>}</pre><p>This made the system <strong>hard to maintain and extend</strong> whenever a new transaction type was introduced.</p><h3>How I Applied It</h3><p>To simplify and make the code maintainable, I implemented a <strong>Factory Pattern</strong>:</p><h4>Step 1: Define a common interface</h4><pre>public interface Document {<br>    void prepare();<br>    void generate();<br>    void save(String path);<br>}</pre><h4>Step 2: Implement concrete classes</h4><pre>public class Invoice implements Document {<br>    public void prepare() {<br>        System.out.println(&quot;Preparing Invoice template...&quot;);<br>    }<br>    public void generate() {<br>        System.out.println(&quot;Generating Invoice PDF...&quot;);<br>    }<br>    public void save(String path) {<br>        System.out.println(&quot;Saving Invoice to &quot; + path);<br>    }<br>}<br><br>public class Statement implements Document {<br>    public void prepare() {<br>        System.out.println(&quot;Preparing Statement template...&quot;);<br>    }<br>    public void generate() {<br>        System.out.println(&quot;Generating Statement PDF...&quot;);<br>    }<br>    public void save(String path) {<br>        System.out.println(&quot;Saving Statement to &quot; + path);<br>    }<br>}<br><br>public class TaxReport implements Document {<br>    public void prepare() {<br>        System.out.println(&quot;Preparing Tax Report template...&quot;);<br>    }<br>    public void generate() {<br>        System.out.println(&quot;Generating Tax Report PDF...&quot;);<br>    }<br>    public void save(String path) {<br>        System.out.println(&quot;Saving Tax Report to &quot; + path);<br>    }<br>}</pre><h4>Step 3: Create the Factory</h4><pre>public class DocumentFactory {<br>    public static Document getDocument(String type) {<br>        switch (type.toUpperCase()) {<br>            case &quot;INVOICE&quot;: return new Invoice();<br>            case &quot;STATEMENT&quot;: return new Statement();<br>            case &quot;TAX_REPORT&quot;: return new TaxReport();<br>            default: throw new IllegalArgumentException(&quot;Invalid document type&quot;);<br>        }<br>    }<br>}</pre><h4>Step 4: Use the factory in the service</h4><pre>public class DocumentService {<br>    public static void main(String[] args) {<br>        Document doc = DocumentFactory.getDocument(&quot;INVOICE&quot;);<br>        doc.prepare();<br>        doc.generate();<br>        doc.save(&quot;/documents/output.pdf&quot;);<br>    }<br>}</pre><h3>Benefits Observed</h3><ul><li>Removed repetitive conditional logic from the main service.</li><li>Made the system <strong>open for extension, closed for modification</strong> (OCP principle).</li><li>Simplified <strong>unit testing</strong> — we could mock individual transaction types independently.</li><li>Adding a new transaction type became as simple as creating a new class and updating the factory — no changes to existing service logic.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9c5a18c9575" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[️ Abstract Factory Design Pattern — When I Used It]]></title>
            <link>https://medium.com/@mahithapasupuleti/%EF%B8%8F-abstract-factory-design-pattern-when-i-used-it-b47fce33b570?source=rss-7e42287127ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/b47fce33b570</guid>
            <dc:creator><![CDATA[Mahitha Pasupuleti]]></dc:creator>
            <pubDate>Tue, 28 Oct 2025 16:06:56 GMT</pubDate>
            <atom:updated>2025-10-28T16:29:00.149Z</atom:updated>
            <content:encoded><![CDATA[<h3>🏗️ Abstract Factory Design Pattern — When I Used It</h3><h3>When to Use</h3><p>The <strong>Abstract Factory Pattern</strong> is useful when you need to create <strong>families of related objects</strong> that must work together, but without specifying their concrete classes in your main code.</p><p>You’d typically use it when:</p><ul><li>Your system needs to support <strong>multiple configurations or platforms</strong> (e.g., different APIs, UIs, or notification channels).</li><li>You want to <strong>enforce consistency</strong> among related objects (so that objects from one “family” are always used together).</li><li>You want to <strong>add new variants easily</strong> in the future, without modifying existing logic.</li></ul><h3>When It Made Sense</h3><p>I used the <strong>Abstract Factory Pattern</strong> in a project that involved <strong>integrating multiple external payment gateways</strong>.<br> Each gateway (for example, “Gateway A”, “Gateway B”, and “Gateway C”) required:</p><ul><li>A unique <strong>authentication handler</strong> (OAuth, API key, etc.)</li><li>A specific <strong>payment processor</strong> (different payload structures)</li><li>A custom <strong>notification mechanism</strong> (email, webhook, or callback)</li></ul><p>However, the core system had to stay independent of any single gateway — meaning the main business logic shouldn’t need to know which gateway was being used.</p><h3>How I Applied It</h3><p>I designed an <strong>abstract factory layer</strong> to encapsulate the creation of these related components for each gateway.</p><h4>Step 1: Define abstract products</h4><pre>interface AuthHandler {<br>    void authenticate();<br>}</pre><pre>interface PaymentProcessor {<br>    void processPayment(double amount);<br>}<br>interface Notifier {<br>    void sendNotification(String message);<br>}</pre><h4>Step 2: Define the Abstract Factory</h4><pre>interface PaymentGatewayFactory {<br>    AuthHandler createAuthHandler();<br>    PaymentProcessor createPaymentProcessor();<br>    Notifier createNotifier();<br>}</pre><h4>Step 3: Implement concrete factories for each gateway</h4><pre>class GatewayAFactory implements PaymentGatewayFactory {<br>    public AuthHandler createAuthHandler() { return new OAuthHandler(); }<br>    public PaymentProcessor createPaymentProcessor() { return new GatewayAPaymentProcessor(); }<br>    public Notifier createNotifier() { return new EmailNotifier(); }<br>}</pre><pre>class GatewayBFactory implements PaymentGatewayFactory {<br>    public AuthHandler createAuthHandler() { return new ApiKeyHandler(); }<br>    public PaymentProcessor createPaymentProcessor() { return new GatewayBPaymentProcessor(); }<br>    public Notifier createNotifier() { return new WebhookNotifier(); }<br>}</pre><h4>Step 4: Use in client code</h4><pre>public class PaymentService {<br>    private final PaymentGatewayFactory factory;</pre><pre>public PaymentService(PaymentGatewayFactory factory) {<br>        this.factory = factory;<br>    }<br>    public void execute(double amount) {<br>        factory.createAuthHandler().authenticate();<br>        factory.createPaymentProcessor().processPayment(amount);<br>        factory.createNotifier().sendNotification(&quot;Payment successful&quot;);<br>    }<br>}</pre><h4>Step 5: Switch gateways easily</h4><pre>public static void main(String[] args) {<br>    PaymentGatewayFactory factory = new GatewayAFactory();<br>    PaymentService service = new PaymentService(factory);<br>    service.execute(250.00);<br>}</pre><h3>Why This Worked</h3><ul><li>Allowed easy switching between gateways — <strong>no code modification</strong>, just factory substitution.</li><li>Simplified testing — mock entire gateway families.</li><li>Ensured <strong>consistency</strong> across related objects (each gateway’s handler/processor/notifier came from the same factory).</li></ul><h3>Key Benefit</h3><p>This approach provided a <strong>plug-and-play architecture</strong> for onboarding new payment partners — reducing integration time and preventing tight coupling with any vendor-specific implementation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b47fce33b570" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How a Simple BFS Made Me Think About Uber’s Matching System]]></title>
            <link>https://medium.com/@mahithapasupuleti/how-a-simple-bfs-made-me-think-about-ubers-matching-system-961bb1ac5ced?source=rss-7e42287127ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/961bb1ac5ced</guid>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[datastrucutre]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[uber]]></category>
            <dc:creator><![CDATA[Mahitha Pasupuleti]]></dc:creator>
            <pubDate>Wed, 24 Sep 2025 03:18:42 GMT</pubDate>
            <atom:updated>2025-09-24T03:18:42.881Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2kQIqKuTLkqqcLsu3JSzig.jpeg" /></figure><p>I’ve been learning data structures and algorithms, and something clicked: the concepts we practice in class sometimes resemble real-world systems — not exactly the same, but conceptually similar. One example that struck me is Uber’s driver matching problem.</p><h3>The Spark: Uber’s H3 Library</h3><p>I came across <strong>H3</strong>, a library that Uber open-sourced. It divides the Earth into hexagonal grids.</p><ul><li>Every location (rider, driver, restaurant, etc.) can be mapped to one of these hexagons.</li><li>Nearby hexagons are easy to calculate, which makes searching faster.</li></ul><p>When I saw this, my brain immediately went: <em>“Wait — that feels like a graph problem.”</em></p><h3>My Graph Lens</h3><p>In algorithms, a <strong>Breadth-First Search (BFS)</strong> explores neighbors level by level.</p><p>Now imagine this applied to a rider request:</p><ol><li>Start at the rider’s hexagon.</li><li>If no driver is inside, look at the neighboring hexagons.</li><li>If still empty, expand outward to the next ring of hexagons.</li><li>Keep going until a driver is found.</li></ol><p>That’s basically BFS on a grid!</p><p>At first glance, this feels like a neat analogy. But the more I thought about it, the more I realized why it isn’t that simple in reality.</p><h3>🚦 Why Real Uber Matching Is More Complex</h3><p>Of course, I know this isn’t how Uber actually does it in production.</p><ul><li><strong>Nearest ≠ Best</strong>: Just because a driver is the closest by distance doesn’t mean they’re the best choice. Maybe they’re on a one-way street, maybe they just declined a trip, or maybe another driver would result in a faster ETA.</li><li><strong>Multiple Riders &amp; Drivers</strong>: At any given second, Uber has to consider <em>millions</em> of riders and drivers. It’s not a one-to-one BFS search — it’s a global optimization problem.</li><li><strong>Scalability</strong>: A simple BFS expanding cell by cell for every rider would quickly overload the system. Uber needs specialized spatial indexes, batching techniques, and marketplace algorithms to make this efficient.</li></ul><p>Still, just noticing that a real-world problem resembles BFS gave me a new way to connect theory with practice.</p><pre>class Solution {<br>    class Cell {<br>        int x, y;<br>        Cell(int x, int y) { this.x = x; this.y = y; }<br>    }<br><br>    int bfsNearestDriver(Cell rider) {<br>        Queue&lt;Cell&gt; queue = new LinkedList&lt;&gt;();<br>        Set&lt;String&gt; visited = new HashSet&lt;&gt;();<br><br>        queue.add(rider);<br>        visited.add(rider.x + &quot;,&quot; + rider.y);<br><br>        int distance = 0;<br><br>        while (!queue.isEmpty()) {<br>            int size = queue.size();<br>            for (int i = 0; i &lt; size; i++) {<br>                Cell current = queue.poll();<br><br>                // Conceptual check: if current cell has a driver<br>                if (hasDriver(current)) {<br>                    return distance;<br>                }<br><br>                // Explore neighboring cells (4 directions example)<br>                for (int[] dir : new int[][] { {1,0}, {-1,0}, {0,1}, {0,-1} }) {<br>                    Cell next = new Cell(current.x + dir[0], current.y + dir[1]);<br>                    String key = next.x + &quot;,&quot; + next.y;<br>                    if (!visited.contains(key)) {<br>                        visited.add(key);<br>                        queue.add(next);<br>                    }<br>                }<br>            }<br>            distance++;<br>        }<br><br>        return -1; // no driver found<br>    }<br><br>    // Abstract function to represent driver presence<br>    boolean hasDriver(Cell c) {<br>        // In a real scenario, check if a driver exists in this cell<br>        return false;<br>    }<br>}</pre><h3>Why This Felt Cool</h3><ul><li><strong>Algorithms don’t just live on paper.</strong> Once you see BFS in a grid, you start spotting it everywhere.</li><li><strong>Abstractions help us think.</strong> Even if Uber’s real system is different, imagining it as BFS on hexagons made the idea approachable.</li><li><strong>It’s a learning mindset.</strong> The point wasn’t accuracy, but curiosity — asking <em>“what if?”</em></li></ul><h3>Takeaway</h3><p>So no, Uber doesn’t literally run BFS on a giant hex grid. But for me, seeing it that way made algorithms click in a more practical way. And that’s the fun part of learning: once you have the concepts, you start finding echoes of them in the systems you use every day.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=961bb1ac5ced" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Double Payments: A Childhood Experience and How Stripe Solved It]]></title>
            <link>https://medium.com/@mahithapasupuleti/double-payments-a-childhood-experience-and-how-stripe-solved-it-dbb74df0d4c4?source=rss-7e42287127ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/dbb74df0d4c4</guid>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[fintech]]></category>
            <dc:creator><![CDATA[Mahitha Pasupuleti]]></dc:creator>
            <pubDate>Thu, 21 Aug 2025 03:03:35 GMT</pubDate>
            <atom:updated>2025-08-21T03:03:35.441Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h8EH81phEWq9mVL1A554Ww.jpeg" /></figure><p>Several years ago, I faced my first “double payment” situation, a problem that many of us have likely encountered without realizing it. <strong>Double Payments: A Childhood Experience and How Stripe Solved It </strong>why it happens. I was making a payment online and wasn’t sure if it had gone through.</p><p>This uncertainty leads to two frustrating scenarios:</p><ol><li>The payment request shows “transaction failed,” so I try paying again, only to find out later that the first payment actually succeeded.</li><li>The request keeps loading for a long time, so I cancel it and try again, resulting in two charges for the same item.</li></ol><p>At the time, I had no idea why this happened. It seemed like bad luck. But recently, I came across a ByteByteGo article that explained how modern payment systems, like Stripe, elegantly solve this problem using <strong>idempotency keys</strong>.</p><h3>Why Double Payments Happen</h3><p>Double payments are often caused by <strong>network delays, client-side timeouts, or payment gateway retries</strong>. At a system level, it looks like this:</p><pre>User -&gt; Payment Request -&gt; Network delay -&gt; Timeout response<br>User retries -&gt; Payment Request -&gt; Processed twice</pre><p>Without safeguards, multiple retries can lead to the user being charged multiple times for the same transaction.</p><h3>How Stripe Solves It</h3><p>Stripe uses <strong>idempotency keys</strong> to ensure that even if a user retries a payment, <strong>only one request is processed</strong>.</p><ul><li>Each transaction gets a <strong>unique UUID</strong> as its idempotency key.</li><li>This key is included in the API request.</li><li>If the same key is sent again (due to retries or timeouts), Stripe recognizes it and ignores duplicate requests.</li></ul><p><strong>Example (Python):</strong></p><pre>import stripe<br>stripe.api_key = &quot;sk_test_...&quot;<br><br>stripe.PaymentIntent.create(<br>  amount=1000,<br>  currency=&quot;usd&quot;,<br>  payment_method_types=[&quot;card&quot;],<br>  idempotency_key=&quot;unique-transaction-uuid&quot;<br>)</pre><p>Even if the user clicks “Pay” multiple times, only <strong>one payment</strong> is processed.</p><h3>Other Approaches and Why They Fail</h3><p>Before idempotency keys, some systems tried:</p><ul><li><strong>Manual reconciliation</strong> by finance teams.</li><li><strong>Duplicate detection</strong> using timestamps, amounts, and user IDs.</li></ul><p>These methods are less reliable because network conditions and user behavior are unpredictable. Stripe’s approach ensures <strong>reliability at scale</strong>.</p><h3>Real-World Examples</h3><p>Many modern payment platforms now use idempotency or similar mechanisms:</p><ul><li><strong>PayPal</strong>: Ensures only one capture per authorization.</li><li><strong>Square</strong>: Uses idempotency keys for payment retries.</li><li><strong>Shopify</strong>: Prevents duplicate charges on checkout retries.</li></ul><p>Imagine buying concert tickets online. Network lags, you refresh, and click “Pay” again. Without idempotency, you could be charged twice. With it, only <strong>one payment goes through</strong>, saving users and businesses from headaches.</p><h3>Lessons Learned</h3><ul><li><strong>For developers</strong>: Always design APIs to handle retries safely. Idempotency isn’t just for payments. It’s useful wherever network requests can fail.</li><li><strong>For users</strong>: Double charges are often not a mistake but a network/system issue. Modern platforms are built to prevent this.</li></ul><p>Reflecting on my childhood experience, I finally understand how what seemed like “bad luck” was actually a <strong>classic problem solved elegantly by modern engineering</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dbb74df0d4c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[REST, GraphQL, and gRPC: Choosing the Right API Style]]></title>
            <link>https://medium.com/@mahithapasupuleti/rest-graphql-and-grpc-choosing-the-right-api-style-2f029795f756?source=rss-7e42287127ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f029795f756</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Mahitha Pasupuleti]]></dc:creator>
            <pubDate>Mon, 04 Aug 2025 03:09:03 GMT</pubDate>
            <atom:updated>2025-08-04T03:09:03.483Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TuoCII7cmdSxi2rz7xzzCQ.png" /></figure><p>As a backend developer, one of the first decisions I often face when building or designing systems is: <strong>How should services communicate?</strong> REST is the default for many teams, GraphQL is gaining popularity fast, and gRPC is quietly powering high-performance systems behind the scenes.</p><p>Each one brings something valuable to the table, but the key is knowing when and where to use them.</p><h3>HTTP: The Common Denominator</h3><p>All three styles rely on HTTP as the foundation. REST and GraphQL typically use HTTP/1.1, while gRPC uses HTTP/2 to enable multiplexing, streaming, and more efficient connections.</p><p>Understanding HTTP helps make sense of the trade-offs in each API style — especially when it comes to things like caching, performance, and protocol semantics.</p><h3>REST: Reliable and Familiar</h3><p>REST is arguably the most widely used API style today. It’s resource-based, meaning each URL points to a resource, and actions are defined using HTTP verbs like GET, POST, PUT, and DELETE.</p><p>Typical REST endpoint:</p><pre>GET /users/42</pre><p><strong>Where REST works well:</strong></p><ol><li>CRUD-based systems</li><li>Public-facing APIs</li><li>Simpler client-server interactions</li><li>When caching is important</li></ol><p><strong>Where it struggles:</strong></p><ol><li>Fetching nested or related data</li><li>Requiring multiple requests to populate a single page</li><li>Versioning over time (e.g., /v1/, /v2/)</li></ol><h3>GraphQL: Flexible and Frontend-Oriented</h3><p>GraphQL is a query language for APIs that allows clients to request exactly the data they need — nothing more, nothing less. It replaces multiple endpoints with a single one and shifts more control to the client.</p><p>Example query:</p><pre>query {<br>  user(id: &quot;42&quot;) {<br>    name<br>    posts {<br>      title<br>    }<br>  }<br>}</pre><p>This returns a user’s name and a list of their post titles, all in one request.</p><p><strong>Strengths of GraphQL:</strong></p><ol><li>Ideal when frontend teams need control over data shape</li><li>Eliminates over-fetching and under-fetching</li><li>Versioning becomes less of an issue</li><li>Strongly typed schema with introspection</li></ol><p><strong>Challenges with GraphQL:</strong></p><ol><li>Caching is harder compared to REST</li><li>Complex queries can impact performance</li><li>Access control and rate limiting require more thought</li><li>Learning curve is higher for backend teams used to REST</li></ol><h3>gRPC: Fast, Compact, and Service-to-Service Friendly</h3><p>gRPC is a high-performance, open-source framework developed by Google. It uses Protocol Buffers (a compact binary format) and HTTP/2 for transport, enabling fast communication between systems.</p><p>Instead of REST-style URLs or flexible queries, gRPC uses .proto files to define services and data contracts, and then auto-generates client and server code.</p><p>Example .proto definition:</p><pre>service UserService {<br>  rpc GetUser(UserRequest) returns (UserResponse);<br>}</pre><p><strong>Why gRPC is a good fit:</strong></p><ol><li>Internal communication in microservice architectures</li><li>Strong typing and contract enforcement across teams</li><li>Streaming support for real-time data exchange</li><li>Smaller payloads and faster performance than REST/GraphQL</li></ol><p><strong>Downsides to consider:</strong></p><ol><li>Not human-readable (you’ll need tooling to inspect messages)</li><li>Less browser support (gRPC-Web is needed)</li><li>Debugging is harder without the right setup</li></ol><h3>How I Decide What to Use</h3><p>There’s no one-size-fits-all answer, but here’s how I typically approach the decision:</p><p><strong>Use REST when:</strong></p><ol><li>The API is publicly exposed</li><li>Simplicity and readability matter</li><li>You need solid HTTP caching support</li></ol><p><strong>Use GraphQL when:</strong></p><ol><li>The frontend is data-hungry and frequently changing</li><li>You want clients to drive what data is returned</li><li>You’re building a backend-for-frontend layer</li></ol><p><strong>Use gRPC when:</strong></p><ol><li>Services need to talk to each other efficiently</li><li>Performance and bandwidth are critical</li><li>You’re building a highly structured, typed system</li></ol><h3>Final Thoughts</h3><p>There was a time I thought one of these styles would win and the rest would disappear. But the reality is: most systems today use a mix. REST works great for exposing data to external consumers. GraphQL is powerful for aggregating and shaping complex data. gRPC shines in low-latency, high-throughput internal systems.</p><p>Choosing the right one is less about trends and more about knowing what trade-offs your system can afford.</p><p>If you’ve built something using one or more of these approaches, I’d love to hear how you made your decisions and what you learned in the process.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f029795f756" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>