<?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"><channel><title><![CDATA[Learn Tech With Kanishk]]></title><description><![CDATA[Here, I share my learnings about tech, web development, generative AI, and whatever I am learning.]]></description><link>https://blogs.kanishk.codes</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 03:28:59 GMT</lastBuildDate><atom:link href="https://blogs.kanishk.codes/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Async/Await in JavaScript: Writing Cleaner Asynchronous Code]]></title><description><![CDATA[Async/await didn't change how JavaScript handles async work. It changed how you write it - and that difference matters more than you'd think.
The Story So Far
We've been on a journey. First, callbacks]]></description><link>https://blogs.kanishk.codes/async-await-in-javascript</link><guid isPermaLink="true">https://blogs.kanishk.codes/async-await-in-javascript</guid><category><![CDATA[asynchronous]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[@hiteshchoudharylco]]></category><category><![CDATA[promises]]></category><category><![CDATA[callback]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Tue, 31 Mar 2026 17:35:15 GMT</pubDate><content:encoded><![CDATA[<p>Async/await didn't change how JavaScript handles async work. It changed how you write it - and that difference matters more than you'd think.</p>
<h2>The Story So Far</h2>
<p>We've been on a journey. First, callbacks - a function passed around to handle async work. Then promises - a cleaner way to represent future values, with <code>.then()</code> and <code>.catch()</code> to handle outcomes.</p>
<p><strong>Step 1:</strong> <strong>Callbacks</strong> - Raw mechanism. Gets the job done. Nests badly.<br /><strong>Step 2: Promises</strong> - Flat chains. Central error handling. Still verbose.<br /><strong>Step 3: Async/Await</strong> - Reads like sync code. Built on promises.</p>
<p>Promises were a massive improvement. But they still have one awkward quality: you're always writing <code>.then()</code> after <code>.then()</code>. What if async code could just look like normal code?</p>
<p>That's what <code>async/await</code> is.</p>
<h2>It's Just Syntactic Sugar</h2>
<p>Before anything else, the most important thing to understand:</p>
<blockquote>
<p>async/await is not a new async system. It's syntax built on top of promises.</p>
</blockquote>
<p>Under the hood, every <code>async</code> function returns a promise. Every <code>await</code> expression waits for a promise to resolve. Nothing about how JavaScript handles async work has changed. What changed is how you write it.</p>
<pre><code class="language-javascript">// These two do the exact same thing

// With promises
function getUser() {
  return fetch("/api/user").then(res =&gt; res.json());
}

// With async/await
async function getUser() {
  const res = await fetch("/api/user");
  return res.json();
}
</code></pre>
<p>Same outcome. The async/await version just reads like synchronous code - one line at a time, top to bottom.</p>
<h2>How Async Functions Work</h2>
<p>You make a function async by putting the <code>async</code> keyword in front of it:</p>
<pre><code class="language-javascript">async function greet() {
  return "Hello!";
}

// greet() returns a promise — not a plain string
greet().then(value =&gt; console.log(value)); // "Hello!"
</code></pre>
<p>Even though you returned a plain string, <code>greet()</code> returns a promise that resolves to <code>"Hello!"</code>. An async function always returns a promise - always. Even if you return a plain value, JavaScript warps it in <code>Promise.resolve()</code> automatically.</p>
<h2>The Await Keyword</h2>
<p><code>await</code> can only be used inside an <code>async</code> function. It pauses the execution of that function until the promise resolves, then gives you the resolved value directly.</p>
<pre><code class="language-javascript">async function fetchUser() {
  const response = await fetch("https://api.example.com/user");
  const user = await response.json();
  console.log(user);
}
</code></pre>
<p>Read that line by line: call <code>fetch()</code>, wait for the response. Call <code>.json()</code>, wait for the data. Log it. It reads exactly like synchronous code - no callbacks, no <code>.then()</code>, just variables holding values one step at a time.</p>
<div>
<div>💡</div>
<div><strong>Important: </strong><code>await</code> doesn't block the entire JavaScript thread. It only pauses that specific async function. Everything else keeps running normally.</div>
</div>

<h2>Error Handling with try/catch</h2>
<p>With promises, you handle errors using <code>.catch()</code>. With async/await, you use a plain <code>try/catch</code> block - the same syntax you'd use for any synchronous error.</p>
<pre><code class="language-javascript">async function fetchUser() {
  try {
    const response = await fetch("https://api.example.com/user");
    const user = await response.json();
    console.log(user);
  } catch (error) {
    console.log("Something went wrong:", error);
  } finally {
    console.log("Request finished");
  }
}
</code></pre>
<p>If anything inside <code>try</code> throws - network error, JSON parsing failure, anything - it jumps straight to <code>catch</code>. One block handles everything. The error handling sits right next to the code it's guarding, in a pattern every developer already knows.</p>
<h2>Comparison: All Three Approaches</h2>
<p>Same task - fetch a user, then fetch their posts - written three ways:</p>
<ol>
<li><p><strong>CALLBACKS</strong></p>
<pre><code class="language-javascript">getUser(function(err, user) {
  if (err) return handleError(err);
  getPosts(user.id, function(err, posts) {
    if (err) return handleError(err);
    displayPosts(posts);
  });
});
</code></pre>
</li>
<li><p><strong>PROMISES</strong></p>
<pre><code class="language-javascript">getUser()
  .then(user =&gt; getPosts(user.id))
  .then(posts =&gt; displayPosts(posts))
  .catch(err =&gt; handleError(err));
</code></pre>
</li>
<li><p><strong>ASYNC/AWAIT</strong></p>
<pre><code class="language-javascript">async function loadUserPosts() {
  try {
    const user = await getUser();
    const posts = await getPosts(user.id);
    displayPosts(posts);
  } catch (err) {
    handleError(err);
  }
}
</code></pre>
</li>
</ol>
<p>Same logic, three different shapes. Async/await wins on readability - it looks like a plain list of steps, which is exactly what it is.</p>
<h2>A Few Real Patterns</h2>
<h3><strong>Running operations in parallel</strong></h3>
<p>If your async operations don't depend on each other, don't <code>await</code> them one by one - that makes them sequential when they could run simultaneously.</p>
<pre><code class="language-javascript">// Slow — waits for each before starting the next
const user          = await getUser();
const settings      = await getSettings();
const notifications = await getNotifications();

// Fast — all three start at the same time
const [user, settings, notifications] = await Promise.all([
  getUser(),
  getSettings(),
  getNotifications()
]);
</code></pre>
<h3>Async in loops - a gotcha</h3>
<div>
<div>💡</div>
<div><strong>Watch out: </strong><code>await</code> doesn't work as expected inside <code>.forEach()</code>. Use a <code>for...of</code> loop instead when you need sequential async iteration.</div>
</div>

<pre><code class="language-javascript">// Doesn't work — forEach doesn't wait
ids.forEach(async (id) =&gt; {
  const user = await getUser(id);
});

// Works — for...of waits at each step
for (const id of ids) {
  const user = await getUser(id);
  console.log(user);
}
</code></pre>
<h2>Conclusion</h2>
<p><strong>You now have all three</strong><br />Callbacks are the raw mechanism. Promises gave it structure. Async/await gave it readability. You're not learning three separate things - you're learning one thing expressed in progressively cleaner syntax.</p>
<h2>Want More?</h2>
<p>Blog: <a href="https://blogs.kanishk.codes"><strong>https://blogs.kanishk.codes</strong></a><br />Twitter: <a href="https://x.com/kanishk_fr"><strong>https://x.com/kanishk_fr</strong></a><br />LinkedIn: <a href="https://linkedin.com/in/kanishk-chandna"><strong>https://linkedin.com/in/kanishk-chandna</strong></a><br />Instagram: <a href="https://instagram.com/kanishk__fr"><strong>https://instagram.com/kanishk__fr</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[JavaScript Promises Explained for Beginners]]></title><description><![CDATA[Promises didn't replace callbacks - they made them readable. Here's how they work, why they were created, and how to use them confidently.
The Problem With Callbacks (A Quick Recap)
In the last articl]]></description><link>https://blogs.kanishk.codes/javascript-promises-explained</link><guid isPermaLink="true">https://blogs.kanishk.codes/javascript-promises-explained</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[promises]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[@hiteshchoudharylco]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Tue, 31 Mar 2026 12:17:16 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/689a3a398bfe32289695a9fc/896b7f3f-0195-4b94-9413-2483345f1981.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Promises didn't replace callbacks - they made them readable. Here's how they work, why they were created, and how to use them confidently.</p>
<h2>The Problem With Callbacks (A Quick Recap)</h2>
<p>In the last article, we talked about callbacks - a function you pass to other functions so they can be called later. They work. But when you need multiple async operations to happen in sequence, the code starts nesting deeper and deeper.</p>
<pre><code class="language-javascript">getUser(function(err, user) {
  getProfile(user.id, function(err, profile) {
    getPosts(profile.username, function(err, posts) {
      // buried three levels deep
    });
  });
});
</code></pre>
<p>Hard to read. Hard to debug. Hard to maintain. This is the problem promises were built to solve.</p>
<h2>A Promise Is a Future Value</h2>
<p>Here's the mental model that makes promises click:</p>
<blockquote>
<p>A promise is a placeholder for a value you don't have yet.</p>
</blockquote>
<p>Think about ordering food at a restaurant. You place your order, and the waiter gives you a little buzzer. That buzzer is a promise - it doesn't have your food right now, but it represents a commitment that food is coming. You don't stand at the counter waiting. You go sit down, do other things, and when the buzzer goes off, you know your order is ready.</p>
<p>That's exactly what a JavaScript Promise does. When you kick off an async operation, you get a promise back immediately. You can say: "when this resolves, do this. If it fails, do that."</p>
<h2>The Three States of a Promise</h2>
<p>Every promise is always in one of three states:</p>
<ol>
<li><p>Pending:<br />Operation still in progress. Waiting for the buzzer.</p>
</li>
<li><p>Fulfilled:<br />Completed successfully. You got your food.</p>
</li>
<li><p>Rejected:<br />Something went wrong. The kitchen ran out.</p>
</li>
</ol>
<p>A promise starts as pending. It then either fulfils or rejects - and once it does, it stays that way. A fulfilled promise can't become rejected. That's it, no going back.</p>
<h2>Creating a Basic Promise</h2>
<p>Here's what a promise looks like from the inside:</p>
<pre><code class="language-javascript">const myPromise = new Promise(function(resolve, reject) {
  const success = true;

  if (success) {
    resolve("It worked!");
  } else {
    reject("Something went wrong.");
  }
});
</code></pre>
<p>You create a promise by passing a function to <code>new Promise()</code>. That function receives two arguments: <code>resolve</code> and <code>reject</code>. You call <code>resolve</code> when things go well, and <code>reject</code> when they don't .</p>
<p>A more realistic example - wrapping <code>setTimeout</code> in a promise:</p>
<pre><code class="language-javascript">function wait(ms) {
  return new Promise(function(resolve) {
    setTimeout(resolve, ms);
  });
}

wait(2000).then(function() {
  console.log("2 seconds passed");
});
</code></pre>
<p>Instead of nesting a callback inside <code>setTimeout</code>, you get a promise back that you can chain cleanly off of.</p>
<h2>Handling Success and Failure</h2>
<p>You handle a fulfilled promise with <code>.then()</code>, and a rejected promise with <code>.catch()</code>:</p>
<pre><code class="language-javascript">fetch("https://api.example.com/user")
  .then(function(response) {
    return response.json();
  })
  .then(function(data) {
    console.log(data);
  })
  .catch(function(error) {
    console.log("Something went wrong:", error);
  });
</code></pre>
<p>A few things to notice:</p>
<ul>
<li><p>.<code>then()</code> receives the resolved value</p>
</li>
<li><p><code>.catch()</code> receives the rejection reason</p>
</li>
<li><p>One <code>.catch()</code> at the end handles errors from anywhere in the chain.</p>
</li>
</ul>
<p>With callbacks, you had to manually check <code>if (error)</code> inside every single callback.<br />With promises, error handling is centralised. One <code>.catch()</code> covers the whole chain.</p>
<h2>Promise Chaining</h2>
<p>This is the main feature that made promises revolutionary. Each <code>.then()</code> returns a new promise, so you can chain them in a flat, readable sequence:</p>
<pre><code class="language-javascript">fetch("https://api.example.com/user")
  .then(response =&gt; response.json())
  .then(user =&gt; fetch("/api/posts/" + user.id))
  .then(response =&gt; response.json())
  .then(posts =&gt; console.log(posts))
  .catch(error =&gt; console.log(error));
</code></pre>
<p>Now compare the same logic, written both ways:</p>
<p><strong>Callbacks:</strong></p>
<pre><code class="language-javascript">getUser(function(err, user) {
  if (err) return log(err);
  getPosts(user.id,
    function(err, posts) {
      if (err) return log(err);
      display(posts);
    }
  );
});
</code></pre>
<p><strong>Promises:</strong></p>
<pre><code class="language-javascript">getUser()
  .then(user =&gt;
    getPosts(user.id)
  )
  .then(posts =&gt;
    display(posts)
  )
  .catch(err =&gt; log(err));
</code></pre>
<p>Same logic. Completely different readability. The promise version reads top to bottom like a sequence of steps. Flat code is genuinely easier to reason about - especially when you're debugging at midnight.</p>
<h2>The Full Lifecycle</h2>
<pre><code class="language-javascript">const promise = new Promise(function(resolve, reject) {
  // 1. Starts as "pending"
  setTimeout(function() {
    const worked = Math.random() &gt; 0.5;

    if (worked) {
      resolve("Success!");   // 2a. Fulfilled
    } else {
      reject("Failed!");     // 2b. Rejected
    }
  }, 1000);
});

promise
  .then(value =&gt; console.log("Fulfilled:", value))
  .catch(reason =&gt; console.log("Rejected:", reason))
  .finally(() =&gt; console.log("Done either way"));
</code></pre>
<p><code>.finally()</code> runs regardless of whether the promise is fulfilled or rejected. Handy for cleanup - hiding a loading spinner, closing a connection, that sort of thing.</p>
<h2>A Few Things Worth Knowing</h2>
<blockquote>
<p><strong>Promises are eager.</strong> The function you pass to <code>new Promise()</code> runs immediately - not lazily. The async part is what gets deferred.</p>
</blockquote>
<blockquote>
<p><code>.then()</code> <strong>always returns a new promise</strong>. This is why chaining works. Each step waits for the previous one to resolve before running.</p>
</blockquote>
<blockquote>
<p>If you return a promise inside <code>.then()</code>, the chain waits for it. Returning <code>fetch(...)</code> inside a <code>.then()</code> means the next <code>.then()</code> doesn't run until that fetch completes.</p>
</blockquote>
<blockquote>
<p>Always handle rejections. It you forget <code>.catch()</code> and the promise rejects, you'll get a warning in Node.js - and potentially a crash. Never skip error handling.</p>
</blockquote>
<h2>Conclusion</h2>
<p><strong>Promises are not magic.</strong><br />They're just a better way to manage the same callbacks you already know. The mental model - a future value, three states, .<code>then()</code> and <code>.catch()</code> - is what everything else builds on.</p>
<h2>Want More?</h2>
<p>Blog: <a href="https://blogs.kanishk.codes/"><strong>https://blogs.kanishk.codes</strong></a><br />Twitter: <a href="https://x.com/kanishk_fr/"><strong>https://x.com/kanishk_fr</strong></a><br />LinkedIn: <a href="https://linkedin.com/in/kanishk-chandna/"><strong>https://linkedin.com/in/kanishk-chandna</strong></a><br />Instagram: <a href="https://instagram.com/kanishk__fr/"><strong>https://instagram.com/kanishk__fr</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[Callbacks in JavaScript: Why They Exist]]></title><description><![CDATA[Before promises, before async/await - there were callbacks. Understanding them deeply is what makes everything else click.
Functions Are Just Values
Before we even get to callbacks, there's one thing ]]></description><link>https://blogs.kanishk.codes/callbacks</link><guid isPermaLink="true">https://blogs.kanishk.codes/callbacks</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[callback functions]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[@hiteshchoudharylco]]></category><category><![CDATA[oop]]></category><category><![CDATA[Node.js]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Tue, 31 Mar 2026 11:10:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/689a3a398bfe32289695a9fc/6606bede-6ac9-4739-acd7-5d324bb956ff.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Before promises, before async/await - there were callbacks. Understanding them deeply is what makes everything else click.</p>
<h2>Functions Are Just Values</h2>
<p>Before we even get to callbacks, there's one thing you need to internalise about JavaScript: functions are values.</p>
<p>That's it. That's the foundation of everything in this article.</p>
<p>In most languages, a function is a special construct - you define it, you call it, that's it. But in JavaScript, a function is just a value like a number or a string. You can store it in a variable, put it in an array, pass it to another function, or return it from a function.</p>
<pre><code class="language-javascript">const greet = function() {
  console.log("Hello!");
};

greet(); // "Hello!"
</code></pre>
<p>This is not just a fun quirk. It's what makes callbacks possible - and what makes JavaScript's async model work the way it does.</p>
<h2>What Is a Callback Function?</h2>
<p>A callback is simply a function you pass to another function, so that the other function can call it later.</p>
<p>That's the whole definition. Nothing more complicated than that.</p>
<pre><code class="language-javascript">function doSomething(callback) {
  console.log("Doing something...");
  callback();
}

function finished() {
  console.log("Done!");
}

doSomething(finished);
// "Doing something..."
// "Done!"
</code></pre>
<p>Notice you're passing <code>finished</code> - not <code>finished()</code>. You're passing the function itself, not the result of calling it. The <code>doSomething</code> function decides when to call it.</p>
<p>That "deciding when to call it" part is what makes callbacks useful.</p>
<h2>Passing Functions as Arguments</h2>
<p>Let's look at a few more examples before we get into async territory, because callbacks aren't only for async code.</p>
<h3>Callbacks in array methods</h3>
<p>You use callbacks all the time without thinking about it.</p>
<pre><code class="language-javascript">const numbers = [1, 2, 3, 4, 5];

const doubled = numbers.map(function(n) {
  return n * 2;
});

console.log(doubled); // [2, 4, 6, 8, 10]
</code></pre>
<p>The function you pass to <code>.map()</code> is a callback. You're telling <code>.map()</code>: "Here's what I want you to do with each element." <code>.map()</code> handles the looping - you just hand it the logic.</p>
<pre><code class="language-javascript">const evens = numbers.filter(n =&gt; n % 2 === 0);
// [2, 4]

numbers.forEach(n =&gt; console.log(n));
// 1, 2, 3, 4, 5
</code></pre>
<h3>A custom example</h3>
<pre><code class="language-javascript">function repeat(n, action) {
  for (let i = 0; i &lt; n; i++) {
    action(i);
  }
}

repeat(3, function(i) {
  console.log("Step " + i);
});
// "Step 0"
// "Step 1"
// "Step 2"
</code></pre>
<p>This pattern - a function that takes another function and decides when to call it - is everywhere in JavaScript.</p>
<h2>Why Callbacks Exist in Async Programming</h2>
<p>Here's where callbacks really shine. JavaScript is single-threaded. That means it can only do one thing at a time. There's no parallel execution, no background threads.</p>
<p>So what happens when you need to do something that takes time - like fetching data from a server, reading a file, or waiting for a user to click something?</p>
<p>You can't just pause everything and wait. That would freeze the entire page. Instead, JavaScript says: "I'll start this task, move on to other things, and call you back when it's done."</p>
<h3>setTimeout - the simplest async example</h3>
<pre><code class="language-javascript">console.log("Start");

setTimeout(function() {
  console.log("This runs after 2 seconds");
}, 2000);

console.log("End");
</code></pre>
<p>What do you think the output is?</p>
<pre><code class="language-plaintext">Start
End
This runs after 2 seconds
</code></pre>
<p>JavaScript doesn't pause at <code>setTimeout</code>. It registers the callback, starts a timer in the background, and moves on. When 2 seconds pass, it comes back and runs your callback. This is the event loop in action.</p>
<h2>Callback Usage in Common Scenarios</h2>
<h3>Event listeners</h3>
<p>Every time you attach a click handler, you're using a callback:</p>
<pre><code class="language-javascript">document.querySelector("button").addEventListener("click", function() {
  console.log("Button clicked!");
});
</code></pre>
<p>You're telling the browser: "when this button is clicked, call this function." You don't know when the click will happen - that's up to the user. The callback is the instruction you leave behind.</p>
<h3>Fetching data - the old way</h3>
<p>Before <code>fetch()</code> and promises, the standard was <code>XMLHttpRequest</code>. The <code>(error, data)</code>pattern it used - called error-first callbacks - was the convention in Node.js for years.\</p>
<pre><code class="language-javascript">function getData(url, callback) {
  const xhr = new XMLHttpRequest();
  xhr.open("GET", url);
  xhr.onload = function() {
    if (xhr.status === 200) {
      callback(null, xhr.responseText);
    } else {
      callback("Error: " + xhr.status, null);
    }
  };
  xhr.send();
}

getData("https://api.example.com/user", function(error, data) {
  if (error) {
    console.log("Something went wrong:", error);
    return;
  }
  console.log("Got data:", data);
});
</code></pre>
<h3>Reading files in Node.js</h3>
<pre><code class="language-javascript">const fs = require("fs");

fs.readFile("notes.txt", "utf8", function(error, content) {
  if (error) {
    console.log("Couldn't read file:", error);
    return;
  }
  console.log(content);
});

console.log("This runs before the file is read");
</code></pre>
<p><code>readfile</code> starts the operation, moves on, and calls your callback when the file is ready.</p>
<h2>The Basic Problem: Callback Nesting</h2>
<p>Callbacks work well for one or two async operations. But things get messy fast when you need to chain multiple async tasks - where the result of one feeds into the next.</p>
<p>Imagine you need to: get a user's ID, use that ID to fetch their profile, then use the profile to fetch their posts. With callbacks:</p>
<pre><code class="language-javascript">getUser(function(error, user) {
  if (error) return console.log(error);

  getProfile(user.id, function(error, profile) {
    if (error) return console.log(error);

    getPosts(profile.username, function(error, posts) {
      if (error) return console.log(error);

      console.log(posts);
    });
  });
});
</code></pre>
<p>Each callback is nested inside the previous one. The code keeps drifting to the right. This is what people call callback hell - or the pyramid of doom, because of the shape it creates.</p>
<pre><code class="language-javascript">step1(function(err, result1) {
  step2(result1, function(err, result2) {
    step3(result2, function(err, result3) {
      step4(result3, function(err, result4) {
        step5(result4, function(err, result5) {
          // you get the idea
        });
      });
    });
  });
});
</code></pre>
<p>It's not just an aesthetic problem. It becomes genuinely hard to follow the logic flow, handle errors consistently, and refactor or reuse parts of the code.</p>
<blockquote>
<p><strong>Important:</strong> Callbacks are not bad. They're the building block. Once you understand them deeply, everything that comes after - Promises, async/await - will make a lot more sense, because they're all just cleaner ways of doing the same thing callbacks were doing.</p>
</blockquote>
<h2>The Mental Model</h2>
<p>Here's a simple way to think about all of this:</p>
<blockquote>
<p>A callback is an instruction you hand to someone else, telling them what to do once they're ready.</p>
</blockquote>
<p>You're not standing there waiting. You're leaving a note. When the task is done, the note gets executed. Whether it's a button click, a file read, a network request - same idea. You say: "Do your thing, and when you're done, call this."</p>
<h2>Conclusion</h2>
<p>Callbacks exist because JavaScript needed a way to handle things that take time without blocking everything else. You've been using them already - every <code>.map()</code>, every <code>addEventListener</code>, every <code>setTimeout</code>. Now you know why it works the way it does.</p>
<h2>Want More?</h2>
<p>Blog: <a href="https://blogs.kanishk.codes/"><strong>https://blogs.kanishk.codes</strong></a><br />Twitter: <a href="https://x.com/kanishk_fr/"><strong>https://x.com/kanishk_fr</strong></a><br />LinkedIn: <a href="https://linkedin.com/in/kanishk-chandna/"><strong>https://linkedin.com/in/kanishk-chandna</strong></a><br />Instagram: <a href="https://instagram.com/kanishk__fr/"><strong>https://instagram.com/kanishk__fr</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[String Polyfills and Common Interview Methods in JavaScript]]></title><description><![CDATA[What Even Are String Methods?
Before we talk about polyfills, let's make sure we're on the same page about what string methods actually are.
In JavaScript, a string isn't just a bunch of characters; i]]></description><link>https://blogs.kanishk.codes/string-polyfills-and-common-interview-methods-in-javascript</link><guid isPermaLink="true">https://blogs.kanishk.codes/string-polyfills-and-common-interview-methods-in-javascript</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[interview questions]]></category><category><![CDATA[@hiteshchoudharylco]]></category><category><![CDATA[chaicode webdev cohort 2026]]></category><category><![CDATA[string]]></category><category><![CDATA[polyfills]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Tue, 24 Mar 2026 20:59:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/689a3a398bfe32289695a9fc/b084b234-8e8c-4be5-aa0b-ffec7109b7f3.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>What Even Are String Methods?</h2>
<p>Before we talk about polyfills, let's make sure we're on the same page about what string methods actually are.</p>
<p>In JavaScript, a string isn't just a bunch of characters; it's an object under the hood.<br />And like any object, it comes with built-in methods you can call on it. Things like <code>.toUpperCase()</code> , <code>.trim()</code>, <code>.includes()</code>, <code>.slice</code> - these are all methods that live on <code>String.prototype</code>.</p>
<pre><code class="language-javascript">const name = "kanishk";
console.log(name.toUpperCase()); // "KANISHK"
console.log(name.includes("ani"));  // true
</code></pre>
<p>Simple, right? You write a string, call a method, and get a result. But these methods didn't always exist. JavaScript evolves constantly, and each new ECMAScript spec adds new ones. That's exactly where polyfills come in.</p>
<h2>Why Would You Even Write a Polyfill?</h2>
<p>A polyfill is basically you saying: <em>"Hey, this built-in method might not exist in older environments - so let me implement it myself, just in case."</em></p>
<p>Think about it. You're building a web app that needs to run in older browsers. You use <code>String.prototype.includes()</code> freely in your code, but then someone opens your app in an old browser that doesn't support it - boom, everything breaks.</p>
<p>A polyfill patches that gap:</p>
<pre><code class="language-javascript">if (!String.prototype.includes) {
  String.prototype.includes = function(search, start) {
    return this.indexOf(search, start) !== -1;
  };
}
</code></pre>
<blockquote>
<p><strong>Interview insight:</strong> When an interviewer asks you to implement <code>String.prototype.repeat</code> from scratch, they're not checking if you memorised the spec. They're checking if you understand <em>what the method actually does</em> at a logical level. Can you think through the steps? Can you handle edge cases?</p>
</blockquote>
<h2>Implementing Common String Utilities</h2>
<p>Let's go through the most commonly asked ones, one by one.</p>
<p><strong>String.prototype.repeat</strong><br />Repeats a string n times. Single concept, but the edge cases are what matter.</p>
<pre><code class="language-javascript">String.prototype.myRepeat = function(count) {
  if (count &lt; 0) throw new RangeError("Invalid count value");
  if (count === 0) return "";

  let result = "";
  for (let i = 0; i &lt; count; i++) {
    result += this;
  }
  return result;
};

console.log("ab".myRepeat(3)); // "ababab"
</code></pre>
<p>The logic is dead simple - loop <code>count</code> times, keep appending the string. The important bit is handling edge cases: negative count throws an error, zero returns an empty string.</p>
<p><strong>String.prototype.includes</strong><br />Checks if a string contains another string. This one's almost trivially easy because <code>indexOf</code> does the heavy lifting.</p>
<pre><code class="language-javascript">String.prototype.myIncludes = function(searchStr, position = 0) {
  return this.indexOf(searchStr, position) !== -1;
};
</code></pre>
<p>The concept: <code>indexOf</code> Returns -1 when the substring isn't found, and any other number when it is. We just convert that to a boolean.</p>
<p><strong>startsWith and endsWith</strong><br />These check if a string starts or ends with a particular substring. The key insight is uses <code>slice</code> to cut out the exact portion you want to compare.</p>
<pre><code class="language-javascript">String.prototype.myStartsWith = function(searchStr, position = 0) {
  return this.slice(position, position + searchStr.length) === searchStr;
};

String.prototype.myEndsWith = function(searchStr, endPosition = this.length) {
  const start = endPosition - searchStr.length;
  return this.slice(start, endPosition) === searchStr;
};
</code></pre>
<p><strong>trim, trimStart, trimEnd</strong><br />These remove whitespace from a string. This is a good one to know because it introduces regex patterns that come up again and again.</p>
<pre><code class="language-javascript">String.prototype.myTrim = function() {
  return this.replace(/^\s+|\s+$/g, "");
};

String.prototype.myTrimStart = function() {
  return this.replace(/^\s+/, "");
};

String.prototype.myTrimEnd = function() {
  return this.replace(/\s+$/, "");
};
</code></pre>
<p>The pattern <code>^\s+</code> matches whitespace at the beginning, and <code>\s+$</code> matches it at the end. The <code>|</code> in myTrim just means "either/or".</p>
<p><strong>padStart and padEnd</strong><br />These pad a string to a specific length. The tricky part is when padString is longer than one character - you need to repeat it and then trim it down to exactly the right length.</p>
<pre><code class="language-javascript">String.prototype.myPadStart = function(targetLength, padString = " ") {
  if (this.length &gt;= targetLength) return String(this);

  const padNeeded = targetLength - this.length;
  let padding = padString.repeat(Math.ceil(padNeeded / padString.length));
  padding = padding.slice(0, padNeeded);

  return padding + this;
};

console.log("5".myPadStart(3, "0")); // "005"
</code></pre>
<h2>Common Interview String Problems</h2>
<p>These are the classics - ones that show up across interviews at startups, mid-size companies, and big tech alike.</p>
<h3>Reverse a String</h3>
<p>Sounds too simple. Interviewers often ask for the manual approach because they want to see if you can work with indices.</p>
<pre><code class="language-javascript">function reverseString(str) {
  let result = "";
  for (let i = str.length - 1; i &gt;= 0; i--) {
    result += str[i];
  }
  return result;
}

console.log(reverseString("hello")); // "olleh"
</code></pre>
<h3>Check for Palindrome</h3>
<p>Always clean the string first. Real-world strings have spaces, punctuation, mixed case - always handle that.</p>
<pre><code class="language-javascript">function isPalindrome(str) {
  const clean = str.toLowerCase().replace(/[^a-z0-9]/g, "");
  const reversed = clean.split("").reverse().join("");
  return clean === reversed;
}

console.log(isPalindrome("A man, a plan, a canal: Panama")); // true
</code></pre>
<h3>Count Character Occurrences</h3>
<p>The pattern <code>count[char] = (count[char] || 0) + 1</code> is a one-liner you should have memorised.</p>
<pre><code class="language-javascript">function charCount(str) {
  const count = {};
  for (let char of str) {
    count[char] = (count[char] || 0) + 1;
  }
  return count;
}

console.log(charCount("hello"));
// { h: 1, e: 1, l: 2, o: 1 }
</code></pre>
<h3>Check if Two Strings are Anagrams</h3>
<pre><code class="language-javascript">function isAnagram(str1, str2) {
  if (str1.length !== str2.length) return false;

  const sort = s =&gt; s.toLowerCase().split("").sort().join("");
  return sort(str1) === sort(str2);
}

console.log(isAnagram("listen", "silent")); // true
</code></pre>
<p>The sorting approach is clean and readable. There's also a frequency counter approach (using charCount), which is O(n) vs O(n log n). Worth knowing both.</p>
<h3>Longest Substring Without Repeating Characters</h3>
<p>A sliding window classic. You're maintaining a window of unique characters - whenever a repeat shows up, you shrink the window from the left.</p>
<pre><code class="language-javascript">function lengthOfLongestSubstring(s) {
  let map = new Map();
  let maxLen = 0;
  let left = 0;

  for (let right = 0; right &lt; s.length; right++) {
    if (map.has(s[right])) {
      left = Math.max(left, map.get(s[right]) + 1);
    }
    map.set(s[right], right);
    maxLen = Math.max(maxLen, right - left + 1);
  }

  return maxLen;
}

console.log(lengthOfLongestSubstring("abcabcbb")); // 3
</code></pre>
<h2>Why Understanding Built-in Behaviour Actually Matters</h2>
<p>You can use <code>.includes()</code> every day without ever thinking about how it works. That's totally fine for shipping features. But in interviews, this deeper understanding separates good candidates from great ones.</p>
<p>When you implement a polyfill from scratch, you're forced to think about:</p>
<ul>
<li><p><strong>What does this method return?</strong> A new string? A boolean? An index?</p>
</li>
<li><p><strong>What happens at the boundaries?</strong> Empty strings, negative indices, undefined inputs.</p>
</li>
<li><p><strong>What's the time complexity?</strong> Is my approach O(n)? O(n²)?</p>
</li>
</ul>
<p>For example, most developers know <code>str.includes(search)</code> returns <code>true</code> or <code>false</code>.<br />But how many know it accepts a second argument - the position to start searching from? And what happens if you pass a RegExp as the search value? (It throws a TypeError.)</p>
<p>That kind of awareness doesn't come from memorising docs. It comes from implementing these things yourself, running them, breaking them, and fixing them.</p>
<h2><strong>Want More?</strong></h2>
<p>Blog: <a href="https://blogs.kanishk.codes/"><strong>https://blogs.kanishk.codes/</strong></a><br />Twitter: <a href="https://x.com/kanishk_fr/"><strong>https://x.com/kanishk_fr/</strong></a><br />LinkedIn: <a href="https://linkedin.com/in/kanishk-chandna/"><strong>https://linkedin.com/in/kanishk-chandna/</strong></a><br />Instagram: <a href="https://instagram.com/kanishk__fr/"><strong>https://instagram.com/kanishk__fr/</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[Understanding Object-Oriented Programming in JavaScript]]></title><description><![CDATA[When people first hear Object-Oriented Programming (OOP), it sounds like some elite programming philosophy invented to confuse beginners, but the reality is it's just a way to organise code so it rese]]></description><link>https://blogs.kanishk.codes/oop-in-javascript</link><guid isPermaLink="true">https://blogs.kanishk.codes/oop-in-javascript</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[@hiteshchoudharylco]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[oop]]></category><category><![CDATA[Object Oriented Programming]]></category><category><![CDATA[Objects]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Thu, 12 Mar 2026 10:19:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/689a3a398bfe32289695a9fc/20ac8e3a-819f-4ca1-b926-b8ad35d46fc7.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When people first hear Object-Oriented Programming (OOP), it sounds like some elite programming philosophy invented to confuse beginners, but the reality is it's just a way to organise code so it resembles real-world things.</p>
<p>Instead of writing random functions everywhere, OOP helps you group related data and behaviour together. Think of it as giving your code a little structure so it doesn't turn into chaos.<br />Let's break it down step by step.</p>
<h2>What Object-Oriented Programming (OOP) menas</h2>
<p>Object-Oriented Programming is a programming style where you structure your code around objects.</p>
<p>An object represents something with:</p>
<ul>
<li><p>Properties (data about the object)</p>
</li>
<li><p>Methods (actions the object can perform)</p>
</li>
</ul>
<p>For example, a Car object might have:<br />Properties:</p>
<ul>
<li><p>color</p>
</li>
<li><p>brand</p>
</li>
<li><p>speed</p>
</li>
</ul>
<p>Methods:</p>
<ul>
<li><p>start()</p>
</li>
<li><p>stop()</p>
</li>
<li><p>accelerate()</p>
</li>
</ul>
<p>So instead of thinking in isolated functions, OOP helps us think in terms of things and their behaviours.</p>
<h2>A Simple Real-World Analogy</h2>
<p>Imagine a car manufacturing company. Before producing cars, engineer create a blueprint.<br />The blueprint describes:</p>
<ul>
<li><p>color</p>
</li>
<li><p>engine type</p>
</li>
<li><p>number of doors</p>
</li>
<li><p>features</p>
</li>
</ul>
<p>But the blueprint itself is not a car.<br />It's just a template.</p>
<p>Using that blueprint, the company can produce many cars.<br />Each car is a separate object, but all follow the same design.</p>
<p>Programming works the same way.<br />In JavaScript:<br />Blueprint -&gt; Class<br />Actual cars -&gt; Objects</p>
<h2>What is a Class in JavaScript?</h2>
<p>A class is basically a blueprint for creating objects.<br />It defines:</p>
<ul>
<li><p>what properties will an object have</p>
</li>
<li><p>what actions they can perform</p>
</li>
</ul>
<p>Here is a simple class example.</p>
<pre><code class="language-javascript">class Car {
    brand = "Toyota";
}
</code></pre>
<p>This defines a blueprint called Car. But notice something important:<br />This code does not create a car yet.<br />It only defines how cars should look.</p>
<h2>Creating Objects from a Class</h2>
<p>To create an actual object, we use the new keyword.</p>
<pre><code class="language-javascript">class Car {
    brand = "Toyota";
}
const car1 = new Car();
</code></pre>
<p>Now car1 is an object created from the Car class.<br />You can access its properties like this:</p>
<pre><code class="language-javascript">console.log(car1.brand);
</code></pre>
<p>Output:</p>
<pre><code class="language-json">Toyota
</code></pre>
<p>You can create multiple objects from the same class.</p>
<pre><code class="language-javascript">const car1 = new Car();
const car2 = new Car();
const car3 = new Car();
</code></pre>
<p>All of them follow the same blueprint.<br />That's code reuseability, which is one of the biggest benefits of OOP.</p>
<h2>The Constructor Method</h2>
<p>Often, we want each object to have different values.<br />For example:<br />Car 1 -&gt; Toyota<br />Car 2 -&gt; BMW<br />Car 3 -&gt; Tesla<br />This is where the constructor comes in.</p>
<p>A constructor is a special method that runs when a new object is created.</p>
<p>Example:</p>
<pre><code class="language-javascript">class Car {
    constructor(brand, color) {
        this.brand = brand;
        this.color = color;
    }
}
</code></pre>
<p>Now we can create different cars.</p>
<pre><code class="language-javascript">const car1 = new Car("Toyota", "Red");
const car2 = new Car("BMW", "Black");

console.log(car1.brand); //Toyota
console.log(car2.brand); //BMW
</code></pre>
<p>The constructor helps initialise the object with specific data.</p>
<h2>Methods Inside a Class</h2>
<p>Classes can also contain methods.<br />Methods are simply functions that belong to the object.</p>
<p>Example:</p>
<pre><code class="language-javascript">class Car {
  constructor(brand) {
    this.brand = brand;
  }

  start() {
    console.log(this.brand + " is starting...");
  }
}
</code></pre>
<p>Now create an object.</p>
<pre><code class="language-javascript">const car1 = new Car("Tesla");

car1.start();
</code></pre>
<p>Output:</p>
<pre><code class="language-json">Tesla is starting...
</code></pre>
<p>The method start() belongs to every object created from the Car class.</p>
<h2>Basic Idea of Encapsulation</h2>
<p>Encapsulation sounds fancy, but the idea is simple.<br />It means keeping related data and behaviour together inside a class. Instead of writing scattered variables and functions everywhere, we group them.</p>
<p>Example without OOP:</p>
<pre><code class="language-javascript">let name = "Rahul";
let age = 20;

function printDetails() {
  console.log(name, age);
}
</code></pre>
<p>Now imagine doing this for hundreds of students. That would be a mess.<br />Using a class keeps everything organised.</p>
<pre><code class="language-javascript">class Student {
  constructor(name, age) {
    this.name = name;
    this.age = age;
  }

  printDetails() {
    console.log(this.name + " is " + this.age + " years old.");
  }
}
</code></pre>
<p>Now the data and behaviour belong together. That's encapsulation in a beginner-friendly sense.</p>
<h2>Assignment: Create Your Own Student Class</h2>
<p>Create a class called Student.</p>
<p>Requirements:<br />Properties:</p>
<ul>
<li><p>name</p>
</li>
<li><p>age</p>
</li>
</ul>
<p>Method:</p>
<ul>
<li>printDetails()</li>
</ul>
<p>Example solution:</p>
<pre><code class="language-javascript">class Student {
  constructor(name, age) {
    this.name = name;
    this.age = age;
  }

  printDetails() {
    console.log(this.name + " is " + this.age + " years old.");
  }
}
</code></pre>
<p>Create multiple students:</p>
<pre><code class="language-javascript">const student1 = new Student("Rahul", 20);
const student2 = new Student("Aisha", 22);

student1.printDetails();
student2.printDetails();
</code></pre>
<p>Output:</p>
<pre><code class="language-plaintext">Rahul is 20 years old.
Aisha is 22 years old.
</code></pre>
<h2>Conclusion</h2>
<p>Object-Oriented Programming is simply a way to model real-world things in code.<br />Key ideas to remember:</p>
<ul>
<li><p>Class -&gt; blueprint</p>
</li>
<li><p>Object -&gt; instance created from the blueprint</p>
</li>
<li><p>Constructor -&gt; initialises object data</p>
</li>
<li><p>Methods -&gt; actions the object can perform</p>
</li>
<li><p>Encapsulation -&gt; grouping data and behaviour together</p>
</li>
</ul>
<p>You don't need to memorise everything right now.<br />Just remember the big idea:</p>
<p>OOP helps you write code that is easier to organise, reuse, and maintain.</p>
<p>And trust me, once your projects grow beyond a few files, you'll appreciate that structure.</p>
<h2><strong>Want More?</strong></h2>
<p>Blog: <a href="https://blogs.kanishk.codes/"><strong>https://blogs.kanishk.codes/</strong></a><br />Twitter: <a href="https://x.com/kanishk_fr/"><strong>https://x.com/kanishk_fr/</strong></a><br />LinkedIn: <a href="https://linkedin.com/in/kanishk-chandna/"><strong>https://linkedin.com/in/kanishk-chandna/</strong></a><br />Instagram: <a href="https://instagram.com/kanishk__fr/"><strong>https://instagram.com/kanishk__fr/</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[How Web Browsers Operate: A Simple Guide]]></title><description><![CDATA[Let’s start with a simple question.
What happens after you type a URL and press Enter?
You open your browser, type example.com, hit Enter…. and a website appears.No explosions. No loading bars from th]]></description><link>https://blogs.kanishk.codes/working-of-browsers</link><guid isPermaLink="true">https://blogs.kanishk.codes/working-of-browsers</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[@hiteshchoudharylco]]></category><category><![CDATA[Browsers]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Browser Internals]]></category><category><![CDATA[Chaiaurcode]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Wed, 11 Mar 2026 17:33:46 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/689a3a398bfe32289695a9fc/5ea569cd-85f1-4afc-9444-7f79e5a78671.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Let’s start with a simple question.</p>
<h2>What happens after you type a URL and press Enter?</h2>
<p>You open your browser, type example.com, hit Enter…. and a website appears.<br />No explosions. No loading bars from the 2000s. Just a page.</p>
<p>Behind the scenes, though, your browser just ran a small orchestra of systems, all working together to turn into pixels.</p>
<p>This article explains that journey in simple language.</p>
<p>No memorisation. No deep engine internals. Just the flow.</p>
<h2>What is a browser, really?</h2>
<p>A browser is now “an app that opens a website”.<br />A browser is a translator and renderer.</p>
<ul>
<li><p>It fetches raw files from the internet (HTML, CSS, JavaScript)</p>
</li>
<li><p>Understands what those files mean</p>
</li>
<li><p>Converts them into a visual page you can see and interact with</p>
</li>
</ul>
<p>Think of a browser as:<br />A factory that turns code into a living, clickable interface.</p>
<h2>High-level parts of a browser</h2>
<p>At a very high level, a browser has a few main pieces:</p>
<ol>
<li><p>Under Interface - what you interact with</p>
</li>
<li><p>Browser Engine - the coordinator</p>
</li>
<li><p>Rendering Engine - turns code into visuals</p>
</li>
<li><p>Networking - fetches files from servers</p>
</li>
<li><p>JavaScript Engine - runs JavaScript code</p>
</li>
<li><p>Storage &amp; Other Helpers - cache, cookies, history, etc.</p>
</li>
</ol>
<p>You don’t need to remember this list.<br />Just know that each part has one job.</p>
<h2>The User Interface (the obvious part)</h2>
<p>This is the part you already know:</p>
<ul>
<li><p>Address bar</p>
</li>
<li><p>Tabs</p>
</li>
<li><p>Back / Forward buttons</p>
</li>
<li><p>Refresh button</p>
</li>
<li><p>Bookmark bar</p>
</li>
</ul>
<p>Important thing to note:</p>
<p>The UI is separate from the web page.</p>
<p>Your browser’s tabs and buttons are not part of the website.<br />They are controlled by the browser itself.</p>
<h2>Browser Engine vs Rendering Engine</h2>
<p>This sounds scary. It’s not.</p>
<ul>
<li><p>Browser Engine:<br />The manager. It connects the UI to everything else.</p>
</li>
<li><p>Rendering Engine:<br />The artist. It takes HTML + CSS and paints pixels on the screen.</p>
</li>
</ul>
<p>So:</p>
<ul>
<li><p>Browser Engine says: “User typed a URL”</p>
</li>
<li><p>Rendering Engine says: “Cool, give me the files, I’ll draw the page”</p>
</li>
</ul>
<p>Different browsers use different engines (like Chromium or Gecko), but the flow stays the same, which is all that matters right now.</p>
<h2>Networking: fetching the website</h2>
<p>When you press Enter, the browser:</p>
<ol>
<li><p>Figures out which server to talk to</p>
</li>
<li><p>Sends a request over the internet</p>
</li>
<li><p>Downloads files like:</p>
<ul>
<li><p>HTML</p>
</li>
<li><p>CSS</p>
</li>
<li><p>JavaScript</p>
</li>
<li><p>Images</p>
</li>
<li><p>Fonts</p>
</li>
</ul>
</li>
</ol>
<p>At this point, the browser has raw text files, not a page.<br />Yet.</p>
<h2>HTML parsing and DOM creation</h2>
<p>The browser starts with HTML.</p>
<p>HTML is just text.<br />The browser needs structure.</p>
<p>So it parses the HTML</p>
<h3>What does parsing mean?</h3>
<p>Parsing means: Reading something piece by piece and understanding its structure.</p>
<p>Example:</p>
<pre><code class="language-xml">&lt;div&gt;
    &lt;h1&gt;Hello&lt;/h1&gt;
    &lt;p&gt;World&lt;/p&gt;
&lt;/div&gt;
</code></pre>
<p>The browser converts this into a tree structure called the DOM.</p>
<h3>DOM (Document Object Model)</h3>
<ul>
<li><p>The DOM is a tree</p>
</li>
<li><p>Every HTML element becomes a node</p>
</li>
<li><p>Parent elements contain child elements</p>
</li>
</ul>
<p>Think of it like a family tree:</p>
<ul>
<li><div> is the parent
</div></li>
<li><h1> and <p> are children</p></h1></li>
</ul>
<p>This DOM is how the browser understands the page.</p>
<h2>CSS parsing and CSSOM creation</h2>
<p>Now CSS comes in.</p>
<p>CSS answers questions like:</p>
<ul>
<li><p>What colour?</p>
</li>
<li><p>What size?</p>
</li>
<li><p>Where should this element sit?</p>
</li>
</ul>
<p>The browser parses CSS and builds another structure called the CSSOM.</p>
<h3>CSSOM (CSS Object Model)</h3>
<ul>
<li><p>Similar to the DOM</p>
</li>
<li><p>Represents styles and rules</p>
</li>
<li><p>Includes inheritance and priorities</p>
</li>
</ul>
<p>So now the browser has:</p>
<ul>
<li><p>DOM → structure</p>
</li>
<li><p>CSSOM → appearance</p>
</li>
</ul>
<h2>DOM + CSSOM = Render Tree</h2>
<p>The browser now combines both.</p>
<p>Not every DOM element is visible.</p>
<ul>
<li><p>“display: none” elements don’t show</p>
</li>
<li><p>Some nodes are just structural</p>
</li>
</ul>
<p>The browser builds a Render Tree, which includes:</p>
<ul>
<li><p>Only visible elements</p>
</li>
<li><p>Their final computed styles</p>
</li>
</ul>
<p>This is the blueprint for drawing the page.</p>
<h2>Layout (reflow): deciding positions</h2>
<p>Now the browser asks:</p>
<ul>
<li><p>Where does each element go?</p>
</li>
<li><p>How wide?</p>
</li>
<li><p>How tall?</p>
</li>
<li><p>Relative to what?</p>
</li>
</ul>
<p>This step is called layout or reflow.</p>
<p>It’s like arranging furniture in a room before painting it.</p>
<p>Change the screen size?<br />Layout runs again.</p>
<h2>Painting and display</h2>
<p>Finally:</p>
<ol>
<li><p>The browser paints pixels</p>
<ul>
<li><p>Text</p>
</li>
<li><p>Colours</p>
</li>
<li><p>Borders</p>
</li>
<li><p>Images</p>
</li>
</ul>
</li>
<li><p>Everything is sent to the screen</p>
</li>
<li><p>You see the website</p>
</li>
</ol>
<p>This step can happen many times as:</p>
<ul>
<li><p>JavaScript runs</p>
</li>
<li><p>Styles change</p>
</li>
<li><p>You scroll or resize</p>
</li>
</ul>
<h2>The big picture</h2>
<p>Here’s the full story:</p>
<ol>
<li><p>User types a URL</p>
</li>
<li><p>Browser fetches files</p>
</li>
<li><p>HTML → DOM</p>
</li>
<li><p>CSS → CSSOM</p>
</li>
<li><p>DOM + CSSOM → Render Tree</p>
</li>
<li><p>Layout calculates positions</p>
</li>
<li><p>Painting draws pixels</p>
</li>
<li><p>Page appears</p>
</li>
</ol>
<p>That’s it.</p>
<h2>Conclusion</h2>
<p>You don’t need to remember:</p>
<ul>
<li><p>All component names</p>
</li>
<li><p>Every step in detail</p>
</li>
<li><p>Engine differences</p>
</li>
</ul>
<p>What matters is this mindset:<br />“A browser is a system that parses, understands, and renders content step-by-step.</p>
<p>Once that clicks, everything else becomes easier to learn later.</p>
<p>And congrats.<br />You now know more about browsers than most people who use them all day.</p>
<h2>Want More?</h2>
<p>Blog: <a href="https://blogs.kanishk.codes/"><strong>https://blogs.kanishk.codes/</strong></a><br />Twitter: <a href="https://x.com/kanishk_fr/%EF%BF%BCLinkedIn"><strong>https://x.com/kanishk_fr/</strong></a><br />LinkedIn: <a href="https://linkedin.com/in/kanishk-chandna/%EF%BF%BCInstagram"><strong>https://linkedin.com/in/kanishk-chandna/</strong></a><br />Instagram: <a href="https://instagram.com/kanishk__fr/"><strong>https://instagram.com/kanishk__fr/</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[How to Spot and Block Bots on Your Website]]></title><description><![CDATA[Modern websites are constantly interacting with automated programs. Some of these bots are useful, like search engine crawlers. Others are not. They scrape data, spam forms, brute-force logins, or abuse APIs.
The challenge is not just blocking bots, ...]]></description><link>https://blogs.kanishk.codes/detect-automated-traffic</link><guid isPermaLink="true">https://blogs.kanishk.codes/detect-automated-traffic</guid><category><![CDATA[Web Development]]></category><category><![CDATA[bot]]></category><category><![CDATA[attack]]></category><category><![CDATA[Developer]]></category><category><![CDATA[development]]></category><category><![CDATA[website]]></category><category><![CDATA[automation]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Mon, 02 Feb 2026 14:46:07 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1770043414107/8c05b969-6e6a-4650-8430-33bebfda6470.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Modern websites are constantly interacting with automated programs. Some of these bots are useful, like search engine crawlers. Others are not. They scrape data, spam forms, brute-force logins, or abuse APIs.</p>
<p>The challenge is not just blocking bots, but doing so without hurting real users. This article explains how to identify automated interactions, how detection works under the hood, and how to mitigate bots in a balanced, practical way.</p>
<h2 id="heading-understanding-the-problem-first">Understanding the Problem First</h2>
<p>Before talking about tools, it helps to understand a basic truth:<br /><strong>Bots behave differently from humans because they don’t have uncertainty.</strong></p>
<p>Humans hesitate, scroll randomly, make mistakes, and act inconsistently. Bots are optimised for speed, repetition, and precision. Almost all bot-detection strategies rely on observing this difference.</p>
<h2 id="heading-indicators-of-bot-activity">Indicators of bot activity</h2>
<p>Bot detection usually starts with recognising patterns that are statistically unlikely for humans.</p>
<h3 id="heading-unnatural-request-patterns">Unnatural request patterns</h3>
<p>A common red flag is request frequency. A human user might generate a few requests per second at most. Bots generate hundreds.</p>
<p>For example:</p>
<ul>
<li><p>A user browsing a product page might load the page, scroll, and click once.</p>
</li>
<li><p>A bot scraping prices might hit the same endpoint repeatedly with no delay.</p>
</li>
</ul>
<p>Consistency is also suspicious. Humans are irregular. Bots often operate on fixed intervals like every 200 ms.</p>
<h3 id="heading-strange-session-behaviour">Strange session behaviour</h3>
<p>Looking at the entire session instead of individual requests reveals more clues:</p>
<ul>
<li><p>Sessions that last only a fraction of a second but perform meaningful actions.</p>
</li>
<li><p>Sessions that never navigate between pages</p>
</li>
<li><p>Sessions that repeatedly trigger the same endpoint (login, search, API calls)</p>
</li>
</ul>
<p>A real user explores, whereas a bot targets.</p>
<h3 id="heading-input-behaviour-that-feels-too-perfect">Input behaviour that feels “too perfect”</h3>
<p>Forms are a goldmine for detection:</p>
<ul>
<li><p>Humans take time to type</p>
</li>
<li><p>Humans make mistakes and use backspace</p>
</li>
<li><p>Humans don’t fill hidden fields</p>
</li>
</ul>
<p>Bots often submit forms instantly, perfectly, and sometimes fill fields that are invisible to users. That difference alone can identify a large percentage of automated traffic.</p>
<h2 id="heading-how-detection-actually-works">How detection actually works</h2>
<p>From simple rules to behavioural intelligence</p>
<h3 id="heading-rule-based-detection">Rule-based detection</h3>
<p>This is the simplest layer and often the first one implemented.</p>
<p>Examples:</p>
<ul>
<li><p>Block more than 100 requests per minute from a single IP</p>
</li>
<li><p>Throttle repeated failed login attempts</p>
</li>
<li><p>Reject requests with malformed headers</p>
</li>
</ul>
<p>This works well against basic bots but fails against more advanced automation using proxies or headless browsers.</p>
<h3 id="heading-behavioral-analysis">Behavioral analysis</h3>
<p>This is where detection becomes more reliable.<br />Instead of asking “Who is this user?”, the system asks:</p>
<ul>
<li><p>How long did they take before clicking?</p>
</li>
<li><p>Did they scroll naturally?</p>
</li>
<li><p>Do they move the mouse like humans?</p>
</li>
<li><p>Is there variation in timing?</p>
</li>
</ul>
<p>These signals are difficult to fake at scale. Even advanced bots struggle to replicate human randomness consistently.</p>
<h3 id="heading-fingerprinting">Fingerprinting</h3>
<p>Fingerprinting combines multiple browser and device attributes to create a probabilistic identity:</p>
<ul>
<li><p>User agent</p>
</li>
<li><p>Screen size</p>
</li>
<li><p>Time zone</p>
</li>
<li><p>Rendering quirks (canvas, WebGL)</p>
</li>
</ul>
<p>One attribute alone proves nothing. But when hundreds of sessions share an identical fingerprint, automation becomes the most reasonable explanation.</p>
<h3 id="heading-third-party-bot-detection-platforms">Third-party bot detection platforms</h3>
<p>Services like Cloudflare or Google reCAPTCHA use machine learning models trained on massive datasets.</p>
<p>Instead of a binary decision, they assign a risk score indicating how likely a session is to be automated. This allows websites to react proportionally instead of blocking blindly.</p>
<h2 id="heading-prevention-and-mitigation">Prevention and mitigation</h2>
<p>Stopping bots without punishing real users</p>
<p>The goal is not to eliminate all bots. That’s unrealistic. The goal is to reduce harmful automation while preserving user experience.</p>
<h3 id="heading-layered-defenses">Layered defenses</h3>
<p>Effective protection is layered, not aggressive.</p>
<ol>
<li><p>Monitor first<br /> Log suspicious behaviour before blocking. False positives are expensive.</p>
</li>
<li><p>Slow down suspicious traffic<br /> Rate limiting or artificial delays frustrate bots without affecting humans much.</p>
</li>
<li><p>Challenge only when needed</p>
<p> CAPTCHAs should appear only when behaviour crosses a risk threshold.</p>
</li>
<li><p>Block repeat offenders<br /> IPs, ranges, or ASNs that repeatedly abuse the system can be denied entirely</p>
</li>
</ol>
<h3 id="heading-smart-use-of-captcha">Smart use of CAPTCHA</h3>
<p>CAPTCHAs are useful, but overuse destroys user trust.</p>
<p>A good approach:</p>
<ul>
<li><p>No CAPTCHA for normal browsing</p>
</li>
<li><p>CAPTCHA after multiple failed logins</p>
</li>
<li><p>CAPTCHA on high-risk actions like password resets or bulk submissions</p>
</li>
</ul>
<p>Modern invisible CAPTCHA systems score behaviour silently and only intervene when confidence is low.</p>
<h3 id="heading-protecting-apis-and-sensitive-endpoints">Protecting APIs and sensitive endpoints</h3>
<p>Bots love unprotected APIs.<br />Mitigation includes:</p>
<ul>
<li><p>Authentication tokens</p>
</li>
<li><p>Strict request validation</p>
</li>
<li><p>Short-lived credentials</p>
</li>
<li><p>Rate limits per user, not just per IP</p>
</li>
</ul>
<p>If a endpoint doesn’t need to be public, it shouldn’t be.</p>
<h3 id="heading-risk-based-decision-making">Risk-based decision making</h3>
<p>Advanced systems assign each session a score instead of a verdict.</p>
<p>For example:</p>
<ul>
<li><p>Low risk: allow normally</p>
</li>
<li><p>Medium risk: monitor or throttle</p>
</li>
<li><p>High risk: challenge or block</p>
</li>
</ul>
<p>This keeps defenses flexible and minimises harm to legitimate users.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Bot detection is not about catching robots. It’s about understanding behaviour.</p>
<p>Humans are inconsistent, slow, and imperfect. Bots are fast, repetitive, and precise. By observing these differences across requests, sessions and interactions, websites can reliably detect automation without relying on guesswork.</p>
<p>The best systems:</p>
<ul>
<li><p>Combine multiple weak signals instead of trusting one</p>
</li>
<li><p>Respond proportianally instead of aggressively</p>
</li>
<li><p>Prioritise user experience as much as security</p>
</li>
</ul>
<p>In practice, effective bot mitigation feels invisible to real users and exhausting to bots.</p>
<h2 id="heading-want-more">Want more?</h2>
<p>Blog: <a target="_blank" href="https://blogs.kanishk.codes/"><strong>https://blogs.kanishk.codes/</strong></a><br />Twitter: <a target="_blank" href="https://x.com/kanishk_fr/%EF%BF%BCLinkedIn"><strong>https://x.com/kanishk_fr/</strong></a><br />LinkedIn: <a target="_blank" href="https://linkedin.com/in/kanishk-chandna/%EF%BF%BCInstagram"><strong>https://linkedin.com/in/kanishk-chandna/</strong></a><br />Instagram: <a target="_blank" href="https://instagram.com/kanishk__fr/"><strong>https://instagram.com/kanishk__fr/</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[Understanding TCP and UDP: Best Usage Scenarios and HTTP's Link to TCP]]></title><description><![CDATA[The internet needs rules
The internet is just a massive pile of wires, routers, and vibes.When data moves across it, things can go wrong constantly.
Packets can:

Get lost

Arrive late

Arrive twice

Arrive in the wrong order


So the internet uses p...]]></description><link>https://blogs.kanishk.codes/tcp-vs-udp</link><guid isPermaLink="true">https://blogs.kanishk.codes/tcp-vs-udp</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[@hiteshchoudharylco]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[networking]]></category><category><![CDATA[http]]></category><category><![CDATA[TCP]]></category><category><![CDATA[development]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Sun, 25 Jan 2026 07:58:44 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769327726024/8171e8f6-a024-46a4-8f11-fe7378ec01e9.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-the-internet-needs-rules">The internet needs rules</h3>
<p>The internet is just a massive pile of wires, routers, and vibes.<br />When data moves across it, things can go wrong constantly.</p>
<p>Packets can:</p>
<ul>
<li><p>Get lost</p>
</li>
<li><p>Arrive late</p>
</li>
<li><p>Arrive twice</p>
</li>
<li><p>Arrive in the wrong order</p>
</li>
</ul>
<p>So the internet uses protocols, which are basically agreements on how data should be sent.<br />Two of the most important ones are TCP and UDP.</p>
<p>They solve the same problem differently. Very differently.</p>
<h2 id="heading-what-are-tcp-and-udp">What are TCP and UDP</h2>
<p>Think of them as two delivery styles.</p>
<h3 id="heading-tcp">TCP</h3>
<p>TCP is careful, slow, and responsible.<br />It checks everything. It waits for confirmation. It resends data if something goes wrong.</p>
<p>It’s like a courier service that makes you sign for the package.</p>
<h3 id="heading-udp">UDP</h3>
<p>UDP is fast, reckless, and emotionally unavailable.<br />It sends data and moves on. No confirmation. No retries.</p>
<p>It’s like shouting information through a megaphone and hoping someone hears it.</p>
<h2 id="heading-key-differences-between-tcp-and-udp">Key differences between TCP and UDP</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>TCP</strong></td><td><strong>UDP</strong></td></tr>
</thead>
<tbody>
<tr>
<td>Reliable</td><td>Unreliable</td></tr>
<tr>
<td>Ordered</td><td>Not ordered</td></tr>
<tr>
<td>Slower</td><td>Faster</td></tr>
<tr>
<td>Connection-based</td><td>Connectionless</td></tr>
<tr>
<td>Error checking + retransmission</td><td>No guarantees</td></tr>
</tbody>
</table>
</div><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769327760640/c29905d9-2ad9-4afc-9d69-d4cf53c1f06b.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-when-to-use-tcp">When to use TCP</h2>
<p>Use TCP when data accuracy matters more than speed.</p>
<p>Examples:</p>
<ul>
<li><p>Website</p>
</li>
<li><p>APIs</p>
</li>
<li><p>Login system</p>
</li>
<li><p>Emails</p>
</li>
<li><p>File uploads and downloads</p>
</li>
<li><p>Payments</p>
</li>
</ul>
<p>If missing or scrambled data would break things or cause panic, TCP is the correct choice.</p>
<p>Basically, anything involving:</p>
<ul>
<li><p>Money</p>
</li>
<li><p>Accounts</p>
</li>
<li><p>Persistence</p>
</li>
<li><p>Trust</p>
</li>
</ul>
<h2 id="heading-when-to-use-udp">When to use UDP</h2>
<p>Use UDP when speed matters more than perfection.</p>
<p>Examples:</p>
<ul>
<li><p>Live video streaming</p>
</li>
<li><p>Online gaming</p>
</li>
<li><p>Voice calls</p>
</li>
<li><p>Live sports broadcasts</p>
</li>
<li><p>DNS queries</p>
</li>
</ul>
<p>If a packet gets lost, it’s usually better to skip it and move forward than wait.<br />No one wants their Zoom call to freeze just to recover a missed syllable.</p>
<h2 id="heading-real-world-analogy">Real-world analogy</h2>
<ul>
<li><p>TCP = Phone call<br />  Both sides connect, talk in order, confirm messages, and hang up properly.</p>
</li>
<li><p>UDP = Live announcement<br />  Information is broadcast instantly. If you miss it, tough luck.</p>
</li>
</ul>
<p>Neither is “better”. They’re built for different jobs.</p>
<h2 id="heading-what-is-http-and-where-does-it-fits">What is HTTP, and where does it fits</h2>
<p>Now let’s talk about the protocol that causes the most confusion.<br /><strong>HTTP (Hypertext Transfer Protocol)</strong> is an application-level protocol.<br />Important sentence. Read it again.</p>
<p>HTTP defines:</p>
<ul>
<li><p>How requests are structured</p>
</li>
<li><p>How responses look</p>
</li>
<li><p>Methods like GET, POST, PUT, DELETE</p>
</li>
<li><p>Status codes like 200, 404, 500</p>
</li>
</ul>
<p>HTTP does not care how data physically travels.<br />That’s not its job.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769327788970/c933e6b5-6c26-4d16-ab0d-65e0152cffac.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-relationship-between-tcp-and-http">Relationship between TCP and HTTP</h2>
<p>Here’s the clean mental model:</p>
<ul>
<li><p>HTTP decides what to send</p>
</li>
<li><p>TCP decides how to send it reliably</p>
</li>
<li><p>IP decides where to send it</p>
</li>
</ul>
<p>HTTP runs on top of TCP</p>
<p>TCP handles:</p>
<ul>
<li><p>Connection setup</p>
</li>
<li><p>Packet ordering</p>
</li>
<li><p>Retransmissions</p>
</li>
<li><p>Data integrity</p>
</li>
</ul>
<p>HTTP just assumes: “Cool, transport layer has my back.”</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769327817115/a86684dd-f54d-48e9-8c93-d2a12f149d78.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-why-http-does-not-replace-tcp">Why HTTP does not replace TCP</h2>
<p>Because HTTP is not built to:</p>
<ul>
<li><p>Detect packet loss</p>
</li>
<li><p>Handle retransmission</p>
</li>
<li><p>Maintain low-level connections</p>
</li>
<li><p>Guarantee order</p>
</li>
</ul>
<p>If HTTP tried to do all that, it would basically reinvent TCP and do a worse job.<br />Layering exists so protocols don’t step on each other’s responsibilities.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769327832736/c5c2b653-5cde-40ca-b15a-6e08d65472d7.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-conclusion">Conclusion</h2>
<ul>
<li><p>TCP and UDP are transport protocols</p>
</li>
<li><p>TCP = reliable and ordered</p>
</li>
<li><p>UDP = fast and lightweight</p>
</li>
<li><p>HTTP is an application protocol</p>
</li>
<li><p>HTTP relies on TCP to work properly</p>
</li>
<li><p>They solve different problems at different layers</p>
</li>
</ul>
<p>Once this clicks, networking stops feeling like black magic and starts feeling like organised bureaucracy.</p>
<h2 id="heading-want-more">Want more?</h2>
<p>Blog: <a target="_blank" href="https://blogs.kanishk.codes/"><strong>https://blogs.kanishk.codes/</strong></a><br />Twitter: <a target="_blank" href="https://x.com/kanishk_fr/%EF%BF%BCLinkedIn"><strong>https://x.com/kanishk_fr/</strong></a><br />LinkedIn: <a target="_blank" href="https://linkedin.com/in/kanishk-chandna/%EF%BF%BCInstagram"><strong>https://linkedin.com/in/kanishk-chandna/</strong></a><br />Instagram: <a target="_blank" href="https://instagram.com/kanishk__fr/"><strong>https://instagram.com/kanishk__fr/</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[TCP Working: 3-Way Handshake & Reliable Communication]]></title><description><![CDATA[What happens if we send data without rules?
Imagine shouting instructions across a crowded street.
Some words get lost.Some arrive twice.Some arrive out of order.Some arrive when the other person wasn’t even listening yet.
That’s what raw data transf...]]></description><link>https://blogs.kanishk.codes/working-of-tcp</link><guid isPermaLink="true">https://blogs.kanishk.codes/working-of-tcp</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[@hiteshchoudharylco]]></category><category><![CDATA[TCP]]></category><category><![CDATA[networking]]></category><category><![CDATA[internet]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Sat, 24 Jan 2026 09:51:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769247958961/cfb26bf7-901f-4e46-bfe5-a3f7a38b5028.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-happens-if-we-send-data-without-rules">What happens if we send data without rules?</h2>
<p>Imagine shouting instructions across a crowded street.</p>
<p>Some words get lost.<br />Some arrive twice.<br />Some arrive out of order.<br />Some arrive when the other person wasn’t even listening yet.</p>
<p>That’s what raw data transfer looks like without rules. Computers are fast, and they need structure.</p>
<p>This is where TCP walks in like the boring but responsible adult.</p>
<h2 id="heading-what-is-tcp-and-why-is-it-needed">What is TCP, and why is it needed?</h2>
<p>TCP (Transmission Control Protocol) is a communication rulebook used on the Internet to send data reliably.</p>
<p>When you open a website, send a message, upload a file, or log in anywhere, TCP is usually working behind the scenes, making sure:</p>
<ul>
<li><p>Data reaches the right place</p>
</li>
<li><p>Nothing important is lost</p>
</li>
<li><p>Everything arrives in the correct order</p>
</li>
<li><p>Both sides agree on what’s happening</p>
</li>
</ul>
<p>Without TCP, the internet would feel like a glitchy group chat with a bad network.</p>
<h2 id="heading-problems-tcp-is-designed-to-solve">Problems TCP is designed to solve</h2>
<p>TCP exists because the Internet itself is unreliable.</p>
<p>It solves the problems like:</p>
<ul>
<li><p>Packet loss - data can disappear mid-way</p>
</li>
<li><p>Out-of-order delivery - packets don’t always arrive in sequence</p>
</li>
<li><p>Duplicate packets - sometimes data gets sent twice</p>
</li>
<li><p>Unknown connection state - sender doesn’t know if receiver is ready</p>
</li>
</ul>
<p>TCP doesn’t panic. It plans for all of this.</p>
<h2 id="heading-what-is-the-tcp-3-way-handshake">What is the TCP 3-Way Handshake?</h2>
<p>Before any real data is sent, TCP makes sure both sides are ready.<br />This setup process is called the 3-Way Handshake.</p>
<p>Think of it like starting a phone call:</p>
<ol>
<li><p>“Can you hear me?”</p>
</li>
<li><p>“Yes, I can hear you. Can you hear me?”</p>
</li>
<li><p>“Yes, we’re connected.”</p>
</li>
</ol>
<p>Only after this does the actual conversation start.</p>
<h2 id="heading-step-by-step-syn-syn-ack-ack">Step-by-step: SYN, SYN-ACK, ACK</h2>
<h3 id="heading-syn-synchronise">SYN (Synchronise)</h3>
<p>The client says:<br />“Hey server, I want to talk. Are you available?”</p>
<p>This message contains a sequence number, which is basically:<br />“This is where I’m starting from.”</p>
<h3 id="heading-syn-ack-synchronise-acknoledge">SYN-ACK (Synchronise + Acknoledge)</h3>
<p>The server replies:<br />“I hear you. I’m ready. And I got your starting number.”</p>
<p>The server also sends its own sequence number.<br />Now both sides know:</p>
<ul>
<li><p>The order exists</p>
</li>
<li><p>The other is listening</p>
</li>
<li><p>Where counting should start</p>
</li>
</ul>
<h3 id="heading-ack-acknowledge">ACK (Acknowledge)</h3>
<p>The client responds:<br />“Cool, I got your message too.”</p>
<p>Handshake complete. Connection established. Data can flow.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769248042827/f9c888fa-955c-4c16-a729-58d903f914ed.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-how-data-transfer-looks-in-tcp">How data transfer looks in TCP</h2>
<p>Once the connection is open, TCP starts sending data in chunks called segments.</p>
<p>Each segment includes:</p>
<ul>
<li><p>Sequence number - where this piece fits</p>
</li>
<li><p>Acknowledgement number - what has been received so far.</p>
</li>
</ul>
<p>The receiver keeps saying:<br />“I got data up to number X.”</p>
<p>This constant feedback loop keeps everything synchronised.</p>
<h2 id="heading-how-tcp-ensures-reliability-order-and-correctness">How TCP ensures reliability, order, and correctness</h2>
<ol>
<li><h3 id="heading-reliability">Reliability</h3>
<p> If a packet goes missing, TCP notices.<br /> No acknowledgement? TCP resends it.</p>
<p> Simple and effective.</p>
</li>
<li><h3 id="heading-order">Order</h3>
<p> Packets can arrive in any order.<br /> TCP rearranges them using sequence numbers before handing data to the application.</p>
<p> So your video doesn’t play sentence 5 before sentence 2.</p>
</li>
<li><h3 id="heading-correctness">Correctness</h3>
<p> TCP checks for corrupted data.<br /> If something looks wrong, it gets reset.</p>
<p> Your files arrive intact, not haunted.</p>
</li>
</ol>
<h2 id="heading-how-tcp-handles-packet-loss">How TCP handles packet loss</h2>
<p>TCP assumes failure is normal.<br />If a packet isn’t acknowledged within a certain time:</p>
<ul>
<li><p>It is retransmitted</p>
</li>
<li><p>Sending speed may be reduced</p>
</li>
<li><p>Network congestion is assumed, not ignored</p>
</li>
</ul>
<p>TCP doesn’t rage. It adapts.</p>
<h2 id="heading-how-tcp-connection-is-closed">How TCP connection is closed</h2>
<p>Ending a TCP connection is also polite. No ghosting.</p>
<h3 id="heading-fin-and-ack">FIN and ACK</h3>
<ol>
<li><p>One side sends FIN<br /> “I’m done sending data.”</p>
</li>
<li><p>Other side sends ACK<br /> “Got it.”</p>
</li>
<li><p>Other side sends its own FIN<br /> “I’m done too.”</p>
</li>
<li><p>Final ACK<br /> “Connection closed.”</p>
</li>
</ol>
<p>Everyone agrees. No loose ends.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769248134159/824d7858-f215-4e62-94bc-26a2245f4a11.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>TCP is not flashy. It doesn’t try to be cool.<br />It:</p>
<ul>
<li><p>Establishes trust before talking</p>
</li>
<li><p>Keeps track of every message</p>
</li>
<li><p>Fixes mistakes silently</p>
</li>
<li><p>Ends conversations cleanly</p>
</li>
</ul>
<p>That’s why the internet mostly works, even when everything else feels broken.</p>
<p>And yes, all of this happens every time you open a website.<br />In milliseconds. Without asking for applause.</p>
<h2 id="heading-want-more">Want more?</h2>
<p>Blog: <a target="_blank" href="https://blogs.kanishk.codes/"><strong>https://blogs.kanishk.codes/</strong></a><br />Twitter: <a target="_blank" href="https://x.com/kanishk_fr/%EF%BF%BCLinkedIn"><strong>https://x.com/kanishk_fr/</strong></a><br />LinkedIn: <a target="_blank" href="https://linkedin.com/in/kanishk-chandna/%EF%BF%BCInstagram"><strong>https://linkedin.com/in/kanishk-chandna/</strong></a><br />Instagram: <a target="_blank" href="https://instagram.com/kanishk__fr/"><strong>https://instagram.com/kanishk__fr/</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[Network Devices 101: Key Components and Their Functions]]></title><description><![CDATA[Before your API request hits a server, it passes through a small army of network devices that quietly do their jobs and never get credit. If any one of them messes up, your app is “down” and everyone suddenly becomes a network expert.
How the Interne...]]></description><link>https://blogs.kanishk.codes/understand-network-devices</link><guid isPermaLink="true">https://blogs.kanishk.codes/understand-network-devices</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[@hiteshchoudharylco]]></category><category><![CDATA[networking]]></category><category><![CDATA[backend]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Thu, 22 Jan 2026 09:09:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769072457996/0d3e1027-cff2-45b3-90d2-03e53f729eca.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Before your API request hits a server, it passes through a small army of network devices that quietly do their jobs and never get credit. If any one of them messes up, your app is “down” and everyone suddenly becomes a network expert.</p>
<h2 id="heading-how-the-internet-reaches-your-home-or-office">How the Internet Reaches Your Home or Office</h2>
<p>When you open a website, the data does not teleport from a server to your laptop.</p>
<p>It flows through:</p>
<ul>
<li><p>Your local network</p>
</li>
<li><p>Your internet service provider</p>
</li>
<li><p>Multiple networks across the internet</p>
</li>
<li><p>And finally reaches a server somewhere else</p>
</li>
</ul>
<p>Between you and the internet sit several network devices, each with a very specific role.</p>
<p>Understanding these roles makes system design, debugging, and production deployments far less mysterious.</p>
<h2 id="heading-what-is-a-modem">What Is a Modem?</h2>
<p><strong>Responsibility:</strong> Connect your local network to your Internet Service Provider (ISP).</p>
<p>A model is a device that communicates directly with your ISP using cable, fiber, or DSL. Your home network cannot speak the ISP’s language on its own. The modem translates between the two.</p>
<p>Think of the modem as:<br />The translator between your house and the outside world.</p>
<p>Important clarification:</p>
<ul>
<li><p>A modem does not manage devices</p>
</li>
<li><p>A modem does not route traffic</p>
</li>
<li><p>A modem only establishes the internet connection</p>
</li>
</ul>
<p>If the modem is down, you have zero internet. No amount of restarting your router will save you.</p>
<h2 id="heading-what-is-a-router">What Is a Router?</h2>
<p><strong>Responsibility:</strong> Direct traffic between devices and networks.</p>
<p>A router decides where packets should go.</p>
<p>Inside your home and office:</p>
<ul>
<li><p>Your laptop</p>
</li>
<li><p>Your phone</p>
</li>
<li><p>Your TV</p>
</li>
<li><p>Your smart toaster</p>
</li>
</ul>
<p>All of them share one internet connection. The router figures out:</p>
<ul>
<li><p>Which device made which request</p>
</li>
<li><p>Where the response should go</p>
</li>
<li><p>How traffic moves between local devices and the internet</p>
</li>
</ul>
<p>Modem vs Router</p>
<ul>
<li><p>A modem connects you to the internet</p>
</li>
<li><p>The router manages traffic within and out of your network</p>
</li>
</ul>
<h2 id="heading-hub-vs-switch-working-of-local-networks">Hub vs Switch: Working of Local Networks</h2>
<h3 id="heading-hub-old-and-mostly-useless">Hub (Old and Mostly Useless)</h3>
<p>Responsibility: Broadcast everything to everyone.</p>
<p>A hub sends incoming data to all connected devices, whether they asked for it or not.<br />You can think of a hub as someone shouting messages in a crowded room.</p>
<p>Problems:</p>
<ul>
<li><p>Massive inefficiency</p>
</li>
<li><p>Security nightmare</p>
</li>
<li><p>Practically extinct for good reasons</p>
</li>
</ul>
<h3 id="heading-switch-what-we-actually-use">Switch (What We Actually Use)</h3>
<p><strong>Responsibility:</strong> Send data only to the intended device.</p>
<p>A switch learns which device is connected to which port and forwards data intelligently.</p>
<p>Why switches matter:</p>
<ul>
<li><p>Faster local communication</p>
</li>
<li><p>Better security</p>
</li>
<li><p>Foundation of modern LANs</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769072601746/90d811fa-661d-4947-8c57-dbd70b7954aa.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-what-is-a-firewall">What Is a Firewall?</h2>
<p>Responsibility: Decide what traffic is allowed and what is blocked.</p>
<p>A firewall sits between networks and enforces security rules:</p>
<ul>
<li><p>Which ports are open</p>
</li>
<li><p>Which IPs are allowed</p>
</li>
<li><p>Which traffic is suspicious</p>
</li>
</ul>
<p>Firewalls exist at multiple levels:</p>
<ul>
<li><p>Hardware firewalls</p>
</li>
<li><p>Software firewalls</p>
</li>
<li><p>Cloud firewalls</p>
</li>
</ul>
<p>For backend engineers, this matters because:</p>
<ul>
<li><p>A service can be “running” but unreachable</p>
</li>
<li><p>Ports can be blocked silently</p>
</li>
<li><p>Misconfigured firewalls cause legendary debugging sessions</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769072774044/9702b8a1-b1db-433a-93ca-ddf8ccf12932.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-what-is-a-load-balancer">What Is a Load Balancer?</h2>
<p>Responsibility: Distribute traffic across multiple servers.</p>
<p>When one server is now enough, you add more. But users still need one entry point.<br />That’s the job of a load balancer.</p>
<p>Load balancers:</p>
<ul>
<li><p>Improve performance</p>
</li>
<li><p>Increase reliability</p>
</li>
<li><p>Enable horizontal scaling</p>
</li>
</ul>
<p>From a backend perspective:</p>
<ul>
<li><p>Your API instances are stateless</p>
</li>
<li><p>The load balancer decides where each request goes</p>
</li>
<li><p>If one instance dies, traffic shifts automatically</p>
</li>
</ul>
<p>This is how real production systems survive traffic without breaking.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769072804714/68223c1e-4349-4d2b-a978-c91b7112e02f.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-how-all-these-devices-work-together">How All These Devices Work Together</h2>
<p>A simplified real-world flow looks like this:</p>
<ol>
<li><p>Your device sends a request</p>
</li>
<li><p>Switch forwards it locally</p>
</li>
<li><p>The router decides it’s going outside</p>
</li>
<li><p>Firewall checks if it’s allowed</p>
</li>
<li><p>The modem sends it to the ISP</p>
</li>
<li><p>Internet happens</p>
</li>
<li><p>On the server side, a load balancer receives it</p>
</li>
<li><p>The load balancer forwards it to a backend service</p>
</li>
</ol>
<p>Each device does one job, and does it well. This separation of responsibility is not accidental. It’s how networks scale and stay debuggable.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769072880006/8e9fbd0e-c944-4ad2-acc6-1ff3f767c0e8.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-why-software-engineers-should-care">Why Software Engineers Should Care</h2>
<p>Even if you never touch hardware:</p>
<ul>
<li><p>APIs depend on routers, firewalls, and load balancers</p>
</li>
<li><p>“Works on localhost” dies in production because of networking</p>
</li>
<li><p>Cloud infrastructure is just these devices abstracted</p>
</li>
</ul>
<p>Understanding network devices helps you:</p>
<ul>
<li><p>Debug outages faster</p>
</li>
<li><p>Design scalable systems</p>
</li>
<li><p>Communicate better with the infra and DevOps teams</p>
</li>
<li><p>Stop blaming “the internet” for everything</p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Network devices are not magical boxes. They are specialised tools solving very specific problems.</p>
<p>Once you understand who does what, networking stops being scary and starts being predictable.</p>
<p>And predictable systems are the only ones worth building.</p>
<h2 id="heading-want-more">Want more?</h2>
<p>Blog: <a target="_blank" href="https://blogs.kanishk.codes/"><strong>https://blogs.kanishk.codes/</strong></a><br />Twitter: <a target="_blank" href="https://x.com/kanishk_fr/%EF%BF%BCLinkedIn"><strong>https://x.com/kanishk_fr/</strong></a><br />LinkedIn: <a target="_blank" href="https://linkedin.com/in/kanishk-chandna/%EF%BF%BCInstagram"><strong>https://linkedin.com/in/kanishk-chandna/</strong></a><br />Instagram: <a target="_blank" href="https://instagram.com/kanishk__fr/"><strong>https://instagram.com/kanishk__fr/</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[Introduction to Using cURL for Beginners]]></title><description><![CDATA[Before directly jumping into what cURL is, it’s usecase or working, we must understand the need for it, which will make it easy for you to understand.
What is a Server?
In very simple terms, a server is a machine that stays online 24×7 and runs a pro...]]></description><link>https://blogs.kanishk.codes/curl-for-beginners</link><guid isPermaLink="true">https://blogs.kanishk.codes/curl-for-beginners</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[@hiteshchoudharylco]]></category><category><![CDATA[terminal]]></category><category><![CDATA[curl]]></category><category><![CDATA[server]]></category><category><![CDATA[command line]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Wed, 21 Jan 2026 16:43:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769013441261/7c81bcce-7c9b-49ce-84e7-ecf3dffee59a.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Before directly jumping into what cURL is, it’s usecase or working, we must understand the need for it, which will make it easy for you to understand.</p>
<h2 id="heading-what-is-a-server">What is a Server?</h2>
<p>In very simple terms, a server is a machine that stays online 24×7 and runs a program or a website that provides data, resources, and services to other computers (also known as clients) over the network using the client-server model, where the client requests and the server responds.</p>
<p>When you open a website, your browser is the client. The machine hosting that website is the server. The browser sends a request like “give me this page”, and the server replies with the data needed to show it.</p>
<p>That’s the entire internet in one sentence.</p>
<h2 id="heading-how-do-clients-and-servers-talk">How Do Clients and Servers Talk?</h2>
<p>Clients and servers don’t magically understand each other. They communicate by sending structured messages over the network.</p>
<p>Your browser does this quietly in the background. You type a URL, hit enter, and things just work.</p>
<p>But as a programmer, we often want to:</p>
<ul>
<li><p>Test a server</p>
</li>
<li><p>Talk to an API</p>
</li>
<li><p>See what a server actually returns</p>
</li>
<li><p>Debug things when they break</p>
</li>
</ul>
<p>For that, we need a way to send messages without a browser.<br />That’s where a cURL comes in.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769013509438/49bd0d69-ebe8-43ca-8d8e-ee02b0744823.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-what-is-curl">What is cURL?</h2>
<p>cURL (Client URL) is a command-line tool that lets you send requests to a server directly from the terminal and see the response.</p>
<p>You give cURL a URL, and it:</p>
<ul>
<li><p>Sends a request to the server</p>
</li>
<li><p>Receives the response</p>
</li>
<li><p>Shows it to you</p>
</li>
</ul>
<p>Under the hood, it supports many protocols and advanced features, but you do not need to care about any of that right now.</p>
<h2 id="heading-why-programmers-need-curl">Why Programmers Need cURL</h2>
<p>cURL is useful because it removes the UI layer and shows you exactly what’s happening between a client and a server.</p>
<p>Programmers use cURL to:</p>
<ul>
<li><p>Test APIs before writing frontend code</p>
</li>
<li><p>Check if a server is responding correctly</p>
</li>
<li><p>Debug backend issues</p>
</li>
<li><p>Automate simple network requests</p>
</li>
<li><p>Learn how HTTP actually works</p>
</li>
</ul>
<p>If you work with backend systems, APIs, or DevOps even a little, cURL becomes unavoidable.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769013564037/cf19ec07-f914-41db-8a8f-ed3221d18a79.jpeg" alt class="image--center mx-auto" /></p>
<h3 id="heading-your-first-curl-command">Your first cURL Command</h3>
<p>Let’s start with the simplest possible example.</p>
<pre><code class="lang-plaintext">curl https://example.com/
</code></pre>
<p>This command:</p>
<ul>
<li><p>Sends a request to <code>example.com</code></p>
</li>
<li><p>Fetches the response</p>
</li>
<li><p>Prints it in the terminal</p>
</li>
</ul>
<p>If the URL returns HTML, you’ll see HTML.<br />If it returns JSON, you’ll see JSON.<br />If it returns plain text, you’ll see plain text.</p>
<p>It just shows you what the server sends back.</p>
<h3 id="heading-using-curl-to-talk-to-apis">Using cURL to Talk to APIs</h3>
<p>APIs are just servers that expect structured requests and return structured responses, usually in JSON.</p>
<pre><code class="lang-plaintext">curl https://api.github.com
</code></pre>
<p>This sends a simple request and returns JSON data describing the API.</p>
<p>You didn’t open a browser.<br />You didn’t write any JavaScript.<br />You talked directly to the API.</p>
<p>This is why cURL is often the first tool used when working with APIs.</p>
<h3 id="heading-get-and-post-requests">GET and POST Requests</h3>
<p>For now, we’ll just focus on two request types:</p>
<ul>
<li><p>GET: asking the server for data</p>
</li>
<li><p>POST: sending data to the server</p>
</li>
</ul>
<p>A basic GET request is what you’ve already been doing.<br />POST requests come later, once you’re comfortable reading responses.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769013702229/6d059933-abb0-495b-b2f3-c7585f857abe.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-common-mistakes-beginners-make-with-curl">Common Mistakes Beginners Make with cURL</h2>
<p>Some very normal mistakes:</p>
<ul>
<li><p>Trying to learn every flag on day one</p>
</li>
<li><p>Copy-pasting complex commands without understanding them</p>
</li>
<li><p>Panicking when the output looks “ugly”</p>
</li>
<li><p>Assuming cURL is only for backend developers</p>
</li>
</ul>
<p>cURL output is waw by design. It’s now meant to be pretty. It’s meant to be honest.<br />If you understand what you sent and what you got back, you’re already doing it right.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>cURL is not a fancy tool. It’s a fundamental one.</p>
<p>Once you’re comfortable using cURL:</p>
<ul>
<li><p>APIs feel less intimidating</p>
</li>
<li><p>Backend systems make more sense</p>
</li>
<li><p>Debugging becomes easier</p>
</li>
<li><p>You stop guessing and start verifying</p>
</li>
</ul>
<p>You don’t need to master cURL to use it effectively. You just need to understand that it’s a direct line between you and a server.</p>
<h2 id="heading-want-more">Want more?</h2>
<p>Blog: <a target="_blank" href="https://blogs.kanishk.codes/"><strong>https://blogs.kanishk.codes/</strong></a><br />Twitter: <a target="_blank" href="https://x.com/kanishk_fr/%EF%BF%BCLinkedIn"><strong>https://x.com/kanishk_fr/</strong></a><br />LinkedIn: <a target="_blank" href="https://linkedin.com/in/kanishk-chandna/%EF%BF%BCInstagram"><strong>https://linkedin.com/in/kanishk-chandna/</strong></a><br />Instagram: <a target="_blank" href="https://instagram.com/kanishk__fr/"><strong>https://instagram.com/kanishk__fr/</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[A Beginner's Guide to How DNS Resolution Functions]]></title><description><![CDATA[We humans, like names. Computers like numbers. This mismatch is the entire reason DNS exists.
When you type “google.com” into a browser, your machine has absolutely no idea where that is. Networks do not route packets based on vibes or brand recognit...]]></description><link>https://blogs.kanishk.codes/how-dns-resolution-works</link><guid isPermaLink="true">https://blogs.kanishk.codes/how-dns-resolution-works</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[@hiteshchoudharylco]]></category><category><![CDATA[networking]]></category><category><![CDATA[dns]]></category><category><![CDATA[server]]></category><category><![CDATA[Chaiaurcode]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Wed, 21 Jan 2026 14:41:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769005989968/310e911d-f6bc-446c-b6a3-b43736a1e7e6.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>We humans, like names. Computers like numbers. This mismatch is the entire reason DNS exists.</p>
<p>When you type “google.com” into a browser, your machine has absolutely no idea where that is. Networks do not route packets based on vibes or brand recognition. They route packets using IP addresses. DNS exists to translate human-readable domain names into machine-readable IP addresses.</p>
<p>That translation process is called <strong>name resolution.</strong> It exists because nobody wants to memorise 142.250.195.46 just to check their email.</p>
<p>At a high level, DNS answers one question:<br />“What IP address should I talk to for this domain?”</p>
<h2 id="heading-dig-your-x-ray-for-dns">dig: Your X-Ray for DNS</h2>
<p>dig stands for Domain Information Groper, which sounds like it was named during a very different era of the internet.</p>
<p>dig is a diagnostic tool. You don’t use it to browse the web. You use it to inspect how DNS works, debug weird DNS issues, and understand who is responsible for answering what.</p>
<p>If DNS were a bureaucracy, dig would be the form that lets you see who approved what and why.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769006051350/1fd7b26b-9940-4427-93e9-4764e1c373b1.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-dns-resolution-is-layered">DNS Resolution Is Layered</h2>
<p>DNS resolution does not immediately provide the answer. It moves through layers.<br />Root → TLD → Authoritative<br />Each layer knows just enough to point you to the next one. Nobody knows everything. This is intentional and very important for scalability.</p>
<h3 id="heading-dig-ns-root-name-servers">“dig . NS” - Root Name Servers</h3>
<p>When you run “dig . NS”, you’re basically asking:<br />“Who is responsible for the root of the DNS system?”</p>
<p>The answer is a list of root name servers. These servers do not know where “google.com” lives. What they do know is who manages “.com”, “.org”, “.in”, and every other top-level domain.</p>
<p>You can think of root servers as the front desk. They don’t know where every employee sits. They just know which department to send you to.</p>
<h3 id="heading-dig-com-ns-tld-name-servers">“dig com NS” - TLD Name Servers</h3>
<p>Now you are asking the “.com” TLD servers:<br />“Who is authoritative for domains ending in .com?”</p>
<p>These servers still don’t know Google’s IP address. They only know which authoritative name servers are responsible for “google.com”.</p>
<p>Yes, DNS is a chain of directions.</p>
<h3 id="heading-dig-googlecom-ns-authoritative-name-servers">“dig google.com NS” - Authoritative Name Servers</h3>
<p>This tells you which name servers are authoritative for google.com.</p>
<p>Authoritative name servers are the final authority. They hold the actual DNS records - A, AAAA, MX, TXT, CNAME, etc.</p>
<h3 id="heading-dig-googlecom-the-full-resolution">“dig google.com” - The Full Resolution</h3>
<p>This returns an A record (IPv4) and possibly an AAAA record (IPv6). That’s the IP address your browser will connect to.</p>
<p>Behind the scenes, this is what actually happened:</p>
<ol>
<li><p>Your system asked a recursive resolver (usually your ISP).</p>
</li>
<li><p>The resolver asked a root server.</p>
</li>
<li><p>Root pointed to .com.</p>
</li>
<li><p>.com pointed to Google’s authoritative servers.</p>
</li>
<li><p>Authoritative servers returned the IP.</p>
</li>
<li><p>The resolver cached the result.</p>
</li>
<li><p>Your browser finally made the HTTP request.</p>
</li>
</ol>
<p>All of this happened in milliseconds. The internet is held together by duct tape, caching, and a lot of optimism.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769006095361/aa9b88eb-c884-43f8-bd01-10f48788d2cc.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-what-ns-records-actually-represent">What NS Records Actually Represent</h2>
<p>NS records define responsibility.<br />They answer the question: “Who is allowed to speak with authority for this domain?”</p>
<p>Without NS records:</p>
<ul>
<li><p>Delegation breaks</p>
</li>
<li><p>Caching becomes dangerous</p>
</li>
<li><p>DNS becomes a single giant failure point</p>
</li>
</ul>
<p>NS records are the reason DNS scales globally without collapsing under its own weight.</p>
<h2 id="heading-recursive-resolvers-the-middleman">Recursive Resolvers - The Middleman</h2>
<p>Your browser does not walk the DNS hierarchy every time. That would be painfully slow.</p>
<p>Recursive resolvers:</p>
<ul>
<li><p>Do the walking for you</p>
</li>
<li><p>Cache results</p>
</li>
<li><p>Respect TTLs</p>
</li>
<li><p>Save the internet from imploding</p>
</li>
</ul>
<p>Every time you “dig”, you’re basically peeking behind the curtain to see what your resolver usually does quietly.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769006135107/42b7f430-b72f-4e61-a838-0d690c18dc64.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-from-dig-output-to-a-real-browser-request">From “dig” Output to a Real Browser Request</h2>
<p>When DNS resolution finishes, the browser finally gets an IP address. Only then does HTTP even enter the conversation.</p>
<p>No DNS resolution → No TCP connection → No HTTPS → No website.</p>
<p>So yes, before your browser loads a single pixel, DNS has already done a full distributed lookup across the globe.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769006317516/47bf6773-1f06-444c-870f-5c0273d01255.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>DNS looks simple until you actually look at it. Then you realise it’s a carefully layered, globally distributed system that somehow works every day without drama.</p>
<p>Understanding DNS resolution is not about memorising record types. It’s about understanding delegation, trust, and caching at internet scale.</p>
<p>And now, when someone says “it’s a DNS issue”, you’ll know whether they actually mean it.</p>
<h2 id="heading-want-more">Want more?</h2>
<p>Blog: <a target="_blank" href="https://blogs.kanishk.codes/">https://blogs.kanishk.codes/</a><br />Twitter: <a target="_blank" href="https://x.com/kanishk_fr/%EF%BF%BCLinkedIn">https://x.com/kanishk_fr/</a><br />LinkedIn: <a target="_blank" href="https://linkedin.com/in/kanishk-chandna/%EF%BF%BCInstagram">https://linkedin.com/in/kanishk-chandna/</a><br />Instagram: <a target="_blank" href="https://instagram.com/kanishk__fr/">https://instagram.com/kanishk__fr/</a></p>
]]></content:encoded></item><item><title><![CDATA[DNS Record Types Explained]]></title><description><![CDATA[Introduction
Have you ever wondered how a browser knows where exactly a website lives? Leave the browser for a second. I’m pretty sure that if you’re reading this article, you must have thought about how and where these domains are stored and how the...]]></description><link>https://blogs.kanishk.codes/dns-explained</link><guid isPermaLink="true">https://blogs.kanishk.codes/dns-explained</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[dns]]></category><category><![CDATA[networking]]></category><category><![CDATA[@hiteshchoudharylco]]></category><category><![CDATA[Chaiaurcode]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Tue, 20 Jan 2026 09:13:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1768899725601/b86b0455-9b1b-441d-a03b-9847b2cbb4c1.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>Have you ever wondered how a browser knows where exactly a website lives? Leave the browser for a second. I’m pretty sure that if you’re reading this article, you must have thought about how and where these domains are stored and how they work behind the scenes.</p>
<p>So, in this article, I’ll take you through the entirety of the working of DNS (Domain Name System) in a very beginner-friendly way. We’ll go through What is DNS? Why is it needed? What are DNS records and their types?</p>
<h3 id="heading-need-for-domain-names">Need for Domain Names</h3>
<p>As you must be knowing that every device connected to the internet has its own unique address, known as an IP (Internet Protocol) address, which is a unique numerical label. This enables every device to communicate and locate each other for sending and receiving data over the internet.</p>
<p>As there are billions of devices on the internet, humans cannot remember long numerical labels. For our convenience, we have developed domain names, which are human-friendly, unique web addresses that identify a website or server on the internet, acting as an easy-to-remember shortcut for complex numerical IP addresses. This makes navigation simple and easy.</p>
<h2 id="heading-what-is-dns">What is DNS?</h2>
<p>You can think of DNS as the internet’s phonebook, which maintains all the domain name records, and it translates human-friendly domain names (like www.google.com) into machine-readable numeric IP addresses (like 142.250.186.42) that computers use to find and connect, allowing users to access websites by typing simple names instead of long numbers.</p>
<h3 id="heading-what-are-dns-records-and-why-are-they-needed">What are DNS records, and why are they needed?</h3>
<p>So far, DNS sounds simple, you type a domain name, and somehow you end up at the right server.</p>
<p>But DNS doesn’t work with just one kind of information. Different parts of the internet need different answers. Browsers, mail servers, verification systems, and load balancers all ask DNS different questions.</p>
<p>DNS records are how a domain answers those questions.</p>
<p>A DNS record is a structured instruction stored inside a domain’s DNS zone. Each record tells the internet what to do with a specific kind of request related to that domain.</p>
<p>One record might say, “send website traffic here.”<br />Another might say, “email for this domain goes there.”<br />Another might exist only to prove ownership or configure security.</p>
<p>You can think of DNS records as a rulebook for a domain.<br />When a request comes in, DNS checks the rulebook and responds based on the type of question being asked.</p>
<h2 id="heading-types-of-dns-records">Types of DNS records</h2>
<h3 id="heading-ns-record">NS Record</h3>
<p>An NS (Name Server) record in DNS specifies which DNS servers are authoritative for a domain, basically telling the Internet where to find all other DNS records (like A, MX, CNAME) for that domain, ensuring correct IP resolution and reliable service through primary/secondary servers.</p>
<p>If DNS were a help desk, NS records tell you which desk handles questions for this domain.</p>
<p>You must be wondering why it exists. So, DNS is distributed. There isn’t one global server that knows everything. Instead, responsibility is delegated in the following steps:</p>
<ol>
<li><p>The root servers know which name servers handle “.com”</p>
</li>
<li><p>“.com” servers know which name servers handle “example.com”</p>
</li>
<li><p>Those name servers finally know the actual records</p>
</li>
</ol>
<p>NS records are how this delegation works.</p>
<h3 id="heading-a-record">A Record</h3>
<p>An A Record maps a domain name to an IPv4 address.<br />You can also think of it as - if a domain name is a contact name, and an A record is the phone number saved in it.</p>
<p>When you type “example.com” into a browser, DNS is asked: “What IP address should I connect to for this domain?”<br />The A record is the answer to that question.</p>
<p>If DNS were a phonebook, A records would be the actual numbers people dial.</p>
<h3 id="heading-aaaa-record">AAAA Record</h3>
<p>An AAAA record maps a domain name to an IPv6 address.<br />The only difference between an A and AAAA record is that A handles IPv4 addresses and AAAA does the same for IPv6 addresses.</p>
<p>Pv4 has a limited number of addresses, and the Internet outgrew it.<br />IPv6 exists to solve that problem with a much larger address space.</p>
<h3 id="heading-cname-record">CNAME Record</h3>
<p>A CNAME record makes one domain name an alias of another domain name.<br />If an A record is a phone number, a CNAME record is a contact shortcut that says, “use whatever number this other contact has.”</p>
<p>Basically, instead of storing an IP address, a CNAME points to another hostname, and DNS keeps resolving until it reaches an A or AAAA record.</p>
<p>For example, when a browser asks for “www.example.com”, DNS might respond: “That’s a CNAME for example.com.”<br />DNS then look up “example.com” and returns its A or AAAA record.</p>
<h3 id="heading-mx-record">MX Record</h3>
<p>An MX (Mail Exchange) record tells the Internet where emails for a domain should be delivered.</p>
<p>This is what actually happens:<br />When someone sends an email to “hello@example.com”, their mail server asks DNS: “Which server handles email for example.com?”<br />DNS answers using MX records.</p>
<p>Those MX records point to mail servers, not IP addresses directly.</p>
<h3 id="heading-txt-record">TXT Record</h3>
<p>A TXT record stores text-based instructions or verification data for a domain.</p>
<p>TXT records are how a domain proves things about itself and publishes rules that the internet follows.</p>
<p>Reason why it exists: Some services do not need a destination, like a website or email server.<br />They need confirmation, configuration, or policy.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768900263405/3cd05a1e-f76f-4d36-a7d3-3f5bad88521a.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-how-all-dns-records-work-together">How All DNS Records Work Together</h2>
<p>A single domain name isn’t just a website. It’s an entry point for multiple services, and DNS decides how each request should be handled.</p>
<p>Here’s how it comes together.</p>
<p>When someone types your domain into a browser, DNS uses A or AAAA records to translate that name into an IP address. That’s how web traffic reaches your server.</p>
<p>When someone sends an email to your domain, DNS doesn’t care about those A records. Instead, it checks MX records to find out which mail servers are responsible for receiving email.</p>
<p>If you want multiple names to point to the same place, CNAME record steps in. They let one hostname act as an alias for another, so you don’t have to duplicate configuration.</p>
<p>Behind the scenes, NS records decide who is allowed to answer these questions in the first place. They delegate authority to specific DNS servers and make the entire system scalable.</p>
<p>Through all of this, TXT records quietly publish rules, proof, and security policies.<br />They help verify ownership, protect email, and allow services to trust your domain.</p>
<p>Every website you visit relies on this cooperation. You just don’t notice it, because when DNS is doing its job right, it stays invisible.</p>
<p>And that’s exactly the point.</p>
<h2 id="heading-want-more">Want more?</h2>
<p>Blog: <a target="_blank" href="https://blogs.kanishk.codes/">https://blogs.kanishk.codes/</a></p>
<h3 id="heading-connect-with-me">Connect with me</h3>
<p>Twitter: <a target="_blank" href="https://x.com/kanishk_fr/">https://x.com/kanishk_fr/</a><br />LinkedIn: <a target="_blank" href="https://linkedin.com/in/kanishk-chandna/">https://linkedin.com/in/kanishk-chandna/</a><br />Instagram: <a target="_blank" href="https://instagram.com/kanishk__fr/">https://instagram.com/kanishk__fr/</a></p>
]]></content:encoded></item><item><title><![CDATA[Behind The Scenes of Git Version Control]]></title><description><![CDATA[Git often feels like magic.
You run a few commands, things get saved, history appears, mistakes disappear, and somehow your code survives bad decisions. But Git isn’t magic. It’s just extremely well-organised.
Once you understand what Git is actually...]]></description><link>https://blogs.kanishk.codes/inside-git</link><guid isPermaLink="true">https://blogs.kanishk.codes/inside-git</guid><category><![CDATA[Git]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[@hiteshchoudharylco]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[software development]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Wed, 14 Jan 2026 13:02:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1768395380408/3b9f13af-4cea-489d-b427-c65f1249f999.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Git often feels like magic.</p>
<p>You run a few commands, things get saved, history appears, mistakes disappear, and somehow your code survives bad decisions. But Git isn’t magic. It’s just extremely well-organised.</p>
<p>Once you understand what Git is actually doing under the hood, a lot of confusion disappears. Commands stop feeling random, and Git starts behaving predictably.</p>
<p>Let’s open the box.</p>
<h2 id="heading-how-git-works-internally">How Git Works Internally</h2>
<p>At its core, Git is not a file tracker.<br />It’s a content tracker.</p>
<p>Git doesn’t think in terms of “files changing line by line.” Instead, it stores snapshots of content, identified by hashes. Every time you commit, Git saves a snapshot of how your project looked at that moment and links it to previous snapshots.</p>
<p>Think of Git as:</p>
<ul>
<li><p>A database</p>
</li>
<li><p>Filled with objects</p>
</li>
<li><p>Connected by references</p>
</li>
<li><p>Stored locally on your machine</p>
</li>
</ul>
<p>Everything Git needs lives inside one place.<br />That place is the .git folder.</p>
<h2 id="heading-understanding-the-git-folder">Understanding the .git Folder</h2>
<p>When you run “git init”, git creates a hidden folder called “.git”.</p>
<p>This folder is the entire brain of Git.</p>
<p>Your project files live outside it.<br />Your project’s memory lives inside it.</p>
<p>The “.git” folder contains:</p>
<ul>
<li><p>The complete history of your project</p>
</li>
<li><p>All commits you’ve ever made</p>
</li>
<li><p>Information about branches</p>
</li>
<li><p>References like HEAD</p>
</li>
<li><p>Git’s internal database of objects</p>
</li>
</ul>
<p>If you delete “.git”, your project becomes a normal folder again. No history. No version control.</p>
<p>That’s why Git exists as a separate system layered on top of your files, not mixed into them.</p>
<h2 id="heading-git-objects-the-building-blocks">Git Objects: The Building Blocks</h2>
<p>Git stores everything as objects. There are three core ones you actually need to understand.<br />No more. No less.</p>
<h3 id="heading-blob-the-content">Blob: The content</h3>
<p>A blob stores the content of a file.</p>
<p>Important detail:<br />Git does not store filenames in blobs. Only content.</p>
<p>If two files have identical content, Git stores them once and reuses the blob. Efficient and slightly smug about it.</p>
<h3 id="heading-tree-the-structure">Tree: The Structure</h3>
<p>A tree represents a directory.</p>
<p>It maps:</p>
<ul>
<li><p>Filenames → blobs</p>
</li>
<li><p>Folder names → other trees</p>
</li>
</ul>
<p>In simple terms:</p>
<ul>
<li><p>Blobs hold what the file contains</p>
</li>
<li><p>Trees hold where files live</p>
</li>
</ul>
<h3 id="heading-commit-the-snapshot">Commit: The Snapshot</h3>
<p>A commit ties everything together.</p>
<p>A commit contains:</p>
<ul>
<li><p>A reference to a tree (project structure)</p>
</li>
<li><p>A reference to its parent commit</p>
</li>
<li><p>Author info</p>
</li>
<li><p>Timestamps</p>
</li>
<li><p>Commit message</p>
</li>
</ul>
<p>A commit doesn’t store file changes.<br />It stores a pointer to a complete snapshot.</p>
<p>That’s why Git can move backwards and forward in history so easily.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768395449819/ecb8d3e9-5a7d-4b6f-85df-c494ebe4cdd6.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-what-actually-happens-during-git-add">What Actually Happens During “git add”</h2>
<p>This is where most beginners get confused, so let’s slow down.</p>
<p>When you modify a file:</p>
<ul>
<li><p>Git notices the change</p>
</li>
<li><p>But it doesn’t store it yet</p>
</li>
</ul>
<p>When you run “git add”:</p>
<ol>
<li><p>Git takes the file’s content</p>
</li>
<li><p>Converts it into a blob</p>
</li>
<li><p>Stores it inside the “.git” object database</p>
</li>
<li><p>Updates the staging area to point to that blob</p>
</li>
</ol>
<p>Nothing is committed yet.<br />You’re just telling Git: “This version matters.”</p>
<p>The staging area is not a waiting room.<br />It’s a preview of the next snapshot.</p>
<h2 id="heading-what-actually-happens-during-git-commit">What Actually Happens During “git commit”</h2>
<p>When you run “git commit”:</p>
<ol>
<li><p>Git takes everything in the staging area</p>
</li>
<li><p>Builds a tree representing your project structure</p>
</li>
<li><p>Creates a commit object</p>
</li>
<li><p>Links it to the previous commit</p>
</li>
<li><p>Moves HEAD to point to this new commit</p>
</li>
</ol>
<p>That’s it.<br />No different files.<br />No line-by-line patchwork.<br />Just clean snapshots connected in a chain.</p>
<h2 id="heading-how-git-tracks-changes-without-losing-its-mind">How Git Tracks Changes Without Losing Its Mind</h2>
<p>Here’s the clever part.<br />Git uses cryptographic hashes (SHA-1 or SHA-256 in newer versions).</p>
<p>Every object:</p>
<ul>
<li><p>Blob</p>
</li>
<li><p>Tree</p>
</li>
<li><p>Commit</p>
</li>
</ul>
<p>Is identified by a hash derived from its content.</p>
<p>This means:</p>
<ul>
<li><p>If the content changes, the hash changes</p>
</li>
<li><p>If the hash changes, Git knows something changed</p>
</li>
<li><p>If the hash doesn’t match, corruption is detected</p>
</li>
</ul>
<p>This gives Git:</p>
<ul>
<li><p>Data Integrity</p>
</li>
<li><p>Deduplication</p>
</li>
<li><p>Trust in history</p>
</li>
</ul>
<p>You literally cannot alter a past commit without Git knowing.<br />Which is comforting. And mildly intimidating.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768395525516/3e4d2df5-789c-4501-a24e-d27ff6b1e296.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-the-mental-model-that-makes-git-click">The Mental Model That Makes Git Click</h2>
<p>Stop thinking of Git as a command-line tool.<br />Think of it as:</p>
<ul>
<li><p>A local database</p>
</li>
<li><p>Of immutable objects</p>
</li>
<li><p>Connected by references</p>
</li>
<li><p>That you move around with commands</p>
</li>
</ul>
<p>Commands don’t do magic.<br />They just move pointers and create objects.</p>
<p>Once you see Git this way:</p>
<ul>
<li><p>“git add” makes sense</p>
</li>
<li><p>“git commit” makes sense</p>
</li>
<li><p>Branches make sense</p>
</li>
<li><p>Even rebasing starts to behave</p>
</li>
</ul>
<p>Eventually.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768395647953/24786e70-7af1-421b-aee9-a3483eeb8077.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>You don’t need to memorise Git internals to use Git well.</p>
<p>But understanding what’s happening behind the scenes turns Git from something you fear into something you trust.</p>
<p>Git isn’t trying to confuse you.<br />It’s just very honest about remembering everything.</p>
<p>And sometimes, that honestly feels personal.</p>
]]></content:encoded></item><item><title><![CDATA[Git for Beginners: The Basics without the Headache]]></title><description><![CDATA[If you’ve had folders named “final”, “final_v2”, or “final_really_final”, congratulations. You already understand why Git exists. You just didn’t have a proper tool yet.
Git is one of those things every developer is expected to know, but rarely taugh...]]></description><link>https://blogs.kanishk.codes/git-for-beginners</link><guid isPermaLink="true">https://blogs.kanishk.codes/git-for-beginners</guid><category><![CDATA[Git]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[@hiteshchoudharylco]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[Developer]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Tue, 13 Jan 2026 15:51:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1768319143654/bb2dd7ad-ae4e-4bdb-a40a-d9c931ad0e41.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you’ve had folders named “final”, “final_v2”, or “final_really_final”, congratulations. You already understand why Git exists. You just didn’t have a proper tool yet.</p>
<p>Git is one of those things every developer is expected to know, but rarely taught properly. This article focuses on understanding Git before memorising commands, so you can actually use it with confidence.</p>
<h2 id="heading-what-is-git"><strong>What is Git?</strong></h2>
<p>Git is a distributed version control system.<br />That sounds heavy, so let’s simplify it.</p>
<p>Git is a tool that:</p>
<ul>
<li><p>Tracks changes in your code over time</p>
</li>
<li><p>Lets you save checkpoints of your work</p>
</li>
<li><p>Helps multiple people work on the same project without overwriting each other</p>
</li>
</ul>
<p>Think of Git as a timeline for your code. Instead of copying entire folders, Git remembers what changed, when it changed, and who changed it.</p>
<p>The “distributed” part means every developer has a full copy of the project history on their own machine.<br />You don’t need the internet or a central server just to track changes locally.</p>
<h2 id="heading-why-is-git-used"><strong>Why is Git used?</strong></h2>
<p>Git exists to solve problems that appear the moment a project grows beyond one person or one day of work.</p>
<p>Here’s what Git helps with:</p>
<ol>
<li><p>Tracking History<br /> You can see exactly how your project evolved over time and revert to an older version if something breaks.</p>
</li>
<li><p>Safe Experimentation<br /> You can try new ideas without fear. If it fails, you can discard the changes without damaging the working code.</p>
</li>
<li><p>Collaboration<br /> Multiple developers can work on the same codebase at the same time without overwriting each other’s work.</p>
</li>
<li><p>Accountability<br /> Git shows who made which change and why. This is incredibly useful for debugging and teamwork.</p>
</li>
</ol>
<p>In short, Git replaces guessing, copy-pasting, and panic with structure and confidence.</p>
<h2 id="heading-git-basics-and-core-terminologies">Git Basics and Core Terminologies</h2>
<p>Before touching commands, it’s important to understand Git’s mental model.</p>
<h3 id="heading-repository-repo"><strong>Repository (Repo)</strong></h3>
<p>A repository is a project tracked by Git.<br />It contains your files and the complete history of changes.</p>
<p>You can think of it as a folder with memory.</p>
<h3 id="heading-commit">Commit</h3>
<p>A commit is a saved snapshot of your project at a specific point in time.</p>
<p>Each commit:</p>
<ul>
<li><p>Has a unique ID</p>
</li>
<li><p>Contains the changes made since the last commit</p>
</li>
<li><p>Usually includes a short message describing what changed</p>
</li>
</ul>
<p>Good commits are small, focused, and meaningful.</p>
<h3 id="heading-branch">Branch</h3>
<p>A Branch is an independent line of development.</p>
<p>Branches allow you to:</p>
<ul>
<li><p>Work on new features safely</p>
</li>
<li><p>Fix bugs without touching the main code.</p>
</li>
<li><p>Experiment without breaking anything</p>
</li>
</ul>
<p>The default branch is usually called “main” or “master”.</p>
<h3 id="heading-head">HEAD</h3>
<p>HEAD is simply a pointer to where you currently are in the project history.</p>
<p>If you switch branches or move to an older commit, HEAD moves with you.</p>
<p>You rarely control HEAD directly, but understanding it helps Git make sense.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768319323992/f33a5e41-cf08-4496-a0e5-581e7804cd7f.jpeg" alt class="image--center mx-auto" /></p>
<h3 id="heading-common-git-commands">Common Git Commands</h3>
<p>These are the core commands every beginner should know.</p>
<p><strong>git init</strong><br />Initialises a new Git repository in the current folder.<br />This tells Git: “Start tracking this project”.</p>
<p><strong>git status</strong><br />Shows the current state of your working directory.<br />It tells you:</p>
<ul>
<li><p>Which files are modified</p>
</li>
<li><p>Which files are staged</p>
</li>
<li><p>What Git is waiting for you to do next</p>
</li>
</ul>
<p><strong>git add</strong><br />Stages files for the next commit.<br />“git add filename” or “git add . ”<br />This does not save changes. It prepares them.</p>
<p><strong>git commit</strong><br />Creates a snapshot of the staged changes.<br />“git commit -m “Add user login feature” “</p>
<p><strong>git log</strong><br />Shows the commit history.<br />You’ll see:</p>
<ul>
<li><p>Commit IDs</p>
</li>
<li><p>Authors</p>
</li>
<li><p>Dates</p>
</li>
<li><p>Messages</p>
</li>
</ul>
<p>This is your project’s memory.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768319392964/eebc4103-55a6-49b6-961c-2792e4c4a2f2.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-a-basic-git-workflow">A Basic Git Workflow</h2>
<p>Here’s how a typical solo developer workflow looks:</p>
<ol>
<li><p>Create a project folder</p>
</li>
<li><p>Run “git init”</p>
</li>
<li><p>Write some code</p>
</li>
<li><p>Check changes with “git status”</p>
</li>
<li><p>Stage changes using “git add”</p>
</li>
<li><p>Save progress using “git commit”</p>
</li>
<li><p>Repeat as the project grows</p>
</li>
</ol>
<p>That’s it. Everything else builds on this.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768319400833/91ebba28-093b-448e-8d9b-8f1a91bed51d.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Git isn’t hard. It’s just often introduced badly.</p>
<p>You don’t need to memorise every command or understand Git internals on day one. Focus on:</p>
<ul>
<li><p>Tracking changes</p>
</li>
<li><p>Writing good commits</p>
</li>
<li><p>Practicing regularly</p>
</li>
</ul>
<p>Once the basic click, Git stops feeling scary and starts feeling like a safety net.</p>
<p>And that’s exactly what it’s meant to be.</p>
]]></content:encoded></item><item><title><![CDATA[Email Attachments: The Original Version Control]]></title><description><![CDATA[Imagine you decided to develop some crazy software before 2005. Eventually, the codebase grew to such an extent that it became difficult for you to maintain it all by yourself, so you decided to ask another developer friend who lives in another city ...]]></description><link>https://blogs.kanishk.codes/importance-of-version-control</link><guid isPermaLink="true">https://blogs.kanishk.codes/importance-of-version-control</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Git]]></category><category><![CDATA[version control]]></category><category><![CDATA[@hiteshchoudharylco]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Tue, 13 Jan 2026 14:39:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1768314443247/0bf6efa2-dea2-4b77-8721-c21aa5bb06a2.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Imagine you decided to develop some crazy software before 2005. Eventually, the codebase grew to such an extent that it became difficult for you to maintain it all by yourself, so you decided to ask another developer friend who lives in another city to collaborate with you on the same software. Now you need to share all of your code files with your friend.</p>
<p>You manage to share those files through email, and you, along with your friend, start working on the same project. After a few weeks, your friend sends you the updated code files via email, and now you have two versions of the same software. One, which you were working on and the second, of your friend’s.</p>
<p>Here, the actual problem arises: how to determine the exact changes you and your friend have made and which one to keep.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768314772352/75f23e9e-ed57-45fa-89b7-44b60ab05074.jpeg" alt class="image--center mx-auto" /></p>
<p>At this point, things get messy fast.</p>
<p>You open your friend’s email attachment and stare at a folder full of files that look <em>exactly</em> like yours. Same filenames. Same structure. No obvious labels screaming “THIS IS WHAT I CHANGED.” Now comes the fun part, which is comparing.</p>
<p>You start opening files one by one, scrolling line by line, trying to remember whether that function was yours or theirs. Maybe you copy some parts from your version, paste some from theirs, and hope nothing breaks. Sometimes it works. Sometimes the app refuses to run, and you have no idea why, because you just Frankenstein’d two codebases together at 2 AM.</p>
<p>And this is still the <strong>best-case scenario</strong>.</p>
<p>Now imagine both of you changed the same file. Maybe even the same function. Maybe in slightly different ways. Who wins? Your logic or theirs? Do you manually merge it? Do you trust memory? Do you flip a coin and move on?</p>
<p>There’s also no safety net. If you mess up while merging, the original versions are gone unless you made backups. And if you did make backups, they probably look like:</p>
<ul>
<li><p>project_old</p>
</li>
<li><p>project_old_2</p>
</li>
<li><p>project_old_2_fixed</p>
</li>
<li><p>project_latest_final</p>
</li>
</ul>
<p>Congrats, you’ve invented versioning. Poorly.</p>
<p>The real problem here isn’t email or distance or even collaboration. It’s the complete lack of <strong>history</strong>. You don’t know what changed, when it changed, or why it changed. You don’t know who introduced the bug. You don’t know which version was actually working last. All you have are folders and vibes.</p>
<p>As more people join the project, this approach collapses entirely. Files get overwritten. Changes get lost. Someone forgets to send an email. Someone edits an outdated copy. Suddenly, half the team is building features on code that no longer exists.</p>
<p>This is the moment where people realised they weren’t just sharing files anymore. They were sharing responsibility, decisions, and mistakes. And doing that over email attachments was never going to scale.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768314943690/ffe7dae1-1f05-4043-ba37-5df3d4d56d7f.jpeg" alt class="image--center mx-auto" /></p>
<p>The problem demanded a system that could track changes instead of replacing them. Something that could show differences instead of hiding them. Something that let multiple people work without stepping on each other’s toes, and still allowed everyone to rewind time when things went wrong.</p>
<p>That problem is why version control exists.</p>
]]></content:encoded></item><item><title><![CDATA[Beyond Basic RAG: The Ultimate Guide to Advanced Patterns and Production-Ready Pipelines]]></title><description><![CDATA[The RAG revolution started with a simple promise: ground your AI in external knowledge to reduce hallucinations and deliver accurate, up-to-date responses. Yet, as teams rushed to implement basic RAG systems, they quickly discovered that naive retrie...]]></description><link>https://blogs.kanishk.codes/beyond-basic-rag</link><guid isPermaLink="true">https://blogs.kanishk.codes/beyond-basic-rag</guid><category><![CDATA[RAG ]]></category><category><![CDATA[generative ai]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[@hiteshchoudharylco]]></category><category><![CDATA[openai]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Sun, 24 Aug 2025 09:28:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1756027527520/80c133ba-416c-4e38-b531-26adfb0f2f11.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The RAG revolution started with a simple promise: ground your AI in external knowledge to reduce hallucinations and deliver accurate, up-to-date responses. Yet, as teams rushed to implement basic RAG systems, they quickly discovered that <strong>naive retrieval-augmented generation</strong> often fails spectacularly in production.</p>
<p>Query: "What's our Q3 revenue performance compared to last year?"<br />Basic RAG Response: "I found some financial information,</p>
<p>Sound familiar? If your RAG system is struggling with complex queries, poor retrieval accuracy, or production scalability issues, you're ready for the next evolution: <strong>Advanced RAG</strong>.</p>
<p>Modern RAG isn't just about throwing documents into a vector database and hoping for the best. It's a sophisticated orchestration of intelligent query processing, multi-stage retrieval, contextual understanding, and self-correcting generation pipelines. The companies winning with RAG today—from Microsoft's Copilot to Anthropic's Claude—have moved far beyond basic implementations to embrace advanced patterns that can handle the complexity of real-world applications.</p>
<p>This guide dives deep into the cutting-edge techniques transforming RAG from a promising prototype into a production-ready powerhouse.</p>
<h2 id="heading-the-advanced-rag-architecture"><strong>The Advanced RAG Architecture</strong></h2>
<p>Advanced RAG systems operate on three fundamental principles that set them apart from basic implementations:</p>
<ol>
<li><p><strong>Intelligent Query Processing</strong>: Transform user queries into optimal retrieval requests</p>
</li>
<li><p><strong>Multi-Modal Retrieval</strong>: Combine multiple search strategies and data sources</p>
</li>
<li><p><strong>Self-Reflective Generation</strong>: Continuously evaluate and improve output quality</p>
</li>
</ol>
<p>Unlike basic RAG's linear "retrieve-then-generate" approach, advanced systems use <strong>feedback loops</strong>, <strong>multi-stage processing</strong>, and <strong>adaptive decision-making</strong> to deliver superior results.</p>
<h2 id="heading-query-intelligence-making-every-search-smarter"><strong>Query Intelligence: Making Every Search Smarter</strong></h2>
<p>The foundation of advanced RAG lies in sophisticated query processing. Raw user queries are rarely optimal for retrieval—they're often vague, complex, or use terminology that doesn't match your knowledge base.</p>
<h2 id="heading-query-rewriting-and-expansion"><strong>Query Rewriting and Expansion</strong></h2>
<p>Query rewriting transforms user questions into retrieval-optimized versions. Instead of searching for "AI trends," an advanced system might rewrite this as multiple focused queries: "artificial intelligence trends 2024," "machine learning adoption patterns," and "AI market growth statistics."</p>
<p><strong>Implementation approaches include:</strong></p>
<ul>
<li><p><strong>Zero-shot rewriting</strong>: Use LLMs to rephrase queries without examples</p>
</li>
<li><p><strong>Few-shot rewriting</strong>: Provide examples to guide the rewriting process</p>
</li>
<li><p><strong>Trainable rewriters</strong>: Fine-tune specialized models for domain-specific query optimization</p>
</li>
</ul>
<h2 id="heading-sub-query-decomposition"><strong>Sub-Query Decomposition</strong></h2>
<p>Complex questions often contain multiple information needs that require separate retrieval strategies. Advanced RAG systems decompose these into focused sub-queries:</p>
<p>Original: "How did our marketing spend impact customer acquisition in Q3, and what should we budget for Q4?"</p>
<p>Sub-queries:</p>
<ol>
<li><p>"Marketing spend breakdown Q3 2024"</p>
</li>
<li><p>"Customer acquisition metrics Q3 2024"</p>
</li>
<li><p>"Marketing ROI analysis Q3 2024"</p>
</li>
<li><p>"Q4 marketing budget recommendations"</p>
</li>
</ol>
<p>Each sub-query retrieves targeted context, and the final response synthesizes information from all sources.</p>
<h2 id="heading-step-back-prompting"><strong>Step-Back Prompting</strong></h2>
<p>For questions requiring deep domain knowledge, step-back prompting generates higher-level conceptual queries alongside the original question. This retrieves both specific details and broader context, enabling more comprehensive responses.</p>
<h2 id="heading-hyde-the-game-changing-retrieval-strategy"><strong>HyDE: The Game-Changing Retrieval Strategy</strong></h2>
<p><strong>Hypothetical Document Embeddings (HyDE)</strong> represents one of the most innovative advances in retrieval technology. Instead of directly searching with user queries, HyDE generates hypothetical answers first, then uses these synthetic documents for retrieval.</p>
<p><strong>The HyDE Process:</strong></p>
<ol>
<li><p><strong>Generate</strong>: LLM creates a hypothetical document answering the query</p>
</li>
<li><p><strong>Embed</strong>: Convert the synthetic document into vector embeddings</p>
</li>
<li><p><strong>Search</strong>: Find real documents similar to the hypothetical one</p>
</li>
<li><p><strong>Filter</strong>: Let the encoder remove hallucinated details while preserving relevant patterns</p>
</li>
</ol>
<p>This approach works because <strong>answers are more semantically similar to other answers</strong> than questions are to answers. A hypothetical response to "How do neural networks learn?" will match actual explanations better than the raw question would.</p>
<p><strong>When to use HyDE:</strong></p>
<ul>
<li><p>Complex technical queries requiring detailed explanations</p>
</li>
<li><p>Domain-specific questions where terminology matters</p>
</li>
<li><p>Cases where precision is more important than speed</p>
</li>
</ul>
<h2 id="heading-hybrid-search-the-best-of-both-worlds"><strong>Hybrid Search: The Best of Both Worlds</strong></h2>
<p>Pure vector search excels at semantic understanding but struggles with exact matches, proper nouns, and specific terminology. Keyword search (BM25) handles precise matching but misses semantic relationships.</p>
<p><strong>Hybrid search combines both approaches:</strong></p>
<pre><code class="lang-json">textHybrid Score = (<span class="hljs-number">1</span>-α) × BM25_Score + α × Vector_Score
</code></pre>
<p>Where α controls the balance between keyword and semantic matching. Advanced systems dynamically adjust this parameter based on query characteristics.</p>
<p><strong>Production implementations typically use:</strong></p>
<ul>
<li><p><strong>Ensemble retrievers</strong>: Combine multiple retrieval strategies with weighted scoring</p>
</li>
<li><p><strong>Rank fusion</strong>: Merge results from different search methods using algorithms like Reciprocal Rank Fusion</p>
</li>
<li><p><strong>Query-adaptive weighting</strong>: Adjust the balance based on query type and domain</p>
</li>
</ul>
<h2 id="heading-contextual-embeddings-understanding-documents-in-context"><strong>Contextual Embeddings: Understanding Documents in Context</strong></h2>
<p>Traditional embedding approaches encode documents in isolation, losing crucial contextual information. <strong>Contextual embeddings</strong> address this by incorporating surrounding document context into chunk representations.</p>
<p><strong>Anthropic's Contextual Retrieval</strong> approach prepends relevant context to each chunk before embedding:</p>
<p>Original chunk: "The new policy increases efficiency by 15%"<br />Contextualized chunk: "Q3 2024 Customer Service Policy Update: The new policy increases efficiency by 15%"</p>
<p>This simple technique <strong>reduces retrieval failures by 49%</strong> and, when combined with reranking, by 67%.</p>
<p><strong>Advanced contextual techniques include:</strong></p>
<ul>
<li><p><strong>Bidirectional context</strong>: Incorporate information from preceding and following sections</p>
</li>
<li><p><strong>Hierarchical context</strong>: Include document structure and section headings</p>
</li>
<li><p><strong>Cross-document context</strong>: Link related documents and maintain relationships</p>
</li>
</ul>
<h2 id="heading-graphrag-the-knowledge-graph-revolution"><strong>GraphRAG: The Knowledge Graph Revolution</strong></h2>
<p>While vector databases excel at similarity search, they struggle with complex relationships and multi-hop reasoning. <strong>GraphRAG</strong> addresses this by structuring knowledge as interconnected graphs rather than isolated chunks.</p>
<p><strong>The GraphRAG Process:</strong></p>
<ol>
<li><p><strong>Entity Extraction</strong>: Identify entities, relationships, and claims from documents</p>
</li>
<li><p><strong>Graph Construction</strong>: Build a knowledge graph with hierarchical community structure</p>
</li>
<li><p><strong>Community Summarization</strong>: Generate summaries at multiple levels of granularity</p>
</li>
<li><p><strong>Intelligent Querying</strong>: Use graph structure for enhanced retrieval and reasoning</p>
</li>
</ol>
<p><strong>GraphRAG Query Modes:</strong></p>
<ul>
<li><p><strong>Global Search</strong>: Leverage community summaries for holistic questions about the entire corpus</p>
</li>
<li><p><strong>Local Search</strong>: Fan out from specific entities to their neighbors and relationships</p>
</li>
<li><p><strong>DRIFT Search</strong>: Combine entity-focused search with community context</p>
</li>
</ul>
<p><strong>Microsoft's GraphRAG</strong> has shown remarkable improvements in handling complex, multi-entity queries that require reasoning across relationships.</p>
<h2 id="heading-corrective-rag-self-healing-systems"><strong>Corrective RAG: Self-Healing Systems</strong></h2>
<p>Even with advanced retrieval, systems can return irrelevant or low-quality documents. <strong>Corrective RAG (CRAG)</strong> introduces self-reflection mechanisms that evaluate retrieval quality and take corrective action when needed.</p>
<p><strong>The CRAG Framework:</strong></p>
<ol>
<li><p><strong>Relevance Grading</strong>: LLM evaluates each retrieved document's relevance to the query</p>
</li>
<li><p><strong>Decision Making</strong>:</p>
<ul>
<li><p><strong>Correct documents</strong>: Proceed to generation with knowledge refinement</p>
</li>
<li><p><strong>Ambiguous/incorrect documents</strong>: Trigger web search and query rewriting</p>
</li>
</ul>
</li>
<li><p><strong>Knowledge Refinement</strong>: Partition documents into "knowledge strips" and filter irrelevant sections</p>
</li>
</ol>
<p>This creates a <strong>feedback loop</strong> that continuously improves retrieval quality and reduces hallucinations.</p>
<h2 id="heading-llm-as-a-judge-intelligent-evaluation-at-scale"><strong>LLM-as-a-Judge: Intelligent Evaluation at Scale</strong></h2>
<p>Traditional RAG evaluation relies on expensive human assessment or simple metrics that miss nuanced quality issues. <strong>LLM-as-a-Judge</strong> enables scalable, sophisticated evaluation using specialized judge models.</p>
<p><strong>Evaluation Approaches:</strong></p>
<ul>
<li><p><strong>Single-output scoring</strong>: Judge individual responses against defined criteria</p>
</li>
<li><p><strong>Reference-based evaluation</strong>: Compare outputs to gold-standard answers</p>
</li>
<li><p><strong>Pairwise comparison</strong>: Choose the better response between two candidates</p>
</li>
</ul>
<p><strong>Key Metrics for RAG Systems:</strong></p>
<ul>
<li><p><strong>Context Precision</strong>: Relevance of retrieved chunks</p>
</li>
<li><p><strong>Context Recall</strong>: Completeness of relevant information retrieval</p>
</li>
<li><p><strong>Faithfulness</strong>: Alignment between generated answers and retrieved context</p>
</li>
<li><p><strong>Answer Relevancy</strong>: How well responses address the original query</p>
</li>
</ul>
<h2 id="heading-ranking-and-reranking-strategies"><strong>Ranking and Reranking Strategies</strong></h2>
<p>Initial retrieval often returns relevant documents mixed with noise. <strong>Reranking</strong> applies more sophisticated models to reorder results based on query-document relevance.</p>
<p><strong>Reranking Approaches:</strong></p>
<ul>
<li><p><strong>Cross-encoder models</strong>: Deep interaction between query and document pairs</p>
</li>
<li><p><strong>LLM-based reranking</strong>: Use instruction-following models to assess relevance</p>
</li>
<li><p><strong>Multi-stage reranking</strong>: Combine multiple reranking signals</p>
</li>
</ul>
<p><strong>Production considerations:</strong></p>
<ul>
<li><p><strong>Latency vs. accuracy trade-offs</strong>: Cross-encoders are more accurate but slower</p>
</li>
<li><p><strong>Caching strategies</strong>: Store reranking results for frequent queries</p>
</li>
<li><p><strong>Batch processing</strong>: Rerank multiple documents simultaneously for efficiency</p>
</li>
</ul>
<h2 id="heading-caching-the-performance-multiplier"><strong>Caching: The Performance Multiplier</strong></h2>
<p>Production RAG systems must handle thousands of queries per second with sub-second latency. <strong>Intelligent caching</strong> dramatically improves performance while reducing computational costs.</p>
<p><strong>Caching Strategies:</strong></p>
<h2 id="heading-query-based-caching"><strong>Query-Based Caching</strong></h2>
<p>Store exact retrieval results for specific queries. Perfect for FAQ-style applications with repeated questions.</p>
<h2 id="heading-semantic-caching"><strong>Semantic Caching</strong></h2>
<p>Cache embeddings of previous queries and reuse results for semantically similar new queries. More flexible but requires careful similarity threshold tuning.</p>
<h2 id="heading-hybrid-caching"><strong>Hybrid Caching</strong></h2>
<p>Combine exact matching with semantic similarity, using exact matches when available and falling back to semantic similarity.</p>
<p><strong>Production Caching Architecture:</strong></p>
<ul>
<li><p><strong>Redis/Memcached</strong>: For high-performance, distributed caching</p>
</li>
<li><p><strong>TTL policies</strong>: Automatic expiration to maintain data freshness</p>
</li>
<li><p><strong>Cache warming</strong>: Precompute results for anticipated queries</p>
</li>
<li><p><strong>Invalidation strategies</strong>: Update caches when underlying data changes</p>
</li>
</ul>
<h2 id="heading-speed-vs-accuracy-the-production-balancing-act"><strong>Speed vs. Accuracy: The Production Balancing Act</strong></h2>
<p>Real-world RAG systems must balance response quality with performance requirements. Different use cases demand different trade-offs:</p>
<p><strong>High-Speed Scenarios</strong> (Customer chat, real-time assistance):</p>
<ul>
<li><p>Smaller, faster embedding models</p>
</li>
<li><p>Limited reranking</p>
</li>
<li><p>Aggressive caching</p>
</li>
<li><p>Simplified query processing</p>
</li>
</ul>
<p><strong>High-Accuracy Scenarios</strong> (Research, legal analysis, medical diagnosis):</p>
<ul>
<li><p>Larger, more capable models</p>
</li>
<li><p>Multi-stage retrieval and reranking</p>
</li>
<li><p>Extensive query processing</p>
</li>
<li><p>Quality-focused evaluation</p>
</li>
</ul>
<p><strong>Dynamic Scaling Approaches:</strong></p>
<ul>
<li><p><strong>Query complexity detection</strong>: Route simple queries to fast paths, complex ones to comprehensive processing</p>
</li>
<li><p><strong>User-adaptive systems</strong>: Learn individual user patterns and optimize accordingly</p>
</li>
<li><p><strong>Load-based routing</strong>: Switch processing intensity based on system load</p>
</li>
</ul>
<h2 id="heading-production-ready-pipeline-architecture"><strong>Production-Ready Pipeline Architecture</strong></h2>
<p>Building RAG systems that work in production requires careful orchestration of all these components. Here's the architecture that powers successful deployments:</p>
<h2 id="heading-data-ingestion-pipeline"><strong>Data Ingestion Pipeline</strong></h2>
<ul>
<li><p><strong>Multi-format processing</strong>: Handle PDFs, web pages, databases, APIs</p>
</li>
<li><p><strong>Incremental updates</strong>: Process new content without full reindexing</p>
</li>
<li><p><strong>Quality filtering</strong>: Remove low-quality or duplicate content</p>
</li>
<li><p><strong>Metadata enrichment</strong>: Add contextual information during ingestion</p>
</li>
</ul>
<h2 id="heading-retrieval-pipeline"><strong>Retrieval Pipeline</strong></h2>
<ul>
<li><p><strong>Query preprocessing</strong>: Rewriting, expansion, decomposition</p>
</li>
<li><p><strong>Multi-stage retrieval</strong>: Initial retrieval → reranking → final selection</p>
</li>
<li><p><strong>Result fusion</strong>: Combine outputs from multiple retrieval strategies</p>
</li>
<li><p><strong>Quality gates</strong>: Filter low-quality results before generation</p>
</li>
</ul>
<h2 id="heading-generation-pipeline"><strong>Generation Pipeline</strong></h2>
<ul>
<li><p><strong>Context optimization</strong>: Arrange retrieved content for maximum relevance</p>
</li>
<li><p><strong>Response synthesis</strong>: Generate coherent answers from multiple sources</p>
</li>
<li><p><strong>Citation tracking</strong>: Maintain links between generated content and sources</p>
</li>
<li><p><strong>Quality validation</strong>: Check responses before returning to users</p>
</li>
</ul>
<h2 id="heading-monitoring-and-observability"><strong>Monitoring and Observability</strong></h2>
<ul>
<li><p><strong>End-to-end tracing</strong>: Track queries through the entire pipeline</p>
</li>
<li><p><strong>Performance metrics</strong>: Latency, throughput, accuracy monitoring</p>
</li>
<li><p><strong>Quality metrics</strong>: Automated evaluation using LLM judges</p>
</li>
<li><p><strong>User feedback loops</strong>: Collect and analyze user satisfaction data</p>
</li>
</ul>
<h2 id="heading-the-future-of-advanced-rag"><strong>The Future of Advanced RAG</strong></h2>
<p>As RAG systems mature, several trends are shaping the next generation of capabilities:</p>
<p><strong>Agentic RAG</strong>: Systems that can plan multi-step retrieval strategies, use tools, and iterate on results. These systems don't just retrieve and generate—they reason about what information they need and how to get it.</p>
<p><strong>Multimodal Integration</strong>: Extending RAG beyond text to include images, audio, video, and structured data. The future of RAG is truly multimodal.</p>
<p><strong>Real-time Learning</strong>: Systems that continuously improve from user interactions, updating their knowledge and retrieval strategies based on feedback.</p>
<p><strong>Federated RAG</strong>: Architectures that can securely query across multiple organizations' data sources while maintaining privacy and compliance.</p>
<h2 id="heading-getting-started-with-advanced-rag"><strong>Getting Started with Advanced RAG</strong></h2>
<p>Ready to upgrade your RAG system? Here's your implementation roadmap:</p>
<ol>
<li><p><strong>Start with Evaluation</strong>: Implement comprehensive metrics before optimizing anything</p>
</li>
<li><p><strong>Add Query Intelligence</strong>: Begin with simple query rewriting and expand to sub-queries</p>
</li>
<li><p><strong>Implement Hybrid Search</strong>: Combine vector and keyword search for immediate improvements</p>
</li>
<li><p><strong>Deploy Caching</strong>: Add semantic caching for performance gains</p>
</li>
<li><p><strong>Introduce Self-Reflection</strong>: Implement basic relevance grading and corrective mechanisms</p>
</li>
<li><p><strong>Scale Gradually</strong>: Add complexity incrementally while monitoring performance impact</p>
</li>
</ol>
<h2 id="heading-the-advanced-rag-advantage"><strong>The Advanced RAG Advantage</strong></h2>
<p>The gap between basic and advanced RAG implementations is vast. While naive systems struggle with complex queries and production demands, advanced RAG delivers <strong>accurate, contextual, and scalable</strong> AI-powered applications.</p>
<p>Companies implementing these advanced techniques report <strong>50-80% improvements</strong> in retrieval accuracy, <strong>2-5x faster response times</strong> through intelligent caching, and <strong>significantly reduced hallucinations</strong> through self-corrective mechanisms.</p>
<p>The future belongs to organizations that embrace this complexity and build RAG systems designed for the demands of real-world applications. The techniques covered in this guide—from HyDE and GraphRAG to contextual embeddings and self-reflection—represent the current state of the art, but the field continues evolving rapidly.</p>
<p><strong>Your users expect accurate, intelligent responses</strong>. Basic RAG won't cut it anymore. The question isn't whether to adopt advanced RAG techniques—it's how quickly you can implement them to stay competitive in an AI-driven world.</p>
<p><em>Ready to build production-ready RAG systems? Start with comprehensive evaluation and query intelligence—the foundation of every successful advanced RAG implementation</em></p>
]]></content:encoded></item><item><title><![CDATA[When RAG Falls Short: Understanding the Critical Failure Points That Can Break Your AI System]]></title><description><![CDATA[Retrieval-Augmented Generation (RAG) promised to revolutionize how AI systems work—combining the power of large language models with real-time access to external knowledge. It was supposed to solve the hallucination problem, deliver accurate answers,...]]></description><link>https://blogs.kanishk.codes/where-rag-fails</link><guid isPermaLink="true">https://blogs.kanishk.codes/where-rag-fails</guid><category><![CDATA[RAG ]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[generative ai]]></category><category><![CDATA[GenAI Cohort]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[@hiteshchoudharylco]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Sun, 24 Aug 2025 09:09:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1756026466343/38a81d9e-ceb0-43da-80b7-7d90a686d6b3.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Retrieval-Augmented Generation (RAG) promised to revolutionize how AI systems work—combining the power of large language models with real-time access to external knowledge. It was supposed to solve the hallucination problem, deliver accurate answers, and ground AI responses in factual data.</p>
<p>Yet, despite its theoretical elegance, many RAG systems in production still fail spectacularly. They return irrelevant documents, miss critical information, or worse—confidently generate incorrect answers while citing legitimate sources.</p>
<p>If you've built or worked with RAG systems, you've likely encountered these frustrations. A seemingly perfect setup suddenly starts producing garbage results after a database update. A query that worked yesterday fails today. The system retrieves relevant documents but somehow generates completely wrong answers.</p>
<p>The reality is that RAG systems are complex beasts with multiple points of failure, each capable of undermining the entire pipeline. Understanding where and why these failures occur is crucial for building robust, production-ready systems.</p>
<h2 id="heading-the-anatomy-of-rag-failure"><strong>The Anatomy of RAG Failure</strong></h2>
<p>RAG failures typically stem from three primary sources: <strong>data quality issues</strong>, <strong>retrieval problems</strong>, and <strong>generation deficiencies</strong>. Each category presents unique challenges that can cascade through your entire system.</p>
<h3 id="heading-1-poor-recall-when-your-system-cant-find-what-it-needs"><strong>1. Poor Recall: When Your System Can't Find What It Needs</strong></h3>
<p>Poor recall is perhaps the most fundamental RAG failure. It occurs when your retrieval system fails to find relevant documents that actually exist in your knowledge base. This leads to incomplete context, forcing the language model to either admit ignorance or hallucinate answers.</p>
<p><strong>Common causes include:</strong></p>
<ul>
<li><p><strong>Missing Content</strong>: The most basic issue—your knowledge base simply doesn't contain the information needed to answer the query</p>
</li>
<li><p><strong>Weak Ranking</strong>: The relevant documents exist but don't rank highly enough to be retrieved</p>
</li>
<li><p><strong>Semantic Mismatches</strong>: Your query and the relevant documents use different terminology or phrasing, causing the vector search to miss important connections</p>
</li>
</ul>
<p><strong>Quick Mitigation:</strong></p>
<ul>
<li><p>Implement <strong>hybrid search</strong> combining dense vector search with traditional keyword-based retrieval (BM25)</p>
</li>
<li><p>Use <strong>query expansion</strong> techniques to include synonyms and related terms</p>
</li>
<li><p>Regularly audit your knowledge base coverage by analyzing queries that result in "I don't know" responses</p>
</li>
</ul>
<h2 id="heading-2-bad-chunking-the-silent-performance-killer"><strong>2. Bad Chunking: The Silent Performance Killer</strong></h2>
<p>Chunking—breaking large documents into smaller, manageable pieces—seems straightforward but is deceptively complex. Poor chunking strategies can destroy context, break semantic meaning, and create fundamental retrieval problems.</p>
<p><strong>The chunking dilemma:</strong></p>
<ul>
<li><p><strong>Chunks too large</strong>: Create coarse representations that obscure important details and may encompass multiple topics, diluting relevance</p>
</li>
<li><p><strong>Chunks too small</strong>: Lose important context and may not contain enough information to be meaningful</p>
</li>
<li><p><strong>Naive splitting</strong>: Character-based splitting can break mid-sentence or separate related concepts</p>
</li>
</ul>
<p><strong>Smart Chunking Strategies:</strong></p>
<ul>
<li><p><strong>Semantic chunking</strong>: Understand meaning rather than just splitting text mechanically</p>
</li>
<li><p><strong>Structure-aware chunking</strong>: Respect document organization like headings and sections</p>
</li>
<li><p><strong>Overlap strategies</strong>: Maintain context windows across chunk boundaries</p>
</li>
<li><p><strong>Domain-specific boundaries</strong>: Use "by title" or "by similarity" strategies to preserve topic coherence</p>
</li>
</ul>
<p><strong>Rule of thumb</strong>: Start with approximately 250 tokens (1000 characters) per chunk, but always experiment with your specific data.</p>
<h2 id="heading-3-query-drift-when-questions-dont-match-answers"><strong>3. Query Drift: When Questions Don't Match Answers</strong></h2>
<p>Query drift occurs when the user's question doesn't align well with how information is stored or indexed in your knowledge base. This mismatch leads to poor retrieval quality, even when relevant information exists.</p>
<p><strong>Manifestations of query drift:</strong></p>
<ul>
<li><p><strong>Vague queries</strong>: "AI trends" when the user actually wants "AI trends in medical imaging"</p>
</li>
<li><p><strong>Complex multi-part questions</strong>: Single queries that actually require multiple separate searches</p>
</li>
<li><p><strong>Domain-specific terminology gaps</strong>: User language that doesn't match your indexed content</p>
</li>
</ul>
<p><strong>Query Rewriting Solutions:</strong></p>
<ul>
<li><p><strong>Query expansion</strong>: Add synonyms and related terms to broaden search scope</p>
</li>
<li><p><strong>Query simplification</strong>: Break complex queries into focused, manageable parts</p>
</li>
<li><p><strong>Contextual enrichment</strong>: Add relevant context from previous interactions or user profiles</p>
</li>
<li><p><strong>Multi-query generation</strong>: Create multiple variations of the same question to increase retrieval chances</p>
</li>
</ul>
<h2 id="heading-4-outdated-indexes-the-staleness-problem"><strong>4. Outdated Indexes: The Staleness Problem</strong></h2>
<p>One of the most insidious RAG failures is the gradual degradation of performance due to outdated indexes and knowledge bases. As your data evolves but your embeddings remain static, the system becomes increasingly disconnected from reality.</p>
<p><strong>The staleness cascade:</strong></p>
<ul>
<li><p><strong>Information gaps</strong>: New data isn't indexed, creating blind spots in retrieval</p>
</li>
<li><p><strong>Embedding drift</strong>: Vector representations become misaligned as content evolves</p>
</li>
<li><p><strong>Inconsistent retrieval</strong>: Updates to vector databases can cause ranking instabilities</p>
</li>
</ul>
<p><strong>Mitigation Strategies:</strong></p>
<ul>
<li><p><strong>Automated update pipelines</strong>: Set up systems to detect and process new content regularly</p>
</li>
<li><p><strong>Drift monitoring</strong>: Use clustering techniques or PCA visualization to detect embedding space changes</p>
</li>
<li><p><strong>Incremental learning</strong>: Update embeddings with recent data without full retraining</p>
</li>
<li><p><strong>Version control</strong>: Maintain embedding versions and monitor semantic degradation over time</p>
</li>
</ul>
<h2 id="heading-5-hallucinations-from-weak-context-the-false-confidence-problem"><strong>5. Hallucinations from Weak Context: The False Confidence Problem</strong></h2>
<p>Even when RAG systems successfully retrieve relevant documents, they can still generate hallucinations—confident-sounding but incorrect information. This is particularly dangerous because users trust cited sources.</p>
<p><strong>Types of RAG hallucinations:</strong></p>
<ul>
<li><p><strong>Context misinterpretation</strong>: The LLM incorrectly processes retrieved information</p>
</li>
<li><p><strong>Information fusion errors</strong>: Incorrectly combining facts from multiple sources</p>
</li>
<li><p><strong>Citation fabrication</strong>: Making up plausible-sounding references</p>
</li>
<li><p><strong>Confidence misalignment</strong>: High confidence in low-quality outputs</p>
</li>
</ul>
<p><strong>Detection and Prevention:</strong></p>
<ul>
<li><p><strong>Multi-metric evaluation</strong>: Use frameworks like RAGAS to measure faithfulness, relevance, and context precision</p>
</li>
<li><p><strong>Semantic similarity checking</strong>: Compare generated responses against retrieved context</p>
</li>
<li><p><strong>Source attribution validation</strong>: Verify that citations actually support the claims made</p>
</li>
<li><p><strong>Hallucination scoring</strong>: Implement automated detection using LLM-based evaluators</p>
</li>
</ul>
<h2 id="heading-building-resilient-rag-systems"><strong>Building Resilient RAG Systems</strong></h2>
<p>Understanding these failure modes is just the beginning. Building production-ready RAG systems requires a systematic approach to prevention, detection, and mitigation.</p>
<h2 id="heading-the-evaluation-framework"><strong>The Evaluation Framework</strong></h2>
<p>You cannot improve what you don't measure. Implement comprehensive evaluation using multiple metrics:</p>
<ul>
<li><p><strong>Context Precision</strong>: Measure how relevant your retrieved chunks are</p>
</li>
<li><p><strong>Context Recall</strong>: Ensure you're finding all relevant information</p>
</li>
<li><p><strong>Faithfulness</strong>: Verify generated answers align with retrieved context</p>
</li>
<li><p><strong>Answer Relevancy</strong>: Check if responses actually address the user's question</p>
</li>
</ul>
<h2 id="heading-monitoring-and-observability"><strong>Monitoring and Observability</strong></h2>
<p>Set up monitoring systems to detect failures early:</p>
<ul>
<li><p><strong>Drift detection</strong>: Monitor embedding space changes over time</p>
</li>
<li><p><strong>Performance degradation</strong>: Track retrieval quality and response accuracy</p>
</li>
<li><p><strong>User feedback loops</strong>: Collect and analyze user satisfaction data</p>
</li>
<li><p><strong>Component-level monitoring</strong>: Isolate failures to specific pipeline stages</p>
</li>
</ul>
<h2 id="heading-iterative-improvement"><strong>Iterative Improvement</strong></h2>
<p>RAG systems require continuous refinement:</p>
<ul>
<li><p><strong>A/B testing</strong>: Compare different chunking strategies, embedding models, and retrieval approaches</p>
</li>
<li><p><strong>User feedback integration</strong>: Learn from real-world usage patterns</p>
</li>
<li><p><strong>Regular audits</strong>: Systematically review system performance across different query types</p>
</li>
<li><p><strong>Proactive updates</strong>: Stay ahead of data drift with automated refresh cycles</p>
</li>
</ul>
<h2 id="heading-the-path-forward"><strong>The Path Forward</strong></h2>
<p>RAG isn't broken—it's simply more complex than initial implementations suggested. The key is understanding that RAG systems are not set-and-forget solutions but require ongoing attention, monitoring, and optimization.</p>
<p>Success comes from treating RAG as an engineering discipline rather than a magic solution. This means rigorous testing, comprehensive evaluation, systematic monitoring, and continuous improvement based on real-world performance.</p>
<p>The organizations succeeding with RAG today are those that have invested in robust evaluation frameworks, implemented comprehensive monitoring, and built systems designed for continuous iteration. They understand that the initial deployment is just the beginning—the real work happens in production, where you discover the unique failure modes of your specific use case and systematically address them.</p>
<p>By understanding and preparing for these common failure points, you can build RAG systems that don't just work in demos but deliver reliable, accurate results in the messy reality of production environments. The future belongs to those who can navigate RAG's complexity, not those seeking simple solutions to complex problems.</p>
<p><em>Ready to build more resilient RAG systems? Start by implementing comprehensive evaluation metrics and monitoring—your future self will thank you when things inevitably break.</em></p>
]]></content:encoded></item><item><title><![CDATA[RAG Unveiled: How AI Learned to Stop Hallucinating and Start Fact-Checking]]></title><description><![CDATA[Picture this: You're having a conversation with ChatGPT about your company's latest quarterly report, but instead of giving you accurate insights, it confidently makes up financial figures that sound plausible but are completely wrong. Frustrating, r...]]></description><link>https://blogs.kanishk.codes/intro-to-rag</link><guid isPermaLink="true">https://blogs.kanishk.codes/intro-to-rag</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[generative ai]]></category><category><![CDATA[RAG ]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[NotebookLM]]></category><category><![CDATA[openai]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Wed, 20 Aug 2025 13:46:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1755697347926/ac3c5797-ce4e-4d97-b853-844b665087a3.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Picture this: You're having a conversation with ChatGPT about your company's latest quarterly report, but instead of giving you accurate insights, it confidently makes up financial figures that sound plausible but are completely wrong. Frustrating, right? This is exactly the problem that <strong>Retrieval-Augmented Generation (RAG)</strong> was designed to solve, and trust me, it's a game-changer.</p>
<p>As someone who's passionate about AI and its real-world applications, I'm excited to take you on this journey to understand RAG - the technology that's revolutionizing how AI systems access and use information. By the end of this article, you'll not only understand what RAG is but also why it's become the secret sauce behind reliable AI applications.</p>
<h2 id="heading-what-is-rag-the-ai-detective-with-a-library-card">What is RAG? The AI Detective with a Library Card</h2>
<p>Retrieval-Augmented Generation, or RAG for short, is like giving your AI assistant a library card and detective skills rolled into one. Instead of relying solely on what it learned during training (which might be outdated or incomplete), RAG enables language models to <strong>actively search for and retrieve relevant information</strong> from external sources before generating responses.</p>
<p>Think of it this way: Traditional Large Language Models (LLMs) are like that friend who knows a lot about many topics but sometimes confidently shares "facts" that turn out to be wrong. RAG transforms this friend into a research-savvy individual who <strong>always checks their sources</strong> before answering your questions.</p>
<h2 id="heading-the-problem-rag-solves">The Problem RAG Solves</h2>
<p>Before RAG came along, LLMs faced several critical limitations:</p>
<p><strong>The Staleness Problem</strong>: Models trained on data from 2021 couldn't tell you about events that happened in 2023. Imagine asking about recent stock prices or current news - you'd get outdated information at best.</p>
<p><strong>The Hallucination Dilemma</strong>: LLMs sometimes generate convincing-sounding but entirely fabricated information. Studies show that traditional LLMs make mistakes <strong>27% of the time</strong> when dealing with specialized questions.</p>
<p><strong>The Knowledge Gap</strong>: Your company's internal documents, recent research papers, or proprietary data weren't part of the model's training, leaving huge blind spots in its knowledge.</p>
<h2 id="heading-why-rag-exists-the-birth-of-smarter-ai">Why RAG Exists: The Birth of Smarter AI</h2>
<p>RAG exists because we needed a way to make AI both <strong>knowledgeable and trustworthy</strong>. The traditional approach of retraining massive models every time new information becomes available is not just expensive - it's practically impossible for most organizations.</p>
<p>Here's what makes RAG special:</p>
<h2 id="heading-access-to-real-time-information">🎯 Access to Real-Time Information</h2>
<p>RAG can pull information from databases that are updated daily, hourly, or even in real-time. This means your AI can answer questions about today's stock prices, this week's company announcements, or the latest research findings.</p>
<h2 id="heading-reduced-hallucinations">🛡️ Reduced Hallucinations</h2>
<p>By grounding responses in actual retrieved documents, RAG reduces AI hallucinations by <strong>60-80%</strong> compared to standard LLMs. It's like having a fact-checker built right into your AI system.</p>
<h2 id="heading-cost-effective-solution">💰 Cost-Effective Solution</h2>
<p>RAG is significantly more cost-effective than continuously retraining models. It can reduce operational costs by <strong>20% per token</strong> compared to traditional LLM approaches.</p>
<h2 id="heading-transparency-and-traceability">🔍 Transparency and Traceability</h2>
<p>Unlike black-box AI systems, RAG can show you exactly which sources it used to generate an answer, making it possible to verify and trust the information.</p>
<h2 id="heading-the-rag-architecture-retriever-generator-magic">The RAG Architecture: Retriever + Generator = Magic</h2>
<p>At its heart, RAG consists of two main components working in perfect harmony:</p>
<h2 id="heading-the-retriever-your-ai-research-assistant">The Retriever: Your AI Research Assistant</h2>
<p>The retriever is like having a super-fast librarian who can search through millions of documents in milliseconds. Here's how it works:</p>
<ol>
<li><p><strong>Query Processing</strong>: When you ask a question, the retriever converts your query into a mathematical representation called a vector embedding.</p>
</li>
<li><p><strong>Similarity Search</strong>: It then searches through a database of pre-computed embeddings to find the most relevant documents or text chunks.</p>
</li>
<li><p><strong>Smart Selection</strong>: The retriever doesn't just grab random information - it uses sophisticated algorithms to identify the most contextually relevant pieces of information.</p>
</li>
</ol>
<h2 id="heading-the-generator-your-ai-storyteller">The Generator: Your AI Storyteller</h2>
<p>Once the retriever has found relevant information, the generator (typically an LLM like GPT-4 or Claude) takes over:</p>
<ol>
<li><p><strong>Context Integration</strong>: The generator receives both your original question and the retrieved information.</p>
</li>
<li><p><strong>Intelligent Synthesis</strong>: It combines this information to create a coherent, accurate response that directly addresses your query.</p>
</li>
<li><p><strong>Source-Grounded Output</strong>: The final answer is based on actual retrieved data rather than just the model's training knowledge.</p>
</li>
</ol>
<h2 id="heading-a-simple-rag-example-lets-see-it-in-action">A Simple RAG Example: Let's See It in Action</h2>
<p>Let me walk you through a practical example that'll make everything click:</p>
<p><strong>Scenario</strong>: You're building a customer support chatbot for a software company.</p>
<p><strong>Step 1: The Question</strong><br />A customer asks: "What's new in version 3.2 of your product?"</p>
<p><strong>Step 2: Traditional LLM Response</strong><br />Without RAG, the LLM might say: "I don't have information about version 3.2, as my training data only goes up to early 2023."</p>
<p><strong>Step 3: RAG in Action</strong><br />With RAG:</p>
<ol>
<li><p>The retriever searches your company's knowledge base</p>
</li>
<li><p>It finds the release notes for version 3.2</p>
</li>
<li><p>It retrieves specific information about new features, bug fixes, and improvements</p>
</li>
<li><p>The generator crafts a comprehensive response like: "Version 3.2 introduces three major features: enhanced API integration, improved dashboard analytics, and faster data processing. Here are the specific improvements..."</p>
</li>
</ol>
<p><strong>The Result</strong>: Your customer gets accurate, up-to-date information that directly answers their question, backed by your actual documentation.</p>
<h2 id="heading-understanding-indexing-the-foundation-of-fast-retrieval">Understanding Indexing: The Foundation of Fast Retrieval</h2>
<p>Before RAG can work its magic, there's a crucial behind-the-scenes process called <strong>indexing</strong>. Think of indexing as creating a super-organized filing system for information.</p>
<h2 id="heading-what-is-indexing">What is Indexing?</h2>
<p>Indexing is the process of organizing and storing information in a way that makes it lightning-fast to search and retrieve. Instead of searching through every single document linearly (which would be painfully slow), indexing creates structures that allow for efficient similarity-based searches.</p>
<h2 id="heading-how-indexing-works">How Indexing Works</h2>
<ol>
<li><p><strong>Document Processing</strong>: Large documents are broken down into smaller, manageable chunks.</p>
</li>
<li><p><strong>Vector Conversion</strong>: Each chunk is converted into a high-dimensional vector using embedding models.</p>
</li>
<li><p><strong>Database Storage</strong>: These vectors are stored in specialized vector databases with efficient indexing structures.</p>
</li>
<li><p><strong>Search Optimization</strong>: When you ask a question, the system can quickly find the most relevant vectors without checking every single one.</p>
</li>
</ol>
<h2 id="heading-popular-indexing-strategies">Popular Indexing Strategies</h2>
<p><strong>Approximate Nearest Neighbors (ANN)</strong>: Trades a tiny bit of accuracy for massive speed improvements.</p>
<p><strong>Hierarchical Navigable Small World (HNSW)</strong>: Creates a multi-layer graph structure that balances speed and accuracy perfectly.</p>
<p><strong>Inverted File Index (IVF)</strong>: Organizes vectors into clusters, making searches in large datasets incredibly efficient.</p>
<h2 id="heading-vectorization-turning-words-into-math">Vectorization: Turning Words into Math</h2>
<p>Here's where things get really interesting. <strong>Vectorization</strong> is the process of converting text into numerical representations that computers can understand and compare.</p>
<h2 id="heading-why-vectorization-matters">Why Vectorization Matters</h2>
<p>Imagine trying to determine how similar "king" and "monarch" are. To a computer, these are just different sequences of letters. But through vectorization, both words get converted into numerical vectors that are positioned close to each other in a high-dimensional space, reflecting their semantic similarity.</p>
<h2 id="heading-the-vectorization-process">The Vectorization Process</h2>
<ol>
<li><p><strong>Text Input</strong>: "The quick brown fox jumps over the lazy dog"</p>
</li>
<li><p><strong>Embedding Model</strong>: Advanced neural networks process this text</p>
</li>
<li><p><strong>Vector Output</strong>: [0.2, -0.8, 1.3, 0.7, ...] (a list of numbers representing meaning)</p>
</li>
<li><p><strong>Storage</strong>: This vector gets stored in a database for future retrieval</p>
</li>
</ol>
<h2 id="heading-real-world-impact">Real-World Impact</h2>
<p>This mathematical representation allows RAG systems to understand that:</p>
<ul>
<li><p>"CEO" and "Chief Executive Officer" are similar</p>
</li>
<li><p>"Python programming" and "coding in Python" are related</p>
</li>
<li><p>"quarterly earnings" and "Q3 financial results" refer to similar concepts</p>
</li>
</ul>
<h2 id="heading-the-art-of-chunking-breaking-it-down-right">The Art of Chunking: Breaking It Down Right</h2>
<p><strong>Chunking</strong> is the process of breaking large documents into smaller, digestible pieces that RAG systems can work with effectively. It's like taking a massive textbook and dividing it into individual pages or sections.</p>
<h2 id="heading-why-chunking-is-crucial">Why Chunking is Crucial</h2>
<p><strong>Model Limitations</strong>: Embedding models have maximum input sizes (typically around 8,000 tokens or about 6,000 words). A single document might be much larger than this limit.</p>
<p><strong>Search Precision</strong>: Smaller chunks allow for more precise retrieval. Instead of returning an entire 50-page document when someone asks about a specific feature, RAG can return just the relevant paragraph.</p>
<p><strong>Context Preservation</strong>: Well-designed chunks maintain enough context to be meaningful on their own.</p>
<h2 id="heading-chunking-strategies">Chunking Strategies</h2>
<p><strong>Fixed-Size Chunking</strong>: Divide text into equal-sized pieces (e.g., 500 words each).</p>
<ul>
<li><p>Pros: Simple to implement, consistent sizes</p>
</li>
<li><p>Cons: Might break sentences or paragraphs awkwardly</p>
</li>
</ul>
<p><strong>Content-Aware Chunking</strong>: Split based on natural boundaries like paragraphs or sections.</p>
<ul>
<li><p>Pros: Preserves semantic coherence</p>
</li>
<li><p>Cons: Variable chunk sizes</p>
</li>
</ul>
<p><strong>Semantic Chunking</strong>: Use AI to determine where topics change and split accordingly.</p>
<ul>
<li><p>Pros: Each chunk focuses on a single topic</p>
</li>
<li><p>Cons: More complex to implement</p>
</li>
</ul>
<h2 id="heading-chunking-best-practices">Chunking Best Practices</h2>
<p><strong>Size Matters</strong>: Typical chunk sizes range from 200-600 tokens with good results.</p>
<p><strong>Think Context</strong>: Each chunk should make sense to a human reader without requiring additional context.</p>
<p><strong>Consider Your Use Case</strong>: Technical documentation might benefit from section-based chunking, while narrative text might work better with paragraph-based splits.</p>
<h2 id="heading-the-power-of-overlapping-never-lose-context">The Power of Overlapping: Never Lose Context</h2>
<p>This is where chunking gets really smart. <strong>Overlapping</strong> means that consecutive chunks share some common text, typically 10-15% of the content.</p>
<h2 id="heading-why-overlapping-is-essential">Why Overlapping is Essential</h2>
<p>Let me illustrate with an example:</p>
<p><strong>Without Overlapping:</strong></p>
<ul>
<li><p>Chunk 1: "Our new product features advanced AI capabilities. It uses machine learning algorithms"</p>
</li>
<li><p>Chunk 2: "to analyze customer behaviour and provide personalized recommendations."</p>
</li>
</ul>
<p><strong>With Overlapping:</strong></p>
<ul>
<li><p>Chunk 1: "Our new product features advanced AI capabilities. It uses machine learning algorithms to analyze customer behaviour"</p>
</li>
<li><p>Chunk 2: "machine learning algorithms to analyze customer behaviour and provide personalized recommendations."</p>
</li>
</ul>
<h2 id="heading-the-problem-overlapping-solves">The Problem Overlapping Solves</h2>
<p><strong>Context Loss</strong>: Without overlapping, important information might be split across chunks, making it impossible to retrieve complete answers.</p>
<p><strong>Meaning Preservation</strong>: Overlapping ensures that key concepts aren't artificially separated, maintaining semantic coherence.</p>
<p><strong>Better Retrieval</strong>: When someone searches for "machine learning customer analysis," both chunks above would be relevant and retrievable with overlapping.</p>
<h2 id="heading-overlapping-best-practices">Overlapping Best Practices</h2>
<p><strong>Percentage Rule</strong>: Start with 10-15% overlap and adjust based on your content type.</p>
<p><strong>Sentence Boundaries</strong>: When possible, overlap at complete sentence boundaries rather than mid-sentence.</p>
<p><strong>Content-Specific</strong>: Technical documents might need more overlap than simple FAQ content.</p>
<h2 id="heading-why-rag-wins-the-compelling-advantages">Why RAG Wins: The Compelling Advantages</h2>
<p>After building and deploying several RAG systems myself, I can tell you that the advantages go beyond just technical improvements:</p>
<h2 id="heading-always-current">🔄 Always Current</h2>
<p>Unlike traditional models that become outdated the moment they're trained, RAG systems stay current with your latest data. Update your knowledge base, and your AI instantly knows about it.</p>
<h2 id="heading-domain-expertise">🎯 Domain Expertise</h2>
<p>RAG allows you to create AI systems that are experts in your specific field, whether that's medical research, legal documents, or your company's products.</p>
<h2 id="heading-transparent-decision-making">💡 Transparent Decision Making</h2>
<p>When RAG provides an answer, it can cite its sources. This transparency is crucial for business applications where you need to verify information.</p>
<h2 id="heading-data-security">🔒 Data Security</h2>
<p>Your sensitive information stays in your control. RAG accesses data on-demand rather than incorporating it into model parameters.</p>
<h2 id="heading-fast-deployment">⚡ Fast Deployment</h2>
<p>Setting up a RAG system is significantly faster than training a custom model from scratch. You can have a working system in days rather than months.</p>
<h2 id="heading-the-road-ahead-rags-future">The Road Ahead: RAG's Future</h2>
<p>As we stand on the cusp of even more advanced AI capabilities, RAG represents a fundamental shift in how we think about AI knowledge systems. It's not just about having smarter AI - it's about having <strong>trustworthy, verifiable, and controllable</strong> AI that can adapt to our changing world.</p>
<p>Whether you're building customer support chatbots, internal knowledge systems, or specialized AI assistants, understanding RAG gives you the foundation to create AI applications that are not just impressive, but actually useful and reliable.</p>
<p>The future of AI isn't just about bigger models - it's about smarter architectures that combine the best of human knowledge organization with artificial intelligence capabilities. And RAG is leading that charge.</p>
<p><em>What aspects of RAG are you most excited to explore in your own projects? Have you encountered the hallucination problem in your AI applications? I'd love to hear your thoughts and experiences in the comments below!</em></p>
]]></content:encoded></item><item><title><![CDATA[Unlocking the Power of Agentic AI: How Autonomous Agents, Reasoning, and Tools Are Shaping Tomorrow]]></title><description><![CDATA[Introduction: The Rise of Agentic AI—Beyond Automation, Towards Real Autonomy
Imagine an AI that doesn’t just answer questions, but thinks, acts, and adapts, planning its own path to achieve real outcomes, making decisions on the fly, and wielding di...]]></description><link>https://blogs.kanishk.codes/agentic-ai</link><guid isPermaLink="true">https://blogs.kanishk.codes/agentic-ai</guid><category><![CDATA[AI]]></category><category><![CDATA[agentic AI]]></category><category><![CDATA[genai]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[aitools]]></category><dc:creator><![CDATA[Kanishk Chandna]]></dc:creator><pubDate>Mon, 18 Aug 2025 15:27:59 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1755530798908/b9983704-6b65-4941-b692-d7460abcb4fd.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction-the-rise-of-agentic-aibeyond-automation-towards-real-autonomy">Introduction: The Rise of Agentic AI—Beyond Automation, Towards Real Autonomy</h2>
<p>Imagine an AI that doesn’t just answer questions, but <em>thinks</em>, <em>acts</em>, and adapts, planning its own path to achieve real outcomes, making decisions on the fly, and wielding digital tools to get things done. This isn’t science fiction—it’s happening right now with <strong>Agentic AI</strong>, the next evolution in artificial intelligence that’s captivating both the tech world and mainstream industries. Gartner projects that by 2029, agentic AI will resolve 80% of customer service issues without human intervention, saving businesses billions in costs. But what exactly are agents? How do they work? And what role do tools play in this transformative leap?</p>
<p>Let’s dive deep into the concepts, architectures, and real-world applications that make Agentic AI both fascinating and revolutionary.</p>
<h2 id="heading-what-are-agents-in-aiand-why-are-they-different">What Are Agents in AI—and Why Are They Different?</h2>
<p><strong>Agents</strong> are autonomous systems designed to operate with limited or zero human oversight, carrying out complex tasks toward predefined goals. Unlike traditional AI that simply reacts to inputs or generates outputs, agents:</p>
<ul>
<li><p><strong>Perceive</strong> their environment (through sensors, data, APIs)</p>
</li>
<li><p><strong>Reason</strong> about goals and constraints</p>
</li>
<li><p><strong>Act</strong> by executing external functions, APIs, or physical controls</p>
</li>
<li><p><strong>Learn</strong> and adapt continuously through feedback and memory</p>
</li>
<li><p><strong>Collaborate</strong> with other agents, forming multi-agent teams</p>
</li>
</ul>
<p>In short, an agent isn’t just a passive bot or a chatbot—it’s a decision-maker that can break objectives into steps, adjust plans, and even use external digital tools to complete the task at hand.</p>
<h2 id="heading-how-do-agents-work-the-architecture-of-intelligence">How Do Agents Work? - The Architecture of Intelligence</h2>
<p>At the core of every agent lies a set of interconnected modules. Here’s how they operate in a continuous loop:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Component</strong></td><td><strong>Function</strong></td></tr>
</thead>
<tbody>
<tr>
<td><strong>Perception/Input</strong></td><td>Collect sensory data or receive triggers (API calls, user prompts, sensor inputs)</td></tr>
<tr>
<td><strong>Memory</strong></td><td>Store context, previous decisions, and external information (short-term &amp; long-term)</td></tr>
<tr>
<td><strong>Planning</strong></td><td>Map goals into actions, sequence subtasks, and use reasoning (rule-based, chain-of-thought)</td></tr>
<tr>
<td><strong>Execution</strong></td><td>Interact with real-world tools, APIs, systems (send emails, fetch data, control devices)</td></tr>
<tr>
<td><strong>Feedback Loop</strong></td><td>Evaluate outcomes, retry or adapt plan, learn from successes/failures</td></tr>
</tbody>
</table>
</div><p>Agents combine all these layers to handle tasks from the simple (“book a meeting”) to the wildly complex (“optimize a supply chain during a global disruption”).</p>
<h2 id="heading-agent-architectures-models-in-action">Agent Architectures: Models in Action</h2>
<ul>
<li><p><strong>Reactive Agents:</strong> Fast yet limited; respond instantly to environment (e.g., thermostat)</p>
</li>
<li><p><strong>Model-Based Agents:</strong> Maintain internal models to predict outcomes (e.g., Roomba, mapping routes)</p>
</li>
<li><p><strong>Goal-Based Agents:</strong> Plan multi-step strategies (e.g., self-driving cars, route planning)</p>
</li>
<li><p><strong>Utility-Based Agents:</strong> Optimize for maximum benefit (e.g., Uber dynamic pricing)</p>
</li>
<li><p><strong>Learning Agents:</strong> Adapt and refine over time (e.g., smart email spam filters)</p>
</li>
<li><p><strong>Multi-Agent Systems:</strong> Many agents cooperate or compete to solve large-scale tasks (e.g., air traffic control)</p>
</li>
</ul>
<h2 id="heading-the-role-of-toolsfrom-function-calling-to-real-world-apis">The Role of Tools—From Function Calling to Real-World APIs</h2>
<p>The real magic of agentic AI lies in its capacity for <strong>tool use</strong>—connecting reasoning models with external functionalities. Think of it as giving the agent “digital hands”.</p>
<h2 id="heading-tool-use-amp-function-calling">Tool Use &amp; Function Calling</h2>
<p>Agentic AI employs function calling—where an LLM (Large Language Model) identifies when to invoke an external tool, API, or custom function. The process:</p>
<ol>
<li><p><strong>Recognize Need:</strong> The agent parses a user request (e.g., “What’s the weather in Delhi?”).</p>
</li>
<li><p><strong>Decide on Action:</strong> The LLM determines an API or tool (e.g., <code>get_current_weather</code>).</p>
</li>
<li><p><strong>Execute Function:</strong> The agent calls the tool/API, retrieves the data.</p>
</li>
<li><p><strong>Integrate Results:</strong> Combines the fetched info into a final answer.</p>
</li>
</ol>
<p>Tools can be business apps, external APIs, code editors, databases, even other agents—making agents capable of writing reports, booking resources, running analyses, and more.</p>
<p><strong>Multi-Agent Frameworks</strong> like LangChain, AutoGen, CrewAI, and LangGraph have emerged, allowing developers to build agents that broker tasks, share memory, and even coordinate using role-based collaborations. This modularity means tools can be constantly upgraded—making agents endlessly extensible.</p>
<h2 id="heading-memory-and-learning-how-agents-remember">Memory and Learning: How Agents "Remember"</h2>
<p>Unlike static models, agents use <strong>vector databases</strong>, knowledge graphs, and neural memory modules to store and recall information from previous tasks, user sessions, and even other agents. This enables personalization (“Remember my preferences?”), context retention for long conversations, and lifelong learning. Memory architectures incorporate:</p>
<ul>
<li><p>Short-term (session context)</p>
</li>
<li><p>Long-term (persistent user data)</p>
</li>
<li><p>Episodic (tracking sequence of actions/events)</p>
</li>
<li><p>Semantic (general facts &amp; learned knowledge)</p>
</li>
<li><p>Procedural (decision rules &amp; task steps)</p>
</li>
</ul>
<p>Frameworks like LangChain use vector stores (Pinecone, ChromaDB) to give agents real semantic recall, not just keyword matching.</p>
<h2 id="heading-how-agents-reason-and-act-the-react-paradigm">How Agents Reason and Act: The ReAct Paradigm</h2>
<p>The cutting-edge <strong>ReAct</strong> agent design blurs the lines between thought and action. Rather than simply returning an answer, a ReAct agent alternates between:</p>
<ul>
<li><p><strong>Thought:</strong> Internally reasons about the next step</p>
</li>
<li><p><strong>Action:</strong> Executes a tool/API call or searches knowledge</p>
</li>
<li><p><strong>Observation:</strong> Integrates external results into reasoning</p>
</li>
</ul>
<p>This cycle repeats, just like a human solving a problem step-wise, until the agent is satisfied with the outcome or reaches the final solution.</p>
<p>Here’s an example trace:</p>
<pre><code class="lang-json">textThought: I need to fetch today’s weather for Mumbai.
Action: Call get_current_weather(Mumbai)
Observation: Sunny, <span class="hljs-number">34</span>°C
Thought: Advise the user on what to pack.
Final Answer: It’s sunny in Mumbai at <span class="hljs-number">34</span>°C—don’t forget sunglasses and water!
</code></pre>
<p>This loop makes agents flexible, self-correcting, and highly adaptive—able to consult references online, calculate, search, and synthesize.</p>
<h2 id="heading-real-world-applications-where-agentic-ai-already-rules">Real-World Applications: Where Agentic AI Already Rules</h2>
<p>Agentic AI isn’t just a buzzword; it’s deeply embedded in the products and services people use daily—even if they don’t notice:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Domain</strong></td><td><strong>Example Uses</strong></td></tr>
</thead>
<tbody>
<tr>
<td><strong>Healthcare</strong></td><td>Diagnostics, personalized treatment, surgery assistance</td></tr>
<tr>
<td><strong>Customer Service</strong></td><td>Dynamic chatbots, smart assistants, 24/7 support</td></tr>
<tr>
<td><strong>Finance</strong></td><td>Fraud detection, dynamic pricing, automated trading</td></tr>
<tr>
<td><strong>Marketing</strong></td><td>Personalized ads, campaign automations, content creation</td></tr>
<tr>
<td><strong>Supply Chain &amp; Logistics</strong></td><td>Route optimization, demand prediction, automated procurement</td></tr>
<tr>
<td><strong>Autonomous Vehicles &amp; Drones</strong></td><td>Navigation, obstacle avoidance, real-time decision-making</td></tr>
<tr>
<td><strong>Smart Manufacturing</strong></td><td>Predictive maintenance, load balancing, process optimization</td></tr>
<tr>
<td><strong>Cybersecurity</strong></td><td>Network anomaly detection, autonomous threat response</td></tr>
<tr>
<td><strong>Content Moderation</strong></td><td>Scanning social media, flagging harmful content</td></tr>
<tr>
<td><strong>Human Resources</strong></td><td>Recruitment, resume screening, interview scheduling</td></tr>
<tr>
<td><strong>Energy</strong></td><td>Smart grid management, energy distribution, fault detection</td></tr>
<tr>
<td><strong>E-commerce</strong></td><td>Personalized shopping assistants, recommendation engines</td></tr>
<tr>
<td><strong>Entertainment</strong></td><td>Dynamic music/movie suggestions (Spotify, Netflix)</td></tr>
</tbody>
</table>
</div><p>More industries are embracing agentic AI every day, unlocking efficiencies and new user experiences.</p>
<h2 id="heading-closing-thoughts-the-future-of-agentic-ai-is-bang-in-the-middle-of-your-daily-life">Closing Thoughts: The Future of Agentic AI Is Bang in the Middle of Your Daily Life</h2>
<p>Agentic AI isn’t just reshaping software—it’s changing the very fabric of how businesses and humans interact with technology. Autonomous, goal-driven, endlessly adaptive, and tool-equipped—agents are the architects of tomorrow’s intelligent workflows.</p>
<p>If you’re a developer, the message is clear: mastering agentic systems, multi-agent frameworks, and tool integration is the fast track to building the next generation of digital experiences.</p>
<p>And for everyone else? You’re already living in an agentic world—ask your virtual assistant what it did to fulfil your last request, and you’ll get a glimpse of how many agents just collaborated to make it happen.</p>
<p><strong>Catchy Headline Variations:</strong></p>
<ul>
<li><p>"Agentic AI Unleashed: Autonomous Agents and the Tools That Make Them Superhuman"</p>
</li>
<li><p>"From Chatbots to Autonomous Decision-Makers: The Agentic AI Revolution Explained"</p>
</li>
<li><p>"Inside Agentic AI: How Digital Agents Plan, Act, and Shape the Future"</p>
</li>
</ul>
<p>Keep following the AI space—it’s not just getting smarter; it’s getting agentic.</p>
]]></content:encoded></item></channel></rss>