<?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 Madhura Jayashanka on Medium]]></title>
        <description><![CDATA[Stories by Madhura Jayashanka on Medium]]></description>
        <link>https://medium.com/@madhurajayashanka?source=rss-f62bfb96deb4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dZjsuQbJxXFacFn8-m6n1A.png</url>
            <title>Stories by Madhura Jayashanka on Medium</title>
            <link>https://medium.com/@madhurajayashanka?source=rss-f62bfb96deb4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 20:34:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@madhurajayashanka/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[AWS Lambda Web Functions: A New Kind of Lambda for Web Apps]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://aws.plainenglish.io/aws-lambda-web-functions-a-new-kind-of-lambda-for-web-apps-f03b6fd57202?source=rss-f62bfb96deb4------2"><img src="https://cdn-images-1.medium.com/max/1735/1*yJG9XWRjxUi0S7FORtBHFg.png" width="1735"></a></p><p class="medium-feed-snippet">Last updated: October 17, 2026. Prices and limits checked against the AWS documentation and the AWS Lambda pricing page.</p><p class="medium-feed-link"><a href="https://aws.plainenglish.io/aws-lambda-web-functions-a-new-kind-of-lambda-for-web-apps-f03b6fd57202?source=rss-f62bfb96deb4------2">Continue reading on AWS in Plain English »</a></p></div>]]></description>
            <link>https://aws.plainenglish.io/aws-lambda-web-functions-a-new-kind-of-lambda-for-web-apps-f03b6fd57202?source=rss-f62bfb96deb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f03b6fd57202</guid>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Madhura Jayashanka]]></dc:creator>
            <pubDate>Sat, 17 Oct 2026 07:30:32 GMT</pubDate>
            <atom:updated>2026-10-17T07:30:32.382Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Why AI Generates Crappy Code, And How to Fix It]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@madhurajayashanka/why-ai-generates-crappy-code-and-how-to-fix-it-92f24a88c6a6?source=rss-f62bfb96deb4------2"><img src="https://cdn-images-1.medium.com/max/1735/1*twRcJm2psEbe53T5O-2DSw.png" width="1735"></a></p><p class="medium-feed-snippet">You open Claude Code. You ask for a small change. It gives you something that compiles, looks correct, and quietly breaks three&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@madhurajayashanka/why-ai-generates-crappy-code-and-how-to-fix-it-92f24a88c6a6?source=rss-f62bfb96deb4------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@madhurajayashanka/why-ai-generates-crappy-code-and-how-to-fix-it-92f24a88c6a6?source=rss-f62bfb96deb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/92f24a88c6a6</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[context-engineering]]></category>
            <category><![CDATA[claude-code]]></category>
            <dc:creator><![CDATA[Madhura Jayashanka]]></dc:creator>
            <pubDate>Sun, 20 Sep 2026 03:28:50 GMT</pubDate>
            <atom:updated>2026-09-20T03:28:50.006Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[The Transactional Outbox Pattern on AWS: Building Reliable Event-Driven Systems Without Dual-Write…]]></title>
            <link>https://medium.com/@madhurajayashanka/the-transactional-outbox-pattern-on-aws-building-reliable-event-driven-systems-without-dual-write-1ce1b06d69a0?source=rss-f62bfb96deb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ce1b06d69a0</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[event-driven-architecture]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Madhura Jayashanka]]></dc:creator>
            <pubDate>Sat, 29 Aug 2026 08:08:39 GMT</pubDate>
            <atom:updated>2026-08-29T08:08:39.469Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Transactional Outbox Pattern on AWS: Building Reliable Event-Driven Systems Without Dual-Write Bugs</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1pQUVyOnhjU-0uP2g8vNdQ.png" /><figcaption><em>The Transactional Outbox Pattern on AWS: Building Reliable Event-Driven Systems Without Dual-Write Bugs</em></figcaption></figure><p>When you build distributed systems or microservices, you almost always run into the same requirement: <strong>save some data to your database, and tell the rest of the system about it via an event bus or queue.</strong></p><p>It sounds simple enough. You write a few lines of code to update a database record, and immediately after, you make an API call to publish a message to Amazon EventBridge, SNS, or SQS.</p><p>In production, this straightforward approach breaks down quickly. You introduce what distributed systems engineers call the <strong>Dual-Write Problem</strong>, leading to silent data corruption, ghost messages, and out-of-sync services.</p><p>This article breaks down why direct publishing fails, how the <strong>Transactional Outbox Pattern</strong> solves it, and how to implement it cleanly on AWS using DynamoDB, Streams, Lambda, and EventBridge.</p><h3>1. The Real Problem: The Dual-Write Trap</h3><p>In a microservice architecture, your service typically interacts with two independent pieces of infrastructure:</p><ol><li><strong>A Database</strong> (PostgreSQL, MySQL, DynamoDB, etc.)</li><li><strong>A Message Broker / Event Bus</strong> (Amazon EventBridge, SNS, SQS, Kafka, etc.)</li></ol><p>These two systems do not share a single distributed transaction coordinator. When you try to update both in a single user request, one of two catastrophic failure modes will inevitably happen:</p><pre>Scenario A: DB Write Succeeds -&gt; Event Publish Fails<br>+----------------+      1. Save Order (OK)      +--------------+<br>|                | ---------------------------&gt; |   Database   |<br>|   App Server   |                              +--------------+<br>|                |      2. Publish Event (FAILED: Network Drop / Timeout)<br>|                | --X------------------------&gt; +--------------+<br>+----------------+                              |  EventBridge |<br>                                                +--------------+<br>Outcome: Database has the record, but downstream systems (payment, inventory,<br>notifications) never hear about it. Your data is silently desynchronized.</pre><pre>Scenario B: Event Published First -&gt; DB Write Fails<br>+----------------+      1. Publish Event (OK)   +--------------+<br>|                | ---------------------------&gt; |  EventBridge |<br>|   App Server   |                              +--------------+<br>|                |      2. Save Order (FAILED: DB Constraint / Timeout)<br>|                | --X------------------------&gt; +--------------+<br>+----------------+                              |   Database   |<br>                                                +--------------+<br>Outcome: Downstream systems process an order that doesn&#39;t exist in your database.<br>You are now fulfilling &quot;ghost&quot; orders.</pre><h3>Why Not Two-Phase Commit (2PC)?</h3><p>Distributed transactions across modern cloud services and message brokers are slow, fragile, and create tight temporal coupling. If your message broker has a momentary latency spike, your database transactions hold locks, starving your database connection pool and taking down your entire API. Cloud-native storage services like DynamoDB and EventBridge do not even support XA transactions.</p><h3>2. How the Transactional Outbox Pattern Works</h3><p>The core philosophy of the Outbox Pattern is straightforward: <strong>Never talk to two external systems inside the same business request.</strong></p><p>Instead of writing to the database and talking over the network to a message broker, you execute a <strong>single, local database transaction</strong> that writes two things to the <em>same</em> database:</p><ul><li>Your domain record (e.g., the new Order row or item).</li><li>An event record in an Outbox table.</li></ul><p>Because both writes happen in the same local database transaction, they either both succeed or both fail. You get atomicity for free.</p><p>An asynchronous, dedicated publisher process then reads new records from the Outbox table and pushes them to your message broker.</p><pre>+-------------------------------------------------------------------------+<br>|                                API REQUEST                              |<br>|                                                                         |<br>|  +--------------------+                                                 |<br>|  |     App Server     |                                                 |<br>|  +---------+----------+                                                 |<br>|            |                                                            |<br>|            | 1. Single Local ACID Transaction                           |<br>|            v                                                            |<br>|  +-------------------------------------------------------------------+  |<br>|  |  DATABASE                                                         |  |<br>|  |                                                                   |  |<br>|  |  +-----------------------+     +-------------------------------+  |  |<br>|  |  |      Orders Table     |     |          Outbox Table         |  |  |<br>|  |  | (Business Data Saved) |     |  (Event Payload Queued)       |  |  |<br>|  |  +-----------------------+     +---------------+---------------+  |  |<br>|  +------------------------------------------------|------------------+  |<br>+---------------------------------------------------|---------------------+<br>                                                    |<br>                                                    | 2. Asynchronous Read<br>                                                    v<br>                                      +---------------------------+<br>                                      |     Outbox Publisher      |<br>                                      +-------------+-------------+<br>                                                    |<br>                                                    | 3. Publish Event<br>                                                    v<br>                                      +---------------------------+<br>                                      |     Amazon EventBridge    |<br>                                      +-------------+-------------+<br>                                                    |<br>                                      +-------------+-------------+<br>                                      |                           |<br>                                      v                           v<br>                             +-----------------+         +-----------------+<br>                             | Payment Service |         | Inventory Svc   |<br>                             +-----------------+         +-----------------+</pre><h3>3. Two Ways to Publish Outbox Events</h3><p>There are two primary ways to get events out of the Outbox table and into the event bus:</p><h4>Approach A: Polling Publisher (Worker Loop)</h4><p>A background worker periodically executes a query against the outbox table:</p><pre>SELECT id, event_type, payload<br>FROM outbox<br>WHERE status = &#39;PENDING&#39;<br>ORDER BY created_at ASC<br>LIMIT 100<br>FOR UPDATE SKIP LOCKED;</pre><ul><li><strong>Pros:</strong> Simple to implement on traditional relational databases (PostgreSQL/MySQL).</li><li><strong>Cons:</strong> Introduces polling latency (events sit waiting for the next poll cycle), increases continuous database CPU load, and requires careful indexing to prevent table locks.</li></ul><h4>Approach B: Change Data Capture (CDC) / Transaction Log Tailing</h4><p>Instead of actively polling the database engine, a background process tails the database’s internal write-ahead log (Postgres WAL, MySQL binlog, or DynamoDB Streams).</p><ul><li><strong>Pros:</strong> Zero query overhead on the database, sub-second latency, completely non-intrusive.</li><li><strong>Cons:</strong> Slightly more infrastructure setup, but on AWS, this is solved natively by managed serverless components.</li></ul><h3>4. Reference Architecture on AWS: DynamoDB + Streams + Lambda + EventBridge</h3><p>On AWS, the cleanest way to implement the Outbox Pattern is using <strong>Amazon DynamoDB</strong>, <strong>DynamoDB Streams</strong>, <strong>AWS Lambda</strong>, and <strong>Amazon EventBridge</strong>.</p><h4>How the AWS Flow Operates:</h4><ul><li><strong>Atomic Write (</strong>TransactWriteItems<strong>)</strong>: The application writes the business item (e.g., Order#101) and the outbox event (Event#evt_987) into DynamoDB in a single transaction.</li><li><strong>DynamoDB Streams</strong>: DynamoDB automatically pushes every committed change to its ordered shard log.</li><li><strong>Lambda Stream Processor</strong>: An AWS Lambda event source mapping reads batches of records from the stream.</li><li><strong>Publish to EventBridge</strong>: Lambda filters for outbox records and calls EventBridge.putEvents().</li><li><strong>EventBridge Routing</strong>: EventBridge evaluates rules and forwards events to downstream SQS queues, Step Functions, or partner APIs.</li><li><strong>Automatic Cleanup (DynamoDB TTL)</strong>: The outbox item includes a ttl timestamp (e.g., 24 hours). DynamoDB expires and purges the item automatically without extra code or compute cost.</li></ul><pre>+-----------------------------------------------------------------------------------+<br>|  AWS Serverless Outbox Architecture                                               |<br>|                                                                                   |<br>|  +--------------------+                                                           |<br>|  | API / Lambda App   |                                                           |<br>|  +---------+----------+                                                           |<br>|            |                                                                      |<br>|            | 1. TransactWriteItems (Order + Outbox Event with TTL)                |<br>|            v                                                                      |<br>|  +--------------------+                                                           |<br>|  |  Amazon DynamoDB   |                                                           |<br>|  +---------+----------+                                                           |<br>|            |                                                                      |<br>|            | 2. Change Data Capture Log                                           |<br>|            v                                                                      |<br>|  +--------------------+                                                           |<br>|  |  DynamoDB Streams  |                                                           |<br>|  +---------+----------+                                                           |<br>|            |                                                                      |<br>|            | 3. Batch Invocation (with Filter Criteria: BeginsWith &#39;EVENT#&#39;)      |<br>|            v                                                                      |<br>|  +--------------------+                                                           |<br>|  | Outbox Lambda      |                                                           |<br>|  | Forwarder          |                                                           |<br>|  +---------+----------+                                                           |<br>|            |                                                                      |<br>|            | 4. PutEvents                                                         |<br>|            v                                                                      |<br>|  +--------------------+                                                           |<br>|  | Amazon EventBridge |                                                           |<br>|  +---------+----------+                                                           |<br>|            |                                                                      |<br>|            +-----------------------+-----------------------+                      |<br>|            |                       |                       |                      |<br>|            v                       v                       v                      |<br>|     +--------------+        +--------------+        +--------------+              |<br>|     | Payment SQS  |        | Shipping SQS |        | Analytics SQS|              |<br>|     +--------------+        +--------------+        +--------------+              |<br>+-----------------------------------------------------------------------------------</pre><h3>5. Crucial Real-World Gotchas</h3><h4>1. At-Least-Once Delivery Means Consumers Must Be Idempotent</h4><p>The outbox pattern guarantees <strong>at-least-once</strong> delivery, not <strong>exactly-once</strong>.</p><p>If your forwarder Lambda publishes to EventBridge, but times out before acknowledging the stream batch, the stream will redeliver the batch and republish the event.</p><p>Downstream consumers must guard against duplicate deliveries using an <strong>Idempotent Consumer Pattern</strong>:</p><ul><li>Store processed eventIds in a DynamoDB table or Redis cache.</li><li>When receiving an event, perform a conditional write.</li><li>If the conditional write throws a ConditionalCheckFailedException, ignore the duplicate message and return success.</li></ul><h4>2. Stream Tuning and Poison Pills</h4><p>When consuming DynamoDB Streams with Lambda:</p><ul><li>Set BisectBatchOnFunctionError: true. If a malformed payload causes your Lambda to throw, DynamoDB Streams automatically splits the batch in two and retries each half until the exact bad record is isolated.</li><li>Configure MaximumRetryAttempts (e.g., 3) and attach an <strong>On-Failure SQS Dead Letter Queue (DLQ)</strong>. This prevents a single bad record (poison pill) from blocking stream progression.</li></ul><h4>3. Outbox Table Cleanup</h4><p>In high-throughput systems, an outbox table grows rapidly:</p><ul><li><strong>In DynamoDB</strong>: Use native Time to Live (TTL). Give outbox items a 24-hour expiration. DynamoDB deletes them in the background with zero impact on your read/write capacity units.</li><li><strong>In PostgreSQL</strong>: Use daily table partitioning (pg_partman) and drop partitions older than 7 days, or run an indexed background purge cron.</li></ul><h3>Summary Checklist for Production</h3><p>When implementing this pattern on AWS, keep this checklist in mind:</p><ul><li><strong>One Transaction:</strong> Always place the business entity update and the outbox event in the same TransactWriteItems call.</li><li><strong>Stream Filtering:</strong> Filter stream events at the Lambda event source mapping level to avoid waking up Lambda for non-event writes.</li><li><strong>Batch Failures:</strong> Handle partial failures returned by EventBridge.PutEvents to prevent dropping messages silently.</li><li><strong>Idempotent Consumers:</strong> Design every downstream consumer assuming it will receive the same event more than once.</li><li><strong>Automated Retention:</strong> Set a TTL on outbox items in DynamoDB so storage remains bounded without maintenance overhead.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ce1b06d69a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Most Frontend Bugs Are One of These 4 Problems]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://javascript.plainenglish.io/most-frontend-bugs-are-one-of-these-4-problems-f2b66a90b6fc?source=rss-f62bfb96deb4------2"><img src="https://cdn-images-1.medium.com/max/2600/1*xgCNmRM00qYMeQMDAwKHeQ.jpeg" width="2848"></a></p><p class="medium-feed-snippet">Only 53% of the top 1,000 most visited websites pass Google&#x2019;s Interaction to Next Paint check, the metric that measures how fast a page&#x2026;</p><p class="medium-feed-link"><a href="https://javascript.plainenglish.io/most-frontend-bugs-are-one-of-these-4-problems-f2b66a90b6fc?source=rss-f62bfb96deb4------2">Continue reading on JavaScript in Plain English »</a></p></div>]]></description>
            <link>https://javascript.plainenglish.io/most-frontend-bugs-are-one-of-these-4-problems-f2b66a90b6fc?source=rss-f62bfb96deb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2b66a90b6fc</guid>
            <category><![CDATA[web-performance]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Madhura Jayashanka]]></dc:creator>
            <pubDate>Sat, 23 May 2026 04:51:14 GMT</pubDate>
            <atom:updated>2026-05-23T04:51:14.015Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Stop Writing Bad Dockerfiles: A Guide to Production Containerization]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://javascript.plainenglish.io/stop-writing-bad-dockerfiles-a-guide-to-production-containerization-0844e1d9e267?source=rss-f62bfb96deb4------2"><img src="https://cdn-images-1.medium.com/max/1672/1*jIv1GQ4_m-UiMwHXjjUEtg.png" width="1672"></a></p><p class="medium-feed-snippet">A bad Dockerfile usually starts with confidence.</p><p class="medium-feed-link"><a href="https://javascript.plainenglish.io/stop-writing-bad-dockerfiles-a-guide-to-production-containerization-0844e1d9e267?source=rss-f62bfb96deb4------2">Continue reading on JavaScript in Plain English »</a></p></div>]]></description>
            <link>https://javascript.plainenglish.io/stop-writing-bad-dockerfiles-a-guide-to-production-containerization-0844e1d9e267?source=rss-f62bfb96deb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/0844e1d9e267</guid>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Madhura Jayashanka]]></dc:creator>
            <pubDate>Tue, 12 May 2026 17:35:39 GMT</pubDate>
            <atom:updated>2026-05-12T17:35:39.432Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Your Phone Already Knows What You Are About to Type. Here Is the Math Behind It.]]></title>
            <link>https://medium.com/@madhurajayashanka/your-phone-already-knows-what-you-are-about-to-type-here-is-the-math-behind-it-40c770acaffe?source=rss-f62bfb96deb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/40c770acaffe</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Madhura Jayashanka]]></dc:creator>
            <pubDate>Thu, 26 Mar 2026 07:36:45 GMT</pubDate>
            <atom:updated>2026-03-26T07:36:45.103Z</atom:updated>
            <content:encoded><![CDATA[<p>A no-nonsense guide to N-gram models and Bigrams for people who want to actually understand NLP from scratch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QurtOIh-jTNq_DXNtPcz5w.png" /></figure><p>Open your messaging app right now. Start typing “I am going to the” and watch what appears above your keyboard. Your phone will probably suggest “store”, “gym”, or “park”. Not “spaceship”. Not “moon”. Those suggestions feel almost human, right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*DTlUl-vLVeSy8tphKvijJQ.png" /></figure><p>That tiny feature, something so small you barely notice it, is powered by one of the oldest and most foundational ideas in Natural Language Processing. It is called an <strong>N-gram model</strong>. And once you understand it, you will see it everywhere.</p><p>Let’s get into it from the ground up.</p><h3>First, What Even Is a Language Model?</h3><p>Before we talk about N-grams specifically, you need a mental model for what a “language model” is trying to do.</p><p>A language model is a system that answers one question:</p><blockquote><strong><em>Given what has been said so far, what word is likely to come next?</em></strong></blockquote><p>That is it. That is the whole game. Whether we are talking about N-grams, LSTMs, or GPT-4, they are all trying to answer this one question. They just do it with different amounts of math and compute.</p><p>N-gram models are the simplest answer to this question. They look at the last N words and make a prediction based on what they have seen in training text. No neural networks. No attention mechanisms. Just counting words.</p><h3>So What Exactly Is an N-gram?</h3><p>An N-gram is just a sequence of N words (or characters, or tokens) that appear together in text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mUWO2Sv0sjE6ukq8coAg5A.png" /></figure><p>Here is a sentence:</p><blockquote><strong><em>“The cat sat on the mat”</em></strong></blockquote><p>Let’s break it into different N-gram sizes:</p><p><strong>Unigrams (N=1)</strong> — single words:</p><pre>&quot;The&quot;, &quot;cat&quot;, &quot;sat&quot;, &quot;on&quot;, &quot;the&quot;, &quot;mat&quot;</pre><p><strong>Bigrams (N=2)</strong> — pairs of consecutive words:</p><pre>(&quot;The&quot;, &quot;cat&quot;), (&quot;cat&quot;, &quot;sat&quot;), (&quot;sat&quot;, &quot;on&quot;), (&quot;on&quot;, &quot;the&quot;), (&quot;the&quot;, &quot;mat&quot;)</pre><p><strong>Trigrams (N=3)</strong> — triplets:</p><pre>(&quot;The&quot;, &quot;cat&quot;, &quot;sat&quot;), (&quot;cat&quot;, &quot;sat&quot;, &quot;on&quot;), (&quot;sat&quot;, &quot;on&quot;, &quot;the&quot;), (&quot;on&quot;, &quot;the&quot;, &quot;mat&quot;)</pre><p>That is all an N-gram is. A <a href="https://www.geeksforgeeks.org/dsa/window-sliding-technique/">sliding window</a> of N words moving across a sentence. The “N” is just whatever number you choose.</p><h3>The Bigram Model: Where Things Get Interesting</h3><p>A <strong>Bigram Model</strong> is an N-gram model where N=2. It predicts the next word by only looking at the one word before it.</p><p>The core idea comes from probability. Given a word W1, what is the probability that word W2 follows it?</p><p>We write this as:</p><pre>P(W2 | W1) = Count(W1, W2) / Count(W1)</pre><p>Read that as: the probability of W2 given W1 equals the number of times we saw W1 followed by W2, divided by the total times we saw W1 appear.</p><p>Let me show you with a concrete example.</p><h3>Real Example: Building a Tiny Bigram Model from Scratch</h3><p>Imagine our entire training corpus is just these three sentences:</p><pre>&quot;I love coffee&quot;<br>&quot;I love tea&quot;<br>&quot;I drink coffee every morning&quot;</pre><p><strong>Step 1: Collect all bigrams and count them</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*ZlK1pWgP1YQHwtYTGjcthQ.png" /></figure><p><strong>Step 2: Count how often each first word appears</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*UsDBoY6upcoJIzTP1gikgw.png" /></figure><p><strong>Step 3: Calculate probabilities</strong></p><pre>P(love | I)   = 2/3 = 0.67<br>P(drink | I)  = 1/3 = 0.33<br><br>P(coffee | love) = 1/2 = 0.50<br>P(tea | love)    = 1/2 = 0.50</pre><p>So if someone types “I”, our bigram model says there is a 67% chance the next word is “love” and a 33% chance it is “drink”. That is your autocomplete, right there.</p><h3>Let’s Write the Code</h3><p>Here is a clean Python implementation of a Bigram model from scratch. No libraries needed for the core logic.</p><pre>from collections import defaultdict, Counter<br>import random<br><br># Our tiny training corpus<br>corpus = [<br>    &quot;I love coffee&quot;,<br>    &quot;I love tea&quot;,<br>    &quot;I drink coffee every morning&quot;,<br>    &quot;she loves coffee too&quot;,<br>    &quot;she drinks tea every evening&quot;,<br>    &quot;coffee is great in the morning&quot;,<br>    &quot;tea is great in the evening&quot;<br>]<br><br># Step 1: Tokenize and build bigram counts<br>bigram_counts = defaultdict(Counter)<br><br>for sentence in corpus:<br>    words = sentence.lower().split()<br>    for i in range(len(words) - 1):<br>        w1 = words[i]<br>        w2 = words[i + 1]<br>        bigram_counts[w1][w2] += 1<br><br># Step 2: Convert counts to probabilities<br>def get_next_word_probabilities(word):<br>    if word not in bigram_counts:<br>        return {}<br>    <br>    followers = bigram_counts[word]<br>    total = sum(followers.values())<br>    <br>    return {w: count / total for w, count in followers.items()}<br><br># Step 3: Predict next word (greedy - picks the most likely)<br>def predict_next(word):<br>    probs = get_next_word_probabilities(word)<br>    if not probs:<br>        return None<br>    return max(probs, key=probs.get)<br><br># Step 4: Generate a full sentence<br>def generate_sentence(start_word, max_words=10):<br>    sentence = [start_word]<br>    current = start_word.lower()<br>    <br>    for _ in range(max_words - 1):<br>        next_word = predict_next(current)<br>        if next_word is None:<br>            break<br>        sentence.append(next_word)<br>        current = next_word<br>    <br>    return &quot; &quot;.join(sentence)<br><br># Let&#39;s test it<br>print(predict_next(&quot;i&quot;))<br>print(predict_next(&quot;coffee&quot;))<br>print(generate_sentence(&quot;I&quot;))<br>print(generate_sentence(&quot;she&quot;))</pre><p><strong>Output:</strong></p><pre>love<br>is<br>I love coffee is great in the morning<br>she loves coffee is great in the morning</pre><p>Notice how “I love coffee is great in the morning” kind of makes sense in pieces but falls apart as a full sentence. That is a classic bigram model behavior. It is locally coherent but globally confused.</p><h3>Adding Randomness: Sampling Instead of Greedy Picking</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FF6ynqWMVttEmfJOD6LpeQ.png" /></figure><p>The greedy approach always picks the most probable word. That makes the output repetitive and boring. Real language has variety. So instead, we can <strong>sample</strong> from the probability distribution.</p><pre>def sample_next_word(word):<br>    probs = get_next_word_probabilities(word)<br>    if not probs:<br>        return None<br>    <br>    words = list(probs.keys())<br>    probabilities = list(probs.values())<br>    <br>    return random.choices(words, weights=probabilities, k=1)[0]<br><br>def generate_sentence_sampled(start_word, max_words=10):<br>    sentence = [start_word]<br>    current = start_word.lower()<br>    <br>    for _ in range(max_words - 1):<br>        next_word = sample_next_word(current)<br>        if next_word is None:<br>            break<br>        sentence.append(next_word)<br>        current = next_word<br>    <br>    return &quot; &quot;.join(sentence)<br><br># Run it a few times and notice the variety<br>for _ in range(4):<br>    print(generate_sentence_sampled(&quot;I&quot;))</pre><p><strong>Sample Output (will vary each run):</strong></p><pre>I drink coffee is great in the evening<br>I love tea is great in the morning<br>I love coffee every morning<br>I drink coffee every evening</pre><p>Now each run gives you something slightly different. This is actually how early text generation systems worked before transformers took over.</p><h3>Where N-gram Models Show Up in the Real World</h3><p>You probably interact with N-gram based systems more than you think.</p><p><strong>1. Autocomplete and autocorrect</strong> on your phone uses N-gram models, sometimes combined with neural methods. Early versions of Gmail Smart Compose were partially bigram/trigram based before they moved to neural approaches.</p><p><strong>2. Spell checking</strong> uses N-gram context to figure out which correction makes more sense. “I want to meat you” versus “I want to meet you” is a context problem that N-grams can catch.</p><p><strong>3. Speech recognition</strong> systems use N-gram language models to pick the most probable transcription among similar sounding words. “I scream” versus “ice cream” is a classic example.</p><p><strong>4. SEO and keyword analysis</strong> tools use N-gram analysis to understand what phrases appear together in high ranking content. Many content optimization tools internally count bigrams and trigrams from top-ranking pages.</p><p><strong>5. Plagiarism detection</strong> compares N-gram fingerprints between documents. If two documents share an unusually high number of 5-grams, there is probably some copying going on.</p><h3>Why N-gram Models Matter Even in the Age of GPT</h3><p>You might be thinking: if we have transformers now, why should anyone care about N-gram models?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AXlY4lPma-QA3fdf1R1kTA.png" /></figure><p>A few honest reasons:</p><p><strong>1. They are interpretable.</strong> You can look at every probability in an N-gram model and understand exactly why it made a prediction. You cannot do that with a 70 billion parameter neural network.</p><p><strong>2. They are fast and cheap.</strong> No GPU needed. A bigram model can run on a Raspberry Pi. For simple applications on low-resource devices, they are still used.</p><p><strong>3. They are a fundamental building block.</strong> Understanding N-grams gives you the intuition for why neural language models work the way they do. The attention mechanism in transformers is basically a very sophisticated version of “what context do I need to predict the next word.”</p><p><strong>4. Character-level N-grams are still useful.</strong> For tasks like language identification, author attribution, and certain types of text classification, character N-grams remain competitive even against modern deep learning approaches.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40c770acaffe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Using Express.js in 2026: The Modern Node.js Backend Stack That Replaced It]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://javascript.plainenglish.io/stop-using-express-js-in-2026-the-modern-node-js-backend-stack-that-replaced-it-a503bfc42878?source=rss-f62bfb96deb4------2"><img src="https://cdn-images-1.medium.com/max/1600/1*94IGdtVdXrqpRTai077Lvw.png" width="1600"></a></p><p class="medium-feed-snippet">Express.js was created in 2010. That&#x2019;s 16 years ago. Your framework is old enough to get a driver&#x2019;s license.</p><p class="medium-feed-link"><a href="https://javascript.plainenglish.io/stop-using-express-js-in-2026-the-modern-node-js-backend-stack-that-replaced-it-a503bfc42878?source=rss-f62bfb96deb4------2">Continue reading on JavaScript in Plain English »</a></p></div>]]></description>
            <link>https://javascript.plainenglish.io/stop-using-express-js-in-2026-the-modern-node-js-backend-stack-that-replaced-it-a503bfc42878?source=rss-f62bfb96deb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/a503bfc42878</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Madhura Jayashanka]]></dc:creator>
            <pubDate>Fri, 06 Mar 2026 13:14:42 GMT</pubDate>
            <atom:updated>2026-06-04T13:26:12.543Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[My Hard Learned Guide to Med + IT]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://blog.stackademic.com/my-hard-learned-guide-to-med-it-577ddd4f2fbd?source=rss-f62bfb96deb4------2"><img src="https://cdn-images-1.medium.com/max/2600/1*2Zpm_bB8KFS9Mr9Lqj_j3A.jpeg" width="2752"></a></p><p class="medium-feed-snippet">Recently, I have done some projects and competitions related to combining IT and medicine together. I honestly knew only 2 compliances&#x2026;</p><p class="medium-feed-link"><a href="https://blog.stackademic.com/my-hard-learned-guide-to-med-it-577ddd4f2fbd?source=rss-f62bfb96deb4------2">Continue reading on Stackademic »</a></p></div>]]></description>
            <link>https://blog.stackademic.com/my-hard-learned-guide-to-med-it-577ddd4f2fbd?source=rss-f62bfb96deb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/577ddd4f2fbd</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[healthtech]]></category>
            <category><![CDATA[healthcare]]></category>
            <category><![CDATA[data-privacy]]></category>
            <dc:creator><![CDATA[Madhura Jayashanka]]></dc:creator>
            <pubDate>Wed, 25 Feb 2026 07:39:08 GMT</pubDate>
            <atom:updated>2026-02-27T08:11:51.414Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Web MCP: Turning Websites into AI Tools]]></title>
            <link>https://medium.com/@madhurajayashanka/web-mcp-turning-websites-into-ai-tools-41ce50f3b3bb?source=rss-f62bfb96deb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/41ce50f3b3bb</guid>
            <category><![CDATA[chrome-developer-tools]]></category>
            <category><![CDATA[web-mcp]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[mcps]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Madhura Jayashanka]]></dc:creator>
            <pubDate>Wed, 18 Feb 2026 03:10:42 GMT</pubDate>
            <atom:updated>2026-02-18T03:18:44.919Z</atom:updated>
            <content:encoded><![CDATA[<p>The Model Context Protocol (MCP) has been gaining traction as the “USB-C for AI applications.” It is a standard way to plug AI models into data sources and tools. Until recently, connecting an AI agent to a website was messy. Agents had to “look” at the screen, take screenshots, or guess which buttons to click.</p><p>That just changed.</p><p>Google’s Chrome team recently introduced “WebMCP.” This is a new browser standard that allows any website to explicitly tell an AI agent, <em>“Here are the tools I offer, and here is how you use them.”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p37MS-YnsBSJnzoKLHJvYg.jpeg" /></figure><h3>High Level View of What is Happening</h3><p>In simple terms, Web MCP turns your standard website into an API that browser-based AI agents can read.</p><p>Currently, if you ask an AI to “buy me a flight,” it has to scrape the webpage, guess what the “Search” button looks like, and hope it clicks the right thing. It is slow and error-prone (<strong>nondeterministic</strong>).</p><p>Web MCP fixes this by giving the website a voice. The website can now say:</p><ul><li>“I have a tool called search_flights.&quot;</li><li>“It requires a destination and a date.&quot;</li></ul><p>The AI doesn’t guess. It calls the tool.</p><h3>Why is This a Big Deal</h3><p>Browser-based AI has a reliability problem. Agents fail because websites are built for human eyes, not robot logic. A slight design change can break an AI agent’s ability to navigate.</p><p>Web MCP solves this by separating the <strong>action</strong> from the <strong>visuals</strong>.</p><ul><li><strong>Speed:</strong> The agent doesn’t need to parse a massive HTML tree or process images.</li><li><strong>Accuracy:</strong> The website defines exactly what inputs are needed. If a form requires an email, the agent knows it must provide a valid email format.</li><li><strong>Privacy:</strong> The action happens locally in the user’s browser session. The agent uses the user’s existing login state.</li></ul><h3>Example: A “Grocery List” App</h3><p>Imagine a simple React-based grocery list app. You want an AI to “Add ingredients for Chicken Soup.”</p><p><strong>The Old Way:</strong> The AI takes a screenshot. It tries to find the “Add Item” input box. It types “Chicken,” clicks enter, waits, types “Carrots,” clicks enter. It might miss a click or type in the wrong box.</p><p><strong>The Web MCP Way:</strong> The developer adds a few lines of code to their app.</p><ol><li>They register a tool called add_grocery_item.</li><li>They define the inputs: item_name (text) and quantity (number).</li></ol><p>Now, the user says, “Add ingredients for Chicken Soup.” The AI sees the add_grocery_item tool. It instantly fires a list of commands: &quot;Add Chicken,&quot; &quot;Add Carrots,&quot; &quot;Add Celery.&quot; The app updates instantly. No clicking, no guessing.</p><h3>Technical Snapshot: Two Ways to Connect</h3><p>Web MCP offers two simple methods for developers to expose these tools.</p><p><strong>1. The Declarative Way (HTML)</strong> You add special attributes directly to your HTML forms. The browser reads these and creates a tool automatically.</p><pre>&lt;form tool-name=&quot;book_reservation&quot; tool-description=&quot;Book a table&quot;&gt;<br>  &lt;input name=&quot;party_size&quot; tool-param-description=&quot;Number of guests&quot; /&gt;<br>&lt;/form&gt;</pre><p><strong>2. The Imperative Way (JavaScript)</strong> For dynamic apps (like React or Vue), you use the new JavaScript API. You can register tools when a component loads and unregister them when it vanishes.</p><pre>window.navigator.modelContext.registerTool({<br>  name: &quot;add_task&quot;,<br>  description: &quot;Adds a new task to the board&quot;,<br>  parameters: { ... },<br>  handler: (args) =&gt; { app.addTask(args.title); }<br>});</pre><p><strong>Flow:</strong></p><ol><li><strong>Discovery:</strong> When the AI agent visits the page, it asks the browser, “What tools are here?”</li><li><strong>Selection:</strong> The browser lists the registered tools (e.g., search, add_to_cart).</li><li><strong>Execution:</strong> The AI sends a command. The browser executes the JavaScript handler defined by the website.</li><li><strong>Feedback:</strong> The website returns the result (e.g., “Item added”), and the agent confirms it to the user.</li></ol><h3>Why This Matters</h3><p>This update bridges the gap between “looking at” the web and “interacting with” the web. It allows developers to build “Agent-Ready” websites without building a separate, complex backend API just for bots.</p><p>It also introduces human-in-the-loop security. Browsers can show a “Please Confirm” prompt before an agent executes a sensitive tool, like “Purchase Flight.”</p><h3>Resources</h3><ul><li><a href="https://developer.chrome.com/blog/webmcp-epp?hl=en">WebMCP is available for early preview | Blog | Chrome for Developers</a></li><li><a href="https://modelcontextprotocol.io/">What is the Model Context Protocol (MCP)? - Model Context Protocol</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41ce50f3b3bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Multi-Tenant SaaS on AWS: Database Per Tenant vs Shared Schema (With Terraform)]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://aws.plainenglish.io/building-multi-tenant-saas-on-aws-database-per-tenant-vs-shared-schema-with-terraform-5b53c4f4ec2b?source=rss-f62bfb96deb4------2"><img src="https://cdn-images-1.medium.com/max/2600/1*6tftLJ82ZOP23ZiQHx1GZg.jpeg" width="2752"></a></p><p class="medium-feed-snippet">This is one of those classic engineering debates that doesn&#x2019;t have a single correct answer, only trade-offs. If you&#x2019;re building a SaaS&#x2026;</p><p class="medium-feed-link"><a href="https://aws.plainenglish.io/building-multi-tenant-saas-on-aws-database-per-tenant-vs-shared-schema-with-terraform-5b53c4f4ec2b?source=rss-f62bfb96deb4------2">Continue reading on AWS in Plain English »</a></p></div>]]></description>
            <link>https://aws.plainenglish.io/building-multi-tenant-saas-on-aws-database-per-tenant-vs-shared-schema-with-terraform-5b53c4f4ec2b?source=rss-f62bfb96deb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b53c4f4ec2b</guid>
            <category><![CDATA[multi-tenant-database]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[database-design]]></category>
            <dc:creator><![CDATA[Madhura Jayashanka]]></dc:creator>
            <pubDate>Fri, 06 Feb 2026 02:49:33 GMT</pubDate>
            <atom:updated>2026-02-07T12:43:13.873Z</atom:updated>
        </item>
    </channel>
</rss>