<?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 Srirammoorthy on Medium]]></title>
        <description><![CDATA[Stories by Srirammoorthy on Medium]]></description>
        <link>https://medium.com/@srirammoorthy11?source=rss-caea6de944f2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*N2uAmyGNyRRUEcM6KAqJeg.jpeg</url>
            <title>Stories by Srirammoorthy on Medium</title>
            <link>https://medium.com/@srirammoorthy11?source=rss-caea6de944f2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 10:30:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@srirammoorthy11/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[JWT Is More Than You Think: Authentication, Expiration, Refresh Tokens & DPOP]]></title>
            <link>https://medium.com/@srirammoorthy11/jwt-is-more-than-you-think-authentication-expiration-refresh-tokens-dpop-5bed61ba4d9d?source=rss-caea6de944f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/5bed61ba4d9d</guid>
            <category><![CDATA[jwt-authentication]]></category>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[refresh-token]]></category>
            <category><![CDATA[web-authentication]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Srirammoorthy]]></dc:creator>
            <pubDate>Sat, 21 Nov 2026 15:33:33 GMT</pubDate>
            <atom:updated>2026-11-21T15:33:33.723Z</atom:updated>
            <content:encoded><![CDATA[<p>Authentication is one of the most important parts of any modern application. Whether you’re building an e-commerce platform, a SaaS product, or a REST API, you need a reliable way to identify users and control access to protected resources.</p><p>One popular approach is <strong>JSON Web Token (JWT)</strong> authentication.</p><p>JWT makes it possible to exchange user identity and authorization information between different components of an application without requiring the server to maintain a traditional session for every access-token request.</p><p>But how does JWT actually work? What happens when a token expires? How do refresh tokens work? And how can we store these tokens securely?</p><p>Let’s understand the complete authentication flow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*61lVNzbZDZ11yPE_" /></figure><h3>1. What is JWT?</h3><p>JSON Web Token (JWT) is a compact, URL-safe format used to securely represent claims between two parties.</p><p>A claim is simply a piece of information about a user or another entity.</p><p>For example:</p><ul><li>User ID</li><li>Username</li><li>Role</li><li>Permissions</li><li>Token expiration time</li></ul><p>A typical signed JWT consists of three parts:</p><ol><li>Header</li><li>Payload</li><li>Signature</li></ol><p>These three parts are separated by dots (.).</p><pre>header.payload.signature</pre><p>Each part is Base64URL-encoded.</p><h3>2. Understanding the Three Parts of JWT</h3><h3>Header</h3><p>The header contains metadata about the token.</p><p>For example:</p><pre>{<br>  &quot;alg&quot;: &quot;HS256&quot;,<br>  &quot;typ&quot;: &quot;JWT&quot;<br>}</pre><p>Here:</p><ul><li>alg specifies the signing algorithm.</li><li>typ identifies the token type.</li></ul><p>The algorithm tells the receiving server how the signature should be verified.</p><h3>Payload</h3><p>The payload contains the claims associated with the token.</p><p>For example:</p><pre>{<br>  &quot;sub&quot;: &quot;user_123&quot;,<br>  &quot;role&quot;: &quot;admin&quot;,<br>  &quot;scope&quot;: &quot;read write&quot;,<br>  &quot;iat&quot;: 1795000000,<br>  &quot;exp&quot;: 1795000900<br>}</pre><p>Some commonly used claims include:</p><ul><li>sub: Subject or user identifier.</li><li>iat: Issued-at timestamp.</li><li>exp: Expiration timestamp.</li><li>iss: Token issuer.</li><li>aud: Intended audience.</li><li>jti: Unique token identifier.</li></ul><p><strong>Important security point:</strong> A signed JWT is not encrypted by default. Its header and payload are Base64URL-encoded, meaning anyone who obtains the token can decode and read them.</p><p>Therefore, never include passwords, secret keys, or sensitive personal information in an ordinary signed JWT.</p><h3>Signature</h3><p>The signature is what protects the token against unauthorized modification.</p><p>When generating a signed JWT, the server:</p><ol><li>Encodes the header.</li><li>Encodes the payload.</li><li>Combines both encoded values.</li><li>Signs the combined data using a secret key or private key and the selected algorithm.</li></ol><p>Conceptually:</p><pre>signature = Sign(<br>    encoded_header + &quot;.&quot; + encoded_payload,<br>    secret_key<br>)</pre><p>When a client sends the token back, the server verifies the signature.</p><p>If someone modifies the payload, the signature verification fails.</p><p>This provides integrity and authenticity, assuming the signing key and verification process are properly secured.</p><h3>3. How JWT Authentication Works</h3><p>Let’s understand the authentication process using a simple example.</p><p>Imagine a user logging into an application.</p><p><strong>Step 1 — Login</strong></p><p>The user submits their username and password.</p><p><strong>Step 2 — Credential verification</strong></p><p>The backend verifies the submitted credentials against the stored user information.</p><p><strong>Step 3 — Token generation</strong></p><p>If the credentials are valid, the server generates:</p><ul><li>A short-lived access token.</li><li>A longer-lived refresh token.</li></ul><p><strong>Step 4 — Token delivery</strong></p><p>The server sends the access token to the client and securely stores the refresh token in an HttpOnly cookie.</p><p><strong>Step 5 — Accessing protected resources</strong></p><p>The client includes the access token in API requests:</p><pre>Authorization: Bearer &lt;access_token&gt;</pre><p>The backend verifies the token’s signature, expiration, issuer, audience, and other required claims before granting access.</p><p>This process allows the backend to authenticate requests without querying a session record for every access-token verification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7PejFe8Xcunc-SaJ" /></figure><h3>4. Access Tokens vs Refresh Tokens</h3><p>Using a single long-lived access token creates a security problem.</p><p>If someone steals that token, they may be able to access protected resources until it expires or is otherwise invalidated.</p><p>A better approach is to use two different tokens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*SRqKjqhKmwB9ubzq1KWa_w.png" /></figure><p>The access token is used for normal API requests, whereas the refresh token is used only when a new access token is required.</p><p>An important distinction: refresh tokens do not have to be JWTs. They can be opaque, cryptographically random values.</p><h3>5. Secure Refresh Token Storage Using HttpOnly Cookies</h3><p>For browser-based applications, securely storing refresh tokens is particularly important.</p><p>One recommended approach is to store the refresh token in an HttpOnly cookie.</p><p>Consider the following cookie configuration:</p><pre>Set-Cookie: refresh_token=&lt;token&gt;;<br>HttpOnly;<br>Secure;<br>SameSite=Lax;<br>Path=/auth/refresh</pre><p>Let’s understand these attributes:</p><ul><li><strong>HttpOnly:</strong> JavaScript cannot directly read the cookie through document.cookie.</li><li><strong>Secure:</strong> The browser sends the cookie only over HTTPS.</li><li><strong>SameSite:</strong> Controls when the browser sends cookies in cross-site requests.</li><li><strong>Path:</strong> Restricts the requests to which the browser attaches the cookie.</li></ul><p>The main advantage is that JavaScript cannot directly access the refresh token.</p><p>However, HttpOnly cookies do not eliminate every security risk. Since browsers automatically attach cookies to matching requests, applications must also implement appropriate CSRF protections.</p><p>Also, avoid storing long-lived authentication tokens in localStorage or sessionStorage because JavaScript executing in the same origin can access them.</p><h3>6. What Happens When an Access Token Expires?</h3><p>Access tokens are intentionally short-lived.</p><p>Suppose an access token expires after 10 minutes.</p><p>When the client makes another API request using that expired token, the backend responds with:</p><pre>HTTP/1.1 401 Unauthorized</pre><p>The frontend can then initiate the refresh process.</p><p>The flow is:</p><ol><li>The frontend detects the expired access token.</li><li>It sends a POST request to /auth/refresh.</li><li>The browser automatically attaches the refresh-token cookie.</li><li>The backend validates the refresh token against its server-side record.</li><li>If valid, the backend generates a new access token.</li><li>The frontend uses the new access token for subsequent API requests.</li></ol><p>If the refresh token is invalid, expired, or revoked, the backend rejects the request, clears the refresh cookie, and requires the user to authenticate again.</p><p>Notice that the frontend does not need to read the refresh token itself.</p><h3>7. Refresh Token Rotation</h3><p>Refresh token rotation is an important security mechanism.</p><p>Instead of allowing the same refresh token to be reused repeatedly, the server issues a new refresh token whenever the existing one is successfully used.</p><p>For example:</p><pre>Initial Login<br>     |<br>     v<br>Refresh Token A<br>     |<br>     v<br>Refresh Request<br>     |<br>     v<br>Validate Token A<br>     |<br>     v<br>Issue Token B<br>     |<br>     v<br>Invalidate Token A</pre><p>Now, imagine someone tries to use Token A again.</p><p>Since Token A has already been invalidated, the server detects that an old token has been reused.</p><p>This could indicate token theft or a replay attack.</p><p>A robust implementation can revoke the entire refresh-token family associated with that session.</p><p>The invalidation and replacement operations should be performed atomically using a database transaction to prevent race conditions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G_QycYBF5XaPMI-i" /></figure><h3>8. Additional Security: Token Binding</h3><p>Another interesting security concept is token binding.</p><p>The idea is to associate a token with additional information about the client that is authorized to use it.</p><p>One modern approach is <strong>Demonstrating Proof of Possession (DPoP)</strong>.</p><p>Instead of relying only on possession of a bearer token, the client also provides a cryptographic proof demonstrating possession of a corresponding private key.</p><p>This makes it harder for an attacker to reuse a stolen token independently.</p><p>However, DPoP introduces additional implementation complexity and is not a replacement for basic JWT validation or secure token storage.</p><h3>9. Advantages and Trade-offs of JWT</h3><h3>Advantages</h3><ul><li><strong>Stateless access-token verification:</strong> The server can verify signed tokens without maintaining a traditional session record for every request.</li><li><strong>Fast verification:</strong> Signature verification can happen locally without a database lookup.</li><li><strong>Portability:</strong> JWTs use a standardized JSON-based format.</li><li><strong>Distributed architecture:</strong> Multiple services can verify tokens using shared verification configuration or public keys.</li><li><strong>Broad ecosystem support:</strong> Many programming languages provide established JWT libraries.</li></ul><h3>Trade-offs</h3><ul><li><strong>Revocation complexity:</strong> A JWT generally remains valid until expiration unless additional revocation mechanisms are implemented.</li><li><strong>Token theft:</strong> A stolen bearer token can be reused by an attacker.</li><li><strong>Payload visibility:</strong> Signed JWT payloads are readable and are not encrypted by default.</li><li><strong>Token size:</strong> JWTs are generally larger than simple opaque session identifiers.</li><li><strong>Key management:</strong> Signing keys must be securely stored, rotated, and protected.</li></ul><p>JWT is not automatically better than traditional session-based authentication. The right approach depends on your application’s architecture, security requirements, and operational needs.</p><h3>Conclusion</h3><p>JWT authentication is more than generating a token after a successful login.</p><p>A production-ready authentication system requires proper signature verification, token expiration, secure storage, refresh-token rotation, revocation strategies, and protection against common attacks.</p><p>Understanding how these components work together is essential when building secure backend applications.</p><p>The next time you implement authentication in a FastAPI or any other backend application, don’t just focus on generating JWTs. Think about the entire token lifecycle — from login to expiration, refresh, rotation, and logout.</p><p><strong>Because authentication isn’t just about issuing tokens. It’s about managing trust securely.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5bed61ba4d9d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the Transformer Architecture: From Embeddings to Attention]]></title>
            <link>https://medium.com/@srirammoorthy11/understanding-the-transformer-architecture-from-embeddings-to-attention-1158eab542ee?source=rss-caea6de944f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/1158eab542ee</guid>
            <category><![CDATA[encoder-decoder]]></category>
            <category><![CDATA[attention-is-all-you-need]]></category>
            <category><![CDATA[transformer-architecture]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Srirammoorthy]]></dc:creator>
            <pubDate>Fri, 06 Nov 2026 08:36:28 GMT</pubDate>
            <atom:updated>2026-11-06T08:36:28.043Z</atom:updated>
            <content:encoded><![CDATA[<p>The Transformer architecture is one of the most important developments in modern Artificial Intelligence. It powers many of today’s Large Language Models (LLMs) and has changed how machines process and understand human language.When I started learning about Transformers, I wanted to understand more than just how to use an LLM through an API. I wanted to understand what happens inside the model: how it represents words, captures relationships between tokens, and processes contextual information.</p><p>After studying the fundamental components, here’s my understanding of the Transformer architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*LmYL_a1BeRbFuQdoVCSXdw.png" /></figure><h3>1. Why Were Transformers Introduced?</h3><p>Before Transformers, sequence-processing models such as Recurrent Neural Networks (RNNs) and Long Short-Term Memory networks (LSTMs) were widely used for natural language processing.</p><p>However, these models processed sequences step by step. This made parallel processing difficult and created challenges when learning long-range relationships in text.</p><p>In 2017, researchers introduced the Transformer architecture in the paper <strong>“Attention Is All You Need.”</strong></p><p>The key idea was to build a sequence-processing architecture based on attention mechanisms rather than recurrence or convolution.</p><p>This made it possible to process input positions in parallel during training and capture relationships between different tokens using attention.</p><h3>2. Tokenization and Embeddings: Converting Text into Numbers</h3><p>Neural networks cannot directly understand raw text. Text must first be converted into numerical representations.</p><p>This process begins with tokenization.</p><p>Consider the sentence:</p><p>“The Transformer is powerful.”</p><p>A tokenizer splits the sentence into tokens and maps them to numerical token IDs.</p><p>These IDs are then passed through an embedding layer, which converts each token ID into a dense vector.</p><p>An embedding is a learned numerical representation that allows the model to work with tokens in a continuous vector space.</p><p>However, token embeddings alone do not tell the model where each token appears in a sequence.</p><p>That’s where positional information becomes important.</p><h3>3. Positional Encoding: Understanding Word Order</h3><p>Consider these two sentences:</p><ul><li>The dog chased the cat.</li><li>The cat chased the dog.</li></ul><p>They contain similar words, but their meanings are different because the word order changes.</p><p>Since self-attention does not inherently understand sequence order, the Transformer needs positional information.</p><p>The original Transformer uses sinusoidal positional encodings, which are added to token embeddings.</p><p><strong>Input representation = Token Embedding + Positional Encoding</strong></p><p>Other approaches include learned positional embeddings and Rotary Positional Embeddings (RoPE), which are used in many modern LLM architectures.</p><p>The important idea is that the model needs both token information and positional information to process a sequence effectively.</p><h3>4. Self-Attention: The Core of the Transformer</h3><p>Self-attention is one of the most important mechanisms in the Transformer architecture.</p><p>It allows each token to gather relevant information from other tokens in the same sequence.</p><p>Consider:</p><p>“The student studied hard because she had an exam.”</p><p>To understand the word “she”, the model needs to consider its relationship with other words, particularly “student”.</p><p>Self-attention helps the model establish these contextual relationships.</p><p>To calculate attention, the model creates three representations:</p><ul><li><strong>Query (Q):</strong> What information is this token looking for?</li><li><strong>Key (K):</strong> What information does this token offer for matching?</li><li><strong>Value (V):</strong> What information should be contributed?</li></ul><p>These are generated using learned linear transformations of the input representations.</p><p>The scaled dot-product attention formula is:</p><p>Attention(Q, K, V) = softmax(QKᵀ / √dₖ)V</p><p>The calculation involves four main steps:</p><ol><li>Calculate similarity scores between queries and keys.</li><li>Scale the scores using the square root of the key dimension.</li><li>Apply softmax to obtain attention weights.</li><li>Use those weights to calculate a weighted sum of value vectors.</li></ol><p>The result is a contextual representation of each token.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oUeKHqIpkO324XLf" /></figure><h3>5. Multi-Head Attention: Learning Different Relationships</h3><p>A single attention operation can capture relationships between tokens, but the Transformer uses multiple attention heads.</p><p>This is called Multi-Head Attention.</p><p>Each attention head has its own learned Query, Key, and Value projections.</p><p>Multiple heads perform attention computations in parallel. Their outputs are concatenated and passed through a final learned linear projection.</p><p>Why multiple heads?</p><p>Different heads can learn different attention patterns and represent different types of relationships within the input.</p><p>For example, one head might focus on nearby words, while another might learn relationships between words that are farther apart.</p><p>However, these roles are not predefined. The model learns its attention patterns during training.</p><h3>6. Inside a Transformer Block</h3><p>Attention alone is not enough. A Transformer block contains additional components that help the model process and transform information.</p><h3>Feed-Forward Network (FFN)</h3><p>After attention, each token representation passes through a Feed-Forward Network.</p><p>Unlike attention, which allows information to flow between token positions, the FFN processes each token position independently using the same learned network.</p><p>A simplified representation is:</p><p>FFN(x) = W₂ σ(W₁x + b₁) + b₂</p><p>It applies learned transformations and a non-linear activation function to the representation.</p><h3>Residual Connections</h3><p>Deep neural networks contain many layers, and training them can become difficult.</p><p>Residual connections provide a direct path for information and gradients to flow through the network.</p><p>Their simplified formula is:</p><p>Output = x + F(x)</p><p>Instead of replacing the original representation entirely, the model adds the sub-layer’s output to the original input.</p><h3>Layer Normalization</h3><p>Layer Normalization helps stabilize the values within a token representation during training.</p><p>It normalizes features within each token representation and uses learnable scale and shift parameters.</p><p>Together, attention, feed-forward networks, residual connections, and normalization form the fundamental structure of a Transformer block.</p><h3>7. Understanding the Three Major Transformer Designs</h3><p>Transformer-based models can use different architectural designs depending on their purpose.</p><h3>Encoder-Only Architecture</h3><p>The encoder processes input tokens using bidirectional self-attention. Each token can attend to both preceding and following tokens.</p><p>A popular example is BERT.</p><p>Common applications include:</p><ul><li>Sentiment analysis</li><li>Text classification</li><li>Named entity recognition</li><li>Semantic similarity</li></ul><h3>Decoder-Only Architecture</h3><p>The decoder-only architecture uses causal self-attention.</p><p>A token can attend to itself and previous tokens, but not future tokens.</p><p>This makes it suitable for autoregressive text generation, where the model predicts the next token based on the tokens already available.</p><p>Examples include GPT, Llama, and Qwen.</p><h3>Encoder-Decoder Architecture</h3><p>This architecture combines an encoder and a decoder.</p><p>The encoder processes the input, while the decoder generates the output using information from the encoder.</p><p>Cross-attention allows the decoder to attend to the encoder’s output.</p><p>A common example is T5.</p><p>Typical applications include machine translation and sequence-to-sequence tasks.</p><h3>8. Bringing Everything Together</h3><p>Let’s connect the concepts we have studied.</p><p>A simplified Transformer processing pipeline looks like this:</p><ol><li>Text is split into tokens.</li><li>Tokens are converted into numerical IDs.</li><li>Embedding layers convert IDs into vectors.</li><li>Positional information is incorporated.</li><li>Attention mechanisms capture relationships between tokens.</li><li>Feed-forward networks transform token representations.</li><li>Residual connections and Layer Normalization support stable deep processing.</li><li>Multiple Transformer blocks are stacked to build deeper representations.</li><li>Depending on the architecture, the model produces contextual representations or generates output tokens.</li></ol><p>The original Transformer uses both encoder and decoder stacks. Modern architectures such as GPT-style models use decoder-only designs.</p><h3>Conclusion</h3><p>Learning the Transformer architecture has helped me understand what happens behind modern language models.</p><p>The most important takeaway is that Transformers are not simply neural networks that predict the next word. They use embeddings, positional information, attention mechanisms, and multiple processing layers to build contextual representations of sequences.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1158eab542ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Message Queue vs Pub/Sub vs Message Broker: What’s Really Different?]]></title>
            <link>https://medium.com/@srirammoorthy11/message-queue-vs-pub-sub-vs-message-broker-whats-really-different-b79d5271f376?source=rss-caea6de944f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/b79d5271f376</guid>
            <category><![CDATA[rabbitmq]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[pub-sub]]></category>
            <category><![CDATA[message-queue]]></category>
            <category><![CDATA[message-broker]]></category>
            <dc:creator><![CDATA[Srirammoorthy]]></dc:creator>
            <pubDate>Wed, 04 Nov 2026 18:01:51 GMT</pubDate>
            <atom:updated>2026-11-04T18:01:51.962Z</atom:updated>
            <content:encoded><![CDATA[<p>Modern applications often perform multiple operations in response to a single user request. For example, when a customer places an order, the application might need to update inventory, send an email, generate an invoice and update analytics.</p><p>Performing all these operations synchronously can increase response time and tightly couple different services.</p><p>This is where <strong>message queues and messaging systems</strong> become useful.</p><p>Let’s understand the fundamental concepts behind them.</p><h3>1. What is a Message Queue?</h3><p>A message queue is a messaging pattern that enables asynchronous communication between different components of an application.</p><p>It allows one component to send a message without waiting for another component to process it immediately.</p><p>A typical message queue architecture consists of three components:</p><ul><li><strong>Producer:</strong> Creates and sends messages.</li><li><strong>Queue:</strong> Temporarily stores messages until they are processed.</li><li><strong>Consumer:</strong> Receives and processes messages.</li></ul><p>The communication flow looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*k8Y6dtb9JpquZaw3.png" /></figure><p>For example, imagine an application that sends emails after user registration.</p><p>Instead of sending the email directly during the registration request, the application can publish an email job to a queue. A background worker retrieves that job and sends the email.</p><p>The user does not need to wait for the email operation to finish before receiving a registration response.</p><h3>Why do we need message queues?</h3><p>Message queues solve several important problems:</p><ol><li><strong>Decoupling:</strong> Producers and consumers do not need to communicate directly.</li><li><strong>Asynchronous processing:</strong> Time-consuming operations can run in the background.</li><li><strong>Load distribution:</strong> Multiple workers can process incoming jobs.</li><li><strong>Reliability:</strong> Messages can remain available for retry or recovery when processing fails, depending on broker configuration.</li><li><strong>Scalability:</strong> We can increase the number of consumers when the workload increases.</li></ol><p>Common applications include:</p><ul><li>Payment-related background workflows.</li><li>Email and notification delivery.</li><li>Image and video processing.</li><li>Report generation.</li><li>Background job processing.</li></ul><h3>2. Producer–Consumer Architecture</h3><p>Producer–Consumer is a fundamental architecture in distributed systems.</p><p>The producer generates work, while the consumer processes that work. A queue acts as an intermediary between them.</p><p>Consider an application that receives 1,000 image uploads.</p><p>Instead of processing all images inside the API request, the application can publish 1,000 image-processing jobs to a queue.</p><p>Multiple workers can then retrieve and process those jobs concurrently.</p><h3>Competing Consumers (Work Queue Pattern)</h3><p>When multiple consumers listen to the same work queue, they compete to receive available messages.</p><p>For example:</p><p>Producer → Queue → Consumer 1, Consumer 2, Consumer 3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jWzydKgz5sVhuPP6.png" /></figure><p>The broker distributes available messages among the consumers so that each message is normally handled by one consumer in the group.</p><p>If Consumer 1 is busy processing a job, another available consumer can receive a different job.</p><p>This approach provides:</p><ul><li>Parallel processing.</li><li>Better workload distribution.</li><li>Increased processing throughput.</li><li>Greater flexibility when scaling workers.</li></ul><p>This pattern is commonly called the <strong>Competing Consumers Pattern</strong> or <strong>Work Queue Pattern</strong>.</p><p>An important detail: in systems with manual acknowledgements, a message is generally removed or marked as successfully handled only after the consumer acknowledges it. If processing fails, it may be redelivered depending on the broker and its configuration.</p><h3>3. What is Publish–Subscribe (Pub/Sub)?</h3><p>Publish–Subscribe is another messaging pattern.</p><p>Unlike a traditional work queue, Pub/Sub allows one publisher to distribute an event to multiple independent subscribers.</p><p>The publisher does not need to know which services are interested in the event.</p><p>For example, imagine an e-commerce application.</p><p>When a customer places an order, an OrderCreated event is published.</p><p>Multiple services can subscribe to this event:</p><ul><li>Inventory Service</li><li>Analytics Service</li><li>Notification Service</li></ul><p>The architecture looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*YLGtBABTgumZfiXn" /></figure><p>Each independent subscriber receives the event and processes it according to its responsibility.</p><h3>Why do we need Pub/Sub?</h3><p>Pub/Sub solves the problem of event broadcasting.</p><p>Consider an order creation workflow.</p><p>When an order is created:</p><ol><li>Inventory Service updates the available stock.</li><li>Analytics Service records the order information.</li><li>Notification Service sends an order confirmation.</li></ol><p>These services do not need to call each other directly.</p><p>They independently subscribe to the OrderCreated event.</p><p>This provides:</p><ul><li>Loose coupling between services.</li><li>Independent service development.</li><li>Better scalability.</li><li>Easier integration of new subscribers.</li><li>Event-driven communication.</li></ul><p>This pattern is especially useful in microservices architectures.</p><h3>4. Message Queue vs Pub/Sub</h3><p>Both patterns support asynchronous communication, but their message distribution models are different.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*_k8uRafTDBDvBU8IuGKQ7w.png" /></figure><p>A simple way to remember:</p><p><strong>Message Queue:</strong> One job, one successful processing path within a competing consumer group.</p><p><strong>Pub/Sub:</strong> One event, multiple independent subscribers.</p><h3>5. What is a Message Broker?</h3><p>A message broker is an intermediary software system that manages communication between producers and consumers.</p><p>It receives messages from producers and handles tasks such as:</p><ul><li>Message routing.</li><li>Message storage.</li><li>Delivery to consumers.</li><li>Acknowledgements.</li><li>Message retention.</li><li>Replication and fault tolerance, depending on the system.</li></ul><p>A broker can support different messaging patterns, including work queues and Pub/Sub.</p><p>Some popular messaging technologies are:</p><ul><li><strong>RabbitMQ:</strong> A traditional message broker supporting queues, exchanges and routing.</li><li><strong>Apache Kafka:</strong> A distributed event-streaming platform built around topics, partitions and retained event logs.</li><li><strong>Amazon SQS:</strong> A fully managed message queuing service.</li></ul><p>An important distinction is that these technologies are not identical. They provide different messaging abstractions and delivery guarantees.</p><p>The messaging pattern describes how applications communicate, while the messaging infrastructure provides the mechanisms to implement that communication.</p><h3>6. Message Acknowledgements</h3><p>In distributed systems, sending a message does not necessarily mean that the consumer successfully processed it.</p><p>A consumer might receive a message and then crash before completing the job.</p><p>Acknowledgements help solve this problem.</p><p>An acknowledgement (ACK) is a confirmation sent by a consumer to the broker indicating that a message has been successfully processed or handled.</p><p>Consider this flow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*DuXV7Dt3d8Dg7--tIE8I9g.png" /></figure><ol><li>The producer publishes a message.</li><li>The broker accepts and stores the message according to its configuration.</li><li>The consumer receives the message.</li><li>The consumer processes the message.</li><li>The consumer sends an acknowledgement.</li><li>The broker marks the message as successfully handled.</li></ol><p>In systems such as RabbitMQ, an unacknowledged message can be requeued if the consumer connection fails.</p><p>However, acknowledgements do not automatically guarantee exactly-once processing.</p><p>Three important delivery models are:</p><ul><li><strong>At-most-once:</strong> A message is delivered zero or one time. Messages may be lost.</li><li><strong>At-least-once:</strong> A message is delivered one or more times. Duplicates are possible.</li><li><strong>Exactly-once:</strong> Processing occurs exactly once within a defined guarantee boundary. Achieving this across an entire distributed workflow is challenging.</li></ul><p>For reliable background jobs, applications should generally use idempotent processing so that retrying a job does not cause unintended duplicate operations.</p><h3>7. Replication and Durability</h3><p>Distributed messaging systems need to handle failures.</p><p>Imagine a broker server crashes while it contains thousands of messages.</p><p>How can the system recover without losing important data?</p><p>Two important concepts help address this problem.</p><h3>Replication</h3><p>Replication means maintaining copies of data across multiple nodes or servers.</p><p>If one node fails, another replica may be able to continue serving the data.</p><h3>Durability</h3><p>Durability refers to the ability of a system to preserve accepted data despite failures.</p><p>Messaging systems achieve durability through mechanisms such as:</p><ul><li>Persistent message storage.</li><li>Replication across nodes.</li><li>Acknowledgement policies.</li><li>Recovery mechanisms.</li></ul><p>Replication improves fault tolerance, but it does not automatically guarantee durability. The actual guarantee depends on the broker’s configuration and acknowledgement policy.</p><h3>8. Putting Everything Together</h3><p>Let’s connect these concepts.</p><p>A producer generates a message or event.</p><p>A messaging system receives it and uses a configured messaging pattern to distribute it.</p><p>The consumer processes the message and, where supported, acknowledges successful processing.</p><p>The broker manages storage, routing, delivery and recovery mechanisms.</p><p>Depending on the requirements, the system can use:</p><ul><li>A work queue for background job processing.</li><li>Pub/Sub for distributing events across independent services.</li><li>Replication and persistence for fault tolerance.</li><li>Acknowledgements and retries for reliable processing.</li></ul><h3>Conclusion</h3><p>Message queues and Pub/Sub are fundamental messaging patterns used in modern backend and distributed systems.</p><p>Understanding these patterns helps us design applications that are asynchronous, loosely coupled and scalable.</p><p>The next step is to understand how messaging technologies such as RabbitMQ, Apache Kafka and Redis with BullMQ implement these concepts in real applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b79d5271f376" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Happens When You Type www.google.com and Press Enter?]]></title>
            <link>https://medium.com/@srirammoorthy11/what-happens-when-you-type-www-google-com-and-press-enter-713a12b8eca7?source=rss-caea6de944f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/713a12b8eca7</guid>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[computer-networking]]></category>
            <dc:creator><![CDATA[Srirammoorthy]]></dc:creator>
            <pubDate>Fri, 16 Oct 2026 14:19:24 GMT</pubDate>
            <atom:updated>2026-10-16T14:19:24.557Z</atom:updated>
            <content:encoded><![CDATA[<p><em>The complete journey of a web request — from your browser to Google’s servers and back to your screen.</em></p><p>Have you ever wondered what happens behind the scenes when you type <a href="http://www.google.com/">www.google.com</a> into your browser and press Enter?</p><p>Within seconds, your browser displays the Google homepage. It looks like a simple action, but several computer networking concepts work together to make it happen.</p><p>Behind this everyday experience are <strong>DNS resolution, IP addressing, TCP connections, TLS encryption, HTTP communication, server infrastructure, caching, and browser rendering</strong>.</p><p>Understanding this process gives us a practical view of how the internet works. It also helps us understand concepts that are essential for backend development, system design, cybersecurity, and network troubleshooting.</p><p>Let’s walk through the complete journey, step by step.</p><h3>The complete journey at a glance</h3><p>When you enter www.google.com and press Enter, the process generally follows this sequence:</p><ol><li>The browser parses the URL and checks its caches.</li><li>The operating system checks its DNS cache.</li><li>A DNS resolver finds the IP address if necessary.</li><li>The browser establishes a network connection.</li><li>A TLS handshake establishes secure communication.</li><li>The browser sends an HTTP request.</li><li>Google’s infrastructure processes the request and returns a response.</li><li>The browser receives and processes the response.</li><li>The browser downloads additional resources and renders the page.</li></ol><p>These steps are a simplified model. Modern browsers can reuse existing connections, use HTTP/3 over QUIC instead of TCP, and retrieve cached content without repeating every step.</p><p>Let’s explore what happens in detail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pugJ9fJjGzEv3aMfsSgdlg.png" /></figure><h3>1. Entering the URL: The browser’s first job</h3><p>Suppose we type the following address into Chrome:</p><p><a href="https://www.google.com/search?q=computer+networks">https://www.google.com/search?q=computer+networks</a></p><p>Before communicating with a server, the browser parses the URL to understand its different components.</p><p>A URL can contain several parts:</p><ul><li><strong>Scheme:</strong> https specifies the protocol used to access the resource.</li><li><strong>Hostname:</strong> www.google.com identifies the destination host.</li><li><strong>Path:</strong> /search identifies the requested resource.</li><li><strong>Query parameters:</strong> q=computer+networks provides additional information to the server.</li></ul><p>The browser also determines whether the input should be treated as a web address or a search query.</p><p>For a typical HTTPS website, the browser uses port 443 unless a different port is explicitly specified.</p><p>However, the hostname is not yet enough to send an IP packet to the destination. The browser needs an IP address to identify the destination on the network.</p><p>That brings us to DNS resolution.</p><h3>2. Checking the cache: Can the browser reuse information?</h3><p>Before performing a new DNS lookup, the browser may check whether it already knows the IP address associated with the hostname.</p><p>A cache is a temporary storage mechanism that keeps previously obtained information so it can be reused more quickly.</p><p>DNS information can be cached at multiple levels, including the browser, the operating system, and a recursive DNS resolver.</p><p>If a valid cached entry exists, the system may avoid repeating the entire DNS lookup process.</p><p>If the browser has an existing connection to Google, it may also be able to reuse that connection rather than establishing a new one.</p><p>These optimizations reduce latency, network traffic, and unnecessary work.</p><p><strong>Important distinction:</strong> The browser cache and DNS cache are not the same thing. The browser’s HTTP cache stores resources such as HTML, CSS, JavaScript, and images. A DNS cache stores name-resolution information, such as the IP addresses associated with domain names.</p><p>If no usable DNS result is available locally, the operating system typically asks a configured DNS resolver for help.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UAtmj4p7YxJAtrWbCEYyqQ.png" /></figure><h3>3. DNS resolution: Converting a domain name into an IP address</h3><p>Computers use IP addresses to identify network destinations, but people prefer memorable names such as <a href="http://www.google.com./">www.google.com.</a></p><p>The Domain Name System (DNS) connects these two worlds.</p><p>Think of DNS as a distributed directory for domain names. It allows a client to discover the IP address associated with a hostname.</p><p>For example, a DNS response might contain an IPv4 address in an A record or an IPv6 address in an AAAA record. The actual addresses returned for Google can vary depending on location, network conditions, and DNS configuration.</p><h3>Step 1: The DNS resolver receives the query</h3><p>If the operating system does not have a valid cached answer, it sends a DNS query to a configured resolver.</p><p>This resolver is commonly operated by an internet service provider, an organization, or a public DNS service such as Google Public DNS.</p><p>A recursive resolver is responsible for obtaining an answer on behalf of the client.</p><h3>Step 2: The resolver checks its cache</h3><p>The resolver first checks whether it already knows the answer.</p><p>If it has a valid cached record, it can return the answer immediately.</p><p>Otherwise, it begins querying the DNS hierarchy.</p><h3>Step 3: The resolver queries a root DNS server</h3><p>The root DNS system helps the resolver find the appropriate top-level domain (TLD) name servers.</p><p>For example, the root server can direct the resolver toward the name servers responsible for .com.</p><p>A root server generally does not provide the final IP address of www.google.com. It provides information that helps the resolver move to the next level.</p><h3>Step 4: The resolver queries the TLD name server</h3><p>The resolver contacts a .com TLD name server.</p><p>The TLD server identifies the authoritative name servers for the relevant domain, google.com.</p><p>The TLD server usually does not provide the final address for www.google.com; it directs the resolver toward the domain&#39;s authoritative DNS infrastructure.</p><h3>Step 5: The resolver queries an authoritative DNS server</h3><p>The authoritative DNS server provides the relevant DNS records for the domain it serves.</p><p>The answer may contain an A record, an AAAA record, or other DNS information needed to resolve the hostname.</p><p>The resolver can then return the answer to the client and cache it according to the record’s time to live (TTL).</p><h3>A simple DNS example</h3><pre>Browser<br>   |<br>   | Needs the IP address of www.google.com<br>   v<br>Operating System<br>   |<br>   v<br>Recursive DNS Resolver<br>   |<br>   |-- Root DNS: Where can I find .com?<br>   |<br>   |-- .com TLD DNS: Where are google.com&#39;s<br>   |                  authoritative name servers?<br>   |<br>   |-- Authoritative DNS: What is the answer<br>                          for www.google.com?<br>   |<br>   v<br>DNS response returned to the client</pre><p>The resolver may not need to query every level on every request because it can reuse cached delegation records and DNS answers.</p><p><strong>Why is DNS important?</strong></p><p>Without DNS, people would need to remember IP addresses instead of convenient domain names. DNS also supports changes in infrastructure, traffic distribution, and different services associated with the same domain.</p><p>Once the client obtains a usable IP address, it can proceed toward establishing communication with the destination.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S0d3s9F_UgOF5MMIiDCYvw.png" /></figure><h3>4. Establishing a TCP connection: The three-way handshake</h3><p>For a typical HTTPS connection using HTTP/1.1 or HTTP/2 over TCP, the client first establishes a TCP connection with the server endpoint.</p><p>TCP stands for Transmission Control Protocol. It provides a reliable, ordered byte stream between communicating endpoints.</p><p>The familiar TCP three-way handshake consists of three messages: SYN, SYN-ACK, and ACK.</p><h3>Step 1: SYN</h3><p>The client sends a TCP segment with the SYN flag set.</p><p>This indicates that the client wants to establish a connection and synchronizes the initial sequence number.</p><h3>Step 2: SYN-ACK</h3><p>The server responds with a segment containing both SYN and ACK flags.</p><p>It acknowledges the client’s connection request and provides its own initial sequence number.</p><h3>Step 3: ACK</h3><p>The client sends an acknowledgment.</p><p>At this point, the TCP connection is established, assuming the handshake succeeds.</p><p>The sequence looks like this:</p><pre>Client                              Server<br>  |                                   |<br>  | ----------- SYN ----------------&gt; |<br>  |                                   |<br>  | &lt;-------- SYN + ACK ------------- |<br>  |                                   |<br>  | ----------- ACK ----------------&gt; |<br>  |                                   |<br>  |          TCP connected            |</pre><p>TCP handles reliable delivery through mechanisms such as sequence numbers, acknowledgments, retransmissions, and flow control.</p><p>However, TCP alone does not encrypt application data. For HTTPS, the connection must also use TLS to establish secure communication.</p><p>One important exception is HTTP/3, which uses QUIC over UDP rather than TCP. Consequently, an HTTP/3 connection does not use the traditional TCP three-way handshake.</p><h3>5. TLS handshake: Making the connection secure</h3><p>HTTPS is HTTP protected by TLS, or Transport Layer Security.</p><p>TLS provides confidentiality and integrity for data exchanged over the connection and helps authenticate the server.</p><p>Without encryption, sensitive information transmitted over an ordinary unencrypted HTTP connection could potentially be read or modified by an attacker with a suitable position on the network.</p><p>For a typical new HTTPS connection using TLS 1.3 over TCP, the handshake broadly works as follows.</p><h3>Step 1: ClientHello</h3><p>The browser sends a ClientHello message containing information such as supported TLS versions, cryptographic algorithms, and key-exchange parameters.</p><p>It may also include the intended hostname through Server Name Indication (SNI), depending on the connection configuration.</p><h3>Step 2: ServerHello and authentication</h3><p>The server responds with a ServerHello and the information required to continue the handshake.</p><p>In a typical TLS 1.3 handshake, the server also provides its certificate chain and cryptographic handshake messages.</p><p>The certificate helps the browser verify that the server is authorized to represent the requested hostname.</p><h3>Step 3: Certificate validation</h3><p>The browser checks the certificate chain against its trusted certificate authorities and verifies relevant details, including the hostname, validity period, and applicable constraints.</p><p>If validation fails, the browser may display a security warning or refuse the connection.</p><h3>Step 4: Establishing cryptographic keys</h3><p>The client and server derive shared session keys using the handshake’s cryptographic mechanisms.</p><p>They do not normally exchange a single shared secret directly over the network.</p><h3>Step 5: Secure communication begins</h3><p>After the handshake succeeds, the browser and server can exchange protected application data.</p><p>The connection is now ready for HTTPS communication.</p><p><strong>A note about terminology:</strong> SSL stands for Secure Sockets Layer, an older protocol that is no longer considered secure. Modern HTTPS uses TLS, even though people sometimes informally refer to TLS certificates as SSL certificates.</p><p>TLS 1.3 also differs from older TLS versions in its handshake details. The description above is a simplified overview, not a packet-by-packet specification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a7TO1cYxn3rizdLpbgNYlw.png" /></figure><h3>6. Sending the HTTP request</h3><p>Once the browser has a usable connection, it can send an HTTP request for the requested resource.</p><p>HTTP stands for Hypertext Transfer Protocol. It defines how clients and servers exchange requests and responses.</p><p>For example, the browser might send a request resembling this:</p><pre>GET / HTTP/1.1<br>Host: www.google.com<br>Accept: text/html<br>User-Agent: &lt;browser information&gt;</pre><p>This is an illustrative example, not a guaranteed exact request emitted by a modern browser.</p><p>Let’s understand the components.</p><ul><li><strong>GET:</strong> The HTTP method indicates that the client wants to retrieve a resource.</li><li><strong>Path:</strong> / identifies the requested resource at the server.</li><li><strong>Host:</strong> The header identifies the intended hostname in HTTP/1.1.</li><li><strong>Accept:</strong> The header indicates which response media types the client can accept.</li><li><strong>User-Agent:</strong> The header can identify the client software, although modern browsers may limit or reduce the information it exposes.</li></ul><p>With HTTPS, HTTP application data is protected by TLS while it travels across the network.</p><p>The request is routed through the network toward Google’s infrastructure. The exact route depends on network topology, routing decisions, and the infrastructure used for the connection.</p><p>The browser does not necessarily connect directly to one physical application server. Large services often use distributed infrastructure to receive and process requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*68rpg3rtQRX0WNw9c1FNXQ.png" /></figure><h3>7. Google’s server infrastructure: Processing the request</h3><p>When the request reaches Google’s infrastructure, several components may participate in delivering the response.</p><p>The exact internal architecture used for a particular request is not publicly visible to us, and it can change. The following describes a common architecture for large-scale web services.</p><h3>Step 1: Traffic reaches an appropriate endpoint</h3><p>A load balancer or other traffic-management component may direct the request toward a suitable server or service.</p><p>Traffic distribution can consider factors such as availability, capacity, and routing configuration. The nearest server is not necessarily selected in every situation.</p><h3>Step 2: A cache may satisfy the request</h3><p>If a suitable cached response is available and the caching rules permit its use, the system may serve it without repeating all application processing.</p><p>Caching can occur in the browser, at intermediary infrastructure, or within a service’s backend systems. Not every response is eligible for caching.</p><h3>Step 3: The application processes the request</h3><p>If the request needs application processing, the relevant service executes the necessary logic.</p><p>Depending on the requested resource, that work could involve retrieving data, applying business rules, communicating with other services, or generating a response.</p><p>For a search request, processing is more complex than serving a static HTML file. The service may need to interpret the query and retrieve relevant results.</p><h3>Step 4: The server creates an HTTP response</h3><p>The server returns an HTTP response containing a status code, headers, and, where appropriate, a body.</p><p>A successful response might use the status code 200 OK, but other codes are possible depending on the outcome.</p><p>The body could contain HTML, JSON, an image, or another representation.</p><p>The browser and server do not exchange an entire interactive website as a single magical object. They exchange protocol messages and resources that the browser processes.</p><h3>8. The HTTP response travels back to the browser</h3><p>After the server processes the request, the response travels back through the network to the client.</p><p>An illustrative HTTP/1.1 response might look like this:</p><pre>HTTP/1.1 200 OK<br>Content-Type: text/html; charset=UTF-8</pre><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;Example page&lt;/title&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;h1&gt;Hello, world!&lt;/h1&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>Again, this is a simplified example rather than Google’s actual response.</p><p>The response contains three important elements:</p><ul><li><strong>Status code:</strong> Indicates the result of the request.</li><li><strong>Headers:</strong> Provide metadata about the response, such as content type and caching instructions.</li><li><strong>Body:</strong> Contains the resource, when a body is appropriate.</li></ul><p>For HTTPS, TLS protects the response in transit.</p><p>TCP carries an ordered byte stream, and the receiving system reconstructs that stream from the data it receives. TCP does not guarantee that the application will receive the response in a single packet.</p><p>The browser then processes the HTTP response and determines whether it needs additional resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UDWzhGYntx9cz16Lz2geZA.png" /></figure><h3>9. Browser rendering: Turning HTML, CSS, and JavaScript into a webpage</h3><p>Receiving the HTML is not the end of the process. The browser must interpret the response and turn it into the visual page displayed on the screen.</p><p>This process involves several browser subsystems.</p><h3>Step 1: Parse HTML and build the DOM</h3><p>The browser parses the HTML and constructs the Document Object Model (DOM).</p><p>The DOM represents the document as a structured tree of nodes and elements.</p><p>For example:</p><pre>&lt;body&gt;<br>  &lt;h1&gt;Welcome&lt;/h1&gt;<br>  &lt;p&gt;Learning computer networks.&lt;/p&gt;<br>&lt;/body&gt;</pre><p>This markup produces a document tree containing a body element, a heading, and a paragraph.</p><h3>Step 2: Process CSS and build the CSSOM</h3><p>The browser parses CSS rules and constructs the CSS Object Model (CSSOM), which represents the styles applicable to the document.</p><p>CSS determines properties such as colors, fonts, spacing, borders, and layout behavior.</p><p>The browser combines the document structure with styling information to determine how elements should appear.</p><h3>Step 3: Fetch additional resources</h3><p>The HTML may reference additional resources, including:</p><ul><li>CSS stylesheets</li><li>JavaScript files</li><li>Images and icons</li><li>Fonts</li><li>Other resources needed by the page</li></ul><p>The browser requests these resources when necessary. Depending on the resource and existing cache entries, some requests may reuse established connections or avoid network transfers entirely.</p><p>JavaScript can modify the DOM and CSSOM, trigger additional requests, and update the page after the initial HTML arrives.</p><h3>Step 4: Construct the render tree</h3><p>The browser uses the DOM and relevant styling information to determine which elements participate in rendering and how they should be styled.</p><p>The resulting rendering structures help the browser calculate the visual representation of the page.</p><p>The render tree is related to, but not identical to, the DOM.</p><h3>Step 5: Perform layout</h3><p>During layout, the browser calculates the geometry of elements: their positions, dimensions, and relationships within the page.</p><p>For example, it determines where a heading appears and how much space a paragraph occupies.</p><p>Changes to content, styles, or the viewport can require layout calculations to be performed again.</p><h3>Step 6: Paint and composite</h3><p>The browser paints visual information such as text, backgrounds, borders, and images.</p><p>It may then composite different layers to produce the final frame displayed on the screen.</p><p>Modern browsers optimize this pipeline, so not every update requires every stage to run again.</p><p>Eventually, the Google homepage appears on your display. Some resources and scripts may continue loading or executing after the initial page becomes visible.</p><h3>10. Performance optimizations: Why does the page load so quickly?</h3><p>A modern browser and large-scale web service use several techniques to reduce the time required to display a page.</p><h3>Caching</h3><p>Browser caches, DNS caches, and server-side caches can avoid repeated work and unnecessary network transfers.</p><p>Each cache has its own purpose, rules, and expiration behavior.</p><h3>Persistent connections</h3><p>HTTP/1.1 and HTTP/2 can reuse TCP connections, while HTTP/3 can reuse QUIC connections. Reusing a connection avoids repeating connection setup for every resource.</p><h3>HTTP/2 and HTTP/3</h3><p>HTTP/2 supports multiple concurrent streams over one connection, allowing requests to share the connection more efficiently.</p><p>HTTP/3 uses QUIC, which operates over UDP and provides secure, reliable transport with features designed to improve performance in modern network conditions.</p><h3>Content delivery networks</h3><p>A content delivery network (CDN) can serve eligible content from distributed locations closer to users.</p><p>Whether a particular resource uses a CDN depends on the service’s infrastructure and configuration.</p><h3>Compression and optimized resources</h3><p>Servers and browsers can use compression and modern resource formats to reduce the amount of data transferred.</p><p>Smaller resources generally take less time to transfer, especially on slower connections.</p><h3>Speculative loading</h3><p>Browsers may anticipate future resource needs and begin certain operations early, depending on the page and browser implementation.</p><p>These optimizations explain why a website can appear almost instantly even though many operations may be involved.</p><h3>Conclusion</h3><p>Typing www.google.com and pressing Enter is a simple action from the user&#39;s perspective, but it demonstrates how several layers of technology work together.</p><p>The browser interprets the URL, checks available caches, and obtains an IP address through DNS when necessary. It establishes or reuses a connection, uses TLS to protect HTTPS communication, sends an HTTP request, and receives a response from the service’s infrastructure.</p><p>Finally, the browser parses the response, retrieves additional resources, calculates layout, paints the page, and displays it on the screen.</p><p>Each component has a specific responsibility, and the complete process depends on these components working together efficiently.</p><p>As someone learning computer networks, I find this process especially valuable because it connects theoretical concepts to something we do every day. DNS, TCP, TLS, HTTP, caching, and rendering are not isolated topics — they are parts of the same real-world workflow.</p><p><strong>The next time you open a website, remember that a single press of Enter can trigger an entire journey across the internet.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=713a12b8eca7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Simple Mail Transfer Protocol (SMTP)]]></title>
            <link>https://medium.com/@srirammoorthy11/understanding-simple-mail-transfer-protocol-smtp-857cfc316595?source=rss-caea6de944f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/857cfc316595</guid>
            <category><![CDATA[mail-protocols]]></category>
            <category><![CDATA[smtp-server]]></category>
            <category><![CDATA[internet-protocol]]></category>
            <category><![CDATA[smtp]]></category>
            <dc:creator><![CDATA[Srirammoorthy]]></dc:creator>
            <pubDate>Thu, 16 Jul 2026 02:31:01 GMT</pubDate>
            <atom:updated>2026-07-16T02:31:01.539Z</atom:updated>
            <content:encoded><![CDATA[<p>SMTP is an application-layer protocol used to send and transfer email between servers. It relies on a TCP connection to port 25 to reliably deliver messages from a client to an email server.</p><ul><li>Uses TCP for reliable message transmission</li><li>Servers listen on port 25 for incoming email</li><li>Client establishes a TCP connection before sending mail</li><li>Core protocol for email delivery between mail servers</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*Ct5VNmlCAvOwl2VC717P5Q.png" /></figure><h3>Types of SMTP Protocol</h3><p>The SMTP model supports two types of email delivery methods: <strong>end-to-end</strong> and <strong>store-and-forward</strong>.</p><ul><li><strong>End-to-end</strong> delivery is used between organizations. In this method, the email is sent directly from the sender’s SMTP client to the recipient’s SMTP server without passing through intermediate servers.</li><li><strong>Store-and-forward</strong> is used within organizations that have TCP/IP and SMTP-based networks. In this method, the email may pass through several intermediate servers (Message Transfer Agents, or MTAs) before reaching the recipient.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*jh71Ax82RHmSpx5NCSvQhA.png" /></figure><h3>Model of SMTP System</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*5KFdZUFux40hy06egGy11A.png" /></figure><ul><li><strong>User at a Terminal (Sender):</strong> The person composing the email using a mail application (e.g., Outlook, Thunderbird, webmail).</li><li><strong>User Agent (Sender):</strong> The email client software that allows the sender to create, edit, and send emails.<br>It hands the outgoing email to the system’s mail queue.</li><li><strong>Queue of Mail to Be Sent:</strong> A temporary storage area where outgoing emails wait before being processed by the mail server (Message Transfer Agent).</li><li><strong>Message Transfer Agent (Client Side):</strong> The software responsible for sending emails across the network. It retrieves messages from the outgoing queue and communicates with the receiving server.</li><li><strong>TCP Connection (Port 25):</strong> The client’s MTA opens a TCP connection to the server’s MTA on port 25. SMTP commands, responses, and mail data are exchanged over this connection.</li><li><strong>Message Transfer Agent (Server Side):</strong> The receiving email server accepts the incoming SMTP connection. It processes the incoming email and stores it for the user.</li><li><strong>User Mailboxes:</strong> The server stores the received messages in individual user mailboxes.</li><li><strong>User Agent (Receiver):</strong> The email application used by the recipient to access the mailbox. It retrieves emails using protocols like POP3 or IMAP.</li><li><strong>User at a Terminal (Receiver):</strong> The person reading the received email on their device.</li></ul><h3>Components of SMTP</h3><ul><li><strong>Mail User Agent (MUA):</strong> It is a computer application that helps you in sending and retrieving mail. It is responsible for creating email messages for transfer to the <a href="https://www.geeksforgeeks.org/linux-unix/7-best-mail-transfer-agents-mtas-for-linux/">mail transfer agent(MTA).</a></li><li><strong>Mail Submission Agent (MSA):</strong> It is a computer program that receives mail from a Mail User Agent(MUA) and interacts with the Mail Transfer Agent(MTA) for the transfer of the mail.</li><li><strong>Mail Transfer Agent (MTA):</strong> It is software that has the work to transfer mail from one system to another with the help of SMTP.</li><li><strong>Mail Delivery Agent (MDA):</strong> A mail Delivery agent or Local Delivery Agent is basically a system that helps in the delivery of mail to the local system.</li></ul><h3>How does SMTP Work?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*z_8IG4UjW6G09_JsAwg5sA.png" /></figure><h3>1. Sending Email:</h3><ul><li>When a user wants to send an email, they use a User Agent (UA), like Outlook or Gmail.</li><li>The email is handed over to the MTA, which is responsible for transferring the email to the recipient’s mail server.</li></ul><h3>2. SMTP Client and Server:</h3><ul><li><strong>Sender-SMTP (Client)</strong>: The email sender’s MTA initiates the connection to the recipient’s MTA (Receiver-SMTP).</li><li><strong>Receiver-SMTP (Server)</strong>: The receiving MTA listens for incoming connections and receives the email from the sender-SMTP.</li><li>This communication happens over <a href="https://www.geeksforgeeks.org/computer-networks/what-is-transmission-control-protocol-tcp/">TCP</a> port 25.</li></ul><h3>3. Relays and Gateways:</h3><ul><li><strong>Relays</strong>: In some cases, the email may pass through several intermediate MTAs before reaching the destination server. These MTAs act as <strong>relays</strong>.</li><li><strong>Gateways</strong>: If the sending and receiving systems use different email protocols (e.g., SMTP and non-SMTP), an <strong>email gateway</strong> can convert the email to the appropriate format for delivery.</li></ul><h3>4. Email Delivery:</h3><ul><li>The sender’s MTA sends the email to the receiver’s MTA, either directly or through relays.</li><li>The MTA uses the SMTP protocol to transfer the message. Once it’s delivered to the destination MTA, the email is placed in the recipient’s mailbox.</li><li>The recipient’s User Agent (UA) can then download the email.</li></ul><h3>SMTP Envelope</h3><h3>Purpose</h3><ul><li>The SMTP envelope contains information that guides email delivery between servers.</li><li>It is distinct from the email headers and body and is not visible to the email recipient.</li></ul><h3>Contents of the SMTP Envelope</h3><ul><li><strong>Sender Address</strong>: Specifies where the email originates.</li><li><strong>Recipient Addresses</strong>: Indicates where the email should be delivered.</li><li><strong>Routing Information</strong>: Helps servers determine the path for email delivery.</li></ul><h3>Comparison to Regular Mail</h3><ul><li>Think of the SMTP envelope as the <strong>address on a physical envelope</strong> for regular mail.</li><li>Just like an envelope guides postal delivery, the SMTP envelope directs email servers on where to send the email.</li></ul><h3>SMTP Commands</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*4TB3_oCIGRadJfTBCXiMHA.png" /></figure><h3>SMTP Ports</h3><p>These ports play a important role in defining how email clients and servers communicate securely and efficiently across the internet using the SMTP protocol.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*v1jpDB_HAegVODPSGJS4zA.png" /></figure><ul><li><strong>Port 587</strong>: This is the most commonly used port for <strong>secure SMTP submission</strong> using <strong>TLS (Transport Layer Security)</strong>. It is recommended for client-to-server communication, as it ensures the security of the email transmission.</li><li><strong>Port 465</strong>: Previously used for <strong>secure SMTP</strong> (SMTPS), this port is <strong>no longer considered an official standard</strong> and is generally not recommended anymore. Many email providers have moved away from port 465 in favor of port 587.</li><li><strong>Port 25</strong>: This port is traditionally used for <strong>SMTP relay</strong> between mail servers, not for email submission from clients. It is often blocked by ISPs for outgoing mail due to its frequent use for spam and malicious activities.</li><li><strong>Port 2525</strong>: Although <strong>not an official SMTP port</strong>, it is sometimes used as an alternative for SMTP submission, especially in cases where port 25 is blocked or restricted. Many email providers support this port as an alternative for secure communication.</li></ul><h3>SMTP vs POP vs IMAP</h3><p>Although these protocols are related to email, they serve different purposes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*EOQLIJ59yl1azsTRhIzzeQ.png" /></figure><h3>Advantages of SMTP</h3><ul><li>If necessary, the users can have a dedicated server.</li><li>It allows for bulk mailing.</li><li>Low cost and wide coverage area.</li><li>Offer choices for email tracking.</li><li>Reliable and prompt email delivery.</li></ul><h3>Disadvantages of SMTP</h3><ul><li>SMTP’s common port can be blocked by several <a href="https://www.geeksforgeeks.org/computer-networks/introduction-of-firewall-in-computer-network/">firewalls</a>.</li><li>SMTP security is a bigger problem.</li><li>Its simplicity restricts how useful it can be.</li><li>Just 7-bit ASCII characters can be used.</li><li>If a message is longer than a certain length, SMTP servers may reject the entire message.</li><li>Delivering your message will typically involve additional back-and-forth processing between servers, which will delay sending and raise the likelihood that it won’t be sent.</li></ul><h3>Real-World Applications of SMTP</h3><p>SMTP is used in countless everyday applications, including:</p><ul><li>Password reset emails</li><li>Email verification</li><li>OTP delivery</li><li>Order confirmations</li><li>Newsletter distribution</li><li>Marketing campaigns</li><li>Banking alerts</li><li>System notifications</li></ul><p>Whenever an application sends an email automatically, SMTP is typically working behind the scenes.</p><h3>Final Thoughts</h3><p>SMTP is one of the foundational protocols of the Internet, making reliable email communication possible across different platforms and providers. While users simply click <strong>“Send”</strong>, SMTP coordinates the entire delivery process, transferring messages between mail servers until they reach the recipient.</p><p>For backend developers, understanding SMTP is essential when building features such as user registration, password recovery, transactional emails, and automated notifications. Whether you’re working with <strong>Node.js</strong>, <strong>Python</strong>, <strong>Java</strong>, or any other backend technology, SMTP remains a core technology you’ll encounter when integrating email functionality into your applications.</p><p>Mastering SMTP, along with related protocols like <strong>POP3</strong> and <strong>IMAP</strong>, provides a strong foundation for understanding how email systems work behind the scenes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=857cfc316595" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding WebSockets: The Technology Behind Real-Time Web Applications]]></title>
            <link>https://medium.com/@srirammoorthy11/understanding-websockets-the-technology-behind-real-time-web-applications-4607e8c248fc?source=rss-caea6de944f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/4607e8c248fc</guid>
            <category><![CDATA[websocket-api]]></category>
            <category><![CDATA[websocketdevelopment]]></category>
            <category><![CDATA[websocket]]></category>
            <category><![CDATA[http-vs-websocket]]></category>
            <category><![CDATA[socketio]]></category>
            <dc:creator><![CDATA[Srirammoorthy]]></dc:creator>
            <pubDate>Wed, 15 Jul 2026 04:31:07 GMT</pubDate>
            <atom:updated>2026-07-15T04:31:07.270Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever wondered how a message sent on <strong>WhatsApp</strong> appears instantly on your friend’s phone? Or how <strong>Google Docs</strong> updates everyone’s screen as multiple people edit the same document? What about live stock prices, sports score updates, or multiplayer online games that react in real time?</p><p>The technology behind these seamless experiences is <strong>WebSockets</strong>.</p><p>Traditional web communication using HTTP works well for most applications, but it wasn’t designed for continuous, real-time communication. WebSockets solve this limitation by enabling a persistent connection between the client and the server, allowing both to exchange data instantly.</p><p>In this article, we’ll explore what WebSockets are, why they were introduced, how they work, and where they are used in modern web applications.</p><h3>What is a WebSocket?</h3><p>A <strong>WebSocket</strong> is a communication protocol that enables <strong>persistent, bidirectional (full-duplex) communication</strong> between a client and a server over a single TCP connection.</p><p>Unlike HTTP, which creates a new connection for every request, WebSockets establish one connection that remains open until either the client or the server closes it.</p><p>This persistent connection allows data to flow in both directions without repeatedly creating new connections.</p><blockquote><em>In simple terms, WebSockets allow the client and server to “stay connected” and communicate instantly whenever new information is available.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/0*qkNwy6zFB6dyeAr2.png" /></figure><h3>Why Were WebSockets Introduced?</h3><p>Before WebSockets, web applications relied primarily on HTTP.</p><p>HTTP follows a <strong>request-response</strong> model:</p><ol><li>The client sends a request.</li><li>The server processes it.</li><li>The server returns a response.</li><li>The connection is closed.</li></ol><pre>Browser<br>    │<br>HTTP Request<br>    ▼<br>Server<br>    │<br>HTTP Response<br>    ▼<br>Browser</pre><pre>Connection Closed</pre><p>This model works perfectly for loading web pages, submitting forms, or requesting API data.</p><p>However, it becomes inefficient for applications that require continuous updates.</p><p>Imagine a chat application where the browser asks every second:</p><blockquote><em>“Do I have any new messages?”</em></blockquote><p>Most of the time, the server replies:</p><blockquote><em>“No.”</em></blockquote><p>Even though nothing has changed, the browser continues sending requests repeatedly.</p><p>This approach wastes:</p><ul><li>Network bandwidth</li><li>Server resources</li><li>Processing power</li><li>Battery life on mobile devices</li></ul><p>Clearly, a better solution was needed.</p><h3>How WebSockets Solve This Problem</h3><p>Instead of repeatedly asking the server for updates, WebSockets establish a single persistent connection.</p><pre>Client<br>      │<br>      │══════════════════════╗<br>      ║                      ║<br>      ║  Persistent          ║<br>      ║  WebSocket           ║<br>      ║  Connection          ║<br>      ║                      ║<br>      ╚══════════════════════│<br>                             │<br>                          Server</pre><p>Once connected:</p><ul><li>The client can send messages at any time.</li><li>The server can also send messages whenever new data is available.</li><li>No repeated HTTP requests are required.</li></ul><p>As a result, communication becomes significantly faster and more efficient.</p><h3>Key Characteristics of WebSockets</h3><h3>Persistent Connection</h3><p>Unlike HTTP, the connection remains open after it is established.</p><p>This eliminates the overhead of creating a new connection for every request.</p><h3>Full-Duplex Communication</h3><p>One of the biggest advantages of WebSockets is <strong>full-duplex communication</strong>.</p><p>Both the client and the server can send data independently.</p><pre>Client   ⇄⇄⇄   Server</pre><p>Neither side has to wait for the other to initiate communication.</p><h3>Real-Time Data Exchange</h3><p>As soon as new information becomes available, it can be delivered immediately.</p><p>There is no need for:</p><ul><li>Refreshing the webpage</li><li>Polling the server</li><li>Waiting for scheduled updates</li></ul><h3>Low Latency</h3><p>Because the connection already exists, messages travel with minimal overhead.</p><p>This makes WebSockets ideal for applications where speed is critical.</p><h3>How WebSockets Work</h3><p>Although WebSockets provide a completely different communication model, they actually begin with a regular HTTP request.</p><p>Let’s understand the process step by step.</p><h3>Step 1: HTTP Handshake</h3><p>The client sends an HTTP request asking the server to upgrade the connection.</p><pre>GET /chat HTTP/1.1<br>Host: example.com<br>Upgrade: websocket<br>Connection: Upgrade</pre><p>This is known as the <strong>WebSocket handshake</strong>.</p><h3>Step 2: Server Accepts the Upgrade</h3><p>If the server supports WebSockets, it responds with:</p><pre>HTTP/1.1 101 Switching Protocols</pre><p>At this point, the communication protocol changes from HTTP to WebSocket.</p><h3>Step 3: Persistent Connection</h3><p>After the upgrade, the connection remains open.</p><pre>Browser  ⇄⇄⇄  Server</pre><p>No additional HTTP requests are needed.</p><h3>Step 4: Real-Time Communication</h3><p>Now both sides can exchange data whenever they want.</p><pre>Server<br>   │<br>New Notification<br>   ▼<br>Browser</pre><p>Or</p><pre>Browser<br>   │<br>Chat Message<br>   ▼<br>Server</pre><p>This continues until one side closes the connection.</p><h3>Complete WebSocket Communication Flow</h3><pre>User Opens Website<br>        │<br>        ▼<br>HTTP Handshake<br>        │<br>        ▼<br>Protocol Upgrade<br>        │<br>        ▼<br>Persistent Connection<br>        │<br>        ▼<br>Real-Time Communication<br>        │<br>        ▼<br>Connection Closed</pre><h3>HTTP vs WebSockets</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*AjoSf4cK89udn6VRM5XrIQ.png" /></figure><p>While HTTP is excellent for standard web communication, WebSockets are designed specifically for scenarios requiring instant updates.</p><h3>Real-World Applications of WebSockets</h3><p>WebSockets power many of the applications we use every day.</p><h3>Messaging Applications</h3><p>Applications like:</p><ul><li>WhatsApp</li><li>Discord</li><li>Slack</li><li>Microsoft Teams</li></ul><p>deliver messages instantly using WebSockets.</p><h3>Online Gaming</h3><p>Multiplayer games continuously synchronize player positions, scores, and actions in real time.</p><h3>Financial Applications</h3><p>Stock trading platforms use WebSockets to stream live market prices without requiring users to refresh the page.</p><h3>Live Sports</h3><p>Sports websites update scores instantly as events occur.</p><h3>Collaborative Applications</h3><p>Platforms like:</p><ul><li>Google Docs</li><li>Figma</li><li>Notion</li></ul><p>allow multiple users to edit the same document simultaneously.</p><h3>Ride-Sharing Services</h3><p>Applications like Uber and Ola continuously update driver locations using persistent connections.</p><h3>IoT Systems</h3><p>Smart homes and industrial monitoring systems use WebSockets for real-time sensor updates.</p><h3>Advantages of WebSockets</h3><p>WebSockets provide several important benefits.</p><ul><li>Real-time communication</li><li>Persistent connection</li><li>Low latency</li><li>Reduced network overhead</li><li>Efficient bandwidth usage</li><li>Full-duplex messaging</li><li>Better user experience</li></ul><h3>Limitations of WebSockets</h3><p>Despite their advantages, WebSockets are not suitable for every application.</p><p>Some limitations include:</p><ul><li>Long-lived connections consume server memory.</li><li>Scaling millions of persistent connections requires additional infrastructure.</li><li>More complex than traditional REST APIs.</li><li>Not ideal for simple request-response operations like loading webpages or retrieving static content.</li></ul><p>For many applications, HTTP and REST APIs remain the better choice.</p><h3>Implementing WebSockets in Node.js</h3><p>Node.js is particularly well-suited for WebSockets because of its event-driven, non-blocking architecture.</p><p>Developers commonly use libraries such as:</p><ul><li><strong>ws</strong> — A lightweight WebSocket implementation.</li><li><strong>Socket.IO</strong> — A feature-rich library that simplifies real-time communication by handling reconnections, rooms, broadcasting, and fallback transports.</li></ul><p>A typical implementation involves:</p><ol><li>Creating an HTTP server.</li><li>Initializing a WebSocket server.</li><li>Listening for client connections.</li><li>Receiving and broadcasting messages.</li><li>Handling client disconnections.</li></ol><p>The same concepts apply across other backend technologies such as Java (Spring Boot), Python (FastAPI, Django Channels), Go, and .NET.</p><h3>A Simple Analogy</h3><p>Imagine calling a friend.</p><h3>HTTP</h3><p>Every time you want to say something, you:</p><ul><li>Call your friend.</li><li>Say one sentence.</li><li>Hang up.</li></ul><p>The next message requires another phone call.</p><h3>WebSockets</h3><p>You call your friend once.</p><p>The call stays connected.</p><p>Now either of you can talk whenever you want until the conversation ends.</p><p>This is exactly how WebSockets work.</p><h3>Final Thoughts</h3><p>WebSockets transformed the way modern web applications communicate by enabling persistent, bidirectional connections between clients and servers. Unlike traditional HTTP, which requires a new request for every interaction, WebSockets keep the connection alive, making real-time communication fast, efficient, and seamless.</p><p>Whether you’re building chat applications, live dashboards, multiplayer games, collaborative tools, or IoT systems, understanding WebSockets is an essential skill for modern backend development.</p><p>As technologies continue to evolve, WebSockets remain one of the foundational building blocks behind the real-time experiences users expect from today’s web applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4607e8c248fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding REST APIs]]></title>
            <link>https://medium.com/@srirammoorthy11/understanding-rest-apis-2252bbbedb6e?source=rss-caea6de944f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/2252bbbedb6e</guid>
            <category><![CDATA[rest-api-architecture]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[http-request]]></category>
            <category><![CDATA[client-server-achitecture]]></category>
            <dc:creator><![CDATA[Srirammoorthy]]></dc:creator>
            <pubDate>Tue, 14 Jul 2026 04:31:08 GMT</pubDate>
            <atom:updated>2026-07-14T04:31:08.251Z</atom:updated>
            <content:encoded><![CDATA[<p>Every modern application — from Instagram and WhatsApp to Amazon and Netflix — relies on APIs to exchange data between clients and servers. Whether you’re building a web application, a mobile app, or integrating third-party services, understanding <strong>REST APIs</strong> is one of the most important skills for a backend developer.</p><p>In this article, we’ll explore what REST APIs are, how they work, the HTTP methods they use, their core principles, and even build a simple REST API using <strong>Node.js</strong> and <strong>Express</strong>.</p><h3>What is a REST API?</h3><p><strong>REST (Representational State Transfer)</strong> is an architectural style used for designing web APIs. A REST API enables communication between a client and a server over the HTTP protocol.</p><p>A client sends a request to a specific endpoint, and the server processes the request and returns a response — typically in <strong>JSON</strong> format.</p><blockquote><em>REST defines </em>how APIs should be designed<em>, while </em><strong><em>HTTP</em></strong><em> is the protocol that carries the requests and responses.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*BYUzUoll8AhuE7p_3kU25w.png" /></figure><h3>How REST APIs Work</h3><p>A REST API follows a simple request-response model.</p><ol><li>A client (browser, mobile app, or frontend application) sends an HTTP request.</li><li>The request targets a specific endpoint (URL).</li><li>The server processes the request.</li><li>The server sends back a response containing data and an HTTP status code.</li></ol><pre>Client<br>   │<br>HTTP Request<br>   │<br>   ▼<br>REST API Server<br>   │<br>Processes Request<br>   │<br>   ▼<br>HTTP Response (JSON)<br>   │<br>   ▼<br>Client</pre><p>Most REST APIs exchange data using <strong>JSON</strong>, although XML, HTML, images, and other formats are also supported.</p><h3>HTTP Methods Used in REST APIs</h3><p>REST APIs use standard HTTP methods to perform operations on resources.</p><p>These operations correspond to the four basic database operations known as <strong>CRUD</strong>:</p><p>CRUD OperationHTTP MethodCreatePOSTReadGETUpdatePUT / PATCHDeleteDELETE</p><h3>GET — Retrieve Data</h3><p>The <strong>GET</strong> method retrieves data from the server without modifying it.</p><p>Example:</p><pre>GET /users/123</pre><p>This request fetches the details of the user with ID <strong>123</strong>.</p><p>Typical success response:</p><pre>200 OK</pre><p>Common error responses:</p><pre>400 Bad Request<br>404 Not Found</pre><h3>POST — Create a Resource</h3><p>The <strong>POST</strong> method creates a new resource on the server.</p><p>Example:</p><pre>POST /users</pre><p>Request Body</p><pre>{<br>  &quot;name&quot;: &quot;Anne&quot;,<br>  &quot;email&quot;: &quot;anne@example.com&quot;<br>}</pre><p>Successful response:</p><pre>201 Created</pre><p>A <strong>Location</strong> header is often returned, pointing to the newly created resource.</p><blockquote><strong><em>POST is neither safe nor idempotent</em></strong><em>, meaning sending the same request multiple times may create multiple resources.</em></blockquote><h3>PUT — Replace an Entire Resource</h3><p>The <strong>PUT</strong> method replaces an existing resource with the data provided in the request body.</p><p>Example:</p><pre>PUT /users/123</pre><pre>{<br>  &quot;name&quot;: &quot;Anne&quot;,<br>  &quot;email&quot;: &quot;anne@example.com&quot;<br>}</pre><p>If the resource exists, it is completely replaced.</p><p>If it doesn’t exist, some APIs create it.</p><p>PUT is <strong>idempotent</strong>, meaning repeating the same request produces the same server state.</p><h3>PATCH — Update Part of a Resource</h3><p>Unlike PUT, <strong>PATCH</strong> updates only specific fields.</p><p>Example:</p><pre>PATCH /users/123</pre><pre>{<br>    &quot;email&quot;:&quot;new.email@example.com&quot;<br>}</pre><p>Only the email changes.</p><p>Everything else remains unchanged.</p><p>PATCH is commonly used when only a few fields need updating.</p><h3>PUT vs PATCH</h3><p>PUTPATCHReplaces the entire resourceUpdates selected fieldsSends the complete objectSends only modified fieldsIdempotentNot always idempotentLarger payloadSmaller payload</p><p><strong>Example</strong></p><p>PUT updates an entire user profile.</p><p>PATCH updates only the user’s email address.</p><h3>DELETE — Remove a Resource</h3><p>The <strong>DELETE</strong> method removes a resource from the server.</p><p>Example:</p><pre>DELETE /users/123</pre><p>Typical response:</p><pre>200 OK</pre><p>After deletion, making the same DELETE request again usually has no additional effect.</p><p>This makes DELETE an <strong>idempotent</strong> operation.</p><h3>What is Idempotency?</h3><p>An HTTP method is <strong>idempotent</strong> if making the same request multiple times produces the same result as making it once.</p><h3>Idempotent Methods</h3><ul><li>GET</li><li>PUT</li><li>DELETE</li><li>HEAD</li><li>OPTIONS</li></ul><h3>Non-Idempotent Methods</h3><ul><li>POST</li><li>PATCH (not always)</li></ul><p>Understanding idempotency is important when designing reliable APIs, especially in distributed systems where requests may be retried.</p><h3>Building a Simple REST API with Node.js and Express</h3><p>Let’s build a simple REST API that performs CRUD operations.</p><h3>Step 1: Create a Project</h3><pre>mkdir node-app<br>cd node-app</pre><h3>Step 2: Initialize Node.js</h3><pre>npm init -y</pre><h3>Step 3: Install Express</h3><pre>npm install express</pre><h3>Step 4: Create the Server</h3><p>Create a file named <strong>server.js</strong>.</p><pre>const express = require(&#39;express&#39;);</pre><pre>const app = express();</pre><pre>const port = 3000;</pre><pre>app.use(express.json());</pre><pre>app.get(&#39;/users&#39;, (req, res) =&gt; {<br>    res.json({ message: &#39;Returning list of users&#39; });<br>});</pre><pre>app.post(&#39;/users&#39;, (req, res) =&gt; {<br>    const newUser = req.body;</pre><pre>    res.json({<br>        message: &#39;User created&#39;,<br>        user: newUser<br>    });<br>});</pre><pre>app.put(&#39;/users/:id&#39;, (req, res) =&gt; {</pre><pre>    const userId = req.params.id;</pre><pre>    const updatedUser = req.body;</pre><pre>    res.json({<br>        message: `User ${userId} updated`,<br>        updatedUser<br>    });</pre><pre>});</pre><pre>app.delete(&#39;/users/:id&#39;, (req, res) =&gt; {</pre><pre>    const userId = req.params.id;</pre><pre>    res.json({<br>        message: `User ${userId} deleted`<br>    });</pre><pre>});</pre><pre>app.listen(port, () =&gt; {<br>    console.log(`Server running on <a href="http://localhost:${port}`);">http://localhost:${port}`);</a><br>});</pre><h3>Step 5: Run the Server</h3><pre>node server.js</pre><p>You should see:</p><pre>Server running on http://localhost:3000</pre><p>You can now test your endpoints using <strong>Postman</strong>, <strong>Insomnia</strong>, or <strong>Thunder Client</strong>.</p><h3>Available Endpoints</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*tnr7ExSENtadojGzCJiCjw.png" /></figure><p>These endpoints demonstrate the basic CRUD operations performed by a REST API.</p><h3>Core Principles of REST APIs</h3><p>REST APIs follow several architectural principles that make them scalable and maintainable.</p><h3>Stateless</h3><p>Each request contains all the information needed to process it.</p><p>The server does not remember previous requests.</p><p>Authentication is commonly handled using tokens such as JWT.</p><h3>Client-Server Architecture</h3><p>The frontend and backend are independent.</p><p>This separation allows each side to evolve without affecting the other.</p><h3>Cacheable Responses</h3><p>Responses can be cached to improve performance and reduce server load.</p><p>Examples include:</p><ul><li>Browser cache</li><li>CDN cache</li><li>API Gateway cache</li></ul><h3>Uniform Interface</h3><p>REST APIs use:</p><ul><li>Consistent URLs</li><li>Standard HTTP methods</li><li>Standard HTTP status codes</li><li>Predictable responses</li></ul><p>Example:</p><pre>GET /users<br>POST /users<br>PUT /users/1<br>DELETE /users/1</pre><h3>Layered System</h3><p>A client doesn’t need to know whether it communicates directly with the server or through:</p><ul><li>Reverse Proxies</li><li>Load Balancers</li><li>API Gateways</li><li>Authentication Services</li></ul><p>This improves scalability, security, and maintainability.</p><h3>Real-World Applications of REST APIs</h3><p>REST APIs power almost every modern application.</p><h3>Social Media</h3><ul><li>User authentication</li><li>Posts</li><li>Likes</li><li>Comments</li><li>Notifications</li></ul><h3>E-Commerce</h3><ul><li>Product catalog</li><li>Shopping cart</li><li>Payments</li><li>Order management</li></ul><h3>Advantages of REST APIs</h3><ul><li>Easy to understand and implement</li><li>Platform independent</li><li>Stateless and scalable</li><li>Uses standard HTTP methods</li><li>Lightweight communication using JSON</li><li>Excellent support across programming languages and frameworks</li></ul><h3>Limitations of REST APIs</h3><p>Despite their popularity, REST APIs have some limitations.</p><ul><li>Every request must include all necessary information.</li><li>Less suitable for real-time communication compared to WebSockets.</li><li>Clients may receive more or less data than required.</li><li>API versioning becomes more challenging as applications evolve.</li><li>REST is an architectural style, so implementations can differ between organizations.</li></ul><h3>Final Thoughts</h3><p>REST APIs have become the standard for communication between modern applications. Their simplicity, scalability, and compatibility with HTTP make them the preferred choice for building web services.</p><p>Whether you’re developing applications with <strong>FastAPI</strong>, <strong>Express.js</strong>, <strong>Spring Boot</strong>, <strong>Django</strong>, or <strong>ASP.NET</strong>, mastering REST APIs is an essential step toward becoming a skilled backend developer.</p><p>Once you understand REST principles, HTTP methods, status codes, and resource-oriented design, you’ll be well-equipped to build secure, scalable, and maintainable APIs that power real-world applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2252bbbedb6e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTTP vs HTTPS: The Complete Guide Every Backend Developer Should Know]]></title>
            <link>https://medium.com/@srirammoorthy11/http-vs-https-the-complete-guide-every-backend-developer-should-know-2c909234a5fe?source=rss-caea6de944f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c909234a5fe</guid>
            <category><![CDATA[http-request]]></category>
            <category><![CDATA[client-server-connection]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[http-vs-https]]></category>
            <category><![CDATA[internet-protocol]]></category>
            <dc:creator><![CDATA[Srirammoorthy]]></dc:creator>
            <pubDate>Mon, 13 Jul 2026 05:49:30 GMT</pubDate>
            <atom:updated>2026-07-13T05:49:30.798Z</atom:updated>
            <content:encoded><![CDATA[<p>The web feels instantaneous. You type a URL, press <strong>Enter</strong>, and within milliseconds a webpage appears on your screen. But have you ever wondered what actually happens behind the scenes?</p><p>The answer begins with one of the most fundamental protocols on the Internet: <strong>HTTP</strong>. And when security becomes essential, <strong>HTTPS</strong> takes over.</p><p>In this article, we’ll explore how HTTP and HTTPS work, why HTTPS is now the standard for modern websites, and what every aspiring software engineer should know about them.</p><h3>What is HTTP?</h3><p><strong>HTTP (HyperText Transfer Protocol)</strong> is an application-layer protocol that defines how a client (such as a web browser) communicates with a web server.</p><p>It establishes a set of rules that allows clients to request resources and servers to deliver them over the Internet.</p><p>Without HTTP, websites would not be able to transfer webpages, images, videos, stylesheets, or APIs between browsers and servers.</p><blockquote><em>Simply put, HTTP is the language spoken between your browser and a web server.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*q3r4NwhImMOMM6uTrEA8Mg.png" /></figure><h3>How HTTP Works</h3><p>HTTP follows a simple <strong>Client → Server → Client</strong> communication model.</p><ol><li>A user enters a website URL.</li><li>The browser sends an HTTP request.</li><li>The server processes the request.</li><li>The server returns an HTTP response.</li><li>The browser renders the received content.</li></ol><pre>Browser<br>    │<br>    │ HTTP Request<br>    ▼<br>Web Server<br>    │<br>Processes Request<br>    │<br>    ▼<br>HTTP Response<br>    │<br>    ▼<br>Browser Displays Webpage</pre><p>This communication is known as the <strong>Request-Response Cycle</strong>, which forms the backbone of every web application.</p><h3>Key Features of HTTP</h3><h3>1. Stateless Protocol</h3><p>HTTP is <strong>stateless</strong>, meaning each request is completely independent.</p><p>The server does not remember previous requests.</p><p>For example:</p><ul><li>Request 1: Login</li><li>Request 2: View Dashboard</li></ul><p>The second request contains no memory of the first unless mechanisms like <strong>cookies</strong>, <strong>sessions</strong>, or <strong>JWT tokens</strong> are used.</p><h3>2. Client-Server Architecture</h3><p>HTTP separates responsibilities.</p><p><strong>Client</strong></p><ul><li>Browser</li><li>Mobile App</li><li>Desktop Application</li></ul><p><strong>Server</strong></p><ul><li>Processes requests</li><li>Retrieves data</li><li>Sends responses</li></ul><p>This separation allows applications to scale efficiently.</p><h3>3. Text-Based Protocol</h3><p>HTTP messages are written as plain text.</p><p>This makes them easy to inspect and debug using browser developer tools or applications like Postman.</p><p>Example:</p><pre>GET /users HTTP/1.1<br>Host: example.com<br>User-Agent: Chrome<br>Accept: application/json</pre><h3>4. Request-Response Communication</h3><p>HTTP always follows this sequence:</p><pre>Request<br>     ↓<br>Server Processing<br>     ↓<br>Response</pre><p>The server never sends information unless the client requests it first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*jw0vdcaZW47XmUzkMmFfPA.png" /></figure><h3>Common HTTP Methods</h3><p>HTTP methods define what action the client wants the server to perform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*0ISdiz210LjSbhHGuIJn1A.png" /></figure><h3>GET Example</h3><pre>GET /products</pre><p>Returns a list of products.</p><h3>POST Example</h3><pre>POST /users</pre><p>Creates a new user.</p><h3>PUT Example</h3><pre>PUT /users/10</pre><p>Completely replaces user 10.</p><h3>PATCH Example</h3><pre>PATCH /users/10</pre><p>Updates only specific fields.</p><h3>DELETE Example</h3><pre>DELETE /users/10</pre><p>Deletes the specified user.</p><h3>HTTP Request Structure</h3><p>Every HTTP request contains several components.</p><pre>GET /products HTTP/1.1<br>Host: example.com<br>Authorization: Bearer token<br>Content-Type: application/json</pre><pre>{<br>   &quot;name&quot;:&quot;Laptop&quot;<br>}</pre><p>It consists of:</p><h3>Request Line</h3><p>Contains:</p><ul><li>HTTP Method</li><li>Resource URL</li><li>HTTP Version</li></ul><p>Example</p><pre>GET /products HTTP/1.1</pre><h3>Request Headers</h3><p>Headers provide metadata about the request.</p><p>Examples include:</p><ul><li>Host</li><li>Authorization</li><li>Content-Type</li><li>User-Agent</li><li>Accept</li></ul><h3>Request Body</h3><p>The request body contains the data sent to the server.</p><p>Typically used with:</p><ul><li>POST</li><li>PUT</li><li>PATCH</li></ul><p>Example</p><pre>{<br>  &quot;username&quot;:&quot;SriRam&quot;,<br>  &quot;password&quot;:&quot;********&quot;<br>}</pre><h3>HTTP Response Structure</h3><p>Once the server processes the request, it returns a response.</p><p>Example:</p><pre>HTTP/1.1 200 OK<br>Content-Type: application/json</pre><pre>{<br>   &quot;message&quot;:&quot;Success&quot;<br>}</pre><p>The response consists of:</p><ul><li>Status Code</li><li>Response Headers</li><li>Response Body</li></ul><h3>HTTP Status Codes</h3><p>Status codes indicate whether the request succeeded or failed.</p><h3>1xx — Informational</h3><pre>100 Continue</pre><p>The request is still being processed.</p><h3>2xx — Success</h3><pre>200 OK<br>201 Created<br>204 No Content</pre><p>The request completed successfully.</p><h3>3xx — Redirection</h3><pre>301 Moved Permanently<br>302 Found<br>304 Not Modified</pre><p>The client is redirected to another resource.</p><h3>4xx — Client Errors</h3><pre>400 Bad Request<br>401 Unauthorized<br>403 Forbidden<br>404 Not Found</pre><p>The client made an invalid request.</p><h3>5xx — Server Errors</h3><pre>500 Internal Server Error<br>502 Bad Gateway<br>503 Service Unavailable</pre><p>Something went wrong on the server.</p><h3>What Resources Can HTTP Request?</h3><p>A browser doesn’t request only an HTML page.</p><p>When you open a website, multiple requests are sent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*nITe_pprDupFogAaQ3pHLw.png" /></figure><p>A single webpage may generate dozens or even hundreds of HTTP requests.</p><h3>Limitations of HTTP</h3><p>Despite being revolutionary, HTTP has one major drawback.</p><p>Everything is transferred <strong>without encryption</strong>.</p><p>If someone intercepts the communication, they can read all transmitted information.</p><p>This includes:</p><ul><li>Usernames</li><li>Passwords</li><li>Credit Card Numbers</li><li>Personal Information</li></ul><p>This vulnerability led to the development of <strong>HTTPS</strong>.</p><h3>What is HTTPS?</h3><p><strong>HTTPS (HyperText Transfer Protocol Secure)</strong> is the secure version of HTTP.</p><p>Instead of sending information as plain text, HTTPS encrypts all communication between the browser and the server.</p><pre>HTTP<br>Browser  ←──────── Plain Text ────────→ Server</pre><pre>HTTPS<br>Browser ←── Encrypted TLS Connection ─→ Server</pre><p>Today, nearly every modern website uses HTTPS.</p><p>You’ll recognize it by the <strong>padlock icon</strong> and URLs that begin with:</p><pre>https://</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*wdKcy5lHCPnAjPnkx0VycQ.png" /></figure><h3>Why HTTPS Matters</h3><p>Imagine sending this message over HTTP:</p><pre>Password = MySecret123</pre><p>Anyone intercepting the traffic could read it instantly.</p><p>With HTTPS, the same information is transformed into encrypted data, appearing as meaningless characters to anyone without the proper decryption key.</p><p>This is especially important on:</p><ul><li>Public Wi-Fi</li><li>Banking Websites</li><li>Shopping Platforms</li><li>Email Services</li><li>Social Media</li><li>Online Learning Platforms</li></ul><h3>How HTTPS Works</h3><p>HTTPS follows the same request-response model as HTTP but adds a secure layer using <strong>TLS (Transport Layer Security)</strong>.</p><p>The process is:</p><ol><li>Browser connects to the server.</li><li>Server presents a TLS certificate.</li><li>Browser verifies the certificate.</li><li>A secure encrypted connection is established.</li><li>HTTP requests and responses travel through this encrypted channel.</li></ol><pre>Browser<br>      │<br> TLS Handshake<br>      │<br>Certificate Verification<br>      │<br>Encrypted Connection<br>      │<br>HTTP Request<br>      │<br>HTTP Response<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Je_rHFSIT7QWhV3UbkUEog.png" /></figure><h3>SSL and TLS</h3><p>Originally, HTTPS used <strong>SSL (Secure Sockets Layer)</strong>.</p><p>Today, SSL has been replaced by <strong>TLS (Transport Layer Security)</strong>, which provides stronger security and better performance.</p><p>TLS is responsible for:</p><ul><li>Encrypting data</li><li>Verifying server identity</li><li>Protecting data integrity</li></ul><p>Although people still say “SSL Certificate,” modern websites actually use <strong>TLS certificates</strong>.</p><h3>Encryption in HTTPS</h3><p>HTTPS uses two types of cryptographic keys.</p><h3>Public Key</h3><ul><li>Shared openly</li><li>Encrypts data</li><li>Used during the initial connection</li></ul><h3>Private Key</h3><ul><li>Stored securely on the server</li><li>Never shared</li><li>Decrypts encrypted data</li></ul><p>Together, these keys enable secure communication without exposing sensitive information.</p><h3>Cryptographic Algorithms Used</h3><p>HTTPS relies on multiple algorithms for different purposes.</p><p><strong>RSA</strong></p><ul><li>Asymmetric encryption algorithm</li><li>Used during the TLS handshake for secure key exchange</li></ul><p><strong>SHA-256</strong></p><ul><li>Cryptographic hashing algorithm</li><li>Ensures data integrity and validates digital signatures</li><li>Not used to encrypt application data</li></ul><p>Modern TLS implementations may also use algorithms such as <strong>ECDHE</strong> for key exchange and <strong>AES-GCM</strong> or <strong>ChaCha20-Poly1305</strong> for encrypting the actual data traffic.</p><h3>HTTP vs HTTPS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*X5dT4TrgKHIAFndhuq2poQ.png" /></figure><h3>Advantages of HTTP</h3><ul><li>Simple and lightweight</li><li>Platform independent</li><li>Easy to implement</li><li>Highly compatible</li><li>Fast for non-sensitive communication</li></ul><h3>Disadvantages of HTTP</h3><ul><li>No encryption</li><li>Vulnerable to eavesdropping</li><li>No authentication</li><li>No integrity protection</li><li>Requires additional mechanisms for session management</li></ul><h3>Advantages of HTTPS</h3><ul><li>Encrypts all transmitted data</li><li>Authenticates the website using TLS certificates</li><li>Protects against man-in-the-middle attacks</li><li>Preserves data integrity</li><li>Builds user trust through secure browser indicators</li><li>Required for many modern web features, including service workers and progressive web apps</li></ul><h3>Final Thoughts</h3><p>HTTP revolutionized the web by creating a standard way for browsers and servers to communicate. However, as the Internet evolved and security became essential, HTTPS emerged as the trusted standard for protecting online communication.</p><p>For backend developers, understanding the difference between HTTP and HTTPS is more than an interview topic — it’s foundational knowledge for building secure, reliable, and modern web applications. Whether you’re developing REST APIs with FastAPI, Express.js, Spring Boot, or any other framework, understanding how requests travel across the Internet and how they are protected is a critical skill.</p><p>The next time you see the padlock icon in your browser, you’ll know that behind it is a sophisticated combination of protocols, certificates, encryption, and networking that works together to keep your data safe.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c909234a5fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying a FastAPI Application to Azure Container Apps with Docker: A Complete Step-by-Step Guide]]></title>
            <link>https://medium.com/@srirammoorthy11/deploying-a-fastapi-application-to-azure-container-apps-with-docker-a-complete-step-by-step-guide-c12b780d8940?source=rss-caea6de944f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/c12b780d8940</guid>
            <category><![CDATA[microsoft-azure]]></category>
            <category><![CDATA[docker-image]]></category>
            <category><![CDATA[fastapi]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[cloud-deployment]]></category>
            <dc:creator><![CDATA[Srirammoorthy]]></dc:creator>
            <pubDate>Tue, 07 Jul 2026 17:46:15 GMT</pubDate>
            <atom:updated>2026-07-07T17:46:15.495Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>Learn how to deploy a Dockerized FastAPI application to Azure Container Apps using Azure Container Registry (ACR), Azure Database for PostgreSQL, and Azure Blob Storage.</em></blockquote><h3>Introduction</h3><p>Deploying a web application to the cloud is one of the most valuable skills for any backend engineer. In this guide, I’ll walk through how I deployed my <strong>Chronicle</strong> blogging platform to <strong>Microsoft Azure</strong> using modern cloud-native technologies.</p><p>The application uses:</p><ul><li><strong>FastAPI</strong> as the backend framework</li><li><strong>PostgreSQL</strong> as the relational database</li><li><strong>Azure Blob Storage</strong> for profile image storage</li><li><strong>Docker</strong> for containerization</li><li><strong>Azure Container Registry (ACR)</strong> for storing Docker images</li><li><strong>Azure Container Apps</strong> for hosting the application</li></ul><p>By the end of this guide, you’ll have a production-style deployment running entirely on Azure.</p><h3>Tech Stack</h3><ul><li>Python</li><li>FastAPI</li><li>PostgreSQL</li><li>SQLAlchemy</li><li>Alembic</li><li>Docker</li><li>Azure Blob Storage</li><li>Azure Database for PostgreSQL</li><li>Azure Container Registry</li><li>Azure Container App</li></ul><h3>Prerequisites</h3><p>Before starting, make sure you have:</p><ul><li>Azure Account</li><li>Docker Desktop</li><li>Git</li><li>VS Code</li><li>Azure CLI</li><li>A FastAPI project</li><li>Dockerfile</li><li>pyproject.toml / requirements.txt</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*_8zQx9nubJoYSXbXojVdeQ.png" /></figure><h3>Step 1 — Prepare the FastAPI Application</h3><p>Ensure your application runs locally.</p><pre>uv run uvicorn main:app --reload</pre><p>Verify:</p><ul><li>Database connection</li><li>Static files</li><li>Templates</li><li>Authentication</li><li>Image upload</li></ul><p>Everything should work before moving to Azure.</p><h3>Step 2 — Create Azure Resources</h3><p>Create the following Azure services:</p><ul><li>Azure Database for PostgreSQL Flexible Server</li><li>Azure Storage Account</li><li>Blob Container</li><li>Azure Container Registry</li><li>Azure Container Apps Environment</li><li>Azure Container App</li></ul><p>Keep all resources inside the same Resource Group.</p><h3>Step 3 — Configure Azure PostgreSQL</h3><p>Create a PostgreSQL Flexible Server.</p><p>Example:</p><ul><li>PostgreSQL 16</li><li>Burstable B1ms</li><li>1 vCore</li><li>2 GB RAM</li><li>32 GB Storage</li></ul><p>Create your database:</p><pre>CREATE DATABASE blog_db;</pre><p>Update your environment variable:</p><pre>DATABASE_URL=postgresql+asyncpg://username:password@server.postgres.database.azure.com/blog_db?ssl=require</pre><p>Run migrations:</p><pre>uv run alembic upgrade head</pre><h3>Step 4 — Configure Azure Blob Storage</h3><p>Create:</p><ul><li>Storage Account</li><li>Blob Container</li></ul><p>Copy the connection string from Azure Portal.</p><p>Update:</p><pre>AZURE_STORAGE_CONNECTION_STRING=...<br>AZURE_CONTAINER_NAME=profile-images</pre><p>Now every uploaded profile picture is stored securely in Azure Blob Storage.</p><h3>Step 5 — Create the Dockerfile</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*YHfh6utBpWcCrWYlp0N2zg.png" /></figure><p>Example:</p><pre>FROM python:3.13-slim</pre><pre>WORKDIR /app</pre><pre>COPY pyproject.toml uv.lock ./</pre><pre>RUN pip install uv</pre><pre>RUN uv sync --frozen</pre><pre>COPY . .</pre><pre>EXPOSE 8000</pre><pre>CMD [&quot;uv&quot;,&quot;run&quot;,&quot;uvicorn&quot;,&quot;main:app&quot;,&quot;--host&quot;,&quot;0.0.0.0&quot;,&quot;--port&quot;,&quot;8000&quot;,&quot;--proxy-headers&quot;,&quot;--forwarded-allow-ips=*&quot;]</pre><blockquote><strong><em>Important:</em></strong><em> If you’re deploying behind Azure Container Apps, include both </em><em>--proxy-headers and </em><em>--forwarded-allow-ips=*. Without them, FastAPI may generate </em><em>http:// URLs instead of </em><em>https://, causing browsers to block CSS and JavaScript due to mixed-content errors.</em></blockquote><h3>Step 6 — Build the Docker Image</h3><pre>docker build -t blog-app .</pre><p>Verify:</p><pre>docker images</pre><h3>Step 7 — Create Azure Container Registry</h3><p>Create an Azure Container Registry.</p><p>Example:</p><pre>Registry Name<br>blogacrsriram2026</pre><p>Login:</p><pre>az login</pre><pre>az acr login --name blogacrsriram2026</pre><h3>Step 8 — Tag and Push the Image</h3><pre>docker tag blog-app blogacrsriram2026.azurecr.io/blog-app:v1</pre><p>Push:</p><pre>docker push blogacrsriram2026.azurecr.io/blog-app:v1</pre><p>Your image is now stored inside Azure Container Registry.</p><h3>Step 9 — Deploy to Azure Container Apps</h3><p>Create a Container App.</p><p>Configure:</p><ul><li>Registry → Azure Container Registry</li><li>Image → blog-app</li><li>Tag → v1</li></ul><p>CPU</p><pre>0.5</pre><p>Memory</p><pre>1 GiB</pre><p>Container Port</p><pre>8000</pre><p>Ingress</p><pre>External</pre><p>Transport</p><pre>Auto</pre><p>Azure automatically provisions HTTPS and provides a public URL.</p><h3>Step 10 — Configure Environment Variables</h3><p>Add all required environment variables inside Container Apps.</p><p>Example:</p><pre>DATABASE_URL<br>SECRET_KEY<br>AZURE_STORAGE_CONNECTION_STRING<br>AZURE_CONTAINER_NAME<br>MAIL_USERNAME<br>MAIL_PASSWORD</pre><p>Never hardcode secrets inside your project.</p><h3>Step 11 — Troubleshooting</h3><p>During deployment, I encountered several real-world issues.</p><h3>Docker couldn’t connect</h3><pre>error during connect</pre><p>Solution:</p><p>Start Docker Desktop before building.</p><h3>Missing environment variables</h3><pre>ValidationError</pre><p>Solution:</p><p>Configure all required environment variables inside Azure Container Apps.</p><h3>Alembic migration errors</h3><pre>invalid interpolation syntax</pre><p>Solution:</p><p>Escape special characters correctly in the database connection string and verify the .env configuration.</p><h3>Mixed Content (HTTP vs HTTPS)</h3><p>The application loaded successfully, but CSS and JavaScript were blocked because FastAPI generated http:// URLs behind Azure&#39;s reverse proxy.</p><p>Solution:</p><p>Run Uvicorn with:</p><pre>--proxy-headers<br>--forwarded-allow-ips=*</pre><p>This allows FastAPI to trust Azure’s proxy headers and correctly generate HTTPS URLs.</p><h3>Final Architecture</h3><pre>User<br>      │<br>      ▼<br>Azure Container Apps<br>      │<br>      ▼<br>FastAPI Backend<br>      │<br> ┌────┴─────────────┐<br> ▼                  ▼<br>Azure PostgreSQL   Azure Blob Storage<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ij6yqe5FGIgSUVSbB55qVA.png" /></figure><h3>Conclusion</h3><p>Deploying a FastAPI application to Azure Container Apps is a great way to learn modern backend deployment practices. Combining FastAPI, Docker, Azure PostgreSQL, Azure Blob Storage, and Azure Container Apps results in a scalable and maintainable cloud-native architecture.</p><p>I hope this guide saves you time and helps you avoid some of the deployment challenges I encountered.</p><p>If you found this article helpful, feel free to share it and connect with me. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c12b780d8940" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Retrieval and Generation in RAG Systems]]></title>
            <link>https://medium.com/@srirammoorthy11/understanding-retrieval-and-generation-in-rag-systems-4d99431adbe0?source=rss-caea6de944f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d99431adbe0</guid>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[llm-agent]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <category><![CDATA[agentic-rag]]></category>
            <dc:creator><![CDATA[Srirammoorthy]]></dc:creator>
            <pubDate>Mon, 01 Jun 2026 14:09:07 GMT</pubDate>
            <atom:updated>2026-06-01T14:09:07.171Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Retrieval-Augmented Generation (RAG) has become one of the most important architectures in modern AI systems. As Large Language Models such as GPT-4, Gemini, Claude, and Llama continue evolving, organizations are increasingly integrating retrieval systems to improve factual accuracy, reduce hallucinations, and provide domain-specific intelligence.</p><p>However, many developers focus heavily on:</p><ul><li>Prompt engineering</li><li>LLM selection</li><li>Model parameters</li></ul><p>while ignoring the most critical component of a RAG system: <em>The Retrieval Pipeline.</em></p><p>In reality, the quality of retrieval directly determines the quality of generation.</p><p>Even the most advanced LLM cannot produce accurate responses if the retrieved context is weak, fragmented, or irrelevant.</p><p>This is why modern RAG architectures are rapidly evolving from:</p><ul><li>Basic semantic retrieval<br>to</li><li>Context-aware intelligent retrieval systems.</li></ul><p>In this blog, we will deeply explore:</p><ul><li>The retrieval process in RAG</li><li>Naive retrieval</li><li>Sentence-window retrieval</li><li>Auto-merging retrieval</li><li>Augmentation and synthesis</li><li>Response generation</li><li>Benefits and limitations of RAG retrieval systems</li></ul><p>This article is designed to provide both conceptual clarity and production-level understanding in a simple and professional way.</p><h3>Understanding the Retrieval Process in RAG</h3><p>The retrieval layer is responsible for identifying the most relevant information from the knowledge base before the response reaches the Large Language Model.</p><p>The complete retrieval workflow generally involves:</p><ol><li>User query</li><li>Query embedding</li><li>Similarity search</li><li>Context retrieval</li><li>Context augmentation</li><li>Response synthesis</li></ol><p>The retrieval system acts as the bridge between:</p><ul><li>External knowledge<br>and</li><li>The reasoning capabilities of the LLM.</li></ul><p>Its primary goal is to retrieve semantically relevant information with high precision and contextual completeness.</p><h3>Why Retrieval Matters in RAG Systems</h3><p>Traditional LLMs rely entirely on information stored inside model weights.</p><p>This creates several limitations:</p><ul><li>Static knowledge</li><li>Hallucinations</li><li>Lack of private enterprise data</li><li>No real-time awareness</li></ul><p>RAG solves this problem by dynamically retrieving relevant information before generation.</p><p>A strong retrieval system improves:</p><ul><li>Accuracy</li><li>Context grounding</li><li>Response relevance</li><li>Multi-document understanding</li><li>Hallucination reduction</li></ul><p>Modern retrieval systems are no longer just keyword search engines.</p><p>They are semantic reasoning systems capable of understanding:</p><ul><li>Context</li><li>Intent</li><li>Relationships</li><li>Meaning</li></ul><h3>1. Naive Retrieval (Basic RAG Pipeline)</h3><h3>What is Naive Retrieval?</h3><p>Naive retrieval is the simplest and most fundamental retrieval strategy in RAG systems.</p><p>In this approach:</p><ul><li>Documents are split into chunks</li><li>Chunks are converted into embeddings</li><li>Embeddings are stored in a vector database</li><li>Similar chunks are retrieved during querying</li><li>Retrieved chunks are directly passed to the LLM</li></ul><p>This is commonly referred to as the <strong>standard RAG pipeline</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xx9hDUA8jVX33OrblWuxbg.png" /></figure><h3>How Naive Retrieval Works</h3><p>The workflow is straightforward.</p><h3>Step 1 — Document Chunking</h3><p>Large documents are divided into smaller text chunks.</p><p>Example:</p><pre>Document:<br>&quot;Deep learning is a subset of machine learning. GPUs accelerated modern neural network training.&quot;</pre><p>Chunks:</p><pre>Chunk 1 → &quot;Deep learning is a subset of machine learning.&quot;<br>Chunk 2 → &quot;GPUs accelerated modern neural network training.&quot;</pre><h3>Step 2 — Embedding Generation</h3><p>Each chunk is converted into vector embeddings using embedding models such as:</p><ul><li>OpenAI Embeddings</li><li>Sentence Transformers</li><li>BGE Models</li><li>Gemini Embeddings</li></ul><p>These embeddings capture semantic meaning numerically.</p><h3>Step 3 — Store in Vector Database</h3><p>Embeddings are stored inside vector databases such as:</p><ul><li>Pinecone</li><li>ChromaDB</li><li>FAISS</li><li>Weaviate</li><li>Qdrant</li></ul><p>These systems perform efficient similarity search on high-dimensional vectors.</p><h3>Step 4 — Query Embedding</h3><p>When the user asks a question:</p><pre>&quot;What accelerated neural network training?&quot;</pre><p>The query is also converted into embeddings.</p><h3>Step 5 — Similarity Search</h3><p>The vector database compares:</p><ul><li>Query vector</li><li>Chunk vectors</li></ul><p>Top-k most similar chunks are retrieved.</p><p>Example:</p><pre>Retrieved Chunk:<br>&quot;GPUs accelerated modern neural network training.&quot;</pre><h3>Step 6 — Response Generation</h3><p>The retrieved chunk is passed directly to the LLM.</p><p>The LLM then synthesizes the final response.</p><h3>Advantages of Naive Retrieval</h3><h3>1. Simplicity and Efficiency</h3><p>Naive retrieval is extremely easy to implement.</p><p>It is ideal for:</p><ul><li>Beginners learning RAG</li><li>Small AI systems</li><li>Lightweight applications</li></ul><h3>2. Fast Retrieval</h3><p>Smaller chunks enable efficient vector similarity search.</p><h3>3. Uniformity in Data Handling</h3><p>The same chunks are used for:</p><ul><li>Embedding generation</li><li>Retrieval</li><li>Response synthesis</li></ul><p>This creates a clean and simple architecture.</p><h3>4. Lower Infrastructure Complexity</h3><p>No advanced orchestration logic is required.</p><h3>Limitations of Naive Retrieval</h3><p>Despite its simplicity, naive retrieval has major weaknesses.</p><h3>1. Limited Contextual Understanding</h3><p>Small chunks often lose surrounding context.</p><p>Example:</p><pre>&quot;He achieved it in 1947.&quot;</pre><p>Without surrounding context:</p><ul><li>The sentence becomes ambiguous.</li></ul><h3>2. Fragmented Information</h3><p>Important information may exist across multiple chunks.</p><p>Naive retrieval retrieves isolated fragments instead of connected context.</p><h3>3. Potential for Suboptimal Responses</h3><p>The retrieved chunks may contain:</p><ul><li>Incomplete information</li><li>Missing references</li><li>Broken semantic continuity</li></ul><p>This weakens final response generation.</p><h3>The Core Problem with Naive Retrieval</h3><p>This is the most important limitation:</p><blockquote><em>Embedding-based retrieval works best with smaller chunks, while LLM generation performs better with richer contextual information.</em></blockquote><p>This creates a tradeoff between:</p><ul><li>Retrieval precision<br>and</li><li>Context completeness</li></ul><p>This limitation led to more advanced retrieval architectures.</p><h3>2. Sentence-Window Retrieval (Small-to-Large Retrieval)</h3><p>Sentence-window retrieval was introduced to solve the context-loss problem of naive retrieval.</p><p>This approach is also known as:</p><ul><li>Small-to-Large Retrieval</li><li>Context Window Retrieval</li><li>Context Expansion Retrieval</li></ul><h3>Core Idea Behind Sentence-Window Retrieval</h3><p>Instead of passing only the retrieved sentence to the LLM:</p><blockquote><em>Retrieve a small precise chunk → Expand it with surrounding context.</em></blockquote><p>This preserves:</p><ul><li>Semantic precision</li><li>Contextual richness</li></ul><p>simultaneously.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lhneRtdU3nHQuf6RdZPMfw.png" /></figure><h3>Why Sentence-Window Retrieval is Needed</h3><p>Embedding-based retrieval performs best on:</p><ul><li>Small focused chunks</li></ul><p>However:</p><ul><li>Small chunks often lack complete meaning.</li></ul><p>Sentence-window retrieval solves this by:</p><ol><li>Retrieving smaller semantic units</li><li>Expanding neighboring contextual information afterward</li></ol><p>This creates a balanced retrieval architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WaPdSIPjkYufDKTMNtGPmQ.png" /></figure><h3>How Sentence-Window Retrieval Works</h3><h3>Step 1 — Split into Small Semantic Units</h3><p>Documents are divided into:</p><ul><li>Sentences</li><li>Small contextual chunks</li></ul><p>Example:</p><pre>Sentence 1 → AI is transforming industries.<br>Sentence 2 → Deep learning improved computer vision.<br>Sentence 3 → CNNs became popular after ImageNet.<br>Sentence 4 → GPUs accelerated neural network training.</pre><h3>Step 2 — Generate Embeddings</h3><p>Each sentence receives its own embedding vector.</p><h3>Step 3 — Query Similarity Search</h3><p>User query:</p><pre>&quot;Why are GPUs important in deep learning?&quot;</pre><p>Retrieved sentence:</p><pre>&quot;GPUs accelerated neural network training.&quot;</pre><h3>Step 4 — Context Window Expansion</h3><p>Instead of returning only the matched sentence:</p><p>The retriever also collects surrounding sentences.</p><p>Expanded context:</p><pre>Sentence 2 → Deep learning improved computer vision.<br>Sentence 3 → CNNs became popular after ImageNet.<br>Sentence 4 → GPUs accelerated neural network training.</pre><p>This gives the LLM:</p><ul><li>Context continuity</li><li>Better semantic understanding</li><li>Richer information flow</li></ul><h3>Advantages of Sentence-Window Retrieval</h3><h3>1. Enhanced Specificity in Retrieval</h3><p>Small chunks improve semantic precision.</p><h3>2. Context-Rich Synthesis</h3><p>The LLM receives broader contextual understanding.</p><h3>3. Balanced Retrieval Architecture</h3><p>This method balances:</p><ul><li>Precision</li><li>Context completeness</li></ul><p>effectively.</p><h3>4. Improved Response Quality</h3><p>The generated response becomes:</p><ul><li>More coherent</li><li>More grounded</li><li>More contextually aware</li></ul><h3>5. Reduced Hallucinations</h3><p>Surrounding evidence improves factual grounding.</p><h3>Disadvantages of Sentence-Window Retrieval</h3><h3>1. Increased Complexity</h3><p>Additional orchestration logic is required.</p><h3>2. Higher Token Usage</h3><p>Expanded context increases:</p><ul><li>Prompt size</li><li>Inference cost</li></ul><h3>3. Increased Retrieval Latency</h3><p>Extra processing steps increase response time slightly.</p><h3>Real-World Importance of Sentence-Window Retrieval</h3><p>This technique works exceptionally well for:</p><ul><li>Research papers</li><li>Enterprise knowledge systems</li><li>Medical AI systems</li><li>Technical documentation</li><li>Educational AI assistants</li></ul><p>because contextual continuity is extremely important in these domains.</p><h3>3. Auto-Merging Retrieval (Hierarchical Retrieval)</h3><p>Auto-merging retrieval is a more advanced context-aware retrieval strategy.</p><p>It is specifically designed to solve:</p><ul><li>Information fragmentation</li><li>Multi-section reasoning</li><li>Long-document comprehension</li></ul><p>This approach is highly useful for:</p><ul><li>Large research papers</li><li>Legal contracts</li><li>Enterprise reports</li><li>Multi-page technical documentation</li></ul><h3>Core Idea Behind Auto-Merging Retrieval</h3><p>Instead of retrieving isolated chunks:</p><blockquote><em>Retrieve smaller chunks → Merge related parent chunks dynamically.</em></blockquote><p>This creates:</p><ul><li>Richer contextual understanding</li><li>Better semantic continuity</li><li>More comprehensive retrieval</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ol_fWTHqcKUbKeN5B2Uniw.png" /></figure><h3>Hierarchical Chunk Structure</h3><p>Documents are structured hierarchically.</p><p>Example:</p><pre>Parent Chunk (512 tokens)<br>   ├── Child Chunk (128)<br>   ├── Child Chunk (128)<br>   ├── Child Chunk (128)<br>   └── Child Chunk (128)</pre><p>Small chunks are optimized for:</p><ul><li>Precise semantic retrieval</li></ul><p>Larger parent chunks are optimized for:</p><ul><li>Context-aware generation</li></ul><h3>How Auto-Merging Retrieval Works</h3><h3>Step 1 — Hierarchical Chunking</h3><p>Documents are divided into:</p><ul><li>Parent chunks</li><li>Child chunks</li></ul><h3>Step 2 — Retrieve Smaller Chunks</h3><p>The retriever performs similarity search on child chunks.</p><p>Example:</p><pre>Retrieved:<br>Child Chunk A<br>Child Chunk B<br>Child Chunk C</pre><h3>Step 3 — Detect Shared Parent Context</h3><p>The system checks:</p><ul><li>Do these chunks belong to the same parent section?</li></ul><p>If yes:</p><ul><li>The chunks are merged.</li></ul><h3>Step 4 — Merge Into Larger Context</h3><p>Instead of fragmented information:</p><p>The LLM receives:</p><ul><li>Larger unified contextual sections.</li></ul><p>This dramatically improves comprehension.</p><h3>Advantages of Auto-Merging Retrieval</h3><h3>1. Comprehensive Contextual Responses</h3><p>Excellent for long-form reasoning tasks.</p><h3>2. Reduced Fragmentation</h3><p>Related information is merged intelligently.</p><h3>3. Dynamic Content Integration</h3><p>The system reconstructs meaningful context dynamically.</p><h3>4. Better Multi-Hop Reasoning</h3><p>The LLM receives connected knowledge rather than isolated chunks.</p><h3>Disadvantages of Auto-Merging Retrieval</h3><h3>1. Complexity in Hierarchy and Threshold Management</h3><p>The system must carefully manage:</p><ul><li>Parent-child relationships</li><li>Similarity thresholds</li><li>Merge conditions</li></ul><h3>2. Risk of Overgeneralization</h3><p>Improper merging may introduce:</p><ul><li>Irrelevant information</li><li>Noise</li></ul><h3>3. Computational Intensity</h3><p>Hierarchical retrieval requires:</p><ul><li>Additional indexing</li><li>Parent mapping</li><li>Merge orchestration</li></ul><p>This increases computational cost.</p><h3>Understanding the Augmentation and Generation Process</h3><p>After retrieval, the next major stage is:</p><ul><li>Augmentation</li><li>Response synthesis</li><li>Final generation</li></ul><p>This is where the LLM generates the final answer.</p><h3>Step 1 — User Query</h3><p>The user provides a natural language query.</p><p>Example:</p><pre>&quot;Explain how GPUs accelerated deep learning.&quot;</pre><h3>Step 2 — Information Retrieval</h3><p>The retriever searches the vector database for semantically similar chunks.</p><p>The query itself is also embedded.</p><p>Retrieved information is selected based on:</p><ul><li>Semantic similarity</li><li>Context relevance</li><li>Retrieval ranking</li></ul><h3>Step 3 — Context Augmentation</h3><p>The retrieved chunks are combined with:</p><ul><li>User query</li><li>System instructions</li><li>Prompt templates</li></ul><p>This creates an expanded contextual prompt.</p><p>Example:</p><pre>[User Query]<br>+<br>[Retrieved Chunks]<br>+<br>[Prompt Instructions]</pre><p>This process is called:</p><blockquote><em>Prompt Augmentation.</em></blockquote><h3>Step 4 — Response Synthesis</h3><p>The enriched prompt is passed to the LLM.</p><p>The LLM synthesizes:</p><ul><li>Retrieved knowledge</li><li>User intent</li><li>Contextual understanding</li></ul><p>to generate the final response.</p><h3>Why Augmentation is Important</h3><p>Augmentation allows the LLM to:</p><ul><li>Access external knowledge</li><li>Generate grounded responses</li><li>Reduce hallucinations</li><li>Improve factual accuracy</li></ul><p>Without augmentation:</p><ul><li>The model relies only on static training data.</li></ul><h3>Benefits of RAG Retrieval Systems</h3><p>RAG systems provide several major advantages.</p><h3>1. Improved Relevance and Accuracy</h3><p>Responses become more factual and context-aware.</p><h3>2. Access to External Knowledge Bases</h3><p>The system can retrieve:</p><ul><li>Real-time data</li><li>Enterprise documents</li><li>Private organizational knowledge</li></ul><h3>3. Reduced Hallucinations</h3><p>Retrieved evidence grounds model responses.</p><h3>4. Open-Domain Question Answering</h3><p>RAG systems can answer questions across multiple domains.</p><h3>5. Multi-Modal Expansion</h3><p>Modern RAG systems increasingly support:</p><ul><li>Images</li><li>Tables</li><li>Audio</li><li>Video retrieval</li></ul><h3>6. No Need for Frequent Model Retraining</h3><p>External knowledge can be updated dynamically without retraining the LLM.</p><h3>Limitations of RAG Systems</h3><p>Despite their power, RAG systems still face several challenges.</p><h3>1. Retrieval Dependency</h3><p>Generation quality depends heavily on retrieval quality.</p><p>Poor retrieval leads to poor responses.</p><h3>2. Information Loss</h3><p>Important context may still be missed during chunking or retrieval.</p><h3>3. Computational Cost</h3><p>Advanced retrieval architectures increase:</p><ul><li>Infrastructure complexity</li><li>Inference cost</li><li>Latency</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d99431adbe0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>