<?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 Pasindu on Medium]]></title>
        <description><![CDATA[Stories by Pasindu on Medium]]></description>
        <link>https://medium.com/@pasiya10975?source=rss-40265f64ffc0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3S8VRxweiTEwTAU8</url>
            <title>Stories by Pasindu on Medium</title>
            <link>https://medium.com/@pasiya10975?source=rss-40265f64ffc0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 14:51:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pasiya10975/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[Java ArrayList Explained Visually — with Coffee Cups ☕]]></title>
            <link>https://medium.com/@pasiya10975/java-arraylist-explained-visually-with-coffee-cups-bbd61f40c1fd?source=rss-40265f64ffc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbd61f40c1fd</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[java-arraylist]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Pasindu]]></dc:creator>
            <pubDate>Sun, 25 Oct 2026 16:28:05 GMT</pubDate>
            <atom:updated>2026-10-25T16:28:05.513Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine a tray of coffee cups. Each cup represents a value, and its position represents an index.</p><p>That’s the idea behind this visual introduction to Java’s ArrayList.</p><p>An ArrayList stores elements in order and can grow or shrink as you add or remove them. Its indexes start at 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hTXHRA1oZNrv7PhmliNoRg.png" /></figure><h3>Read the picture, then try the code</h3><p>The illustration shows eight common operations. Each row is an independent example: read the cups on the left, apply the code, then look at the result on the right.</p><p>Here is a runnable example that demonstrates the same operations:</p><pre>import java.util.ArrayList;<br>import java.util.Arrays;</pre><pre>public class Main {<br>    public static void main(String[] args) {<br>        ArrayList&lt;Integer&gt; list =<br>                new ArrayList&lt;&gt;(Arrays.asList(10, 20));</pre><pre>        list.add(30);<br>        System.out.println(list); // [10, 20, 30]</pre><pre>        list.add(1, 30);<br>        System.out.println(list); // [10, 30, 20, 30]</pre><pre>        System.out.println(list.get(1)); // 30</pre><pre>        list.set(1, 99);<br>        System.out.println(list); // [10, 99, 20, 30]</pre><pre>        list.remove(1);<br>        System.out.println(list); // [10, 20, 30]</pre><pre>        System.out.println(list.contains(20)); // true<br>        System.out.println(list.size());       // 3</pre><pre>        list.clear();<br>        System.out.println(list); // []<br>    }<br>}</pre><p>Unlike the separate rows in the picture, this code runs sequentially: each operation uses the list left by the previous operation.</p><h3>One detail that can catch beginners</h3><p>With an ArrayList&lt;Integer&gt;, these calls have different meanings:</p><pre>list.remove(1);                  // Removes the second element<br>list.remove(Integer.valueOf(20)); // Removes the first matching value 20</pre><p>The first call uses an index. The second uses an object value.</p><p>Also, get() reads an element without removing it, while set() replaces an element without changing the list’s size.</p><p>This is the first post in “Code in Pictures,” a series exploring programming concepts through visual examples.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbd61f40c1fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Built a Production-Grade Spring Boot Backend with Design Patterns, Redis, RabbitMQ, and AWS]]></title>
            <link>https://medium.com/@pasiya10975/how-i-built-a-production-grade-spring-boot-backend-with-design-patterns-redis-rabbitmq-and-aws-84f8edd295e9?source=rss-40265f64ffc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/84f8edd295e9</guid>
            <category><![CDATA[java-dsa]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Pasindu]]></dc:creator>
            <pubDate>Sun, 12 Jul 2026 17:41:16 GMT</pubDate>
            <atom:updated>2026-07-12T17:41:16.571Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A practical walkthrough of building a real-world order processing system — from clean architecture to cloud deployment</em></p><h3>Why I Built This</h3><p>Most Spring Boot tutorials teach you how to build a basic CRUD app. Controller → Service → Repository → done.</p><p>But real production systems are different. They use design patterns to handle complexity, async messaging so users aren’t kept waiting, caching to reduce database load, and cloud infrastructure to run reliably at scale.</p><p>So I set out to build something that reflects all of that — a <strong>Smart Order Processing &amp; Notification Engine</strong> that I could point to in interviews and say: <em>“Here’s exactly how I’d approach a real backend system.”</em></p><p>In this post, I’ll walk you through what I built, the decisions I made, and what I learned along the way.</p><h3>The Project — What It Does</h3><p>At its core, the system processes customer orders. But the interesting part is <em>how</em> it does it:</p><ul><li>A customer places an order via REST API</li><li>The right payment method is selected automatically at runtime</li><li>All interested parties (email service, inventory system) are notified automatically on status changes</li><li>Notifications are sent asynchronously via a message queue — the customer gets their response instantly, not after waiting for emails to send</li><li>Frequently accessed orders are served from cache, not the database</li><li>VIP orders jump to the front of the processing queue</li><li>Repeat order spam is blocked by a rate limiter</li></ul><p>Let me show you how each of these works.</p><h3>The Architecture — Clean Layers</h3><p>Before writing a single line of code, I set up a clean architecture with four layers:</p><pre>domain/          → Pure business objects. No Spring, no JPA. Just Java.<br>application/     → Business logic and use cases.<br>infrastructure/  → Technical details: DB, Redis, RabbitMQ.<br>interfaces/      → REST controllers that talk to the outside world.</pre><p>The key rule: <strong>inner layers never depend on outer layers.</strong> The domain knows nothing about Spring. The service knows nothing about JPA. This is what makes the system flexible and testable.</p><h3>Design Pattern #1 — Builder (Order Creation)</h3><p>Creating an order has many fields. Without a Builder, you’d write:</p><pre>new Order(&quot;Pasindu&quot;, &quot;Laptop&quot;, 2, 150000.0, &quot;Colombo&quot;, 3, CREDIT_CARD);</pre><p>Which field is which? Easy to mix up. With Builder:</p><pre>Order order = new Order.Builder()<br>    .customerName(&quot;Pasindu&quot;)<br>    .productName(&quot;Laptop&quot;)<br>    .quantity(2)<br>    .totalPrice(150000.0)<br>    .priority(3)<br>    .paymentType(CREDIT_CARD)<br>    .build();</pre><p>Crystal clear. Safe. Readable. The Builder also sets default values like status = PENDING and createdAt = now() automatically inside .build().</p><h3>Design Pattern #2 — Strategy (Payment)</h3><p>Different customers pay differently. Without Strategy, you’d write:</p><pre>if (type == &quot;CREDIT_CARD&quot;) { ... }<br>else if (type == &quot;PAYPAL&quot;) { ... }<br>else if (type == &quot;COD&quot;) { ... }</pre><p>Every time you add a new payment method, you edit this block. Risky. Error-prone.</p><p>With Strategy Pattern, each payment method is its own class:</p><pre>public class CreditCardPaymentStrategy implements PaymentStrategy {<br>    public boolean pay(double amount) {<br>        // credit card logic<br>        return true;<br>    }<br>}</pre><p>A PaymentContext holds all strategies in a map and picks the right one at runtime:</p><pre>paymentContext.executePayment(&quot;CREDIT_CARD&quot;, 150000.0);</pre><p>Adding PayPal tomorrow? Just add one class. Nothing else changes. That’s <strong>SOLID Open/Closed Principle</strong> in action.</p><h3>Design Pattern #3 — Observer (Order Events)</h3><p>When an order status changes, multiple things need to happen: send an email, update inventory, maybe notify a warehouse. Without Observer, the service would call each one directly:</p><pre>emailService.send(...);<br>inventoryService.update(...);<br>warehouseService.notify(...);</pre><p>Now your service knows about all of these. Every new requirement means editing the service. That’s tight coupling.</p><p>With Observer Pattern:</p><pre>eventPublisher.notifyStatusChange(order, OrderStatus.CONFIRMED);</pre><p>The publisher loops through all registered observers and calls each one. The service doesn’t know who they are. Adding SMS notifications tomorrow? Create SmsObserver, Spring picks it up automatically. Service stays untouched.</p><h3>Design Pattern #4 — Factory (Notifications)</h3><p>Notifications arrive via RabbitMQ with a type field: &quot;EMAIL&quot;, &quot;SMS&quot;, &quot;PUSH&quot;. The Factory Pattern selects the right sender:</p><pre>NotificationSender sender = notificationFactory.getSender(message.getType());<br>sender.send(recipient, messageText);</pre><p>Behind the scenes, all NotificationSender implementations are stored in a map. No if-else. No switch. Just lookup and go.</p><h3>SOLID — Where It Actually Lives</h3><p>The most powerful SOLID application here is <strong>Dependency Inversion (D)</strong>. The OrderService never touches JPA directly:</p><pre>private final OrderRepositoryPort orderRepository; // an interface</pre><p>Spring injects a JpaOrderRepositoryAdapter that implements this interface. The service never knows. Want to switch from PostgreSQL to MongoDB? Write a MongoOrderRepositoryAdapter. The service is completely unchanged. That&#39;s the whole point.</p><h3>Redis Caching — Simple But Powerful</h3><p>Getting an order is a frequent read operation. Without caching, every request hits the database. With @Cacheable:</p><pre>@Cacheable(value = &quot;orders&quot;, key = &quot;#id&quot;)<br>public Order getOrderById(Long id) {<br>    return orderRepository.findById(id)...;<br>}</pre><p>First call: hits the database, stores in Redis. Second call: returns from Redis in microseconds. Database never touched.</p><p>When an order is updated or deleted, @CacheEvict removes the stale entry automatically.</p><h3>RabbitMQ — Why Async Matters</h3><p>Here’s the scenario without RabbitMQ:</p><ol><li>Customer places order</li><li>System saves to DB (1ms)</li><li>System sends email (3000ms — email servers are slow)</li><li>Response returned to customer after 3 seconds</li></ol><p>That’s a terrible experience. With RabbitMQ:</p><ol><li>Customer places order</li><li>System saves to DB (1ms)</li><li>System drops a message in the queue (1ms)</li><li>Response returned immediately ✅</li></ol><p>The email gets sent in the background by a consumer on a separate thread. The customer never waits. This is the fundamental idea behind async messaging — decouple the action from the side effect.</p><h3>DSA — In Real Production Code</h3><p>Two data structures appear naturally in this system:</p><p><strong>Priority Queue</strong> — VIP orders should jump ahead of normal ones. Java’s PriorityQueue handles this natively since Order implements Comparable. O(log n) insert, O(log n) remove, always returns the highest priority first.</p><p><strong>Sliding Window Rate Limiter</strong> — Customers are limited to 5 orders per 60 seconds. A Deque&lt;Long&gt; stores timestamps. For each request, old timestamps outside the window are removed, and the current count is checked. This runs in O(1) amortized time and is thread-safe with ConcurrentHashMap.</p><h3>AWS Deployment</h3><p>For production, the app runs on:</p><ul><li><strong>AWS EC2</strong> — hosts the Spring Boot app, Redis, and RabbitMQ via Docker Compose</li><li><strong>AWS RDS</strong> — managed PostgreSQL (no maintenance overhead)</li><li><strong>AWS ECR</strong> — stores the Docker image</li></ul><p>Deploying is a two-step process:</p><pre># Build and push image<br>docker build -t orderengine .<br>docker push &lt;account&gt;.dkr.ecr.ap-south-1.amazonaws.com/orderengine:latest</pre><pre># On EC2 — pull and run<br>docker-compose -f docker-compose.prod.yml pull<br>docker-compose -f docker-compose.prod.yml up -d</pre><p>The app is live, accessible via the EC2 public IP, connected to a managed database, and can be updated by pushing a new Docker image.</p><h3>What I Learned</h3><p><strong>1. Design patterns solve real problems.</strong> I understood this academically before. Now I feel it. When I add a new payment method without touching the service, that’s Strategy Pattern doing its job.</p><p><strong>2. Async is the right default for side effects.</strong> Any operation that isn’t directly related to the user’s request — emails, SMS, analytics — should be async. RabbitMQ makes this clean and reliable.</p><p><strong>3. Architecture decisions compound.</strong> Because I set up the Port/Adapter pattern early, switching from H2 to PostgreSQL for production was effortless. Good structure pays dividends later.</p><p><strong>4. Docker makes everything reproducible.</strong> The same docker-compose.yml that runs locally runs in production. No environment surprises.</p><h3>Final Thoughts</h3><p>If you’re a backend developer preparing for interviews or wanting to level up — build something like this. Cover:</p><ul><li>Design patterns (Builder, Strategy, Observer, Factory)</li><li>Clean Architecture + SOLID</li><li>Caching with Redis</li><li>Async messaging with RabbitMQ</li><li>DSA in real code (not just LeetCode)</li><li>Docker + cloud deployment</li></ul><p>You’ll have something real to talk about in every interview.</p><p>🔗 Full source code on GitHub: [your-github-link-here]</p><p><em>Pasindu — 4th Year IT Undergraduate, University of Moratuwa, Sri Lanka</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f3zIPQaXlLK6tfaMeL2zFw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*igHCu8SFBOzEN-wDTtpCSw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z4GKsaYw5HKfhbAifEIUxg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CY3wQi-VLIvjMsuzYdUWuw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8XJhcwed5TcnZTv6I_4ajg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*REA-Nl84wbFuC3SuOp5ysQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0-TjNGRwIR3JIUHl2HHQ0w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EVvcIus_-Yp6d6Qab9y4dQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HWpxSe0GhQGl8kS1s3S5qw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kALaBs2iXfVECoIfJNI3hg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*drc04pYzIZSlZOUrXymBGQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84f8edd295e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Built a Production-Grade Spring Boot Backend with Design Patterns, Redis, RabbitMQ, and AWS]]></title>
            <link>https://medium.com/@pasiya10975/how-i-built-a-production-grade-spring-boot-backend-with-design-patterns-redis-rabbitmq-and-aws-cebde9e0edfb?source=rss-40265f64ffc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/cebde9e0edfb</guid>
            <category><![CDATA[order-processing-system]]></category>
            <dc:creator><![CDATA[Pasindu]]></dc:creator>
            <pubDate>Wed, 27 May 2026 18:25:02 GMT</pubDate>
            <atom:updated>2026-05-27T18:25:02.392Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A practical walkthrough of building a real-world order processing system — from clean architecture to cloud deployment</em></p><h3>Why I Built This</h3><p>Most Spring Boot tutorials teach you how to build a basic CRUD app. Controller → Service → Repository → done.</p><p>But real production systems are different. They use design patterns to handle complexity, async messaging so users aren’t kept waiting, caching to reduce database load, and cloud infrastructure to run reliably at scale.</p><p>So I set out to build something that reflects all of that — a <strong>Smart Order Processing &amp; Notification Engine</strong> that I could point to in interviews and say: <em>“Here’s exactly how I’d approach a real backend system.”</em></p><p>In this post, I’ll walk you through what I built, the decisions I made, and what I learned along the way.</p><h3>The Project — What It Does</h3><p>At its core, the system processes customer orders. But the interesting part is <em>how</em> it does it:</p><ul><li>A customer places an order via the REST API</li><li>The right payment method is selected automatically at runtime</li><li>All interested parties (email service, inventory system) are notified automatically of status changes</li><li>Notifications are sent asynchronously via a message queue — the customer gets their response instantly, not after waiting for emails to send</li><li>Frequently accessed orders are served from cache, not the database</li><li>VIP orders jump to the front of the processing queue</li><li>Repeat order spam is blocked by a rate limiter</li></ul><p>Let me show you how each of these works.</p><h3>The Architecture — Clean Layers</h3><p>Before writing a single line of code, I set up a clean architecture with four layers:</p><pre>domain/          → Pure business objects. No Spring, no JPA. Just Java.<br>application/     → Business logic and use cases.<br>infrastructure/  → Technical details: DB, Redis, RabbitMQ.<br>interfaces/      → REST controllers that talk to the outside world.</pre><p>The key rule: <strong>inner layers never depend on outer layers.</strong> The domain knows nothing about Spring. The service knows nothing about JPA. This is what makes the system flexible and testable.</p><h3>Design Pattern #1 — Builder (Order Creation)</h3><p>Creating an order has many fields. Without a Builder, you’d write:</p><pre>new Order(&quot;Pasindu&quot;, &quot;Laptop&quot;, 2, 150000.0, &quot;Colombo&quot;, 3, CREDIT_CARD);</pre><p>Which field is which? Easy to mix up. With Builder:</p><pre>Order order = new Order.Builder()<br>    .customerName(&quot;Pasindu&quot;)<br>    .productName(&quot;Laptop&quot;)<br>    .quantity(2)<br>    .totalPrice(150000.0)<br>    .priority(3)<br>    .paymentType(CREDIT_CARD)<br>    .build();</pre><p>Crystal clear. Safe. Readable. The Builder also sets default values like status = PENDING and createdAt = now() automatically inside .build().</p><h3>Design Pattern #2 — Strategy (Payment)</h3><p>Different customers pay differently. Without Strategy, you’d write:</p><pre>if (type == &quot;CREDIT_CARD&quot;) { ... }<br>else if (type == &quot;PAYPAL&quot;) { ... }<br>else if (type == &quot;COD&quot;) { ... }</pre><p>Every time you add a new payment method, you edit this block. Risky. Error-prone.</p><p>With Strategy Pattern, each payment method is its own class:</p><pre>public class CreditCardPaymentStrategy implements PaymentStrategy {<br>    public boolean pay(double amount) {<br>        // credit card logic<br>        return true;<br>    }<br>}</pre><p>A PaymentContext holds all strategies in a map and picks the right one at runtime:</p><pre>paymentContext.executePayment(&quot;CREDIT_CARD&quot;, 150000.0);</pre><p>Adding PayPal tomorrow? Just add one class. Nothing else changes. That’s <strong>SOLID Open/Closed Principle</strong> in action.</p><h3>Design Pattern #3 — Observer (Order Events)</h3><p>When an order status changes, multiple things need to happen: send an email, update inventory, maybe notify a warehouse. Without Observer, the service would call each one directly:</p><pre>emailService.send(...);<br>inventoryService.update(...);<br>warehouseService.notify(...);</pre><p>Now your service knows about all of these. Every new requirement means editing the service. That’s tight coupling.</p><p>With Observer Pattern:</p><pre>eventPublisher.notifyStatusChange(order, OrderStatus.CONFIRMED);</pre><p>The publisher loops through all registered observers and calls each one. The service doesn’t know who they are. Adding SMS notifications tomorrow? Create SmsObserver, Spring picks it up automatically. Service stays untouched.</p><h3>Design Pattern #4 — Factory (Notifications)</h3><p>Notifications arrive via RabbitMQ with a type field: &quot;EMAIL&quot;, &quot;SMS&quot;, &quot;PUSH&quot;. The Factory Pattern selects the right sender:</p><pre>NotificationSender sender = notificationFactory.getSender(message.getType());<br>sender.send(recipient, messageText);</pre><p>Behind the scenes, all NotificationSender implementations are stored in a map. No if-else. No switch. Just lookup and go.</p><h3>SOLID — Where It Actually Lives</h3><p>The most powerful SOLID application here is <strong>Dependency Inversion (D)</strong>. The OrderService never touches JPA directly:</p><pre>private final OrderRepositoryPort orderRepository; // an interface</pre><p>Spring injects a JpaOrderRepositoryAdapter that implements this interface. The service never knows. Want to switch from PostgreSQL to MongoDB? Write a MongoOrderRepositoryAdapter. The service is completely unchanged. That&#39;s the whole point.</p><h3>Redis Caching — Simple But Powerful</h3><p>Getting an order is a frequent read operation. Without caching, every request hits the database. With @Cacheable:</p><pre>@Cacheable(value = &quot;orders&quot;, key = &quot;#id&quot;)<br>public Order getOrderById(Long id) {<br>    return orderRepository.findById(id)...;<br>}</pre><p>First call: hits the database, stores in Redis. Second call: returns from Redis in microseconds. Database never touched.</p><p>When an order is updated or deleted, @CacheEvict removes the stale entry automatically.</p><h3>RabbitMQ — Why Async Matters</h3><p>Here’s the scenario without RabbitMQ:</p><ol><li>Customer places order</li><li>System saves to DB (1ms)</li><li>System sends email (3000ms — email servers are slow)</li><li>Response returned to the customer after 3 seconds</li></ol><p>That’s a terrible experience. With RabbitMQ:</p><ol><li>Customer places order</li><li>System saves to DB (1ms)</li><li>System drops a message in the queue (1ms)</li><li>Response returned immediately ✅</li></ol><p>The email gets sent in the background by a consumer on a separate thread. The customer never waits. This is the fundamental idea behind async messaging — decouple the action from the side effect.</p><h3>DSA — In Real Production Code</h3><p>Two data structures appear naturally in this system:</p><p><strong>Priority Queue</strong> — VIP orders should jump ahead of normal ones. Java PriorityQueue handles this natively since it Order implements Comparable. O(log n) insert, O(log n) remove, always returns the highest priority first.</p><p><strong>Sliding Window Rate Limiter</strong> — Customers are limited to 5 orders per 60 seconds. A Deque&lt;Long&gt; stores timestamps. For each request, old timestamps outside the window are removed, and the current count is checked. This runs in O(1) amortised time and is thread-safe with ConcurrentHashMap.</p><h3>AWS Deployment</h3><p>For production, the app runs on:</p><ul><li><strong>AWS EC2</strong> — hosts the Spring Boot app, Redis, and RabbitMQ via Docker Compose</li><li><strong>AWS RDS</strong> — managed PostgreSQL (no maintenance overhead)</li><li><strong>AWS ECR</strong> — stores the Docker image</li></ul><p>Deploying is a two-step process:</p><pre># Build and push image<br>docker build -t orderengine .<br>docker push &lt;account&gt;.dkr.ecr.ap-south-1.amazonaws.com/orderengine:latest</pre><pre># On EC2 — pull and run<br>docker-compose -f docker-compose.prod.yml pull<br>docker-compose -f docker-compose.prod.yml up -d</pre><p>The app is live, accessible via the EC2 public IP, connected to a managed database, and can be updated by pushing a new Docker image.</p><h3>What I Learned</h3><p><strong>1. Design patterns solve real problems.</strong> I understood this academically before. Now I feel it. When I add a new payment method without touching the service, that’s Strategy Pattern doing its job.</p><p><strong>2. Async is the right default for side effects.</strong> Any operation that isn’t directly related to the user’s request — emails, SMS, analytics — should be async. RabbitMQ makes this clean and reliable.</p><p><strong>3. Architecture decisions compound.</strong> Because I set up the Port/Adapter pattern early, switching from H2 to PostgreSQL for production was effortless. Good structure pays dividends later.</p><p><strong>4. Docker makes everything reproducible.</strong> The same docker-compose.yml that runs locally runs in production. No environment surprises.</p><h3>Final Thoughts</h3><p>If you’re a backend developer preparing for interviews or wanting to level up, build something like this. Cover:</p><ul><li>Design patterns (Builder, Strategy, Observer, Factory)</li><li>Clean Architecture + SOLID</li><li>Caching with Redis</li><li>Async messaging with RabbitMQ</li><li>DSA in real code (not just LeetCode)</li><li>Docker + cloud deployment</li></ul><p>You’ll have something real to talk about in every interview.</p><p>🔗 Full source code on GitHub: [your-github-link-here]</p><p><em>Pasindu — 4th Year IT Undergraduate, University of Moratuwa, Sri Lanka</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cebde9e0edfb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Understanding gRPC Architecture Through a Patient Management System]]></title>
            <link>https://medium.com/@pasiya10975/understanding-grpc-architecture-through-a-patient-management-system-6944521ecbe5?source=rss-40265f64ffc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/6944521ecbe5</guid>
            <dc:creator><![CDATA[Pasindu]]></dc:creator>
            <pubDate>Sun, 05 Apr 2026 21:40:24 GMT</pubDate>
            <atom:updated>2026-04-05T21:40:24.876Z</atom:updated>
            <content:encoded><![CDATA[<p>When building modern microservices, communication between services becomes a critical challenge. While REST APIs are widely used, they can be slow and inefficient for internal communication.</p><p>This is where <strong>gRPC</strong> comes in.</p><p>In this article, I’ll explain gRPC architecture in a simple way using a real-world example: a <strong>Patient Management System</strong>.</p><h3>🧠 What is gRPC?</h3><p>gRPC is a high-performance communication framework developed by Google that allows services to talk to each other efficiently.</p><p>Unlike REST:</p><ul><li>It uses <strong>HTTP/2</strong></li><li>It sends data in <strong>binary format (Protocol Buffers)</strong></li><li>It is <strong>faster and more efficient</strong></li></ul><h3>🏗️ Project Overview</h3><p>In our system, we have two microservices:</p><ul><li>🧍 Patient Service → Manages patient data</li><li>💳 Billing Service → Handles billing accounts</li></ul><p>These services communicate using <strong>gRPC instead of REST APIs</strong>.</p><h3>📄 Step 1: Defining the Contract (.proto file)</h3><p>In gRPC, everything starts with a .proto file. This acts as a contract between services.</p><p>Here’s our Billing Service definition:</p><pre>syntax = &quot;proto3&quot;;</pre><pre>option java_multiple_files = true;<br>option java_package = &quot;billing&quot;;</pre><pre>service BillingService {<br>  rpc CreateBillingAccount (BillingRequest) returns (BillingResponse);<br>}</pre><pre>message BillingRequest {<br>  string patientId = 1;<br>  string name = 2;<br>  string email = 3;<br>}</pre><pre>message BillingResponse {<br>  string accountId = 1;<br>  string status = 2;<br>}</pre><h3>🔍 What does this mean?</h3><ul><li>CreateBillingAccount → function exposed by Billing Service</li><li>BillingRequest → input data</li><li>BillingResponse → output data</li></ul><p>👉 This file replaces REST controllers and DTOs.</p><h3>⚙️ Step 2: Code Generation</h3><p>From the .proto file, gRPC automatically generates:</p><ul><li>Java classes (BillingRequest, BillingResponse)</li><li>Client stub</li><li>Server base class</li></ul><p>👉 You don’t write these manually!</p><h3>🔄 Step 3: System Flow (Real Example)</h3><p>Let’s walk through what happens when a user creates a patient.</p><h3>🧍 Step 3.1: Create Patient</h3><p>User sends request to Patient Service:</p><pre>{<br>  &quot;name&quot;: &quot;Pasindu&quot;,<br>  &quot;email&quot;: &quot;pasindu@gmail.com&quot;<br>}</pre><p>Patient Service:</p><ul><li>Saves patient in database</li><li>Generates a patientId (e.g., P123)</li></ul><h3>🔗 Step 3.2: Call Billing Service (gRPC)</h3><p>Now Patient Service needs to create a billing account.</p><p>Instead of REST, it uses gRPC:</p><pre>BillingRequest request = BillingRequest.newBuilder()<br>    .setPatientId(&quot;P123&quot;)<br>    .setName(&quot;Pasindu&quot;)<br>    .setEmail(&quot;pasindu@gmail.com&quot;)<br>    .build();</pre><pre>BillingResponse response = billingStub.createBillingAccount(request);</pre><p>👉 Notice: It looks like a normal function call!</p><h3>🖥️ Step 3.3: Inside Billing Service</h3><p>Billing Service receives the request and processes it:</p><pre>@Override<br>public void createBillingAccount(BillingRequest request,<br>                                 StreamObserver&lt;BillingResponse&gt; responseObserver) {</pre><pre>    String accountId = &quot;ACC-&quot; + request.getPatientId();</pre><pre>    BillingResponse response = BillingResponse.newBuilder()<br>            .setAccountId(accountId)<br>            .setStatus(&quot;CREATED&quot;)<br>            .build();</pre><pre>    responseObserver.onNext(response);<br>    responseObserver.onCompleted();<br>}</pre><h3>📤 Step 3.4: Response Sent Back</h3><p>Billing Service returns:</p><pre>{<br>  &quot;accountId&quot;: &quot;ACC-P123&quot;,<br>  &quot;status&quot;: &quot;CREATED&quot;<br>}</pre><p>Patient Service receives this and continues processing.</p><h3>🔁 Full Flow Diagram</h3><pre>User<br>  ↓<br>Patient Service<br>  ↓ (gRPC call)<br>Billing Service<br>  ↓<br>Create Account<br>  ↓<br>Response → Patient Service → User</pre><h3>⚡ Why Use gRPC in Microservices?</h3><p>✅ Faster than REST<br>✅ Smaller payload (binary)<br>✅ Strongly typed (via .proto)<br>✅ Auto-generated code<br>✅ Supports streaming</p><h3>🆚 gRPC vs REST</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XuDGFiKkyybjFGOLwYHB5A.png" /></figure><p>Use gRPC when:</p><ul><li>You are building <strong>microservices</strong></li><li>Services need <strong>fast internal communication</strong></li><li>You want <strong>type safety and performance</strong></li></ul><p>Avoid it when:</p><ul><li>Building public APIs for browsers (REST is easier)</li></ul><h3>🧩 Final Thoughts</h3><p>gRPC simplifies service-to-service communication by making remote calls feel like local function calls.</p><p>In our Patient Management System:</p><ul><li>Patient Service acts as a <strong>client</strong></li><li>Billing Service acts as a <strong>server</strong></li><li>.proto file acts as the <strong>contract</strong></li></ul><p>👉 Together, they create a fast, scalable microservice architecture.</p><h3>🚀 Conclusion</h3><p>If you’re building modern backend systems, learning gRPC is a huge advantage. It not only improves performance but also enforces a clean contract between services.</p><p>Start small, like this Patient-Billing example, and scale from there.</p><p>✍️ Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6944521ecbe5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Observability in Microservices Using Grafana, Prometheus & Spring Boot]]></title>
            <link>https://medium.com/@pasiya10975/observability-in-microservices-using-grafana-prometheus-spring-boot-7ea3c5bdef2c?source=rss-40265f64ffc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ea3c5bdef2c</guid>
            <dc:creator><![CDATA[Pasindu]]></dc:creator>
            <pubDate>Tue, 27 Jan 2026 15:32:20 GMT</pubDate>
            <atom:updated>2026-01-27T15:32:20.552Z</atom:updated>
            <content:encoded><![CDATA[<p>Modern applications are no longer a single large system — they are built using <strong>microservices</strong>. While this architecture improves scalability and flexibility, it also makes monitoring and debugging much harder.</p><p>In my recent microservices project, I implemented <strong>observability</strong> using <strong>Grafana</strong>, <strong>Prometheus</strong>, and <strong>Spring Boot Actuator</strong> to monitor system health, performance, and resource usage in real time.</p><p>Here’s how I did it.</p><h3>🧠 What is Observability?</h3><p>Observability means understanding what is happening <em>inside</em> your system by looking at its <strong>external outputs</strong>.</p><p>It is built on <strong>three pillars</strong>:</p><pre>| Pillar      | Purpose                                        |<br>| ----------- | ---------------------------------------------- |<br>| **Metrics** | Numerical data like CPU, memory, request count |<br>| **Logs**    | Event records showing what happened            |<br>| **Traces**  | Track requests as they move across services    |</pre><p>In my project, I mainly focused on <strong>metrics monitoring</strong> using <strong>Prometheus + Grafana</strong>.</p><h3>🏗 My Microservices Architecture</h3><p>My system consists of:</p><ul><li>🛒 Product Service</li><li>📦 Inventory Service</li><li>🧾 Order Service</li><li>🌐 API Gateway</li><li>🐳 Docker containers for each service</li></ul><p>Since multiple services run independently, it becomes difficult to know:</p><ul><li>Which service is slow?</li><li>Is memory usage increasing?</li><li>Are requests failing?</li></ul><p>That’s where <strong>observability tools</strong> come in.</p><h3>⚙️ Step 1 — Enabling Metrics in Spring Boot</h3><p>I used <strong>Spring Boot Actuator</strong> with <strong>Micrometer</strong> to expose metrics.</p><h3>Dependencies added:</h3><ul><li>spring-boot-starter-actuator</li><li>micrometer-registry-prometheus</li></ul><p>This exposes an endpoint like:</p><pre>/actuator/prometheus</pre><p>Each microservice provides:</p><ul><li>JVM memory usage</li><li>CPU usage</li><li>Thread count</li><li>HTTP request metrics</li></ul><h3>📊 Step 2 — Collecting Metrics with Prometheus</h3><p><strong>Prometheus</strong> pulls metrics from each service at regular intervals.</p><p>Example configuration:</p><pre>scrape_configs:<br>  - job_name: &#39;product-service&#39;<br>    metrics_path: &#39;/actuator/prometheus&#39;<br>    static_configs:<br>      - targets: [&#39;product-service:8080&#39;]</pre><p>Now Prometheus continuously stores time-series data from all services.</p><h3>📈 Step 3 — Visualizing with Grafana</h3><p>Grafana connects to Prometheus and turns raw numbers into <strong>beautiful dashboards</strong>.</p><p>I created dashboards to monitor:</p><h3>🔹 JVM Metrics</h3><ul><li>Heap memory usage</li><li>Non-heap memory</li><li>Garbage collection activity</li></ul><h3>🔹 System Metrics</h3><ul><li>CPU usage</li><li>Load average</li><li>Process uptime</li></ul><h3>🔹 Application Metrics</h3><ul><li>HTTP request count</li><li>Response time</li><li>Error rate</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vtgphSwkB_iAyv7wTZLLtA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1dcu0ohK9bJ3RB8lCONUfw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3TaXhUku1zKBml-UkeYU7Q.png" /></figure><h3>🚨 Why This is Powerful</h3><p>Before observability:<br> ❌ Hard to know why the system is slow<br> ❌ No visibility into service health<br> ❌ Debugging required checking logs manually</p><p>After adding Grafana:<br> ✅ Real-time performance monitoring<br> ✅ Detect memory leaks early<br> ✅ Identify overloaded services<br> ✅ Understand traffic patterns</p><p>Now I can see exactly:</p><ul><li>When memory spikes</li><li>When CPU usage increases</li><li>How long requests take</li></ul><h3>💡 Key Lessons I Learned</h3><p>✔ Observability is <strong>not optional</strong> in microservices<br> ✔ Metrics help detect problems <strong>before</strong> users notice<br> ✔ Grafana dashboards make complex systems easy to understand<br> ✔ Monitoring improves both <strong>performance</strong> and <strong>reliability</strong></p><h3>🏁 Conclusion</h3><p>Microservices give flexibility, but they also require strong monitoring. By integrating:</p><p><strong>Spring Boot Actuator + Prometheus + Grafana</strong></p><p>I transformed my project from a “black box” into a <strong>fully observable system</strong>.</p><p>Observability is what turns a working system into a <strong>production-ready system</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ccz5KbB3DTtLnbndafNpyQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pVgt0vtnRuj-hdkjo1nQvg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2AJ2HXifsCMV8yH1W9vCTw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-M0JFMa-NRXD4jIgbAB0sg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9ULzQQ57Nq53gjr6yHzglA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ea3c5bdef2c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying a Three-Tier Application to AWS EKS: A Beginner’s Complete Guide]]></title>
            <link>https://medium.com/@pasiya10975/deploying-a-three-tier-application-to-aws-eks-a-beginners-complete-guide-fa9ca565520f?source=rss-40265f64ffc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa9ca565520f</guid>
            <dc:creator><![CDATA[Pasindu]]></dc:creator>
            <pubDate>Tue, 06 Jan 2026 16:59:17 GMT</pubDate>
            <atom:updated>2026-01-06T16:59:17.516Z</atom:updated>
            <content:encoded><![CDATA[<p>How I went from “What is AWS?” to deploying production-grade infrastructure in the cloud</p><h3>Introduction</h3><p>Two weeks ago, I had a working Kubernetes application running on my laptop. It worked great locally, but I wanted to take it to the next level: deploy it to a real cloud infrastructure that could serve users anywhere in the world.</p><p>This is the story of how I deployed my first application to AWS EKS (Elastic Kubernetes Service), the challenges I faced, and what I learned about AWS along the way.</p><p><strong>Spoiler:</strong> It’s more accessible than you think!</p><h3>What I Built</h3><p><strong>The Application:</strong></p><ul><li><strong>Frontend:</strong> React application with a modern UI</li><li><strong>Backend:</strong> Node.js REST API</li><li><strong>Database:</strong> MongoDB for data persistence</li></ul><p><strong>The Infrastructure:</strong></p><ul><li><strong>Platform:</strong> AWS EKS (Elastic Kubernetes Service)</li><li><strong>Region:</strong> ap-south-1 (Mumbai, India)</li><li><strong>Automation:</strong> 100% Terraform (Infrastructure as Code)</li><li><strong>High Availability:</strong> Multi-AZ deployment</li></ul><h3>Why AWS EKS?</h3><p>When moving from local Kubernetes to production, I needed:</p><p>✅ <strong>Reliability</strong> — 99.99% uptime SLA<br> ✅ <strong>Scalability</strong> — Handle traffic spikes automatically<br> ✅ <strong>Security</strong> — Professional-grade infrastructure<br> ✅ <strong>Managed Service</strong> — AWS handles the complex parts</p><p><strong>The key insight:</strong> With EKS, AWS manages the Kubernetes control plane (the master nodes). I just focus on deploying my application.</p><h3>The AWS Architecture</h3><p>Let me show you exactly how everything is set up in AWS:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cNUZCylHph7YY-ITcPAZug.png" /></figure><p><em>The EKS cluster dashboard showing the running cluster with 1.30 Kubernetes version, active status, and configured worker nodes in the ap-south-1 region</em></p><p>Here’s how traffic flows through the system:</p><pre>               Internet Users<br>                      ↓<br>       Internet Gateway (AWS entrance)<br>                      ↓<br>Application Load Balancer (Traffic distributor)<br>                      ↓<br>    ┌─────────────────┴─────────────────┐<br>    ↓                                   ↓<br>Public Subnet                    Public Subnet<br>(ap-south-1a)                   (ap-south-1b)<br>    ↓                                   ↓<br>NAT Gateway                      NAT Gateway<br>    ↓                                   ↓<br>Private Subnet                   Private Subnet<br>    ↓                                   ↓<br>EKS Worker Nodes                 EKS Worker Nodes<br>(Your application pods run here)</pre><p><strong>Why this design?</strong></p><ol><li><strong>Public Subnets:</strong> Only load balancers live here. They face the internet.</li><li><strong>Private Subnets:</strong> Your actual application lives here. Hidden from direct internet access.</li><li><strong>NAT Gateways:</strong> Allow private applications to reach the internet (for updates, pulling Docker images) without being directly accessible.</li><li><strong>Two Availability Zones:</strong> If one AWS data center fails, the other keeps running.</li></ol><h3>AWS Services Explained (Simply)</h3><p>Let me explain each AWS service I used and why it matters:</p><h3>1. EKS (Elastic Kubernetes Service)</h3><p><strong>What it is:</strong> Managed Kubernetes control plane</p><p><strong>Without EKS:</strong></p><ul><li>You manage master nodes</li><li>You handle etcd database</li><li>You update Kubernetes yourself</li><li>You ensure high availability</li><li>Lots of complexity!</li></ul><p><strong>With EKS:</strong></p><ul><li>AWS manages all of that</li><li>You just run: aws eks create-cluster</li><li>AWS ensures it’s always up-to-date and secure</li></ul><p><strong>Cost:</strong> $0.10/hour (~$72/month)</p><p><strong>My take:</strong> Worth every penny. The time saved is enormous.</p><h3>2. VPC (Virtual Private Cloud)</h3><p><strong>What it is:</strong> Your own isolated network in AWS</p><p>Think of it like having your own private neighborhood in a big city. You control who enters, who lives where, and how things are connected.</p><p><strong>My VPC setup:</strong></p><ul><li><strong>2 Public Subnets:</strong> For load balancers (face the internet)</li><li><strong>2 Private Subnets:</strong> For applications (hidden from internet)</li><li><strong>2 Availability Zones:</strong> For high availability</li></ul><p><strong>Key learning:</strong> Don’t use AWS default VPC for production. Design your own.</p><h3>3. Application Load Balancer (ALB)</h3><p><strong>What it is:</strong> Intelligent traffic distributor</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W7RVd-IOGaYSniIBtbWfPA.png" /></figure><p><em>The Application Load Balancer in active state, handling incoming traffic and distributing it across healthy targets in multiple availability zones</em></p><p>The load balancer does several jobs:</p><ol><li><strong>Distributes traffic</strong> across multiple application instances</li><li><strong>Health checks</strong> — Continuously pings your application: “Are you alive?”</li><li><strong>Automatic failover</strong> — If one instance fails, stops sending traffic there</li><li><strong>SSL/TLS ready</strong> — Can handle HTTPS certificates</li></ol><p><strong>Real example:</strong> I have 2 backend pods. Load balancer splits traffic 50/50. If one pod crashes, it immediately sends 100% traffic to the healthy one. When the crashed pod restarts, it goes back to 50/50.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SURpkGvvORkohAatCzdYbQ.png" /></figure><p><em>Target groups showing healthy targets (green checkmarks) with successful health checks on port 8080 for backend and port 3000 for frontend</em></p><h3>4. IAM (Identity and Access Management)</h3><p><strong>What it is:</strong> Security and permissions system</p><p><strong>The problem:</strong> In the old days, you’d hard-code AWS credentials in your application. If someone steals your code, they have your credentials. Bad news!</p><p><strong>The modern way (IRSA):</strong></p><ol><li>Create an IAM role with specific permissions</li><li>Assign it to your Kubernetes service account</li><li>Pods automatically get temporary credentials</li><li>Credentials rotate automatically</li></ol><p><strong>Key principle:</strong> Give minimum necessary permissions. If a frontend pod only needs to read from S3, don’t give it permission to delete S3 buckets!</p><h3>5. S3 (Simple Storage Service)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L32pZrtH0AHJNSmYvf7JyA.png" /></figure><p><em>S3 bucket storing Terraform state file with versioning enabled, ensuring infrastructure changes are tracked and can be rolled back if needed</em></p><p><strong>What I use it for:</strong> Storing Terraform state</p><p><strong>Why this matters:</strong></p><ul><li>My infrastructure definition is code (Terraform)</li><li>The state file tracks what actually exists in AWS</li><li>Stored in S3 = team members can collaborate</li><li>Versioning enabled = can rollback changes</li></ul><p><strong>Alternative:</strong> You could store state locally, but then:</p><ul><li>Only you can make changes</li><li>No backup if your laptop dies</li><li>No collaboration with team</li></ul><h3>Real Challenges I Faced</h3><p>Let me share the actual problems I encountered and how I solved them. These are the things tutorials don’t tell you!</p><h3>Challenge #1: Load Balancer Showing “Unhealthy Targets”</h3><p><strong>The Problem:</strong> I deployed everything. EKS cluster: ✅ Running. Pods: ✅ Running. Load balancer: ✅ Created.</p><p>But when I checked the load balancer, it said all targets were “unhealthy”. The app wasn’t accessible.</p><p><strong>First Debugging Attempt:</strong></p><p>bash</p><pre>kubectl get pods -n workshop<br># All pods showing &quot;Running&quot; - so what&#39;s wrong?</pre><pre>kubectl logs deployment/backend -n workshop<br># Logs showing app is listening on port 8080 - looks fine!</pre><p><strong>The Issue:</strong> Security groups! The load balancer couldn’t reach my pods because I forgot to allow traffic.</p><p><strong>The Fix:</strong></p><p>bash</p><pre># Add security group rule:<br># Source: Load Balancer Security Group<br># Target: Node Security Group  <br># Port: 8080 (backend), 3000 (frontend)<br># Protocol: TCP</pre><p><strong>What I Learned:</strong> Security groups are like bouncers at a club. Even if someone has a valid ticket (your pod is running), they can’t get in unless the bouncer (security group) allows them.</p><p><strong>Time spent debugging:</strong> 2 hours (mostly reading AWS docs about security groups)</p><h3>Challenge #2: Pods Couldn’t Pull Docker Images</h3><p><strong>The Problem:</strong> Pods stuck in ImagePullBackOff state:</p><p>bash</p><pre>kubectl get pods -n workshop<br>NAME                        READY   STATUS             RESTARTS   AGE<br>backend-xxx                 0/1     ImagePullBackOff   0          5m</pre><p><strong>Investigation:</strong></p><p>bash</p><pre>kubectl describe pod backend-xxx -n workshop</pre><pre># Error message:<br># Failed to pull image &quot;pasindumalinga/backend-app-host:v1&quot;<br># Error: Get <a href="https://registry-1.docker.io/v2/:">https://registry-1.docker.io/v2/:</a> net/http: request canceled</pre><p><strong>The Issue:</strong> My pods are in private subnets. Private subnets can’t reach the internet directly. They need a NAT Gateway!</p><p><strong>What’s a NAT Gateway?</strong> Think of it like a secure backdoor exit. Your private apartment (pod) needs to order pizza (pull Docker image) from the outside world. You can’t use the main entrance (that would expose you to the internet). Instead, you use the private backdoor (NAT Gateway).</p><p><strong>The Fix:</strong> Added NAT Gateway to my Terraform configuration. This allows outbound internet access from private subnets while keeping inbound traffic blocked.</p><p><strong>Cost Note:</strong> NAT Gateway costs $0.045/hour (~$32/month). It’s one of the pricier components!</p><p><strong>What I Learned:</strong> AWS networking follows clear rules. Private subnets = no internet by default. You must explicitly add NAT Gateway for outbound access.</p><p><strong>Time spent debugging:</strong> 1 hour</p><h3>Challenge #3: MongoDB Crashing Repeatedly</h3><p><strong>The Problem:</strong></p><p>bash</p><pre>kubectl get pods -n workshop<br>NAME                       READY   STATUS             RESTARTS   AGE<br>mongodb-xxx                0/1     CrashLoopBackOff   5          10m</pre><p>The pod kept restarting every few seconds.</p><p><strong>Investigation:</strong></p><p>bash</p><pre>kubectl logs mongodb-xxx -n workshop</pre><pre># Error shown:<br># WARNING: MongoDB requires ARMv8.2-A or higher<br># numactl: command not found<br># Aborted</pre><p><strong>The Issue:</strong> Two problems actually:</p><ol><li>The MongoDB image expected numactl package</li><li>Not enough memory allocated</li></ol><p><strong>The Fix:</strong> Updated Kubernetes deployment:</p><p>yaml</p><pre>containers:<br>- name: mongodb<br>  image: mongo:4.4.6  # Changed to older, more compatible version<br>  resources:<br>    requests:<br>      memory: &quot;512Mi&quot;  # Was 256Mi before<br>      cpu: &quot;250m&quot;<br>    limits:<br>      memory: &quot;1Gi&quot;    # Was 512Mi before<br>      cpu: &quot;500m&quot;</pre><p><strong>What I Learned:</strong></p><ol><li>Container images matter. Different versions have different requirements.</li><li>Resource limits are not optional. Kubernetes needs to know how much CPU/memory your app needs.</li><li>requests = minimum guaranteed resources</li><li>limits = maximum allowed (pod gets killed if it exceeds this)</li></ol><p><strong>Time spent debugging:</strong> 3 hours (this one was tough!)</p><h3>Cost Breakdown (Transparency!)</h3><p><strong>My Strategy for Cost Optimization:</strong></p><p>Instead of running 24/7, I deploy on-demand:</p><p>bash</p><pre># When I need it:<br>terraform apply        # 15 minutes → Everything created</pre><pre># Use it for hours or days<br># Practice, demo, test</pre><pre># When done:<br>terraform destroy      # 10 minutes → Everything deleted</pre><pre># Cost: $0/day when not running!</pre><p><strong>Real numbers:</strong></p><ul><li>$91 in AWS credits</li><li>Deploy for 3 hours = $0.60</li><li>Deploy for 1 day = $4.60</li><li>Deploy for 1 week = $32.20</li></ul><p><strong>Result:</strong> My credits will last for months of learning instead of just weeks!</p><p><strong>Key insight:</strong> Infrastructure as Code means I can recreate everything instantly. Why pay $138/month when I can deploy on-demand?</p><h3>The Power of Infrastructure as Code</h3><p>The biggest “aha!” moment for me was understanding Terraform.</p><p><strong>Before Terraform:</strong></p><ol><li>Log into AWS console</li><li>Click through 20+ screens</li><li>Configure VPC, subnets, security groups…</li><li>2–3 hours of manual work</li><li>Forgot what you did? Start documenting…</li><li>Need to do it again? Good luck remembering!</li></ol><p><strong>With Terraform:</strong></p><ol><li>Write infrastructure in code (one time)</li><li>Run: terraform apply</li><li>15 minutes later → Everything exists</li><li>Destroy when done</li><li>Next week: terraform apply → Exact same setup</li></ol><p><strong>The code IS the documentation.</strong></p><p>Here’s a simplified example of what my Terraform looks like:</p><p>hcl</p><pre># Create VPC<br>module &quot;vpc&quot; {<br>  source = &quot;terraform-aws-modules/vpc/aws&quot;<br>  <br>  name = &quot;my-eks-vpc&quot;<br>  cidr = &quot;10.0.0.0/16&quot;<br>  <br>  azs             = [&quot;ap-south-1a&quot;, &quot;ap-south-1b&quot;]<br>  private_subnets = [&quot;10.0.1.0/24&quot;, &quot;10.0.2.0/24&quot;]<br>  public_subnets  = [&quot;10.0.101.0/24&quot;, &quot;10.0.102.0/24&quot;]<br>  <br>  enable_nat_gateway = true<br>  enable_dns_hostnames = true<br>}</pre><pre># Create EKS cluster<br>module &quot;eks&quot; {<br>  source = &quot;terraform-aws-modules/eks/aws&quot;<br>  <br>  cluster_name    = &quot;my-three-tier-eks&quot;<br>  cluster_version = &quot;1.30&quot;<br>  <br>  vpc_id     = module.vpc.vpc_id<br>  subnet_ids = module.vpc.private_subnets<br>  <br>  eks_managed_node_groups = {<br>    general = {<br>      desired_size = 1<br>      min_size     = 1<br>      max_size     = 10<br>      instance_types = [&quot;t3.small&quot;]<br>    }<br>  }<br>}</pre><p>That’s it! 20 lines of code replaces hours of clicking.</p><h3>Key Takeaways</h3><p>After this journey, here are my biggest learnings:</p><h3>1. AWS Networking is Logical (Once You Understand It)</h3><p><strong>VPC</strong> = Your private neighborhood<br> <strong>Subnets</strong> = Streets in your neighborhood<br> <strong>Internet Gateway</strong> = Main entrance to neighborhood<br> <strong>NAT Gateway</strong> = Backdoor for residents<br> <strong>Security Groups</strong> = Bouncers at every door</p><p>It all follows clear rules. Read the docs, draw diagrams, and it clicks.</p><h3>2. Multi-AZ is Non-Negotiable for Production</h3><p>Single availability zone = Single point of failure<br> Multi-AZ = If one data center fails, others keep running</p><p>The cost is minimal. The reliability gain is massive.</p><h3>3. Start Simple, Then Scale</h3><p><strong>My progression:</strong></p><ol><li>Docker Compose (local)</li><li>Kubernetes (local)</li><li>AWS ECS (simpler than EKS)</li><li>AWS EKS (production-grade)</li></ol><p>Don’t jump straight to EKS. Build up gradually.</p><h3>4. Error Messages are Your Friend</h3><p>AWS error messages are actually helpful! They tell you exactly what’s wrong:</p><pre>DependencyViolation: The subnet has dependencies<br>→ Something is still using the subnet. Find and delete it.</pre><pre>ImagePullBackOff<br>→ Pod can&#39;t pull the Docker image. Check network access.</pre><pre>Unhealthy targets<br>→ Load balancer can&#39;t reach your pods. Check security groups.</pre><p>Read them carefully. They’re not cryptic.</p><h3>5. Infrastructure as Code is Not Optional</h3><p>For anything beyond learning/testing, use Terraform (or similar). Benefits:</p><ul><li>Version controlled</li><li>Reproducible</li><li>Self-documenting</li><li>Team collaboration</li><li>Easy to destroy and recreate</li></ul><h3>6. AWS Free Tier is Generous</h3><p>What I got free:</p><ul><li>750 hours EC2 (first 12 months)</li><li>15 GB data transfer</li><li>Plus: $100 in AWS Educate credits</li></ul><p>Plenty to learn without paying!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa9ca565520f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an Event-Driven Microservices System Using Kafka and Spring Boot]]></title>
            <link>https://medium.com/@pasiya10975/building-an-event-driven-microservices-system-using-kafka-and-spring-boot-acc9a20f4d96?source=rss-40265f64ffc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/acc9a20f4d96</guid>
            <dc:creator><![CDATA[Pasindu]]></dc:creator>
            <pubDate>Fri, 19 Dec 2025 17:01:44 GMT</pubDate>
            <atom:updated>2025-12-19T17:01:44.951Z</atom:updated>
            <content:encoded><![CDATA[<p>Modern applications require <strong>scalability, loose coupling, and resilience</strong>. Traditional REST-based microservice communication often becomes tightly coupled and hard to scale.<br>This is where <strong>Event-Driven Architecture (EDA)</strong> comes in.</p><h3>What Is Event-Driven Architecture?</h3><p>In an <strong>event-driven architecture</strong>, services do not directly call each other.<br> Instead:</p><ul><li>A service <strong>publishes an event</strong> when something happens</li><li>Other services <strong>listen</strong> to that event and react</li></ul><p>📌 Example:</p><ul><li>Order Service creates an order</li><li>It publishes an OrderPlacedEvent</li><li>Notification Service listens and sends an email</li><li>Order Service does <strong>not care</strong> who consumes the event</li></ul><p>This makes services:</p><ul><li>Loosely coupled</li><li>Asynchronous</li><li>Easy to scale</li></ul><h3>Why Apache Kafka?</h3><p>Apache Kafka acts as the <strong>event broker</strong> between services.</p><p>Kafka provides:</p><ul><li>High throughput</li><li>Message durability</li><li>Pub/Sub messaging</li><li>Fault tolerance</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0K8ZRu_Hpyn4YivDxZtWiw.png" /></figure><p>Think a project contains multiple Spring Boot microservices:</p><ul><li><strong>Product Service</strong></li><li><strong>Order Service</strong></li><li><strong>Inventory Service</strong></li><li><strong>Notification Service</strong></li><li><strong>API Gateway</strong></li><li><strong>Angular Frontend</strong></li></ul><p>Kafka is mainly used for <strong>asynchronous communication</strong> between:</p><ul><li><strong>Order Service (Producer)</strong></li><li><strong>Notification Service (Consumer)</strong></li></ul><h3>Order Service: Publishing Events to Kafka</h3><p>When a user places an order:</p><ol><li>Order Service receives the REST request</li><li>Order data is saved</li><li>An event is published to Kafka</li></ol><p>Conceptual Flow</p><pre>Client → Order Service → Kafka Topic</pre><p>Kafka Producer (Concept)</p><pre>kafkaTemplate.send(&quot;order-placed&quot;, orderPlacedEvent);</pre><p>Here:</p><ul><li>order-placed is the Kafka topic</li><li>orderPlacedEvent contains order details</li></ul><p>📌 Order Service does <strong>not</strong> call Notification Service directly.</p><h4>Kafka Topic Visualization</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*82lmf_riVzjnam55xabARg.png" /></figure><ul><li>order-placed</li><li>Messages produced by Order Service</li></ul><h3>Notification Service: Consuming Kafka Events</h3><p>Notification Service listens to Kafka events.</p><p>Conceptual Flow</p><pre>Kafka Topic → Notification Service → Email</pre><p>Kafka Consumer (Concept)</p><pre>@KafkaListener(topics = &quot;order-placed&quot;, groupId = &quot;notificationGroup&quot;)<br>public void listen(OrderPlacedEvent orderPlacedEvent) {<br>    // send email<br>}</pre><p>Once the event is received</p><ul><li>Notification Service processes it</li><li>Sends an email using Mailtrap</li></ul><h3>Email Testing with Mailtrap</h3><p>Mailtrap is used to safely test email notifications without sending real emails.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d1L4t5GKnBMQu0ocIne-kg.png" /></figure><ul><li>Order confirmation email</li><li>Order details from Kafka event</li></ul><p>This proves that:</p><ul><li>Kafka event was consumed successfully</li><li>Notification Service worked independently</li></ul><h3>Why This Architecture Is Powerful</h3><h3>1️⃣ Loose Coupling</h3><p>Order Service does not know about Notification Service.</p><h3>2️⃣ Asynchronous Processing</h3><p>Order creation is fast — no waiting for email sending.</p><h3>3️⃣ Scalability</h3><p>Multiple Notification Service instances can consume messages.</p><h3>4️⃣ Extensibility</h3><p>New services (Analytics, Audit, Logging) can listen to the same event without changing existing code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c33F_dfLk9rL4MIHJDTYWA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=acc9a20f4d96" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Circuit Breaker in Microservices]]></title>
            <link>https://medium.com/@pasiya10975/circuit-breaker-in-microservices-ca20d2fb0878?source=rss-40265f64ffc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca20d2fb0878</guid>
            <dc:creator><![CDATA[Pasindu]]></dc:creator>
            <pubDate>Fri, 12 Dec 2025 16:17:42 GMT</pubDate>
            <atom:updated>2025-12-12T16:21:34.576Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PApeANKTdzughQHSkVs_bg.png" /></figure><p>Microservices communicate with each other through API calls.<br> But what happens when one service becomes slow or goes down?</p><p>👉 The entire chain of dependent services can fail.<br> This problem is known as <strong>cascade failure</strong>.</p><p>To prevent this, we use the <strong>Circuit Breaker pattern</strong> — a simple but powerful reliability technique.</p><h4>🔌 What is a Circuit Breaker?</h4><p>A circuit breaker works exactly like the electrical switch in your home.<br> If there is a high load or continuous failures, the switch turns <em>off</em> to protect the system.</p><p>Microservices use the same idea.<br> If a downstream service fails repeatedly, the circuit breaker <strong>opens</strong> and stops calls temporarily.</p><h4>🔄 States of a Circuit Breaker</h4><h4>1️⃣ Closed</h4><p>Everything is working fine.<br> Requests flow normally.</p><h4>2️⃣ Open</h4><p>The service is failing too often.<br> Circuit Breaker <strong>blocks calls</strong> and immediately returns a fallback response.</p><h4>3️⃣ Half-Open</h4><p>After a delay, a few test requests are sent.</p><ul><li>If they succeed → Circuit closes again</li><li>If they fail → Circuit stays open</li></ul><p>This prevents the whole system from crashing.</p><h4>💻 Implementing Circuit Breaker in Spring Boot (Resilience4j)</h4><p>Let’s assume the <strong>Order Service</strong> calls the <strong>Payment Service</strong>.</p><h4>Add dependency (pom.xml)</h4><pre>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;<br>            &lt;artifactId&gt;spring-cloud-starter-circuitbreaker-resilience4j&lt;/artifactId&gt;<br>        &lt;/dependency&gt;<br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>            &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;<br>        &lt;/dependency&gt;</pre><p>⚙️ <strong>1. Add Circuit Breaker + Retry + Timeout in </strong><strong>application.properties</strong></p><pre># Actuator endpoints<br>management.health.circuitbreakers.enabled=true<br>management.endpoints.web.exposure.include=*<br>management.endpoint.health.show-details=always<br><br># Resilience4j Circuit Breaker Settings<br>resilience4j.circuitbreaker.configs.default.registerHealthIndicator=true<br>resilience4j.circuitbreaker.configs.default.slidingWindowType=COUNT_BASED<br>resilience4j.circuitbreaker.configs.default.slidingWindowSize=10<br>resilience4j.circuitbreaker.configs.default.failureRateThreshold=50<br>resilience4j.circuitbreaker.configs.default.waitDurationInOpenState=5s<br>resilience4j.circuitbreaker.configs.default.permittedNumberOfCallsInHalfOpenState=3<br>resilience4j.circuitbreaker.configs.default.automaticTransitionFromOpenToHalfOpenEnabled=true<br>resilience4j.circuitbreaker.configs.default.minimum-number-of-calls=5<br><br># Timeout (TimeLimiter)<br>resilience4j.timelimiter.configs.default.timeoutDuration=3s<br><br># Retry settings<br>resilience4j.retry.configs.default.max-attempts=3<br>resilience4j.retry.configs.default.wait-duration=2s</pre><h4>✔ What this config means (simple explanation):</h4><ul><li><strong>slidingWindowSize=10</strong> → Circuit breaker checks last 10 calls</li><li><strong>failureRateThreshold=50%</strong> → If 5 of 10 fail → OPEN the circuit</li><li><strong>waitDurationInOpenState=5s</strong> → Stay open for 5 seconds</li><li><strong>timeoutDuration=3s</strong> → If no response in 3s → treat as failure</li><li><strong>retry.max-attempts=3</strong> → Try 3 times before giving up</li><li><strong>retry.wait-duration=2s</strong> → Wait 2 seconds between retries</li></ul><p>This makes your microservices <strong>stable</strong>, even if some services are slow.</p><p>🛡️<strong> 2. Create a Fallback Route in Spring WebFlux</strong></p><pre>@Bean<br>public RouterFunction&lt;ServerResponse&gt; fallbackRoute() {<br>    return route(&quot;fallbackRoute&quot;)<br>            .GET(&quot;/fallbackRoute&quot;, request -&gt; ServerResponse<br>                    .status(HttpStatus.SERVICE_UNAVAILABLE)<br>                    .body(&quot;Service Unavailable, please try again later&quot;))<br>            .build();<br>}</pre><h4>✔ Why we need this?</h4><p>When a downstream microservice fails:</p><p>➡ Gateway does NOT forward the request<br> ➡ It directly returns this fallback response</p><p>It protects your entire system from being overloaded.</p><p>🔄 <strong>3. Apply Circuit Breaker at Route Level (Gateway Filter)</strong></p><pre>.filter(CircuitBreakerFilterFunctions.circuitBreaker(&quot;orderServiceCircuitBreaker&quot;,<br> URI.create(&quot;forward:/fallbackRoute&quot;)))</pre><h4>✔ What this means?</h4><ul><li>&quot;orderServiceCircuitBreaker&quot; → name of your circuit breaker</li><li>If this route fails too many times → circuit opens</li><li>Instead of calling the downstream service →<br> Gateway <strong>forwards</strong> request to /fallbackRoute</li></ul><h4>🧠 Why Route-Level Circuit Breaker Is Powerful</h4><p>It protects your microservices <em>before the request reaches them</em>.</p><p>Benefits:</p><p>✔ Stops bad traffic early<br> ✔ Protects downstream microservices<br> ✔ Reduces cascading failures<br> ✔ Helps your API Gateway maintain stability<br> ✔ Provides consistent fallback responses</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca20d2fb0878" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Object-Oriented Programming (OOP) Core]]></title>
            <link>https://medium.com/@pasiya10975/object-oriented-programming-oop-core-575247af4e98?source=rss-40265f64ffc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/575247af4e98</guid>
            <dc:creator><![CDATA[Pasindu]]></dc:creator>
            <pubDate>Wed, 10 Dec 2025 13:58:25 GMT</pubDate>
            <atom:updated>2025-12-10T13:58:25.257Z</atom:updated>
            <content:encoded><![CDATA[<p><em>The foundation of robust software design.</em></p><h3>The 4 Pillars of OOP</h3><ul><li><strong>Inheritance:</strong> Allows a class to inherit properties and behaviours from another class, promoting code reusability.</li></ul><pre>// Parent Class<br>class Animal {<br>    void eat() {<br>        System.out.println(&quot;This animal eats food.&quot;);<br>    }<br>}<br><br>// Child Class inherits from Animal<br>class Dog extends Animal {<br>    void bark() {<br>        System.out.println(&quot;The dog barks.&quot;);<br>    }<br>}<br><br>public class Main {<br>    public static void main(String[] args) {<br>        Dog myDog = new Dog();<br>        myDog.eat();  // Inherited method<br>        myDog.bark(); // Child&#39;s own method<br>    }<br>}</pre><ul><li><strong>Encapsulation:</strong> Restricts direct access to data components using access modifiers (private, public), ensuring data integrity.</li></ul><pre>public class BankAccount {<br>    // Private variable: Restricted access<br>    private double balance;<br><br>    // Public method: Controlled access<br>    public void deposit(double amount) {<br>        if (amount &gt; 0) {<br>            balance += amount;<br>            System.out.println(&quot;Deposited: &quot; + amount);<br>        }<br>    }<br><br>    // Public Getter<br>    public double getBalance() {<br>        return balance;<br>    }<br>}</pre><ul><li><strong>Polymorphism:</strong> Allows methods to perform different tasks based on context.</li><li><em>Method Overloading:</em> Same method name, different parameters (Compile-time).</li><li><em>Method Overriding:</em> Subclass redefines a method from the parent class (Runtime).</li></ul><pre>class MathUtils {<br>    // Method Overloading: Same name, different parameters<br>    int add(int a, int b) {<br>        return a + b;<br>    }<br><br>    double add(double a, double b) {<br>        return a + b;<br>    }<br>}<br><br>class Animal {<br>    void sound() {<br>        System.out.println(&quot;Animal makes a sound&quot;);<br>    }<br>}<br><br>class Cat extends Animal {<br>    // Method Overriding: Redefining parent&#39;s method<br>    @Override<br>    void sound() {<br>        System.out.println(&quot;Meow&quot;);<br>    }<br>}</pre><ul><li><strong>Abstraction:</strong> Hiding implementation details and showing only functionality to the user.</li></ul><pre>// Abstract class cannot be instantiated directly<br>abstract class Vehicle {<br>    abstract void start(); // Abstract method (no body)<br><br>    void stop() {<br>        System.out.println(&quot;Vehicle stopped.&quot;);<br>    }<br>}<br><br>class Car extends Vehicle {<br>    // Must provide implementation for abstract method<br>    @Override<br>    void start() {<br>        System.out.println(&quot;Car starts with a key.&quot;);<br>    }<br>}</pre><h3>Essential Keywords &amp; Concepts</h3><p><strong>Access Modifiers:</strong></p><ul><li>Private: Accessible only within the same class.</li><li>Public: Accessible from anywhere.</li><li>Protected: Accessible within the same package and subclasses.</li><li>Default: Accessible only within the same package.</li></ul><p><strong>Constructors:</strong></p><ul><li><em>Default:</em> No parameters.</li><li><em>Parameterized:</em> Takes arguments to initialize objects.</li><li><em>Copy Constructor:</em> Creates a new object using an existing object.</li><li><strong>this Keyword:</strong> Refers to the current object instance or instance variable.</li></ul><pre>public class Student {<br>    String name;<br>    int age;<br><br>    // 1. Default Constructor<br>    Student() {<br>        this.name = &quot;Unknown&quot;;<br>        this.age = 0;<br>    }<br><br>    // 2. Parameterized Constructor<br>    Student(String name, int age) {<br>        this.name = name; // &#39;this&#39; refers to current instance variable<br>        this.age = age;<br>    }<br><br>    // 3. Copy Constructor<br>    Student(Student s) {<br>        this.name = s.name;<br>        this.age = s.age;<br>    }<br>}</pre><ul><li><strong>static Block:</strong> Runs once before the main method, used for static initialization.</li></ul><pre>public class DatabaseConfig {<br>    static String dbUrl;<br><br>    // Static block: Runs once when class is loaded<br>    static {<br>        System.out.println(&quot;Loading database configuration...&quot;);<br>        dbUrl = &quot;jdbc:mysql://localhost:3306/mydb&quot;;<br>    }<br><br>    public static void main(String[] args) {<br>        System.out.println(&quot;Database URL: &quot; + dbUrl);<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iklwxt7JqfgPNo1A76K1iw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=575247af4e98" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>