<?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[Manmeet's blog]]></title><description><![CDATA[Personal Blog showcasing my developer's journey]]></description><link>https://blog.thatsmanmeet.com</link><image><url>https://cdn.hashnode.com/uploads/logos/689aa088b1d1b903cb32612c/5b9e82cf-bb1f-4ae7-8c82-e4b9ef23b88c.jpg</url><title>Manmeet&apos;s blog</title><link>https://blog.thatsmanmeet.com</link></image><generator>RSS for Node</generator><lastBuildDate>Wed, 08 Apr 2026 12:42:52 GMT</lastBuildDate><atom:link href="https://blog.thatsmanmeet.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[React Native Fabric Rendering Explained]]></title><description><![CDATA[In the previous article, we explored the legacy and new architecture of React Native, examining various components used in the new architecture. However, we did not delve deeply into the Fabric pipeli]]></description><link>https://blog.thatsmanmeet.com/react-native-fabric-rendering-explained</link><guid isPermaLink="true">https://blog.thatsmanmeet.com/react-native-fabric-rendering-explained</guid><category><![CDATA[React Native]]></category><category><![CDATA[React]]></category><category><![CDATA[Mobile Development]]></category><category><![CDATA[mobile app development]]></category><category><![CDATA[Cross Platform App Development. ]]></category><dc:creator><![CDATA[Manmeet Singh]]></dc:creator><pubDate>Thu, 12 Mar 2026 12:17:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/689aa088b1d1b903cb32612c/1ead2c54-1a5f-4049-bb9c-4ffa39c57477.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the previous article, we explored the legacy and new architecture of React Native, examining various components used in the new architecture. However, we did not delve deeply into the Fabric pipeline. Therefore, this article focuses on the Fabric Renderer and how React Native renders layouts.</p>
<h2>What is Fabric Renderer</h2>
<p>Fabric is React Native's new rendering system that utilizes the JavaScript Interface (JSI) and the Yoga layout library to render the native UI on the target platform. Unlike the old rendering system, which relied on a large JSON dump and was asynchronous, the new Fabric system uses JSI to directly invoke C++ methods, allowing for synchronous updates to the native layout without any performance drop.</p>
<p>Fabric rendering have multiple phases:</p>
<ol>
<li><p><strong>Render Phase</strong>: React executes the code and create a React Element tree which is then uses C++ to translate it to a React shadow tree.</p>
</li>
<li><p><strong>Commit Phase</strong>: Yoga library uses the shadow tree and decided the exact mathematical coordinates of the components and decides the layout.</p>
</li>
<li><p><strong>Mount Phase</strong>: Native side will render layout on the screen based on the information from the yoga tree</p>
</li>
</ol>
<p>Let's say you want to render a <code>&lt;View&gt;</code> with a <code>&lt;Text&gt;</code> component inside it as shown in the code example below:</p>
<pre><code class="language-javascript">export default function HomePage(){
    return (
    &lt;View&gt;
       &lt;Text&gt;Home Page&lt;/Text&gt;
    &lt;/View&gt;
    )
}
</code></pre>
<h3>Render Phase</h3>
<img src="https://cdn.hashnode.com/uploads/covers/689aa088b1d1b903cb32612c/55ffcada-8320-4783-a4e0-026a448da17f.svg" alt="" style="display:block;margin:0 auto" />

<p>In the Render phase, React executes the JavaScript logic, and for every React component, it creates a React Element tree. This is standard React behavior, while at the same time, the Fabric renderer steps in.</p>
<p>The Fabric renderer utilizes C++ to synchronously generate a Shadow element for each React Host Component (such as View or Text) from the React Tree, thereby creating a Shadow Tree.</p>
<p>The React Renderer establishes the same relationships among Shadow Node elements as React does among its multiple React Nodes, resulting in the creation of the <strong>React Shadow Tree.</strong></p>
<p>As this step is performed synchronously using the JSI, there is no serialization overhead.</p>
<p>Now, we have the blueprint of what to draw on the screen, but we don't know the exact location or size of these individual nodes, hence we proceed to the commit phase.</p>
<h3>Commit Phase</h3>
<img src="https://cdn.hashnode.com/uploads/covers/689aa088b1d1b903cb32612c/46cd0a7d-372f-42ce-b074-9d24fa04478d.svg" alt="" style="display:block;margin:0 auto" />

<p>In the Commit Phase, the exact coordinates of the Shadow Nodes to be displayed on the screen are calculated. This involves two asynchronous operations: <strong>Layout Calculation and Tree Promotion.</strong></p>
<ol>
<li><p><strong>Layout Calculation:</strong> During this step, the Renderer calls the Yoga Layout Library to determine the precise <strong>size (height and width)</strong> and <strong>coordinates (X and Y)</strong> for each shadow node in the React Shadow Tree. This layout calculation is primarily handled in C++, except in certain situations where component size or location must be computed on the host platform. In such cases, the Yoga library triggers a native function to perform these calculations on the native layer.</p>
</li>
<li><p><strong>Tree Promotion:</strong> Once the layout math has been completed, then this React Shadow Tree is promoted as the <strong>official</strong> <strong>next tree</strong>, as it has all the information ready to be painted on the screen.</p>
</li>
</ol>
<p>Both of the above operations are asynchronous in nature and executes on the background thread.</p>
<p>We have the blueprint, and we have the exact coordinates. The final step is to actually draw the native UI elements.</p>
<h3>Mount Phase</h3>
<img src="https://cdn.hashnode.com/uploads/covers/689aa088b1d1b903cb32612c/e8d576fb-2be4-4b71-9c29-7e2590435313.svg" alt="" style="display:block;margin:0 auto" />

<p>Mount phase, transforms the C++ React Shadow Tree into <strong>Host View Tree,</strong> hence rendering the actual components on the screen.</p>
<p>So the React code we originally had, which looked like this:</p>
<pre><code class="language-javascript">&lt;View&gt;
&lt;Text&gt;HomePage&lt;/Text&gt;
&lt;/View&gt;
</code></pre>
<p>will be converted to its respective container called as <strong>Host View</strong> for each component and is then mounted on the screen.</p>
<p><strong>Android</strong></p>
<p>For Android, the <code>View</code> component will be converted to <code>android.view.viewGroup</code> and the <code>Text</code> component will be converted to <code>android.widget.TextView</code> and populates the text "HomePage" inside it.</p>
<p><strong>iOS</strong></p>
<p>For iOS, the <code>View</code> component will be converted to <code>UIView</code> and the <code>Text</code> component will be converted to <code>UITextView</code> and populates the text "HomePage" inside it with the help of <code>NSLayoutManager</code>.</p>
<p>Now the <strong>Mount Phase,</strong> itself consist of three different operations.</p>
<ol>
<li><p><strong>Tree Diffing:</strong> The C++ engine calculates the fundamental differences between the previously rendered tree and the new one. This process identifies minor changes, such as a background color alteration, to be applied to the UI, and then produces a list of necessary operations**.**</p>
<ol>
<li><strong>Note:</strong> If it's the initial render, the "previously rendered tree" is empty, so the resulting list will only include operations related to creating the views, setting properties, and so on.</li>
</ol>
</li>
<li><p><strong>Tree Promotion:</strong> The "next tree" officially becomes the "rendered tree". This can be used for further comparison in tree diffing in case of any state updates.</p>
</li>
<li><p><strong>View Mounting:</strong> The calculated changes are applied to the native host views. This happens synchronously on the main UI thread.</p>
</li>
</ol>
<p>The operations are synchronously executed on UI thread. If the commit phase executes on background thread, the mounting phase is scheduled for the next “tick” of UI thread. On the other hand, if the commit phase executes on UI thread, mounting phase executes synchronously on the same thread.</p>
<img src="https://cdn.hashnode.com/uploads/covers/689aa088b1d1b903cb32612c/562179e1-d87b-4497-bf95-7661a66718b7.svg" alt="" style="display:block;margin:0 auto" />

<p>The above diagram shows the complete process of Fabric Rendering in React Native.</p>
<h4>What Happens When State Changes?</h4>
<p>Let's say a user taps a button and changes a background color from red to yellow. How does Fabric handle this without rebuilding everything?</p>
<p>React enforces immutability. To ensure thread safety, the React Shadow Tree cannot be mutated directly. Instead, React creates a <em>new</em> tree. But doing this from scratch every time would be a performance nightmare.</p>
<p>To solve this, Fabric uses <strong>Structural Sharing</strong>. When your state updates, React only clones the specific nodes that were affected by the change, plus their direct path up to the root. All the other unchanged components are simply <em>shared</em> between the old tree and the new tree. This drastically reduces memory consumption and makes state updates incredibly fast.</p>
<h2>Conclusion</h2>
<p>And there you go! Now you understand how React Native's new rendering system, "Fabric," works. Since we already covered the old and new architecture, you now have a solid foundation in the fundamentals of React Native.</p>
]]></content:encoded></item><item><title><![CDATA[React Native Architecture Explained]]></title><description><![CDATA[If you’ve been doing web development for a while, chances are you rely on React to build your frontends. You ship a solid web app. It works well. Users like it and you realise it needs a mobile app.
Y]]></description><link>https://blog.thatsmanmeet.com/react-native-architecture-explained</link><guid isPermaLink="true">https://blog.thatsmanmeet.com/react-native-architecture-explained</guid><category><![CDATA[React]]></category><category><![CDATA[React Native]]></category><category><![CDATA[architecture]]></category><category><![CDATA[Mobile Development]]></category><category><![CDATA[Cross Platform App Development. ]]></category><dc:creator><![CDATA[Manmeet Singh]]></dc:creator><pubDate>Wed, 25 Feb 2026 04:41:29 GMT</pubDate><enclosure url="https://cloudmate-test.s3.us-east-1.amazonaws.com/uploads/covers/689aa088b1d1b903cb32612c/9d174a9f-21d3-4e2f-954a-1a4ca9ae6f38.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you’ve been doing web development for a while, chances are you rely on React to build your frontends. You ship a solid web app. It works well. Users like it and you realise it needs a mobile app.</p>
<p>You start researching and hit a wall, you need Kotlin for Android and Swift for iOS. You start questioning yourself: Do I really need to learn two separate languages? Master completely different tooling? Maintain two isolated codebases?</p>
<p>It sounds like an absolute nightmare. But just as you're about to give up, you stumble into the territory of cross-platform development and discover <strong>React Native</strong>. It’s a framework that lets you write mobile apps using JavaScript and React, tools you already know and with a single codebase that targets both Android and iOS natively.</p>
<p>Suddenly, building mobile apps doesn’t feel like starting from zero. It feels like an extension of what you already know. In this article, we are going to tear down React Native and understand exactly how its architecture works.</p>
<h2>What is React Native</h2>
<p>React Native is an open-source framework that allows developer to build native mobile applications for multiple platforms (Android, iOS, Mac, Windows) using JavaScript programming language and React library.</p>
<p>Unlike hybrid frameworks that render inside a WebView (essentially embedding a browser inside a mobile app), React Native renders real, platform-specific native components.</p>
<p>Let's take this code:</p>
<pre><code class="language-javascript">&lt;View&gt;
  &lt;Text&gt;Hello World&lt;/Text&gt;
&lt;/View&gt;
</code></pre>
<p>The above code does not translate into the HTML. Rather it's actually converted into the Native component of the specified platforms.</p>
<ul>
<li><p><code>View</code> will get converted to the <code>ViewGroup</code> component on Android and <code>UIView</code> on iOS, which are just native components, which acts as the layout containers, holding other components.</p>
</li>
<li><p><code>Text</code> will get converted to the <code>TextView</code> component on Android and <code>UITextView</code> on iOS, which are again the native components, used to render the text on the screens.</p>
</li>
</ul>
<p>They are the same building blocks you would use if you were writing the app directly in Kotlin or Swift. This means apps feel more like they belong on the device they're running on, offering a smoother and more responsive user experience.</p>
<h2>How React Adapts to Web and Mobile</h2>
<p>You might wonder how React, commonly used to build website front-ends, can also render native components for mobile operating systems. Is it really the same React used for the web?</p>
<p>Yes and no. The core React library is consistent across both web and mobile ecosystems, but the difference lies in how components are rendered.</p>
<p>Have a look at the diagram below:</p>
<img src="https://cloudmate-test.s3.us-east-1.amazonaws.com/uploads/covers/689aa088b1d1b903cb32612c/e8c069c4-bc3a-477a-af6d-ddb7a3f4a58e.svg" alt="" style="display:block;margin:0 auto" />

<p>To understand React Native, you need to understand a surprising truth i.e . <strong>React doesn't know how to render an UI on the Screen.</strong></p>
<p>Look at the diagram above. At the very top sits the <strong>React Library</strong>. This is the brain of the operation. The function of the core react library is to manage the state using hooks such as <code>useState</code> and <code>useEffect</code> and calculates which part of the UI needs to be updated based on data changes using a process called Reconciliation. React library itself doesn't know what a HTML <code>div</code> is or what an android <code>ViewGroup</code> is.</p>
<p>That job of rendering the UI is done by the <strong>Renderer</strong>.</p>
<p>This architecture is what allows React to exist anywhere. You keep the same React Core at the top, but you swap out the Renderer depending on which platform you are targeting.</p>
<ol>
<li><p><strong>React-DOM Renderer:</strong> When building for the web, we use a renderer called <code>react-dom</code>. Since browsers natively understand JavaScript, the process is straightforward and synchronous in nature. The <code>react-dom</code> takes the blueprint from the react core and directly manipulates the DOM on the browser.</p>
</li>
<li><p><strong>React-Native Renderer:</strong> Since Mobile platforms like Android &amp; iOS doesn't understand the JavaScript natively, we require a different renderer known as <code>react-native</code> which takes the blueprint from react core and send it across the <strong>JS</strong> <strong>Bridge (old arch)</strong> asynchronously, which tells the mobile OS, to render the native component with specific properties (like color, size etc).</p>
</li>
</ol>
<p>React does not render anything by itself. The renderer determines whether your components become DOM nodes or native UI views.</p>
<p>Now, we have a solid introduction of React Native, it's time to go behind the scenes with the architecture.</p>
<h2>JS Bridge Architecture</h2>
<p>The Bridge Architecture, also known as the <strong>Legacy Architecture</strong>, was how React Native applications originally worked. This was the default architecture before <strong>React Native v0.76</strong>.</p>
<p>Let's understand how the old architecture used to work.</p>
<img src="https://cdn.hashnode.com/uploads/covers/689aa088b1d1b903cb32612c/d4e2f2b3-c582-4527-95a6-07fa921e0c16.svg" alt="" style="display:block;margin:0 auto" />

<h3>Phase 1: Build Time (The Setup)</h3>
<ol>
<li><p>In the build phase, all the JavaScript code, react components, assets are taken from our codebase and are bundled into a single optimised file known as <strong>JS Bundle</strong> using the <strong>Metro Bundler.</strong></p>
</li>
<li><p>This static bundle is the blueprint of your entire application and is embedded with your application during the build time.</p>
</li>
<li><p>Once the app is installed, Metro is no longer involved. Everything from this point forward happens at runtime.</p>
</li>
</ol>
<h3>Phase 2: Run Time (The Execution)</h3>
<p>When the user taps on your app, three different threads are fired for execution of our app:</p>
<ol>
<li><p><strong>JavaScript Thread</strong>: The J<strong>avaScript Engine (JSC)</strong> would boot up and start executing the <strong>JS Bundle</strong> which is embedded in our app. This is where our JavaScript code will be executed and holds all the react logic, state and performs the API calls as well to fetch the data.</p>
</li>
<li><p><strong>UI Thread:</strong> The UI thread will spawn on your mobile OS, which will allow it to paint the initial UI of the app for the interaction based on the instructions it received.</p>
</li>
<li><p><strong>Shadow Thread:</strong> This thread will be used by the <strong>Yoga Library</strong>, that will calculate the entire layout of the app and provides the instructions to the UI Thread on how to render the layout.</p>
</li>
</ol>
<h3>Phase 3: Execution Phase</h3>
<ol>
<li><p>Whenever a user taps on the button, let's say this button will change the colour of the background, then firstly the UI Thread will capture the Tap event on the button.</p>
</li>
<li><p>Since the Native UI cannot execute a JavaScript function directly, it will serialize the touch event into a JSON and will send this even to the <strong>asynchronous bridge.</strong></p>
</li>
<li><p>The JS Bridge will sent this information to the JavaScript engine (JSC), which will deserialize the JSON, process the JavaScript code, let's say update the state using <code>useState</code> and React calculates the new UI based on the changes.</p>
</li>
<li><p>The JS Thread now serializes these instructions in the JSON format and will again send it to the asynchronous bridge.</p>
</li>
<li><p>The Shadow Thread will receive this JSON, and the <strong>Yoga</strong> library will read these instructions and will calculate exact coordinates and properties of the element and will pass it to the <strong>UI Thread</strong> to finally paint the updated screen.</p>
</li>
</ol>
<h3>Limitations of the Asynchronous Bridge</h3>
<p>There were a few limitations of the asynchronous bridge but the biggest ones were the <strong>bridge and the JSON</strong>, as you can see from the diagram above.</p>
<ol>
<li><p><strong>Serialization Bottleneck:</strong> Since mobile platforms and JavaScript cannot directly communicate, they rely on JSON for interaction. Stringifying and parsing JSON costs CPU cycles. This serialization and deserialization process through the asynchronous bridge introduces significant latency, and handling a large number of events can lead to lag and frame drops on the native side.</p>
</li>
<li><p><strong>Asynchronous Bridge:</strong> The serialization and deserialization process isn't inherently problematic, but the issue arose from relying on a single asynchronous bridge. Because JavaScript cannot directly interact with the native side to modify the UI, each event must pass through the entire message-passing phase on the bridge. With a large volume of JSON messages, the bridge often becomes congested, leading to frame drops, laggy animations, and the notorious blank white screens when rendering lists.</p>
</li>
<li><p><strong>Single JavaScript Thread:</strong> All code processing must occur on the JavaScript Thread. Although there are separate threads, such as UI Threads, the majority of application logic is managed by the JavaScript thread. Consequently, intensive computations can block this thread, leading to noticeable performance declines across the entire app.</p>
</li>
</ol>
<p>Since, React Native doesn't block the Main Thread, that's why everything needs to be done in asynchronous way. Hence every event becomes a promise/callback.</p>
<h2>New Architecture</h2>
<p>The React Native core team soon understood that optimizing the JSON Bridge wouldn't lead to the desired performance improvements. Therefore, they chose to eliminate the asynchronous JS Bridge altogether.</p>
<img src="https://cdn.hashnode.com/uploads/covers/689aa088b1d1b903cb32612c/9a67ce78-5d12-4335-9840-b1e56ce22527.svg" alt="" style="display:block;margin:0 auto" />

<p>The bridge has now been replaced with the JavaScript Interface (JSI), featuring C++ bindings that directly call the native API of mobile platforms, bypassing the serialization/deserialization and message-passing process. This enhances the overall app performance.</p>
<h3>Hermes Engine</h3>
<ol>
<li><p>Hermes Engine is an open source JavaScript engine created by Meta for improving the performance of the React Native apps.</p>
</li>
<li><p>It is heavily optimized for the React Native and uses JSI to directly communicate with the native platforms using Native APIs.</p>
</li>
<li><p>It provides other benefits like Improved time to interactive (TTI), smaller app bundle size and reduced memory consumption.</p>
</li>
<li><p>It replaced the old JSC and became the default for React native apps starting from version 0.70 of RN.</p>
</li>
</ol>
<h3>JavaScript Interface (JSI)</h3>
<ol>
<li><p>JavaScript Interface (JSI) is the new lightweight C++ layer that allows the JavaScript to directly communicate with the Native code.</p>
</li>
<li><p>JSI replaced the old legacy bridge architecture which means that no message passing or asynchronous operations are required.</p>
</li>
<li><p>JSI allows JavaScript to hold the references to C++ host objects and invoke methods directly on them in a synchronous manner.</p>
</li>
</ol>
<img src="https://cdn.hashnode.com/uploads/covers/689aa088b1d1b903cb32612c/ee7403b6-652d-4445-b645-4842fc4bd8b0.svg" alt="" style="display:block;margin:0 auto" />

<p>Because of JSI, JavaScript can now hold direct references to C++ Host Objects e.g. <code>nativeObjectRef</code>. When JavaScript calls <code>nativeObjectRef.setProperty()</code>, it isn't sending a JSON message to a queue; it is <strong>synchronously</strong> invoking a method on the C++ object located in the native side.</p>
<h3>Turbo Modules</h3>
<ol>
<li><p>In legacy architecture, if you need to use some native functionality such as Bluetooth, camera etc, then those native modules were loaded eagerly, on the startup and stayed loaded in the memory in case they were needed later.</p>
</li>
<li><p>Due to these reasons, in legacy architecture the native modules would take more time to load, significantly increase the memory footprint and makes the app slow.</p>
</li>
<li><p>However with introduction to Turbo Modules in the new architecture, now these modules are lazily loaded.</p>
</li>
<li><p>As turbo modules are loaded only when they are required, this allowed to reduce the memory footprint and also enhances the performance a lot.</p>
</li>
</ol>
<h3>Fabric System</h3>
<ol>
<li><p>Fabric is the new rendering system which utilizes the JSI and Yoga library to manage the UI on the native side.</p>
</li>
<li><p>In the legacy architecture, if JavaScript wanted to render a massive list, it had to serialize a huge JSON payload, dump it into the queue, and hope the UI thread wouldn't drop frames. It was asynchronous in nature.</p>
</li>
<li><p>With Fabric, JavaScript uses JSI to directly invoke the C++ methods that create and update the native views (like <code>UIView</code> on iOS or <code>ViewGroup</code> on Android) synchronously.</p>
</li>
<li><p>Fabric render pipeline have multiple phases:</p>
<ol>
<li><p>Render Phase: React executed the code and create a React Element tree which is then uses C++ to translate it to a React shadow tree.</p>
</li>
<li><p>Commit Phase: Yoga library uses the shadow tree and decided the exact mathematical coordinates of the components and decides the layout.</p>
</li>
<li><p>Mount Phase: Native side will render layout on the screen based on the information from the yoga tree</p>
</li>
</ol>
</li>
</ol>
<p>In this article, I am not going into the workings of the Fabric, but may create a separate article in future for this.</p>
<h2>Conclusion</h2>
<p>At this point, you have a solid understanding of what React Native is and exactly how it operates under the hood.</p>
<p>We've explored how the Legacy Architecture functioned, why the asynchronous JSON Bridge became a major performance bottleneck, and how the React Native core team solved it by rewriting the engine with C++ and JSI.</p>
<p>What are you waiting for? Go build that app!</p>
]]></content:encoded></item><item><title><![CDATA[Web Browser Internals Explained]]></title><description><![CDATA[We all use web browsers every day. Whether it's surfing social media, watching videos on YouTube, or doing a quick search, browsers have become such an essential part of our lives that we hardly notice them. However, behind this impressive technology...]]></description><link>https://blog.thatsmanmeet.com/web-browser-internals-explained</link><guid isPermaLink="true">https://blog.thatsmanmeet.com/web-browser-internals-explained</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[Browsers]]></category><category><![CDATA[Browser Internals]]></category><dc:creator><![CDATA[Manmeet Singh]]></dc:creator><pubDate>Thu, 05 Feb 2026 04:39:12 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1770227235201/ac083996-4cd5-4ade-becf-ce73afa8f1d9.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>We all use web browsers every day. Whether it's surfing social media, watching videos on YouTube, or doing a quick search, browsers have become such an essential part of our lives that we hardly notice them. However, behind this impressive technology is some great engineering, and that's what we will explore today.</p>
<p>Before we dive in deeply, let's first address the obvious question: What exactly is a web browser?</p>
<h2 id="heading-what-is-a-web-browser">What is a Web Browser</h2>
<p>A web browser is a software application used to access and retrieve information and resources from the World Wide Web, acting as an interface between the user and the internet. Simply put, a web browser is an application that lets a user visit websites.</p>
<p>Technically Speaking, A browser is a compiler and rendered which takes the raw text resources like HTML, CSS and JS and convert them into the visual representations on the screen.</p>
<p>There are some excellent web browsers available, such as Chrome, Edge, Firefox, Safari, and Brave.</p>
<h2 id="heading-components-of-web-browser">Components of Web Browser</h2>
<p>A web browser consists of multiple components such as:</p>
<ol>
<li><p><strong>User Interface:</strong> This is the Graphical User Interface (GUI) part of the browser that the user can see and interact with. For example, in the Chrome browser, this includes the opening window with an address bar, bookmarks, shortcuts, and similar UI features that a user can see and interact with.</p>
</li>
<li><p><strong>Browser Engine</strong>: This part acts as the bridge between the User Interface (UI) and the Rendering Engine.</p>
</li>
<li><p><strong>Rendering Engine:</strong> This is the core of the browser. It transforms documents like HTML and CSS into their respective trees (DOM &amp; CSSOM), which are used to display content on the webpage. In other words, it turns code into pixels. There are many rendering engines, such as Blink, Gecko, and Webkit.</p>
</li>
<li><p><strong>Networking</strong>: This component is very useful for performing network operations like DNS resolution and fetching resources such as HTML, CSS, and images from servers.</p>
</li>
<li><p><strong>JS Interpreter</strong>: This component runs the JavaScript code on our website. It is also known as the JavaScript engine which parses and executes the JavaScript code. Modern Engines also use JIT (Just In Time) Compilation to speed up this process. There are many popular JavaScript engines, such as V8, SpiderMonkey, and WebKit.</p>
</li>
<li><p><strong>UI Backend:</strong> This component interacts with the operating system and allows the display of UI components to users, such as windows and buttons in the browser's interface.</p>
</li>
<li><p><strong>Disk Persistence:</strong> This Layer lets the browser store and retrieve data from the system's storage with the operating system's permission. This includes storage options like Cookies, LocalStorage, and SessionStorage.</p>
</li>
</ol>
<h2 id="heading-how-a-webpage-is-rendered">How a WebPage is Rendered?</h2>
<p>Now let’s go behind the scenes, of what happens when you enter a URL and access a website on the browser.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1770262567678/09c6194c-ace8-4b25-8180-8eb98d7fbee4.png" alt class="image--center mx-auto" /></p>
<ol>
<li><p>When you type a URL into the browser (e.g., thatsmanmeet.com), the Network Layer handles DNS resolution and sends a request to the server. It retrieves resources like HTML, CSS, and other elements such as images and fonts.</p>
</li>
<li><p>Once the HTML and CSS are fetched, these documents are sent to their respective <strong>Parsers</strong>. The Parser converts the raw text in these files into their respective Object Models.</p>
<ol>
<li><p>For HTML, the raw text like <code>&lt;p&gt;Hello&lt;/p&gt;</code> is broken into tokens and converted into objects known as Nodes. A <strong>Node</strong> is a single element or component on the webpage that represents an HTML element. These Nodes are arranged into a tree-like structure known as the <strong>Document Object Model (DOM).</strong></p>
</li>
<li><p>For CSS, the raw text file is also broken into tokens and then parsed into another tree-like structure known as the <strong>CSS Object Model (CSSOM).</strong> This tree represents all the styles associated with the DOM Nodes. This step is important because the browser needs to decide which rule takes precedence among the browser default, user-defined stylesheets, or inline styles.</p>
</li>
</ol>
</li>
<li><p>Once both the <strong>DOM and CSSOM</strong> trees are built, they are combined into a single structure called the <strong>Render Tree.</strong> This process is also known as frame construction in the Gecko Engine. This structure only includes the elements that will be visible on the webpage. Therefore, the Render Tree determines which elements will be displayed on the webpage.</p>
<ol>
<li><p>Elements with the <code>display:none</code> CSS property exist in the DOM but not in the Render Tree.</p>
</li>
<li><p>Elements with <code>visibility: hidden</code> exist in both the DOM and Render Tree, but they take up empty space.</p>
</li>
<li><p>Meta tags like <code>&lt;head&gt;</code>, <code>&lt;meta&gt;</code>, <code>&lt;script&gt;</code>, etc., are also excluded from the Render Tree.</p>
</li>
</ol>
</li>
<li><p>Now that our parsing phase is complete, the browser will begin the rendering process.</p>
</li>
<li><p>At this point, the browser knows what to draw or render, thanks to the Render Tree, but it doesn’t know where each element should be placed on the page. For example, it doesn’t know whether the footer should be at the top or bottom of the page. This is where the next phase, <strong>Layout (Reflow)</strong>, comes into play.</p>
</li>
<li><p>In the <strong>Layout (Reflow)</strong> phase, the browser calculates the exact position and size of every element in the Render Tree to be shown in the viewport. It also determines the exact pixel coordinates of every frame (box), taking into account padding, margins, borders, and other information. This is a computationally expensive process.</p>
</li>
<li><p>Now the browser knows where to draw everything. Next comes the <strong>Painting</strong> process, which converts the layout into pixels. The browser fills in the pixels with text colors, background images, images, shadows, borders, etc. This is usually done in multiple layers, similar to how Photoshop works.</p>
</li>
<li><p>Finally, we reach the <strong>Display</strong> phase, which includes another process known as <strong>Compositing</strong>. Since the browser paints in layers, it needs to flatten the layout to display it properly on the screen. Through the process of compositing, the image is finally displayed on the screen.</p>
</li>
</ol>
<h3 id="heading-the-javascript-interruption">The JavaScript Interruption</h3>
<p>You might have noticed that we didn't mention JavaScript in the flow above. That is because strictly speaking, JavaScript is an <strong>interruption</strong> to the rendering process.</p>
<p>When the HTML Parser is happily building the DOM and encounters a <code>&lt;script&gt;</code> tag, everything stops.</p>
<p>The browser stops building the DOM because it doesn't know what changes the JavaScript might make, such as adding, removing, or editing elements. So, the browser hands control over to the JavaScript Engine (like V8) to interpret and run the JavaScript code.</p>
<p>Only after the JavaScript finishes running does the Rendering Engine continue building the DOM. This is why it's usually recommended to place <code>&lt;script&gt;</code> tags at the end of HTML documents, just before the closing <code>body</code> tag, so the DOM construction isn't interrupted.</p>
<p>If a <code>&lt;script&gt;</code> tag is placed inside the <code>&lt;head&gt;</code> and the JavaScript file being loaded is quite large, the user would just see a blank white or black page, which would be a poor user experience.</p>
<h3 id="heading-reflow-vs-repaint">Reflow vs Repaint</h3>
<p>It is often confusing to understand the difference between Reflow and Repaint, but distinguishing between them is crucial for writing performant CSS.</p>
<ul>
<li><p><strong>Reflow:</strong> Reflow happens when you change the layout or geometry of the page. The browser has to re-calculate the positions and dimensions of elements. Changing properties like <code>width</code>, <code>height</code>, <code>margin</code>, <code>position</code>, or resizing the browser window. This is computationally expensive as single element causing reflow can cause browser to recalculate the layout for its parents and children as well.</p>
<ul>
<li><strong>Example:</strong> You hover over an element and it expands from 200px to 400px, pushing all other text down.</li>
</ul>
</li>
<li><p><strong>Repaint:</strong> Repaint happens when you change the look of an element without changing its <em>size</em> or position. Changing properties like <code>color</code>, <code>background-color</code>, or <code>visibility</code>. This skips the Layout phase entirely and is much faster than a Reflow because the browser doesn't need to do any geometry calculations.</p>
<ul>
<li><strong>Example:</strong> You hover over a button and its background color shifts from blue to dark blue.</li>
</ul>
</li>
</ul>
<h3 id="heading-conclusion">Conclusion</h3>
<p>A browser is far more than just a window to the internet. To the average user, the web feels like magic. But as developers, we now know it is actually a precise feat of engineering. You now understand exactly what happens under the hood from the moment a URL is typed to the millisecond the pixels appear on the screen.</p>
]]></content:encoded></item><item><title><![CDATA[Emmet for HTML: A Beginner’s Guide to Writing Faster Markup]]></title><description><![CDATA[When you first learn HTML, you might wonder if you need to manually type all these tags and elements. It seems like it would take a lot of time and effort, but it is possible. However, you might also ask if there's a faster way to write HTML.
That's ...]]></description><link>https://blog.thatsmanmeet.com/emmet-for-html-a-beginners-guide-to-writing-faster-markup</link><guid isPermaLink="true">https://blog.thatsmanmeet.com/emmet-for-html-a-beginners-guide-to-writing-faster-markup</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[Emmet]]></category><category><![CDATA[HTML]]></category><category><![CDATA[coding]]></category><dc:creator><![CDATA[Manmeet Singh]]></dc:creator><pubDate>Thu, 29 Jan 2026 18:30:05 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769668385304/6debf971-e8e9-4617-be30-ea99f2419730.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When you first learn HTML, you might wonder if you need to manually type all these tags and elements. It seems like it would take a lot of time and effort, but it is possible. However, you might also ask if there's a faster way to write HTML.</p>
<p>That's where Emmet comes in.</p>
<h2 id="heading-what-is-emmet">What is Emmet?</h2>
<p>Emmet is a plugin for text editors and IDEs that allows for quick auto-completion and editing of code in languages like HTML, XML, XSLT, CSS, and others.</p>
<p>Think of Emmet as a fast autocomplete, similar to the autocomplete feature on your mobile keyboard, but for coding.</p>
<p>In the past, Emmet was available only as a plugin that needed to be manually installed in the code editor to enable fast auto-completion and other features. However, now Emmet is built into most code editors like VS Code, Cursor, and WebStorm, and is available as a plugin for editors like Notepad++ and Sublime Text.</p>
<p>When it comes to languages like HTML, Emmet can be thought of as a shortcut language. Let me explain.</p>
<h2 id="heading-emmet-for-html">Emmet for HTML</h2>
<p>I’ll give you a task; write down the basic structure of the HTML in your favourite code editor.</p>
<pre><code class="lang-xml"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"en"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">"UTF-8"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"viewport"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"width=device-width, initial-scale=1.0"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Document<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>

<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>You might type the code example above line by line, right? Now, let me show you a shortcut using Emmet. Open your favorite text editor with Emmet installed (I'll be using VS Code), create a new file named <code>index.html</code>, type an exclamation mark <code>!</code>, and press enter.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769654654043/36808419-9ad2-485f-b1a9-bfe2b02821b6.gif" alt class="image--center mx-auto" /></p>
<p>See, when I typed <code>!</code> and pressed enter, the entire HTML structure was instantly added to the text editor.</p>
<p>Isn't that awesome? We skipped all the manual typing of the HTML code snippet, and Emmet did it automatically for us.</p>
<p>Now, let’s learn some more HTML snippets to make our coding super fast ⚡️.</p>
<h2 id="heading-creating-html-elements-using-emmet">Creating HTML Elements Using Emmet</h2>
<p>All you need to know are the basics of HTML, such as tags, attributes, and how the overall structure and nesting work. Once you understand these, you're ready to use Emmet to enhance your HTML coding.</p>
<h3 id="heading-creating-a-container">Creating a container</h3>
<p>You can easily create a container structure like <code>div</code>, <code>main</code> etc by just typing their name in the editor and hitting the enter.</p>
<pre><code class="lang-xml">div
</code></pre>
<p>will output to</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>You can create other elements such as lists (<code>ol</code> or <code>ul</code>), <code>nav</code>, <code>header</code> and more without having to type the opening and closing tags manually.</p>
<h3 id="heading-creating-multiple-elements-using-operator">Creating multiple elements using * operator</h3>
<p>From manually typing opening and closing tags to just typing the name, we solved one problem. But you might be thinking that it isn’t that useful, as I can type a single element tag easily.</p>
<p>Well, let me ask you to write 5 or 10 div tags. Ok, now you might be agreeing, that now it becomes a problem. Here emmet solves this problem by providing us with asterisk (*) operator.</p>
<p>To write 5 div tags as once, we write the tagname followed by <em>and then the number of times we want it to replicate. e.g.</em> <code>div*5</code></p>
<pre><code class="lang-xml">div*5
</code></pre>
<p>will output to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>Just like that <strong>5 div</strong> tags were created. Now think about it, if you want to have multiple links using <code>a</code> tags, it becomes so much easier with this simple snippet.</p>
<h3 id="heading-creating-sibling-elements-using-operator">Creating Sibling elements using + operator</h3>
<p>In the previous section, we saw an example of how to create multiple elements. However, if you noticed, they were all similar elements, like 5 consecutive div tags.</p>
<p>But what if you need two different tags, one after the other? This is where we use the <code>sibling</code> or <code>plus (+)</code> operator.</p>
<p>To write an <code>h1</code> tag after a <code>div</code> tag, use the syntax <code>div+h1</code>.</p>
<pre><code class="lang-xml">div+h1
</code></pre>
<p>will output to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
</code></pre>
<p>There you go, we have a <code>h1</code> tag which was created right after the <code>div</code> tag, allowing us to create multiple tags without typing each one manually.</p>
<p><strong>Note:</strong> You can combine the <strong>asterisk *</strong> and the <strong>plus +</strong> operators to create multiple elements in sequence, like <code>div*2+h1*2</code>.</p>
<pre><code class="lang-xml">div*2+h1*2
</code></pre>
<p>will output to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
</code></pre>
<p>Now we have 2 <code>div</code> tags which were created followed by 2 <code>h1</code> tags.</p>
<h3 id="heading-creating-child-elements-using-gt-operator">Creating Child Elements using &gt; Operator</h3>
<p>So far, we have been creating elements one after another. However, let's say I want to create an unordered list <code>ul</code> with one list item <code>li</code> inside it.</p>
<p>In this case, we can use the <code>&gt;</code> operator, placing the parent tag before the child tag. For example, <code>ul&gt;li</code>.</p>
<pre><code class="lang-xml">ul&gt;li
</code></pre>
<p>will output to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
</code></pre>
<p>We can see that Emmet created an unordered list with one list item. Now, let's use the <code>*</code> operator to add 5 list items to the unordered list.</p>
<pre><code class="lang-xml">ul&gt;li*5
</code></pre>
<p>will output to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
   <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
   <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
   <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
   <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
   <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
</code></pre>
<p>Now we have 5 list elements in an unordered list and this will save us so much time when writing HTML.</p>
<p>However, you can save even more time by automating the numbering inside multiple elements using <code>{$}</code> symbol.</p>
<pre><code class="lang-xml">ul&gt;li*3&gt;{Item $}
</code></pre>
<p>will output to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>Item 1<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>Item 2<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>Item 3<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
 <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
</code></pre>
<p>Isn’t this great for creating items with fast numbering to save some time</p>
<h3 id="heading-adding-classes-and-id-attributes">Adding Classes and ID Attributes</h3>
<p>In real-world development, you rarely use plain HTML tags. You almost always attach a class or an ID for styling. Emmet makes this incredibly fast using the dot <code>.</code> for classes and the hash <code>#</code> for IDs—just like in CSS.</p>
<h4 id="heading-creating-elements-with-classes">Creating Elements with Classes:</h4>
<p>Classes are used for adding the CSS Styles to multiple elements and is done using the <code>class</code> attribute in the HTML tag. To assign a class using emmet we use the <code>dot .</code> operator followed by class name.</p>
<p>To create a <code>div</code> with a class of "container", you just type: <code>div.container</code>.</p>
<pre><code class="lang-xml">div.container
</code></pre>
<p>will output to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"container"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>There you go we now have a <code>div</code> element with class <code>container</code> added to it.</p>
<p>We can also chain multiple classes by repeatedly using the dot operator followed by the classname.</p>
<pre><code class="lang-xml">div.container.mx-auto.p-5
</code></pre>
<p>will output to:</p>
<pre><code class="lang-xml"> <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"container mx-auto p-5"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>By following this syntax, emmet would create an element like <code>div</code> with multiple class names assigned to it.</p>
<h4 id="heading-creating-elements-with-ids">Creating Elements with IDs:</h4>
<p>IDs in HTML are also used for styling using CSS but is usually done for an unique element on the page. To assign an ID using emmet we use the <code>hash #</code> operator followed by id name.</p>
<p>To create a <code>nav</code> element with an ID of "navbar", type: <code>nav#navbar</code></p>
<pre><code class="lang-xml">nav#navbar
</code></pre>
<p>will output to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">nav</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"navbar"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">nav</span>&gt;</span>
</code></pre>
<p>There you go we now have a <code>nav</code> element with id <code>navbar</code> added to it.</p>
<p><strong>Combining the ID and Classes:</strong></p>
<p>We can even chain the id and class to a single element by adding both <code>hash #</code> and <code>dot .</code> operator to a single element.</p>
<pre><code class="lang-xml">div#hero.section
</code></pre>
<p>will output to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"hero"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"section"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>See, now we have a <code>div</code> element with id as <code>hero</code> and class as <code>section</code>.</p>
<h3 id="heading-generating-dummy-text">Generating Dummy Text</h3>
<p>When creating elements, you might need to add some dummy text for testing how it looks or perhaps you might have heard of <code>lorem ipsum</code>.</p>
<p>Well guess what? Emmet also offers this feature. just type <code>lorem</code> and hit enter!</p>
<pre><code class="lang-xml">p&gt;lorem
</code></pre>
<p>will output to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Lorem ipsum dolor sit amet, consectetur adipisicing elit...<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p>You can even specify the word count! <code>lorem10</code> gives you exactly 10 words.</p>
<h2 id="heading-combining-everything">Combining Everything</h2>
<p>Let's put everything we've learned into one single line of code. Imagine you need a navigation bar with a logo, a list of links, and a login button.</p>
<pre><code class="lang-xml">nav.navbar&gt;div.logo+ul&gt;li*3&gt;a{Link $}+button.btn-login
</code></pre>
<p>will output to:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">nav</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"navbar"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"logo"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">""</span>&gt;</span>Link 1<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">""</span>&gt;</span>Link 2<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">""</span>&gt;</span>Link 3<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"btn-login"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">nav</span>&gt;</span>
</code></pre>
<p>With just one line of Emmet, we scaffolded an entire component!</p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>Emmet is more than just a shortcut tool, it is a fundamental shift in how you write HTML.Once you master these snippets, you won't just be a faster coder; you will be a happier one. You will spend less time wrestling with typos and more time building great things.</p>
]]></content:encoded></item><item><title><![CDATA[CURL Command Explained]]></title><description><![CDATA[In today's world, we mostly use Client-Server Architecture, which means multiple clients connect to a centralized server. Of course, there can be multiple servers and distributed systems too, but to understand the Curl command, we'll focus on one cli...]]></description><link>https://blog.thatsmanmeet.com/curl-command-explained</link><guid isPermaLink="true">https://blog.thatsmanmeet.com/curl-command-explained</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[curl]]></category><category><![CDATA[curl-command]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[terminal]]></category><category><![CDATA[terminal command]]></category><dc:creator><![CDATA[Manmeet Singh]]></dc:creator><pubDate>Tue, 27 Jan 2026 13:11:32 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769512917883/15b050d9-bbfc-4e8f-ae8e-d708d4ba7df7.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In today's world, we mostly use <strong>Client-Server Architecture</strong>, which means multiple clients connect to a centralized server. Of course, there can be multiple servers and distributed systems too, but to understand the Curl command, we'll focus on one client and one server.</p>
<p>Before we dive into the cURL command and how it works, let's first understand the <strong>client-server</strong> architecture.</p>
<h2 id="heading-what-is-server">What is Server?</h2>
<p>A server is a computer system that is always connected to the Internet, listening for incoming requests, and providing appropriate responses.</p>
<p>There are different types of servers, such as application servers, database servers, and mail servers.</p>
<p>Servers play a crucial role in the client-server architecture by ensuring that clients receive the necessary data and services they request. Understanding how servers work helps us use tools like cURL more effectively to interact with these systems.</p>
<h2 id="heading-what-is-a-client">What is a Client?</h2>
<p>A client is anything a user controls, from a web browser to a terminal, that can send requests to a server and receive responses to display to the user.</p>
<p>A client can be a web browser like Chrome or Firefox, an API testing tool like Postman or Bruno, or terminal software like cURL.</p>
<h2 id="heading-client-server-architecture">Client-Server Architecture</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769515439080/e8af9d19-7cf3-4a66-ae3b-88004cb51bfd.png" alt class="image--center mx-auto" /></p>
<p>Client Server Architecture simply says that a client will send a request using REST API (or any other API) to the server, the server will process the request and will send the response appropriately to the client.</p>
<p><strong>Request</strong> will contain information such as the route (URL Path), HTTP Method (POST, GET, etc), Headers (e.g. content-type) and the body, which will contain the payload or any data, that is required by the server to perform the operations.</p>
<p><strong>Response</strong> will also contain information such as the HTTP Status (e.g 200, 201), implying the result of operation, Response Headers (e.g. content-type) and the body which is the payload, that will tell the client about the status of the operation.</p>
<p>We will not dive deep into more things but just keep in mind that client sends request to the server and server provides the response. Now let’s proceed to our main topic cURL.</p>
<h2 id="heading-what-is-curl">What is cURL</h2>
<p>cURL is an utility or an software that allows us to send an request to the server, receive the response and show the data appropriately inside the terminal.</p>
<p>It can also upload and download files from the web servers and also support multiple protocols such as FTP, SMTP, Telnet and more, hence making this a really powerful utility for connecting with servers.</p>
<h2 id="heading-why-programmers-loves-curl">Why Programmers loves cURL</h2>
<p>Well, there’s many reasons programmers love cURL command and many even like using this command over other software.</p>
<ol>
<li><p><strong>No Installation needed</strong>: For many programs such as Postman or Chrome, they need to be installed on the OS, but cURL usually comes pre-installed on all modern OS, making it much easier to switch to any OS and start working immediately from the terminal using cURL.</p>
</li>
<li><p><strong>Great for No-GUI environments</strong>: Many times when working on servers, we don’t have access to GUI programs and this is where the cURL utility really shines. It doesn’t have any fancy UI and can work from the terminal as CLI application.</p>
</li>
<li><p><strong>Lightweight</strong>: cURL is a very lightweight software unlike other clients such as chrome or postman.</p>
</li>
<li><p><strong>Multiple Protocol Support</strong>: cURL supports multiple protocols which clients like chrome don’t and with option to upload/download files from server as well, really makes it a great utility.</p>
</li>
</ol>
<p>Now, that we understood what is cURL and why programmers love it. You might be thinking; “Hmm, okay but then why we learned the client-server architecture first?”</p>
<p>Well, because, now we are going to learn the cURL commands and try sending headers, payloads and other information as well.</p>
<h2 id="heading-basic-curl-commands">Basic cURL Commands</h2>
<p>Let’s understand some basic cURL commands, that we can use in our everyday life as developers.</p>
<h3 id="heading-fetch-the-webpage">Fetch the Webpage</h3>
<p>To fetch the webpage from the a server, we can use the command:</p>
<pre><code class="lang-powershell"><span class="hljs-built_in">curl</span> https://google.com
</code></pre>
<p>Response we got from the server was:</p>
<pre><code class="lang-powershell">&lt;HTML&gt;&lt;HEAD&gt;&lt;meta http<span class="hljs-literal">-equiv</span>=<span class="hljs-string">"content-type"</span> content=<span class="hljs-string">"text/html;charset=utf-8"</span>&gt;
&lt;TITLE&gt;<span class="hljs-number">301</span> Moved&lt;/TITLE&gt;&lt;/HEAD&gt;&lt;BODY&gt;
&lt;H1&gt;<span class="hljs-number">301</span> Moved&lt;/H1&gt;
The document has moved
&lt;A HREF=<span class="hljs-string">"https://www.google.com/"</span>&gt;here&lt;/A&gt;.
&lt;/BODY&gt;&lt;/HTML&gt;
</code></pre>
<p>So, you can see that the server replied us with <code>301</code> status code with message <code>document was moved</code>. This happens because the basic cURL command will not follow up with the redirects.</p>
<p>We can use <code>-L</code> flag which means <code>follow redirects</code></p>
<pre><code class="lang-powershell"><span class="hljs-built_in">curl</span> <span class="hljs-literal">-L</span> https://google.com
</code></pre>
<p>Response we get from the server was:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769517443201/77dc16a1-5f45-4116-a1d0-ae2d1577abd2.png" alt class="image--center mx-auto" /></p>
<p>Hence the <code>-L</code> flag will follow the redirects and will print the entire HTML code from the webpage on the terminal.</p>
<h3 id="heading-view-the-response-headers">View the Response Headers</h3>
<p>Headers are sent by the server as the response. To view the headers we can use <code>-I</code> flag.</p>
<pre><code class="lang-powershell"><span class="hljs-built_in">curl</span> <span class="hljs-literal">-I</span> https://google.com
</code></pre>
<p>Response we get from the server is:</p>
<pre><code class="lang-powershell">
 ~/Developer/cohort/<span class="hljs-built_in">curl</span>/ <span class="hljs-built_in">curl</span> <span class="hljs-literal">-I</span> https://google.com
HTTP/<span class="hljs-number">2</span> <span class="hljs-number">301</span> 
location: https://www.google.com/
content<span class="hljs-literal">-type</span>: text/html; charset=UTF<span class="hljs-literal">-8</span>
content<span class="hljs-literal">-security</span><span class="hljs-literal">-policy</span><span class="hljs-literal">-report</span><span class="hljs-literal">-only</span>: object<span class="hljs-literal">-src</span> <span class="hljs-string">'none'</span>;base<span class="hljs-literal">-uri</span> <span class="hljs-string">'self'</span>;script<span class="hljs-literal">-src</span> <span class="hljs-string">'nonce-B_J2kdosi1cTamYOJzeVxg'</span> <span class="hljs-string">'strict-dynamic'</span> <span class="hljs-string">'report-sample'</span> <span class="hljs-string">'unsafe-eval'</span> <span class="hljs-string">'unsafe-inline'</span> https: http:;report<span class="hljs-literal">-uri</span> https://csp.withgoogle.com/csp/gws/other<span class="hljs-literal">-hp</span>
date: Tue, <span class="hljs-number">27</span> Jan <span class="hljs-number">2026</span> <span class="hljs-number">12</span>:<span class="hljs-number">40</span>:<span class="hljs-number">23</span> GMT
expires: Thu, <span class="hljs-number">26</span> Feb <span class="hljs-number">2026</span> <span class="hljs-number">12</span>:<span class="hljs-number">40</span>:<span class="hljs-number">23</span> GMT
cache<span class="hljs-literal">-control</span>: public, max<span class="hljs-literal">-age</span>=<span class="hljs-number">2592000</span>
server: gws
content<span class="hljs-literal">-length</span>: <span class="hljs-number">220</span>
x<span class="hljs-literal">-xss</span><span class="hljs-literal">-protection</span>: <span class="hljs-number">0</span>
x<span class="hljs-literal">-frame</span><span class="hljs-literal">-options</span>: SAMEORIGIN
alt<span class="hljs-literal">-svc</span>: h3=<span class="hljs-string">":443"</span>; ma=<span class="hljs-number">2592000</span>,h3<span class="hljs-literal">-29</span>=<span class="hljs-string">":443"</span>; ma=<span class="hljs-number">2592000</span>
</code></pre>
<p>You can see the headers that was sent by the server as response to our client, being shown in the terminal. However these are only the headers, if you want to see <code>Headers + Response</code>, then use the <code>-i</code> flag.</p>
<pre><code class="lang-powershell"><span class="hljs-built_in">curl</span> <span class="hljs-literal">-i</span> https://google.com
</code></pre>
<p>Response we get from the server is:</p>
<pre><code class="lang-powershell"> ~/Developer/cohort/<span class="hljs-built_in">curl</span>/ <span class="hljs-built_in">curl</span> <span class="hljs-literal">-i</span> https://google.com
HTTP/<span class="hljs-number">2</span> <span class="hljs-number">301</span> 
location: https://www.google.com/
content<span class="hljs-literal">-type</span>: text/html; charset=UTF<span class="hljs-literal">-8</span>
content<span class="hljs-literal">-security</span><span class="hljs-literal">-policy</span><span class="hljs-literal">-report</span><span class="hljs-literal">-only</span>: object<span class="hljs-literal">-src</span> <span class="hljs-string">'none'</span>;base<span class="hljs-literal">-uri</span> <span class="hljs-string">'self'</span>;script<span class="hljs-literal">-src</span> <span class="hljs-string">'nonce-1k2aoSXbjjeLVNgA55J97A'</span> <span class="hljs-string">'strict-dynamic'</span> <span class="hljs-string">'report-sample'</span> <span class="hljs-string">'unsafe-eval'</span> <span class="hljs-string">'unsafe-inline'</span> https: http:;report<span class="hljs-literal">-uri</span> https://csp.withgoogle.com/csp/gws/other<span class="hljs-literal">-hp</span>
date: Tue, <span class="hljs-number">27</span> Jan <span class="hljs-number">2026</span> <span class="hljs-number">12</span>:<span class="hljs-number">42</span>:<span class="hljs-number">23</span> GMT
expires: Thu, <span class="hljs-number">26</span> Feb <span class="hljs-number">2026</span> <span class="hljs-number">12</span>:<span class="hljs-number">42</span>:<span class="hljs-number">23</span> GMT
cache<span class="hljs-literal">-control</span>: public, max<span class="hljs-literal">-age</span>=<span class="hljs-number">2592000</span>
server: gws
content<span class="hljs-literal">-length</span>: <span class="hljs-number">220</span>
x<span class="hljs-literal">-xss</span><span class="hljs-literal">-protection</span>: <span class="hljs-number">0</span>
x<span class="hljs-literal">-frame</span><span class="hljs-literal">-options</span>: SAMEORIGIN
alt<span class="hljs-literal">-svc</span>: h3=<span class="hljs-string">":443"</span>; ma=<span class="hljs-number">2592000</span>,h3<span class="hljs-literal">-29</span>=<span class="hljs-string">":443"</span>; ma=<span class="hljs-number">2592000</span>

&lt;HTML&gt;&lt;HEAD&gt;&lt;meta http<span class="hljs-literal">-equiv</span>=<span class="hljs-string">"content-type"</span> content=<span class="hljs-string">"text/html;charset=utf-8"</span>&gt;
&lt;TITLE&gt;<span class="hljs-number">301</span> Moved&lt;/TITLE&gt;&lt;/HEAD&gt;&lt;BODY&gt;
&lt;H1&gt;<span class="hljs-number">301</span> Moved&lt;/H1&gt;
The document has moved
&lt;A HREF=<span class="hljs-string">"https://www.google.com/"</span>&gt;here&lt;/A&gt;.
&lt;/BODY&gt;&lt;/HTML&gt;
</code></pre>
<p>From the above response, you can see that the Headers are being displayed along with the response sent by the server.</p>
<h3 id="heading-send-request-headers-to-the-server">Send Request Headers to the server</h3>
<p>We have seen the response headers, that server send as the response. However, we can also send some headers from our client to the server.</p>
<p>We can use <code>-H</code> flag followed by <code>Header-Name: value</code> along with our cURL command to the server.</p>
<pre><code class="lang-powershell"> <span class="hljs-built_in">curl</span> <span class="hljs-literal">-H</span> <span class="hljs-string">"content-type:application/json"</span> https://google.com
</code></pre>
<h3 id="heading-receive-payload-from-the-server">Receive Payload from the Server</h3>
<p>As seen from our client-server architecture, we can receive, the payload from the server. We can specify the HTTP method using <code>-X</code> flag, followed by the HTTP method such as GET, POST etc.</p>
<pre><code class="lang-powershell"><span class="hljs-built_in">curl</span> <span class="hljs-literal">-X</span> GET https://jsonplaceholder.typicode.com/posts/<span class="hljs-number">1</span>
</code></pre>
<p>Response we get from the server is:</p>
<pre><code class="lang-powershell"> ~/ <span class="hljs-built_in">curl</span> <span class="hljs-literal">-X</span> GET https://jsonplaceholder.typicode.com/posts/<span class="hljs-number">1</span>      
{
  <span class="hljs-string">"userId"</span>: <span class="hljs-number">1</span>,
  <span class="hljs-string">"id"</span>: <span class="hljs-number">1</span>,
  <span class="hljs-string">"title"</span>: <span class="hljs-string">"sunt aut facere repellat provident occaecati excepturi optio reprehenderit"</span>,
  <span class="hljs-string">"body"</span>: <span class="hljs-string">"quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"</span>
}
</code></pre>
<p>You can see the payload we received from the server.</p>
<h3 id="heading-send-payload-to-the-server">Send Payload to the Server</h3>
<p>To send some data (payload) to the server, we can use the <code>POST</code> method. We can also pass headers using <code>-H</code> flag and data using <code>-d</code> flag if necessary.</p>
<pre><code class="lang-powershell"><span class="hljs-comment"># make sure they are in same line, I just seperated them to make it more visible</span>
<span class="hljs-built_in">curl</span> <span class="hljs-literal">-X</span> POST \
  <span class="hljs-literal">-H</span> <span class="hljs-string">"content-type: application/json"</span> \
  <span class="hljs-literal">-d</span> <span class="hljs-string">'{"name": "Manmeet", "role": "admin"}'</span> \
  https://jsonplaceholder.typicode.com/users
</code></pre>
<p>Response I get from the server was:</p>
<pre><code class="lang-powershell"> ~/ <span class="hljs-built_in">curl</span> <span class="hljs-literal">-X</span> POST <span class="hljs-literal">-H</span> <span class="hljs-string">"content-type: application/json"</span> <span class="hljs-literal">-d</span> <span class="hljs-string">'{"name" : "Manmeet", "role":"admin"}'</span> https://jsonplaceholder.typicode.com/users
{
  <span class="hljs-string">"name"</span>: <span class="hljs-string">"Manmeet"</span>,
  <span class="hljs-string">"role"</span>: <span class="hljs-string">"admin"</span>,
  <span class="hljs-string">"id"</span>: <span class="hljs-number">11</span>
}
</code></pre>
<p>Here, you can see that the data included my name and role as <code>manmeet</code> and <code>admin</code>, which the server acknowledged and sent me as a response for the confirmation, that my data was received by server.</p>
<p>You can also use other methods such as PUT, PATCH, OPTIONS, DELETE as well.</p>
<h3 id="heading-filtering-data-with-query-parameters">Filtering Data with Query Parameters</h3>
<p>Sometimes, you don't want the server to send back <em>everything</em>. You might want to filter the data, limit the number of results, or sort them. In Client-Server architecture, we usually handle this by passing <strong>Query Parameters</strong> directly in the URL.</p>
<p>Query parameters start with a <code>?</code> after the URL path. Multiple parameters can be separated by the ampersand <code>&amp;</code> symbol, like <code>/users?_limit=5&amp;search=A</code>.</p>
<p>Let's say we want to fetch posts from the server, but we only want the top 5 results, and specifically for user ID 1. We can combine these using parameters provided by the JSONPlaceholder API.</p>
<pre><code class="lang-powershell"><span class="hljs-built_in">curl</span> <span class="hljs-string">"https://jsonplaceholder.typicode.com/posts?_limit=5&amp;userId=1"</span>
</code></pre>
<p>The server will return an array containing only <strong>5 post objects</strong> that belong to <strong>User 1</strong>, rather than the full list.</p>
<h4 id="heading-downloading-files-o">Downloading Files (<code>-o</code>)</h4>
<p>Sometimes the response isn't text as it could be a massive JSON, an image, or a zip file. Printing this response to server will cause a mess, making it harder to understand.</p>
<p>Use the <code>-o</code> (output) flag to save the response to a file.</p>
<pre><code class="lang-powershell"><span class="hljs-comment"># Save the Google homepage source code to a file named 'google.html'</span>
<span class="hljs-built_in">curl</span> <span class="hljs-literal">-o</span> google.html https://www.google.com
</code></pre>
<p>Above command will create a new file <code>google.com</code> and will print the source code of <code>google.com</code> webpage inside it.</p>
<h4 id="heading-debugging-with-verbose-mode-v">Debugging with Verbose Mode (<code>-v</code>)</h4>
<p>As a developer, things <em>will</em> break. Maybe your API returns a <code>500 Error</code>, or your authentication fails. This is where <code>curl</code> becomes a diagnostic tool.</p>
<p>The <code>-v</code> (verbose) flag tells cURL to show the entire conversation—the handshake, the hidden headers, and the raw traffic.</p>
<pre><code class="lang-powershell"><span class="hljs-built_in">curl</span> <span class="hljs-literal">-v</span> https://google.com
</code></pre>
<p><strong>Understanding the Output:</strong></p>
<ul>
<li><p>Lines starting with <code>*</code> show the connection process (DNS resolution, SSL handshake).</p>
</li>
<li><p>Lines starting with <code>&gt;</code> are the data <strong>you sent</strong> (Request).</p>
</li>
<li><p>Lines starting with <code>&lt;</code> are the data <strong>received</strong> (Response).</p>
</li>
</ul>
<p>This gives you "X-Ray vision" into the HTTP protocol.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>We started this journey understanding the <strong>Client-Server Architecture</strong> because tools are useless if you don't understand the system they interact with. We then moved to <strong>cURL</strong>, exploring how to fetch pages, inspect headers, and send data using methods like POST. While graphical tools hide the complexity, cURL forces you to understand the raw <strong>HTTP protocol</strong>. It makes you think about headers, payloads, and status codes. This doesn't just make you better at using the command line; it makes you a better Backend Developer.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding DNS Record Types]]></title><description><![CDATA[In the last post, we discussed DNS and how it works in detail. In this article, we will talk about how DNS resolution doesn't always get the IP address directly. Sometimes, it needs to do more recursive work to find the server's IP address.
A Record
...]]></description><link>https://blog.thatsmanmeet.com/understanding-dns-record-types</link><guid isPermaLink="true">https://blog.thatsmanmeet.com/understanding-dns-record-types</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[dns]]></category><category><![CDATA[dns-records]]></category><dc:creator><![CDATA[Manmeet Singh]]></dc:creator><pubDate>Tue, 27 Jan 2026 08:08:59 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769497753078/c73916d6-3758-4dcb-8a71-902a0e6072d0.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the last post, we discussed DNS and how it works in detail. In this article, we will talk about how DNS resolution doesn't always get the IP address directly. Sometimes, it needs to do more recursive work to find the server's IP address.</p>
<h2 id="heading-a-record">A Record</h2>
<p>This is the most simple and commonly used DNS Record type that we get from the Authoritative Servers. We receive a simple IPv4 address (e.g. 52.74.6.109) from the server.</p>
<pre><code class="lang-powershell">thatsmanmeet.com.    <span class="hljs-number">1</span>    <span class="hljs-keyword">IN</span>    A    <span class="hljs-number">52.74</span>.<span class="hljs-number">6.109</span>
</code></pre>
<p>In the output above, you can see that by running the <code>dig</code> command on my website <code>thatsmanmeet.com</code>, I receive an <code>A</code> record with the IP address <code>52.74.6.109</code>. This IP address can be used by the web browser to easily give users access to the website.</p>
<h2 id="heading-aaaa-record">AAAA Record</h2>
<p>AAAA Record or Quad A Record is completely identical to the <strong>A Record</strong> except instead of the IPV4 address (e.g. 52.74.6.109), it returns an IPV6 address (e.g. 2001:0db8:85a3:0000:0000:8a2e:0370:7334).</p>
<p>IPV6 (Internet Protocol Version 6) is a 128-bit network layer protocol designed to replace the smaller pool of IPV4 addresses on the Internet.</p>
<pre><code class="lang-powershell">example.com. <span class="hljs-number">1</span> <span class="hljs-keyword">IN</span> AAAA <span class="hljs-number">2001</span>:<span class="hljs-number">0</span>db8:<span class="hljs-number">85</span>a3:<span class="hljs-number">0000</span>:<span class="hljs-number">0000</span>:<span class="hljs-number">8</span>a2e:<span class="hljs-number">0370</span>:<span class="hljs-number">7334</span>
</code></pre>
<p>In the output above, you can see that by running the <code>dig</code> command on the website <code>example.com</code>, I get an <code>AAAA</code> record with the IP address <code>2001:0db8:85a3:0000:0000:8a2e:0370:7334</code>. This IP address can be used by the web browser to easily give users access to the website.</p>
<h2 id="heading-cname-record">CNAME Record</h2>
<p>CNAME (Canonical Name) Record, returns another domain from the authoritative server instead of the IP address.</p>
<p>To understand Cname records, let’s understand a situation. Suppose, you hosted a subdomain (blog.example.com) on a famous service provider and they provided an <code>A</code> record to point the subdomain to the website.</p>
<pre><code class="lang-powershell">blog.example.com <span class="hljs-number">1</span> <span class="hljs-keyword">IN</span> A <span class="hljs-number">13.12</span>.<span class="hljs-number">4.1</span>
</code></pre>
<p>For now, the website was working fine. But let's say there's a major outage on the provider's side, and they set up a new machine. This new machine has the IP address <code>13.11.4.2</code>. Suddenly, all the websites pointing to the old IP address would stop working. The service provider would have to email all its customers, asking them to update their <code>A</code> records to the new IP address.</p>
<p>This would be very inconvenient, right?</p>
<p>To solve this issue, we have CNAME Records. Let me run the <code>dig</code> command on my subdomain <code>blog.thatsmanmeet.com</code>.</p>
<pre><code class="lang-powershell">blog.thatsmanmeet.com.    <span class="hljs-number">532</span>    <span class="hljs-keyword">IN</span>    CNAME    hashnode.network.
hashnode.network.    <span class="hljs-number">1</span>    <span class="hljs-keyword">IN</span>    A    <span class="hljs-number">76.76</span>.<span class="hljs-number">21.21</span>
</code></pre>
<p>In the output above, you can see that my subdomain <code>blog.thatsmanmeet.com</code> returned a <code>CNAME</code> record pointing to <code>hashnode.network</code>. A request was then sent to <code>hashnode.network</code> to resolve my subdomain, and we received an <code>A</code> record from <code>hashnode.network</code> as <code>76.76.21.21</code>.</p>
<p>Returning to our problem, all I needed to do was add <code>hashnode.network</code> as the <code>CNAME</code> record in my DNS configuration. Even if the IP address changes on Hashnode’s side, my website will continue to work because I have the same <code>CNAME</code> record, and they can map <code>hashnode.network</code> to the new IP address.</p>
<pre><code class="lang-powershell">subdomain -&gt; Root Servers -&gt; TLD Servers -&gt; Authoritative Servers -&gt; CNAME (domain) 
-&gt; repeat <span class="hljs-keyword">for</span> the CNAME domain -&gt; A IP Address -&gt; Requests to open IP Address
</code></pre>
<p>Hence, CNAME records return another domain or alias, which then resolved to the corresponding A record providing the IP address.</p>
<h2 id="heading-ns-records">NS Records</h2>
<p>NS (Name Server) Records tells the resolver that the current domain is now being handled by another authority or the Authoritative server is not the original one.</p>
<p>Let’s say you bought a domain from hostinger and now the flow would look something like:</p>
<pre><code class="lang-powershell">example.com -&gt; Root Servers -&gt; TLD Servers -&gt;  Authoritative Servers (Hostinger) -&gt; A record
</code></pre>
<p>Now for some reason, you decided to delegate the authority of your domain from the Hostinger to Cloudflare, i.e the Domain Registrar still stays the same (Hostinger) but the authority handling it becomes different (Cloudflare).</p>
<p>So, now if you try to do the DNS Resolution, it would look something like:</p>
<pre><code class="lang-powershell">example.com -&gt; Root Servers -&gt; TLD Servers -&gt; Authoritative Servers (Cloudflare Name Servers)
-&gt; (cloudflare checks internally <span class="hljs-keyword">for</span> the IP of domain example.com) -&gt; Returns A rcord (IP)
</code></pre>
<p>Now in case of sub domain, the above authoritative servers can also return <code>CNAME</code> record as well, then again we need to resolve that <code>CNAME</code> record to get the A records.</p>
<h2 id="heading-mx-record">MX Record</h2>
<p>MX (Mail Exchange) Records are used to direct email to a mail server. They specify the mail servers responsible for receiving email on behalf of a domain.</p>
<p>For example, if you have a domain like <code>example.com</code> and you want to handle emails through a specific mail server, you would set up an MX record pointing to that server.</p>
<p>Let's say you want to use Google's mail servers to handle emails for your domain example.com. You would add MX records in your DNS settings like this:</p>
<pre><code class="lang-powershell">example.com.  <span class="hljs-number">3600</span>  <span class="hljs-keyword">IN</span>  MX  <span class="hljs-number">1</span>  aspmx.l.google.com.
example.com.  <span class="hljs-number">3600</span>  <span class="hljs-keyword">IN</span>  MX  <span class="hljs-number">5</span>  alt1.aspmx.l.google.com.
example.com.  <span class="hljs-number">3600</span>  <span class="hljs-keyword">IN</span>  MX  <span class="hljs-number">5</span>  alt2.aspmx.l.google.com.
example.com.  <span class="hljs-number">3600</span>  <span class="hljs-keyword">IN</span>  MX  <span class="hljs-number">10</span>  alt3.aspmx.l.google.com.
example.com.  <span class="hljs-number">3600</span>  <span class="hljs-keyword">IN</span>  MX  <span class="hljs-number">10</span>  alt4.aspmx.l.google.com.
</code></pre>
<p>In this setup, emails sent to any address at example.com will be directed to Google's mail servers. The numbers (1, 5, 10) indicate priority, with lower numbers having higher priority. This means the server with priority 1 will be tried first. If it's unavailable, the next priority server will be used, and so on. This ensures that your emails are reliably delivered even if one server is down.</p>
<h3 id="heading-txt-records">TXT Records</h3>
<p>TXT (Text) Records are used to store text information in the DNS. They can hold various types of data and are often used for verification purposes.</p>
<p>For example, if you need to verify domain ownership with a service like Google Search Console, you might be asked to add a TXT record to your DNS settings. This record would contain a specific string provided by the service.</p>
<p>Let's say Google gives you a verification code to prove you own example.com. You would add a TXT record like this:</p>
<pre><code class="lang-powershell">example.com.  <span class="hljs-number">3600</span>  <span class="hljs-keyword">IN</span>  TXT  <span class="hljs-string">"google-site-verification=abc123def456"</span>
</code></pre>
<p>In this case, the TXT record contains the verification string. When Google checks your domain, it will look for this record to confirm ownership. TXT records are also used for other purposes, like setting up SPF to prevent email spoofing.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Now you understand why DNS is recursive by nature. It doesn't always hand you an IP address directly; sometimes, it hands you a referral (like a CNAME or NS record), forcing your browser to do the heavy lifting before it finally reaches the destination.</p>
]]></content:encoded></item><item><title><![CDATA[A Beginners Guide to DNS Resolution]]></title><description><![CDATA[Whenever you try to open a website, like "google.com," what do you think happens behind the scenes? How does your browser know which server to get data from among millions of servers worldwide? Is it magic? Well, No! It happens with the help of a sys...]]></description><link>https://blog.thatsmanmeet.com/a-beginners-guide-to-dns-resolution</link><guid isPermaLink="true">https://blog.thatsmanmeet.com/a-beginners-guide-to-dns-resolution</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[WebDevCohort2026]]></category><category><![CDATA[dns]]></category><category><![CDATA[dns resolver]]></category><category><![CDATA[webdev]]></category><category><![CDATA[internet]]></category><dc:creator><![CDATA[Manmeet Singh]]></dc:creator><pubDate>Sat, 24 Jan 2026 11:52:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769238612260/ac10387b-04f5-472c-827d-2fd78bdf140a.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Whenever you try to open a website, like "google.com," what do you think happens behind the scenes? How does your browser know which server to get data from among millions of servers worldwide? Is it magic? Well, No! It happens with the help of a system known as DNS.</p>
<p>Before we understand this complex system, let’s understand the working of DNS with the help of an Analogy.</p>
<h2 id="heading-phonebook-analogy">Phonebook Analogy</h2>
<p>Our smartphones have an app named <strong>Contacts,</strong> which stores all the phone numbers of our friends, family and other people whom we meet in our life.</p>
<p>Let me ask you this question; <strong>Do you remember the phone numbers of all people stored on your mobile?</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769239765119/3f66e29e-d840-4d62-a128-82002ad22fab.jpeg" alt class="image--center mx-auto" /></p>
<p>Most likely, your answer would be no (unless you're a genius or very lonely)! Generally, you might only remember a few phone numbers of your close ones, like your parents. However, you do remember most people's names, and when you need to call them, you open your phone app, search for the person's name, and click the call button. Your phone then automatically dials the number for you.</p>
<p>You see, we humans are not great at remembering numbers, but we are excellent at remembering names. So, we use our contacts app to save a person's name and phone number once, and then our phone app does all the hard work for us.</p>
<p>Just like people have name and phone numbers, the websites have <strong>Domain Name</strong> and <strong>IP Addresses</strong> and we really remember websites names like <strong>Google, Instagram, Reddit</strong> but not their IP Addresses.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Entity</td><td>Name</td><td>Number / IP Address</td></tr>
</thead>
<tbody>
<tr>
<td>Person</td><td>John Doe</td><td>+1034024234</td></tr>
<tr>
<td>Website</td><td>Google.com</td><td><a target="_blank" href="http://172.217.19.164/">172.217.19.164</a> (Real IP btw)</td></tr>
</tbody>
</table>
</div><p><strong>DNS</strong> acts like the internet's phonebook. It converts a <strong>Domain Name</strong> (e.g., Google.com) to its corresponding <strong>IP Address</strong> (e.g., 172.217.19.164).</p>
<p>Just as we rely on our contacts app to convert a name into a phone number, a web browser like Chrome relies on DNS to convert a domain name into an IP address.</p>
<p>However, your phonebook is probably small with maybe about 500 to 1,000 entries max. But there are millions of websites on the internet. Do you think a single phonebook could handle it all?</p>
<p><strong>Well, No.</strong></p>
<p>It’s not just one massive server; it’s actually many different systems working together. We call this a <strong>Decentralised System</strong>."</p>
<h2 id="heading-what-is-dns">What is DNS</h2>
<p><strong>Domain Name System (DNS)</strong> is a hierarchal and distributed naming system that converts the human readable domain names into their respective IP addresses which are used by the client such as web browser to access those websites.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769242246794/8ad1bd6d-9838-4ae0-b6e9-4b8fb10ca34f.png" alt class="image--center mx-auto" /></p>
<p>In the diagram above, the DNS system is shown as a single component for simplicity, but it actually consists of multiple different components.</p>
<h2 id="heading-components-of-dns-system">Components of DNS System</h2>
<ol>
<li><p><strong>Recursive Resolver:</strong> Recursive Resolver is the server that is provided by your Internet Service Provider (ISP) and is the main bridge between your System and the other DNS servers.</p>
<ul>
<li>The name <code>Recursive</code> comes from the fact that it makes request to multiple DNS servers in order to get the IP address of the final server. It is also the initial point of contact between client and the global DNS system.</li>
</ul>
</li>
<li><p><strong>Root Servers:</strong> Root Servers provide the IP Address of the servers which contains the records of the top level domains (like .com or .net) and share them with the Resolver.</p>
<ul>
<li>There are technically only <strong>13 Root Server IP addresses</strong> in the world. However, don't worry about them crashing—there are actually <strong>1,600+ physical servers</strong> worldwide using "Anycast" technology to share those 13 IPs. It’s a massive, distributed safety net.</li>
</ul>
</li>
<li><p><strong>Top Level Domains:</strong> These servers have domain specific and only contains the IP address for the domains that correspond to the specific TLD (e.g .com). This server provides the IP of the Authoritative Servers.</p>
<ul>
<li>TLD are also of different types such as <strong>Country Specific (.jp, .in, .ca etc) and Generic (.com, .org, .net etc)</strong>.</li>
</ul>
</li>
<li><p><strong>Authoritative Server:</strong> These are the servers which holds the actual IP address of the website, you’re trying to visit.</p>
<ul>
<li><p>There’s a common misconception that Authoritative servers are the final servers where the website is hosted. <strong>However, this Idea is wrong!</strong></p>
</li>
<li><p>When you buy a domain (from GoDaddy, Namecheap, etc.), they usually provide this server by default. However, as developers, we often configure this to point to a custom provider like <strong>Cloudflare</strong> or <strong>AWS Route53</strong> for better speed and security.</p>
</li>
</ul>
</li>
</ol>
<h2 id="heading-dns-resolution-process">DNS Resolution Process</h2>
<p>Now, let's understand how your web browser loads websites using a process called DNS Resolution.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769249703391/74f9a911-63ad-4082-b288-a99d02ab9733.png" alt class="image--center mx-auto" /></p>
<ol>
<li><p>A user opens the web browser, types the URL (e.g., https://google.com), and presses enter.</p>
</li>
<li><p>The browser will try to find the website's IP address in its local cache. If it finds the IP address, it will load the website, and the rest of the DNS resolution process is skipped.</p>
</li>
<li><p>If the IP address of the website is not found, the DNS query is sent to the Recursive Resolver.</p>
</li>
<li><p>The Recursive Resolver will also check its cache to see if the IP address is available. If it is, the resolver will return the response to the browser, and the rest of the DNS resolution process will be skipped.</p>
</li>
<li><p>If the IP address of the website is not found in the Recursive Resolver’s cache, the request is sent to the Root Servers.</p>
</li>
<li><p>Root Servers check the top-level domain in the URL (like google.com) and provide the IP address of the Top Level Domain Server for <code>.com</code> domains to the Recursive Resolver.</p>
</li>
<li><p>The Recursive Resolver then sends the request to the Top Level Domain Server, which checks the registrar currently handling the website and returns the IP address of the Authoritative Server to the Recursive Resolver.</p>
</li>
<li><p>The Recursive Resolver sends the request to the Authoritative Servers, which provide the actual IP address of the website server (in this case, Google’s server) to the Recursive Resolver.</p>
</li>
<li><p>The Recursive Resolver returns the response to the browser.</p>
</li>
<li><p>The browser then sends the request directly to the website’s server using the IP address provided by the Recursive Resolver and retrieves the data from the website.</p>
</li>
</ol>
<h2 id="heading-time-to-live-ttl">Time To Live (TTL)</h2>
<p>So far, we have learned the 10-step DNS resolution process. But now, a question might be popping up in your head: <em>“<strong><strong>Does this long, complex process happen for every single resource?</strong></strong>”</em></p>
<p>Think about it for a second!</p>
<p>Let’s say you have a slow internet connection. The DNS resolution itself takes about 2 to 3 seconds, and finally, the webpage loads. However, a modern webpage isn't just one file. It has images, scripts, fonts, and videos. If that page has 10 images, and your browser had to perform a full DNS resolution for <em>every single one</em>, that would be an extra 10 lookups. At 3 seconds per lookup, you are looking at a 30-second delay just to find the images!</p>
<p>In the world of modern web development (React, heavy JavaScript, rich media), this would be a disaster. The web would be unusable.</p>
<p>So what’s the fix? Well, one word <strong>Caching.</strong></p>
<p>Remember, in the DNS resolution step, both the browser and the recursive resolver have a cache, which helps the browser avoid repeating the entire DNS resolution process.</p>
<p>Great, so the browser doesn't need to make requests repeatedly to get the IP address for images and other resources. But who tells the browser when to check the cache again?</p>
<p>Imagine your browser cached a website, and then a developer switched to another server a minute later. If the browser never checks with the recursive resolver again, how would it know the website's IP address has changed?</p>
<p>This is where the concept of Time To Live (TTL) comes into play.</p>
<p><strong>TTL</strong> is a setting attached to the DNS record (configured by the domain owner). It tells the resolver exactly how long to keep the data valid.</p>
<ul>
<li><p><strong>High TTL :</strong> This is good for the websites, that are stable and don’t change as often. High TTL could be like 24 hours of time is beneficial for such websites.</p>
</li>
<li><p><strong>Low TTL :</strong> This is good for the websites, that are change regularly. Low TTL could be like 5 minutes of time is beneficial for such websites.</p>
</li>
</ul>
<p>Essentially, TTL is the <strong>expiration date</strong> on the data. It ensures your browser remains fast by not making too many request to DNS servers but at the same time doesn’t keep serving the Stale data.</p>
<h2 id="heading-dig-command">Dig Command</h2>
<p>So far, we just learned about the theory. Shall we try seeing this in practice?</p>
<p>We can achieve this using the <code>dig</code> (Domain Information Groper) command. It’s a standard tool for developers to query DNS servers directly and see exactly what is happening under the hood.</p>
<p>Open your terminal and type:</p>
<pre><code class="lang-powershell">dig google.com
</code></pre>
<p>Just take a look at the output below.</p>
<pre><code class="lang-powershell">; &lt;&lt;&gt;&gt; DiG <span class="hljs-number">9.10</span>.<span class="hljs-number">6</span> &lt;&lt;&gt;&gt; google.com
;; global options: +cmd
;; Got answer:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: <span class="hljs-number">22386</span>
;; flags: qr <span class="hljs-built_in">rd</span> ra; QUERY: <span class="hljs-number">1</span>, ANSWER: <span class="hljs-number">1</span>, AUTHORITY: <span class="hljs-number">0</span>, ADDITIONAL: <span class="hljs-number">1</span>

;; OPT PSEUDOSECTION:
; EDNS: version: <span class="hljs-number">0</span>, flags:; udp: <span class="hljs-number">1280</span>
;; QUESTION SECTION:
;google.com.            <span class="hljs-keyword">IN</span>    A

;; ANSWER SECTION:
google.com.        <span class="hljs-number">280</span>    <span class="hljs-keyword">IN</span>    A    <span class="hljs-number">142.250</span>.<span class="hljs-number">182.206</span>

;; Query time: <span class="hljs-number">20</span> msec
;; SERVER: <span class="hljs-number">2405</span>:<span class="hljs-number">201</span>:<span class="hljs-number">5500</span>:<span class="hljs-number">6193</span>::c0a8:<span class="hljs-number">1</span>d01<span class="hljs-comment">#53(2405:201:5500:6193::c0a8:1d01)</span>
;; WHEN: Sat Jan <span class="hljs-number">24</span> <span class="hljs-number">16</span>:<span class="hljs-number">50</span>:<span class="hljs-number">36</span> IST <span class="hljs-number">2026</span>
;; MSG SIZE  rcvd: <span class="hljs-number">55</span>
</code></pre>
<p>The output might look like a wall of text, but let's decode the three most important parts:</p>
<ol>
<li><p>Question Section: Contains the query that we sent, In our case to get the IP of google.com</p>
</li>
<li><p>Answer Section: Contains the information about the response we received. This includes information like:</p>
<ol>
<li><p>Domain Name: google.com</p>
</li>
<li><p>Time to Live (TTL): 280 seconds</p>
</li>
<li><p>DNS Record Type : A record</p>
</li>
<li><p>IP Address : 142.250.182.206</p>
</li>
</ol>
</li>
<li><p>Additional information: This contains some additional information about the Query such as:</p>
<ol>
<li><p>Query time: It took 20 milliseconds for this query to return response.</p>
</li>
<li><p>Server: This is most likely our Recursive Resolver</p>
</li>
</ol>
</li>
</ol>
<h3 id="heading-seeing-the-full-dns-resolution-using-the-dig-command">Seeing the full DNS Resolution using the Dig command</h3>
<p>Now with all the knowledge equipped about the DNS and how the Dig command shows the results, are you ready to see full DNS Resolution in action?</p>
<p>Let’s run the dig command with <code>+trace</code> flag.</p>
<pre><code class="lang-powershell">dig google.com + trace
</code></pre>
<p>Just take a look at the output below.</p>
<pre><code class="lang-powershell"> ~/ dig google.com +trace      

; &lt;&lt;&gt;&gt; DiG <span class="hljs-number">9.10</span>.<span class="hljs-number">6</span> &lt;&lt;&gt;&gt; google.com +trace
;; global options: +cmd
.            <span class="hljs-number">86363</span>    <span class="hljs-keyword">IN</span>    NS    a.root<span class="hljs-literal">-servers</span>.net.
.            <span class="hljs-number">86363</span>    <span class="hljs-keyword">IN</span>    NS    b.root<span class="hljs-literal">-servers</span>.net.
.            <span class="hljs-number">86363</span>    <span class="hljs-keyword">IN</span>    NS    c.root<span class="hljs-literal">-servers</span>.net.
.            <span class="hljs-number">86363</span>    <span class="hljs-keyword">IN</span>    NS    d.root<span class="hljs-literal">-servers</span>.net.
.            <span class="hljs-number">86363</span>    <span class="hljs-keyword">IN</span>    NS    e.root<span class="hljs-literal">-servers</span>.net.
.            <span class="hljs-number">86363</span>    <span class="hljs-keyword">IN</span>    NS    f.root<span class="hljs-literal">-servers</span>.net.
.            <span class="hljs-number">86363</span>    <span class="hljs-keyword">IN</span>    NS    g.root<span class="hljs-literal">-servers</span>.net.
.            <span class="hljs-number">86363</span>    <span class="hljs-keyword">IN</span>    NS    h.root<span class="hljs-literal">-servers</span>.net.
.            <span class="hljs-number">86363</span>    <span class="hljs-keyword">IN</span>    NS    i.root<span class="hljs-literal">-servers</span>.net.
.            <span class="hljs-number">86363</span>    <span class="hljs-keyword">IN</span>    NS    j.root<span class="hljs-literal">-servers</span>.net.
.            <span class="hljs-number">86363</span>    <span class="hljs-keyword">IN</span>    NS    k.root<span class="hljs-literal">-servers</span>.net.
.            <span class="hljs-number">86363</span>    <span class="hljs-keyword">IN</span>    NS    l.root<span class="hljs-literal">-servers</span>.net.
.            <span class="hljs-number">86363</span>    <span class="hljs-keyword">IN</span>    NS    m.root<span class="hljs-literal">-servers</span>.net.
;; Received <span class="hljs-number">239</span> bytes from <span class="hljs-number">127.0</span>.<span class="hljs-number">2.2</span><span class="hljs-comment">#53(127.0.2.2) in 1 ms</span>

com.            <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    h.gtld<span class="hljs-literal">-servers</span>.net.
com.            <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    g.gtld<span class="hljs-literal">-servers</span>.net.
com.            <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    k.gtld<span class="hljs-literal">-servers</span>.net.
com.            <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    c.gtld<span class="hljs-literal">-servers</span>.net.
com.            <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    j.gtld<span class="hljs-literal">-servers</span>.net.
com.            <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    b.gtld<span class="hljs-literal">-servers</span>.net.
com.            <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    e.gtld<span class="hljs-literal">-servers</span>.net.
com.            <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    m.gtld<span class="hljs-literal">-servers</span>.net.
com.            <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    d.gtld<span class="hljs-literal">-servers</span>.net.
com.            <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    i.gtld<span class="hljs-literal">-servers</span>.net.
com.            <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    a.gtld<span class="hljs-literal">-servers</span>.net.
com.            <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    f.gtld<span class="hljs-literal">-servers</span>.net.
com.            <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    l.gtld<span class="hljs-literal">-servers</span>.net.
com.            <span class="hljs-number">86400</span>    <span class="hljs-keyword">IN</span>    DS    <span class="hljs-number">19718</span> <span class="hljs-number">13</span> <span class="hljs-number">2</span> <span class="hljs-number">8</span>ACBB0CD28F41250A80A491389424D341522D946B0DA0C0291F2D3D7 <span class="hljs-number">71</span>D7805A
com.            <span class="hljs-number">86400</span>    <span class="hljs-keyword">IN</span>    RRSIG    DS <span class="hljs-number">8</span> <span class="hljs-number">1</span> <span class="hljs-number">86400</span> <span class="hljs-number">20260206050000</span> <span class="hljs-number">20260124040000</span> <span class="hljs-number">21831</span> . E/ZKdBG6pUCuQGB0jkM1cndavlviGO62WgLfbmQPNEz/YY7sufjwe8Jp pQA3VU9dgd46/E+<span class="hljs-number">90</span>p9q8LnK1pdGm7k0RJlA+XuvenHdXVbX+jzZn+N5 p0+fEsbociE7ot1/JmwKacwPPPKtnrep8iRELxXHU20BA4J/<span class="hljs-number">0</span>sp3z9ht <span class="hljs-number">8</span>+<span class="hljs-number">2</span>WgDoaQlKb04JQf5eS0J1hJ+mAELQbQKwWXxX8yaisSObq9axWIAKE NHUv4PO82pBf3BMwLLdZhzlfVoX/ObjcDoTm6yhHkhavB9hNOil8o6kA gg0MMcsbJqEGBrgVT1pKn9pDabUR949GFL8Qo1eHm270Dp72F8E+tfE9 ud4Nyw==
;; Received <span class="hljs-number">1170</span> bytes from <span class="hljs-number">193.0</span>.<span class="hljs-number">14.129</span><span class="hljs-comment">#53(k.root-servers.net) in 36 ms</span>

google.com.        <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    ns2.google.com.
google.com.        <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    ns1.google.com.
google.com.        <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    ns3.google.com.
google.com.        <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    ns4.google.com.
CK0POJMG874LJREF7EFN8430QVIT8BSM.com. <span class="hljs-number">900</span> <span class="hljs-keyword">IN</span> NSEC3 <span class="hljs-number">1</span> <span class="hljs-number">1</span> <span class="hljs-number">0</span> - CK0Q3UDG8CEKKAE7RUKPGCT1DVSSH8LL  NS SOA RRSIG DNSKEY NSEC3<span class="hljs-keyword">PARAM</span>
CK0POJMG874LJREF7EFN8430QVIT8BSM.com. <span class="hljs-number">900</span> <span class="hljs-keyword">IN</span> RRSIG NSEC3 <span class="hljs-number">13</span> <span class="hljs-number">2</span> <span class="hljs-number">900</span> <span class="hljs-number">20260130002721</span> <span class="hljs-number">20260122231721</span> <span class="hljs-number">35511</span> com. FRwJDTYcGgEr+lzbONMVnFNDkoYtjSmaKNF0x+q4JR+sD+rwZDoaYn/D rPkDTs5F1BwixFGXqZQizSc7cFjkdw==
S84BOR4DK28HNHPLC218O483VOOOD5D8.com. <span class="hljs-number">900</span> <span class="hljs-keyword">IN</span> NSEC3 <span class="hljs-number">1</span> <span class="hljs-number">1</span> <span class="hljs-number">0</span> - S84BR9CIB2A20L3ETR1M2415ENPP99L8  NS DS RRSIG
S84BOR4DK28HNHPLC218O483VOOOD5D8.com. <span class="hljs-number">900</span> <span class="hljs-keyword">IN</span> RRSIG NSEC3 <span class="hljs-number">13</span> <span class="hljs-number">2</span> <span class="hljs-number">900</span> <span class="hljs-number">20260131013349</span> <span class="hljs-number">20260124002349</span> <span class="hljs-number">35511</span> com. uW9ufLSEVTnIol0z4l+DX8pBSOvPIVaJSeFV8EE7cYJOgu44vzXw0rus XnZN3Zj/y6mjTGmDpGd4QHBnIevvYg==
;; Received <span class="hljs-number">644</span> bytes from <span class="hljs-number">192.54</span>.<span class="hljs-number">112.30</span><span class="hljs-comment">#53(h.gtld-servers.net) in 352 ms</span>

google.com.        <span class="hljs-number">300</span>    <span class="hljs-keyword">IN</span>    A    <span class="hljs-number">142.250</span>.<span class="hljs-number">182.46</span>
;; Received <span class="hljs-number">55</span> bytes from <span class="hljs-number">216.239</span>.<span class="hljs-number">36.10</span><span class="hljs-comment">#53(ns3.google.com) in 26 ms</span>
</code></pre>
<p>Let's look at the actual output and decode the journey.</p>
<p><strong>Step 1: The Root Check (</strong><code>.</code>)</p>
<pre><code class="lang-plaintext">.            86363    IN    NS    a.root-servers.net.
.            86363    IN    NS    b.root-servers.net.
...
;; Received 239 bytes from 127.0.2.2#53(127.0.2.2) in 1 ms
</code></pre>
<ul>
<li>It first queries the <strong>Root Servers</strong> and picked one of the random servers from the 13 root servers and get’s the IP of TLD server and proceeds to step 2.</li>
</ul>
<p><strong>Step 2: The TLD Check (</strong><code>com.</code>)</p>
<pre><code class="lang-powershell">com.            <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    h.gtld<span class="hljs-literal">-servers</span>.net.
com.            <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    g.gtld<span class="hljs-literal">-servers</span>.net.
...
;; Received <span class="hljs-number">1170</span> bytes from <span class="hljs-number">193.0</span>.<span class="hljs-number">14.129</span><span class="hljs-comment">#53(k.root-servers.net) in 36 ms</span>
</code></pre>
<ul>
<li>Now our computer asked the TLD server <a target="_blank" href="http://k.root-servers.net"><code>k.root-servers.net</code></a>, about the IP of google.com. However it responded with IP of the Authoritative Server.</li>
</ul>
<p><strong>Step 3: The Authoritative Check (</strong><a target="_blank" href="http://google.com"><code>google.com</code></a><code>.</code>)</p>
<pre><code class="lang-powershell">google.com.        <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    ns2.google.com.
google.com.        <span class="hljs-number">172800</span>    <span class="hljs-keyword">IN</span>    NS    ns1.google.com.
...
;; Received <span class="hljs-number">644</span> bytes from <span class="hljs-number">192.54</span>.<span class="hljs-number">112.30</span><span class="hljs-comment">#53(h.gtld-servers.net) in 352 ms</span>
</code></pre>
<ul>
<li>Now our computer asked the Authoritative Server <a target="_blank" href="http://h.gtld-servers.net"><code>h.gtld-servers.net</code></a>, about the IP of google.com. It responded with <code>NS ns2.google.com</code>, telling us to ask the IP from google servers directly.</li>
</ul>
<p><strong>Step 4: The Final Answer</strong></p>
<pre><code class="lang-powershell">google.com.        <span class="hljs-number">300</span>    <span class="hljs-keyword">IN</span>    A    <span class="hljs-number">142.250</span>.<span class="hljs-number">182.46</span>
;; Received <span class="hljs-number">55</span> bytes from <span class="hljs-number">216.239</span>.<span class="hljs-number">36.10</span><span class="hljs-comment">#53(ns3.google.com) in 26 ms</span>
</code></pre>
<ul>
<li>Our computer sent a request to <a target="_blank" href="http://ns3.google.com"><code>ns3.google.com</code></a> which gave us the final IP: <code>142.250.182.46</code> and we can now open google.com on our system.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769255063672/292100e5-2fe0-44cd-81a2-5aaa5197334c.gif" alt class="image--center mx-auto" /></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>If you've followed along this far in the blog, congratulations! You now understand that DNS is not magic but a complex system that required a lot of engineering to get to where it is today.</p>
]]></content:encoded></item><item><title><![CDATA[Exploring the .git Folder: What You Need to Know]]></title><description><![CDATA[In previous articles, we learned about Git, why version control systems were created, and the problems they solve. In this article, we will take a closer look at the .git folder that is created when initializing a local repository in a new codebase.
...]]></description><link>https://blog.thatsmanmeet.com/exploring-the-git-folder-what-you-need-to-know</link><guid isPermaLink="true">https://blog.thatsmanmeet.com/exploring-the-git-folder-what-you-need-to-know</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[Git]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Manmeet Singh]]></dc:creator><pubDate>Wed, 21 Jan 2026 03:37:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1768885725289/4b0935ab-7cbb-47c9-9a17-002ba5216652.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In previous articles, we learned about Git, why version control systems were created, and the problems they solve. In this article, we will take a closer look at the <code>.git</code> folder that is created when initializing a local repository in a new codebase.</p>
<h4 id="heading-creating-a-new-git-repository">Creating a New Git Repository</h4>
<p>We begin our Git journey with the command <code>git init</code>. After running this command, we receive confirmation that an empty Git repository has been created.</p>
<pre><code class="lang-plaintext">Initialized empty Git repository in /Users/manmeet/Developer/cohort/inside-git/.git/
</code></pre>
<p>This command also creates a hidden <code>.git</code> folder inside our current project folder. To see what's inside this <code>.git</code> folder, we can use the <code>tree</code> command. We get the following structure:</p>
<pre><code class="lang-plaintext">.git
├── config
├── description
├── HEAD
├── hooks
│   ├── applypatch-msg.sample
│   ├── commit-msg.sample
│   └── ... (other sample hooks)
├── info
│   └── exclude
├── objects
│   ├── info
│   └── pack
└── refs
    ├── heads
    └── tags
</code></pre>
<p>Alright, there's a lot in this folder. Let's go through each file and directory one by one to understand what they are.</p>
<ul>
<li><p><strong>config:</strong> The config file holds all the settings for the current repository, like the author's information, filemode, and other basic information.</p>
</li>
<li><p><strong>description:</strong> The description file is used only by the GitWeb UI program to display the description of the repository. By default, it holds the content "Unnamed repository..." and can usually be ignored.</p>
</li>
<li><p><strong>HEAD:</strong> The HEAD file contains the reference to the <strong>currently used branch</strong>, such as <code>main</code> or <code>master</code>. If you look through the contents, it usually contains <code>ref: refs/heads/main</code>, which points to the <code>refs</code> folder that we will cover later on.</p>
</li>
<li><p><strong>hooks:</strong> The hooks folder contains multiple scripts that can be used to perform certain steps automatically before or after Git has performed some operation. The files ending in <code>.sample</code> are disabled by default.</p>
</li>
<li><p><strong>info/exclude:</strong> The exclude file is located at <code>/info/exclude</code> and includes the files that you don’t want to be tracked by Git. However, what makes it different from <code>.gitignore</code> is that this is <strong>completely local</strong> and is not versioned or pushed to any remote repository. A real-life use case would be if one developer uses a specific tool for testing and wants those specific files excluded from their system only, without affecting the rest of the team.</p>
</li>
<li><p><strong>objects:</strong> The objects folder contains the data about the files, commits, and other information in the form of Git objects. We will cover this further in the blog.</p>
</li>
<li><p><strong>refs:</strong> The refs folder, as the name implies, stores references or pointers to the branches and tags. The folder <code>/refs/heads</code> contains the reference to the latest commits stored on the branch, and <code>/refs/tags</code> stores the references to the latest commit related to that tag.</p>
</li>
</ul>
<h4 id="heading-how-git-works-under-the-hood">How Git Works Under the Hood</h4>
<p>Let’s create a file <code>hello.txt</code> and create a commit to the main branch. The commands to perform this action are:</p>
<pre><code class="lang-plaintext">echo "hello world" &gt; hello.txt
git add hello.txt 
git commit -m "added hello.txt file"
</code></pre>
<p>The commands would create a new file <code>hello.txt</code> with the content "hello world," add it to the staging area, and then commit it to the main branch with the message "added hello.txt file." The output of the commit message is:</p>
<pre><code class="lang-plaintext">[main (root-commit) 9ef19b4] added hello.txt file
 1 file changed, 1 insertion(+)
 create mode 100644 hello.txt
</code></pre>
<p>We can see the history using <code>git log</code>. The output shows the author, time, message, and a unique SHA-1 hash assigned to the commit.</p>
<pre><code class="lang-plaintext">commit 9ef19b4705d268cbdf5906b6e1bdb73f88dc622b (HEAD -&gt; main)
Author: Manmeet &lt;email_address_here&gt;
Date:   Wed Jan 21 00:28:44 2026 +0530

    added hello.txt file
</code></pre>
<p>Let’s use the <code>tree</code> command again on that hidden <code>.git</code> folder and see what has changed.</p>
<pre><code class="lang-plaintext">.git
├── COMMIT_EDITMSG
├── config
├── ...
├── logs
│   ├── HEAD
│   └── refs
│       └── heads
│           └── main
├── objects
│   ├── 3b
│   │   └── 18e512dba79e4c8300dd08aeb37f8e728b8dad
│   ├── 68
│   │   └── aba62e560c0ebc3396e8ae9335232cd93a3f60
│   ├── 9e
│   │   └── f19b4705d268cbdf5906b6e1bdb73f88dc622b
...
└── refs
    ├── heads
    │   └── main
    └── tags
</code></pre>
<h4 id="heading-observations">Observations</h4>
<ol>
<li><p>The <strong>objects</strong> folder now has multiple subfolders that start with the first two characters of the commit hash. In our commit, the hash was <code>9ef19b4...</code>, and we can clearly see a folder starting with <code>9e</code> in the objects folder.</p>
</li>
<li><p>The <strong>refs</strong> folder has also changed, with <code>/refs/heads</code> now containing a <code>main</code> file. If we look at the contents of this <code>/refs/heads/main</code> file, we find the hash of our latest commit <code>9ef19b4...</code>. It's the same hash that the <code>git log</code> command provided us.</p>
</li>
<li><p>A new file <code>COMMIT_EDITMSG</code> contains the last commit message.</p>
</li>
</ol>
<h4 id="heading-objects-folder">Objects Folder</h4>
<p>So, now we know that the HEAD file contains a pointer to the branch with the latest commit, which in our case is <code>ref: refs/heads/main</code>. This main file contains the hash of the latest commit, and that commit can be found in the objects folder.</p>
<p>Let's go to the <code>.git/objects</code> folder and list all the files and folders in this directory.</p>
<pre><code class="lang-plaintext">cd .git/objects
ls
# outputs: 3b   68   9e   info   pack
</code></pre>
<p>The output of the command above shows several folders with only two characters. These two characters are the <strong>first two characters</strong> of the hash from the latest commit.</p>
<ul>
<li><p><strong>Latest Commit Hash:</strong> <code>9ef19b4705d268cbdf5906b6e1bdb73f88dc622b</code></p>
</li>
<li><p><strong>First two characters:</strong> <code>9e</code></p>
</li>
<li><p><strong>Remaining:</strong> <code>f19b4705d268cbdf5906b6e1bdb73f88dc622b</code></p>
</li>
</ul>
<p>So, if we try to go to the folder <code>9e</code> and print the content of the file <code>f19b4...</code> we get an output that is not easily understandable by us.</p>
<pre><code class="lang-plaintext">cd 9e
ls
cat f19b4705d268cbdf5906b6e1bdb73f88dc622b
# Output: x??A? @Ѯ=???X'?Rz??Nj@c1ho?,{?n...
</code></pre>
<p>Just look at the output above. Can you figure out what it means? Yeah, neither can I. This "garbage" text appears because Git <strong>compresses the files using zlib</strong> to save space. However, luckily, we have a tool called <code>git cat-file</code> that can help us understand the information stored in this file.</p>
<p>Let’s move outside the <code>.git</code> folder and run the command <code>git cat-file -p &lt;latest_commit_hash&gt;</code>:</p>
<pre><code class="lang-plaintext">git cat-file -p 9ef19b4705d268cbdf5906b6e1bdb73f88dc622b
</code></pre>
<p><strong>Output:</strong></p>
<pre><code class="lang-plaintext">tree 68aba62e560c0ebc3396e8ae9335232cd93a3f60
author Manmeet &lt;email_address_here&gt; 1768935524 +0530
committer Manmeet &lt;email_address_here&gt; 1768935524 +0530

added hello.txt file
</code></pre>
<p>This file contains the exact details of the commit object, including the <strong>tree</strong>, author, committer, time, and commit message of the latest commit.</p>
<h4 id="heading-what-is-tree">What is Tree?</h4>
<p>We just saw that on printing the information stored in the latest commit object, there’s some other object called "tree" stored here. Let’s try to use our <code>cat-file</code> command on this git object and see the output.</p>
<pre><code class="lang-plaintext">git cat-file -p 68aba62e560c0ebc3396e8ae9335232cd93a3f60
</code></pre>
<p><strong>Output:</strong></p>
<pre><code class="lang-plaintext">100644 blob 3b18e512dba79e4c8300dd08aeb37f8e728b8dad    hello.txt
</code></pre>
<p>From the output, we can see that the tree object contains yet another hash. Now let’s try to <code>cat-file</code> this new hash that was stored by the tree object.</p>
<pre><code class="lang-plaintext">git cat-file -p 3b18e512dba79e4c8300dd08aeb37f8e728b8dad
</code></pre>
<p><strong>Output:</strong></p>
<pre><code class="lang-plaintext">hello world
</code></pre>
<p>This new hash contained the content stored in our <code>hello.txt</code> file, which was "hello world". This is the <strong>Blob Object</strong>. It contains the actual content of our file.</p>
<p>Hence, a <strong>tree</strong> object acts like a directory. It maps filenames (like <code>hello.txt</code>) to Blob objects.</p>
<h3 id="heading-linking-commits-the-parent-field">Linking Commits: The <code>parent</code> Field</h3>
<p>So far, we have only looked at a single commit. But Git is all about history. How does Git know that one commit comes after another?</p>
<p>Let’s modify our file and create a second commit to see what happens.</p>
<pre><code class="lang-plaintext">echo "hello again" &gt;&gt; hello.txt
git add hello.txt
git commit -m "updated hello.txt"
</code></pre>
<p>Now, let's check the log to get our new commit hash.</p>
<pre><code class="lang-plaintext">git log --oneline
# Output:
# 8ad32c1 (HEAD -&gt; main) updated hello.txt
# 9ef19b4 added hello.txt file
</code></pre>
<p>We have a new commit with the hash starting with <code>8ad32c</code>. Let's use our trusty <code>git cat-file</code> command to look inside this <strong>new</strong> commit object.</p>
<pre><code class="lang-plaintext">git cat-file -p 8ad32c1
</code></pre>
<p><strong>Output:</strong></p>
<pre><code class="lang-plaintext">tree 42091e6d12345...
parent 9ef19b4705d268cbdf5906b6e1bdb73f88dc622b
author Manmeet &lt;email@example.com&gt; 1768936000 +0530
committer Manmeet &lt;email@example.com&gt; 1768936000 +0530

updated hello.txt
</code></pre>
<p><strong>Observation:</strong> Notice that there is a <strong>new line</strong> that wasn't there before: <code>parent</code>.</p>
<ul>
<li><p>The <code>parent</code> field contains the hash of our <strong>previous commit</strong> (<code>9ef19b4...</code>).</p>
</li>
<li><p>This "parent" pointer is how Git connects commits together.</p>
</li>
</ul>
<p>If we made a third commit, it would point to <code>8ad32c</code> as its parent. This chain of parents allows Git to traverse backward through history, from the current state all the way back to the very first commit.</p>
<p>Btw for anyone curious the data structure used here is <strong>Linked List</strong>.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>By following the breadcrumbs, we uncovered how Git stores data:</p>
<ol>
<li><p><strong>Commit:</strong> Stores the metadata (author, time) and points to a Tree.</p>
</li>
<li><p><strong>Tree:</strong> Stores the directory structure and filenames, pointing to Blobs.</p>
</li>
<li><p><strong>Blob:</strong> Stores the raw file content.</p>
</li>
</ol>
<p>Now you know what the hidden <code>.git</code> folder contains and how Git organizes and stores data for efficient project management.</p>
]]></content:encoded></item><item><title><![CDATA[Why the Pendrive Problem Highlights the Need for Version Control]]></title><description><![CDATA[In my previous article, I explained what GIT is. Now, let me ask you a simple question: Why were Version Control Systems created? We had storage solutions like pen drives and hard drives, and sharing files was easy. You could just copy and paste the ...]]></description><link>https://blog.thatsmanmeet.com/why-the-pendrive-problem-highlights-the-need-for-version-control</link><guid isPermaLink="true">https://blog.thatsmanmeet.com/why-the-pendrive-problem-highlights-the-need-for-version-control</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[Git]]></category><category><![CDATA[version control]]></category><dc:creator><![CDATA[Manmeet Singh]]></dc:creator><pubDate>Mon, 19 Jan 2026 18:28:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1768879984053/b4898efa-3542-4c36-a9d9-5b5a210afa02.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In my previous article, I explained <a target="_blank" href="https://blog.thatsmanmeet.com/beginners-guide-to-git">what GIT is</a>. Now, let me ask you a simple question: Why were Version Control Systems created? We had storage solutions like pen drives and hard drives, and sharing files was easy. You could just copy and paste the files to share them with your friends or team members physically. So, what was the problem?</p>
<p>This is where I would like to introduce you to PenDrive Analogy.</p>
<h2 id="heading-the-pendrive-analogy">The Pendrive Analogy</h2>
<p>Let’s assume a situation where Alice is working on a codebase. Now while working on the project Alice realises that she might need to take a leave for 3 days due to some work, so she requests her team member Bob to develop a remaining feature for her.</p>
<p>Bob agrees and Alice copies the files from her computer in a pendrive and hands over the pen drive to the Bob and left the office. Bob plugs the pen drive in his computer, copies the code files and start working on the codebase.</p>
<p>While working on the remaining features Bob realises that certain existing part of the code also needs to be changed in order for this feature to work. So, he tweaks certain existing parts of the code as well including deleting a few existing code, but at the end of the day, he achieved the result. He had successfully coded the feature, tested it by running the code and calls it the day!</p>
<p>Three days later, Alice comes back to the office and found the pen drive in the Bob’s cubicle with the note “I’m going on a vacation and I have coded the remaining feature. Tested it and it worked perfectly”. Alice took the pen drive and after few daily office chores, she sits down to work on further tasks on the codebase.</p>
<p>She plugs the pen drive into her computer, copies the code files to her system and opened the code editor, executes the code and found the feature coded by the Bob is working perfectly fine. She was happy to see the feature working but then immediately notices an issue.</p>
<p>Few of the other features that she had worked on earlier are broken and some are not responding well. She switches back to the code editor and…</p>
<p><strong>She Freezes.</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768847215901/2cab5156-311a-4643-96bf-bad635a94b27.gif" alt class="image--center mx-auto" /></p>
<p>Bob has added enormous amount of the code into developing that feature and also have modified the code for some of the previous features. Since, she has replaced the old version of codebase from her computer with Bob’s version, she is now stuck with no way out to know what changes Bob has made to the codebase and how code used to look earlier.</p>
<p>She panics! Asks another team member, if they had the old version of the codebase present on their system. Luckily, she did find it but now she had two versions <code>Accounting_software_old.zip</code> and <code>Accounting_software_new.zip</code>. Now the old one doesn’t have the feature that Bob developed and new one is broken and she needs to show this to the client in upcoming meetings.</p>
<p>She is now stuck playing a game of "Spot the Difference" manually, line by line, while the client meeting clock ticks down. She calls Bob, who is gone on vacation and tells her about the problem. Bob goes to his hotel room, took his laptop out and checks and found some issues, he immediately fixes it but now the problem arises, how to share it back to Alice?</p>
<p>Another issue is that now there exists another version of the codebase with the Bob’s version <code>Accounting_software_new_fixed.zip</code>, which is again an issue. Which codebase will now be considered as source of truth? Alice’s old one? Bob’s feature one? or the one Bob just fixed?</p>
<p>Somehow, Bob saves the day by sending the new code as Email!</p>
<h2 id="heading-why-the-pendrive-system-failed">Why the Pendrive System Failed</h2>
<ol>
<li><p><strong>The Nightmare of No History (No Undo Button):</strong> When Alice replaced her old files with Bob’s new ones, she effectively erased the past. If Bob made a mistake, there was no way to go back to how the code looked yesterday. The past was overwritten forever.</p>
</li>
<li><p><strong>The Nightmare of Blindness (No Change Tracking):</strong> Alice knew <em>that</em> the code was different, but she couldn't see <em>what</em> was different. She was forced to play a manual game of "Spot the Difference" across thousands of lines of code.</p>
</li>
<li><p><strong>The Nightmare of Truth (Source of Truth Problem):</strong> By the end of the story, we had <code>Accounting_software_</code><a target="_blank" href="http://old.zip"><code>old.zip</code></a>, <code>Accounting_software_</code><a target="_blank" href="http://new.zip"><code>new.zip</code></a>, and the emailed <code>Accounting_software_new_</code><a target="_blank" href="http://fixed.zip"><code>fixed.zip</code></a>. Which one is the real project? If Alice fixes a bug in the "Old" one while Bob adds a feature to the "New" one, they have created two separate realities that will be incredibly hard to combine.</p>
</li>
</ol>
<p>This is why version control systems like GIT, SVN, Mercurial etc were created.</p>
<h2 id="heading-how-version-control-systems-solved-this-problem">How Version Control Systems Solved this Problem</h2>
<p>Version Control Systems (VCS) were created specifically to prevent the "Pendrive Panic" we just described.</p>
<ol>
<li><p><strong>Tracking the Changes:</strong> Think of VCS like a CCTV camera for your code. It doesn't just save the file; it tracks every single line that was added, deleted, or changed. You don't just see <em>that</em> the file changed but also <em>what exactky</em> changed.</p>
</li>
<li><p><strong>Accountability:</strong> In our story, Alice didn't know for sure what Bob touched. VCS tracks exactly <em>who</em> made the change.</p>
</li>
<li><p><strong>Ability to Migrate Back:</strong> This is the biggest lifesaver. Since VCS saves a snapshot of your project every time you commit, you have an infinite Undo button. If the new code crashes the app, you can instantly roll back to the version from yesterday that was working perfectly.</p>
</li>
<li><p><strong>Ability to Work on Multiple Features :</strong> This allows Alice and Bob to work in parallel universes. Alice can work on her feature in a separate "branch" without touching Bob's code. They can both code simultaneously without overriding each other's files.</p>
</li>
<li><p><strong>Collaboration:</strong> No more emailing Zip files. VCS acts as a central hub (like on a server) where everyone syncs their work. It becomes the single source of truth for the whole team.</p>
</li>
</ol>
<h2 id="heading-conclusion">Conclusion</h2>
<p>We learned from the story that version control systems does simplify our lives a lot by tracking changes across entire projects and by providing ability to easily collaborate with others by hosting it on a server, hence solving the traditional pen drive problem.</p>
]]></content:encoded></item><item><title><![CDATA[Beginner's Guide to GIT]]></title><description><![CDATA[Remember when we used to work on school projects and needed a presentation? It was such a hassle for everyone to collaborate on a single project. We had to email the presentation around, and if there was an issue, we'd resend it. Then, everyone had t...]]></description><link>https://blog.thatsmanmeet.com/beginners-guide-to-git</link><guid isPermaLink="true">https://blog.thatsmanmeet.com/beginners-guide-to-git</guid><category><![CDATA[Git]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[version control]]></category><category><![CDATA[version control systems]]></category><dc:creator><![CDATA[Manmeet Singh]]></dc:creator><pubDate>Sun, 18 Jan 2026 06:50:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/842ofHC6MaI/upload/4c8f451cffa2382e3431008d8bfa0e15.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Remember when we used to work on school projects and needed a presentation? It was such a hassle for everyone to collaborate on a single project. We had to email the presentation around, and if there was an issue, we'd resend it. Then, everyone had to delete the old version and download the new one. It was tough to see what changes someone made. In fact, someone had to keep a separate list just to track the changes and the presentation.</p>
<p>However, today it's a different story. If I had the ability to go back in time, I would definitely have used GIT.</p>
<h2 id="heading-what-is-git">What is GIT</h2>
<p>Git is an open source tool which is used mostly by software developers to track the changes and help in easy collaboration between multiple people across entire projects.</p>
<p>GIT is a Version Control System (VCS). Before we understand what a Version Control System is, first we need to understand what versions are.</p>
<p>Whenever you work on a project, you don’t create it in one shot. You improve it step by step:</p>
<ul>
<li><p>first draft</p>
</li>
<li><p>small improvement</p>
</li>
<li><p>new feature</p>
</li>
<li><p>bug fix</p>
</li>
</ul>
<p>Each meaningful state of the project is a <strong>version</strong>. In Git, a version is not just “the next file” or “an updated copy”. A version in Git is a <strong>snapshot of the entire project at a specific moment in time</strong>.</p>
<p>Hence, a version control system is a software that records these snapshots, keep them organised and allow us to move between them easily. Git is one of the widely used version control system.</p>
<h2 id="heading-why-git-is-used">Why GIT is used?</h2>
<p>Git is primarily used for multiple reasons such as:</p>
<ol>
<li><p><strong>Keeping Track of the changes</strong>: As the project grows bigger, manually tracking changes become impossible. However, Git automatically take cares of this problem by keeping a history of every single change done to the project, author who did the changes and when the changes were done.</p>
</li>
<li><p><strong>Easy Collaboration with others:</strong> Git allows multiple people to work on the same project without constantly sending files back and forth.Platforms like <strong>GitHub</strong> act as a shared place where people can synchronize their work, review changes, and collaborate efficiently.</p>
</li>
<li><p><strong>Allow to work on multiple features at once</strong>: Git allows multiple people to work on separate features using the branches and then later merge those features into the main codebase, hence boosting efficiency and development speeds.</p>
</li>
</ol>
<h2 id="heading-common-terminologies">Common Terminologies</h2>
<ol>
<li><p><strong>Working Directory:</strong> This is the current folder where your codebase is located. It includes all the files and folders you see and work on. It contains all the files tracked, modified, untracked, and ignored by Git.</p>
</li>
<li><p><strong>Local Repository:</strong> This is the hidden <code>.git</code> folder that contains a snapshot of your entire project.</p>
</li>
<li><p><strong>Staging Area:</strong> This is where changes made to files in the working directory are stored before saving a snapshot of these changes in the local repository.</p>
</li>
<li><p><strong>Remote Repository:</strong> A Git repository stored on a remote server or cloud platform like GitHub is called a Remote Repository.</p>
</li>
<li><p><strong>Commit</strong>: A commit is when you create a new snapshot of changes from the working directory to the local repository through the staging area.</p>
</li>
<li><p><strong>Push</strong>: The process of moving changes from the local repository to the remote repository is called pushing.</p>
</li>
<li><p><strong>Fetch</strong>: The process of checking for any new changes from the remote repository is called fetching.</p>
</li>
<li><p><strong>Pull</strong>: The process of bringing new changes from the remote repository into the local repository and the current working directory is called pulling.</p>
</li>
<li><p><strong>Untracked Files:</strong> These are the files in the working directory that are not being tracked for changes by Git. In VSCode, they are usually marked with a "U" symbol.</p>
</li>
<li><p><strong>Modified Files</strong>: These are the files in the working directory that are being tracked and have been modified. They are usually marked with an "M" symbol in VSCode.</p>
</li>
<li><p><strong>Added Files:</strong> These are files in the working directory that were initially untracked by Git and have been added to the staging area but haven't been committed yet. In VSCode, they are usually marked with an "A" symbol.</p>
</li>
<li><p><strong>Deleted Files:</strong> These are files in the working directory that are tracked by Git and have been deleted from the working directory. They are usually marked with a "D" symbol in VSCode.</p>
</li>
<li><p><strong>Branch:</strong> A branch allows you to create a separate line of development, enabling you to work on features or fixes without affecting the main codebase.</p>
</li>
<li><p><strong>HEAD:</strong> This is a pointer that shows the current branch or commit you are working on in your repository.</p>
</li>
</ol>
<h2 id="heading-git-basics-how-git-works">GIT Basics: How GIT Works</h2>
<p>To understand, how Git works, here’s a diagram from the official GIT website.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1768715948007/b52fdd5f-9a89-45b0-9e13-8abdba8c5990.png" alt class="image--center mx-auto" /></p>
<ol>
<li><p>Initially, you have a project folder or the working directory where no files are being tracked by the GIT.</p>
</li>
<li><p>When we run a command <code>git init</code>, it initialize an empty git repository and a new hidden <code>.git</code> folder is created in the same directory.</p>
</li>
<li><p>Currently most of the files are still untracked. So, we need to tell the git to start tracking the files and we use <code>git add .</code> command. Once we run this command, then all the files are sent to the <strong>Staging Area</strong> and the files are now being tracked by the GIT.</p>
</li>
<li><p>Once we are satisfied with all the changes, we run the command <code>git commit -m “some message“</code> and all the changes from the staging area is sent to the <strong>local repository</strong>, hence creating a snapshot of the entire project.</p>
</li>
<li><p>Now at this point, our entire project is being tracked by the GIT.</p>
</li>
<li><p>If we make a change in our working directory at this point, either by modifying some file or adding a new file, GIT will immediately notice the files are modified.</p>
</li>
<li><p>So, we need to again use <code>git add .</code> command and send the modified files to the staging area and commit them again to save a new snapshot of these changes.</p>
</li>
<li><p>By running the command <code>git log</code>, we can see entire history of the commits which includes the hash, author and the commit message.</p>
</li>
</ol>
<h2 id="heading-common-git-commands">Common GIT Commands</h2>
<ol>
<li><p><strong>git init:</strong> This command creates an new local repository in your current working directory. In other words, this will convert your normal project folder into a git repository.</p>
</li>
<li><p><strong>git add</strong>: This command allows git to understand which files to track and add them into the staging area. We can add single file like <code>git add hello.txt</code> or all the files using dot symbol like <code>git add .</code></p>
</li>
<li><p><strong>git commit:</strong> This command sends the changes from the staging area into the local repository. It also includes a message flag with it like <code>git commit -m “initial commit“</code>.</p>
</li>
<li><p><strong>git log:</strong> This command shows the entire history of the commits done inside a GIT repository. These logs contain the hash, author, date/time and commit message. There’s also another version of this command that prints shorter logs with <code>—oneline</code> flag. Command becomes <code>git log —oneline</code>.</p>
</li>
<li><p><strong>git diff:</strong> This command shows the changes between the commits. we can use it like <code>git diff &lt;hash_1&gt; &lt;hash_2&gt;</code> or we can see changes in staging area like <code>git diff —staged</code>.</p>
</li>
<li><p><strong>git branch:</strong> This command will show all the branches that exists in the current repository. The branch that shows with aestricks (*) like <code>main*</code> is the currently active branch.</p>
</li>
<li><p><strong>git pull:</strong> This command fetches the latest changes from the remote repository and merges them into the current branch.</p>
</li>
<li><p><strong>git push:</strong> This command sends your local commits to the remote repository.</p>
</li>
</ol>
<h2 id="heading-conclusion">Conclusion</h2>
<p>GIT is a powerful tool that allows for tracking changes and collaboration with other team members in a much easier way and it’s not even difficult to learn. With only these commands shown in the above section we can achieve 95% of the work in the GIT.</p>
]]></content:encoded></item><item><title><![CDATA[Building a Thinking Model from a Non Thinking Model with Chain of Thought]]></title><description><![CDATA[Large language models can be great at fluent writing yet shaky at reasoning. Many jump to an answer without showing the steps. Chain of Thought prompting nudges the model to reason step by step, so a non thinking model starts to behave like a thinkin...]]></description><link>https://blog.thatsmanmeet.com/building-a-thinking-model-from-a-non-thinking-model-with-chain-of-thought</link><guid isPermaLink="true">https://blog.thatsmanmeet.com/building-a-thinking-model-from-a-non-thinking-model-with-chain-of-thought</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[AI]]></category><category><![CDATA[genai]]></category><category><![CDATA[chain of thought]]></category><dc:creator><![CDATA[Manmeet Singh]]></dc:creator><pubDate>Fri, 15 Aug 2025 13:48:17 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/4QVqSh4VvP4/upload/0829d70d87d19f1925ba07945acf7c51.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Large language models can be great at fluent writing yet shaky at reasoning. Many jump to an answer without showing the steps. Chain of Thought prompting nudges the model to reason step by step, so a non thinking model starts to behave like a thinking one.</p>
<h2 id="heading-what-is-chain-of-thought">What is Chain of Thought</h2>
<p>Chain of Thought is a prompt style that asks the model to break a problem into intermediate steps before giving the final answer. That gentle structure reduces careless mistakes.</p>
<p><strong>Example without CoT</strong></p>
<pre><code class="lang-bash">Q: If you have 3 apples and get 2 more, how many <span class="hljs-keyword">do</span> you have?
A: 5
</code></pre>
<p><strong>Example with CoT</strong></p>
<pre><code class="lang-bash">Q: If you have 3 apples and get 2 more, how many <span class="hljs-keyword">do</span> you have?
A: I start with 3 apples. I add 2 apples. Now I have 5 apples <span class="hljs-keyword">in</span> total. The answer is 5.
</code></pre>
<h2 id="heading-why-some-models-need-this">Why some models need this</h2>
<p>Some models are tuned for short, confident replies. They may skip reasoning, make intuitive guesses, or become inconsistent on multi step problems. CoT acts like scaffolding that guides each step.</p>
<h2 id="heading-a-minimal-helper-for-examples">A minimal helper for examples</h2>
<p>Below is a tiny wrapper you can adapt to your setup. Replace the body with your actual chat call.</p>
<pre><code class="lang-js"><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">chatCompletion</span>(<span class="hljs-params">prompt</span>) </span>{
  <span class="hljs-comment">// return await client.responses.create({ input: prompt });</span>
  <span class="hljs-keyword">return</span> <span class="hljs-string">"Mocked response for illustration"</span>;
}
</code></pre>
<h2 id="heading-basic-chain-of-thought-prompt">Basic Chain of Thought prompt</h2>
<p>Add a simple instruction like “Think step by step.”</p>
<pre><code class="lang-js"><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">chainOfThought</span>(<span class="hljs-params">question</span>) </span>{
  <span class="hljs-keyword">const</span> prompt = <span class="hljs-string">`<span class="hljs-subst">${question}</span>
Please think step by step before answering.`</span>;
  <span class="hljs-keyword">const</span> reply = <span class="hljs-keyword">await</span> chatCompletion(prompt);
  <span class="hljs-built_in">console</span>.log(reply);
}

<span class="hljs-comment">// Example</span>
chainOfThought(
  <span class="hljs-string">"A car travels 60 km in 1 hour. How far will it travel in 4 hours?"</span>
);
<span class="hljs-comment">/*
Expected shape:
First, in 1 hour the car travels 60 km.
In 4 hours that is 60 × 4 = 240 km.
So the answer is 240 km.
*/</span>
</code></pre>
<h2 id="heading-structured-reasoning-template">Structured reasoning template</h2>
<p>Give the model a clear structure to follow.</p>
<pre><code class="lang-js"><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">structuredCoT</span>(<span class="hljs-params">question</span>) </span>{
  <span class="hljs-keyword">const</span> template = <span class="hljs-string">`
Question: <span class="hljs-subst">${question}</span>
Step 1: Restate the problem.
Step 2: Identify key facts.
Step 3: Solve step by step.
Step 4: Provide the final answer.`</span>;
  <span class="hljs-keyword">const</span> reply = <span class="hljs-keyword">await</span> chatCompletion(template);
  <span class="hljs-built_in">console</span>.log(reply);
}

<span class="hljs-comment">// Example</span>
structuredCoT(
  <span class="hljs-string">"If a box holds 8 books, how many boxes are needed for 100 books? Return an integer and explain."</span>
);
<span class="hljs-comment">/*
Expected shape:
Step 1: We need the number of boxes...
Step 2: Each box holds 8 books...
Step 3: 100 ÷ 8 = 12.5 so we need 13 boxes...
Step 4: Final answer: 13.
*/</span>
</code></pre>
<h2 id="heading-few-shot-plus-chain-of-thought">Few shot plus Chain of Thought</h2>
<p>Show one or two worked solutions before the real question. This sets a pattern the model can imitate.</p>
<pre><code class="lang-js"><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">fewShotCoT</span>(<span class="hljs-params">question</span>) </span>{
  <span class="hljs-keyword">const</span> prompt = <span class="hljs-string">`
You will solve problems by explaining your steps briefly, then giving a final answer on a new line starting with "Answer:".

Example 1
Q: I have 5 pencils and buy 3 more. How many in total?
A: I start with 5 pencils. I add 3 pencils. That makes 8 pencils in total.
Answer: 8

Example 2
Q: A bag has 4 apples, and I add 6 more. How many apples now?
A: I start with 4 apples. I add 6 apples. That makes 10 apples in total.
Answer: 10

Now your turn
Q: <span class="hljs-subst">${question}</span>
A:`</span>;
  <span class="hljs-keyword">const</span> reply = <span class="hljs-keyword">await</span> chatCompletion(prompt);
  <span class="hljs-built_in">console</span>.log(reply);
}

<span class="hljs-comment">// Example</span>
fewShotCoT(<span class="hljs-string">"There are 7 oranges, and I buy 5 more. How many in total?"</span>);
<span class="hljs-comment">/*
Expected shape:
I start with 7 oranges. I add 5 oranges. That makes 12 oranges in total.
Answer: 12
*/</span>
</code></pre>
<h2 id="heading-guardrails-for-clarity-and-brevity">Guardrails for clarity and brevity</h2>
<p>CoT can increase length and latency. Keep it tidy with explicit formatting rules.</p>
<pre><code class="lang-js"><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">conciseCoT</span>(<span class="hljs-params">question</span>) </span>{
  <span class="hljs-keyword">const</span> prompt = <span class="hljs-string">`
Solve the following task using at most three short steps, then give a final line starting with "Answer:".
Keep explanations compact.

Task: <span class="hljs-subst">${question}</span>`</span>;
  <span class="hljs-keyword">const</span> reply = <span class="hljs-keyword">await</span> chatCompletion(prompt);
  <span class="hljs-built_in">console</span>.log(reply);
}

<span class="hljs-comment">// Example</span>
conciseCoT(<span class="hljs-string">"A train moves 90 km per hour for 2.5 hours. How far does it travel?"</span>);
<span class="hljs-comment">/*
Expected shape:
Step 1: Rate is 90 km per hour.
Step 2: Time is 2.5 hours.
Step 3: Distance = 90 × 2.5 = 225 km.
Answer: 225 km
*/</span>
</code></pre>
<h2 id="heading-programmatic-checker-pattern">Programmatic checker pattern</h2>
<p>Ask the model to propose steps, then verify or recompute the final answer. This can catch slips on arithmetic or logic.</p>
<pre><code class="lang-js"><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">proposeVerify</span>(<span class="hljs-params">question</span>) </span>{
  <span class="hljs-keyword">const</span> prompt = <span class="hljs-string">`
You will solve the problem in two phases.

Phase A Reasoning
Explain your steps briefly.

Phase B Check
Recompute the final value directly and confirm it matches.

Problem: <span class="hljs-subst">${question}</span>

Output format:
Reasoning: &lt;two to four short sentences&gt;
Check: &lt;one sentence&gt;
Answer: &lt;final value only&gt;`</span>;
  <span class="hljs-keyword">const</span> reply = <span class="hljs-keyword">await</span> chatCompletion(prompt);
  <span class="hljs-built_in">console</span>.log(reply);
}

<span class="hljs-comment">// Example</span>
proposeVerify(<span class="hljs-string">"A recipe needs 3 cups of flour for one batch. How many cups for 7 batches?"</span>);
<span class="hljs-comment">/*
Expected shape:
Reasoning: One batch uses 3 cups. Seven batches require 7 × 3.
Check: 7 × 3 = 21.
Answer: 21
*/</span>
</code></pre>
<h2 id="heading-side-by-side-prompt-for-learning-effect">Side by side prompt for learning effect</h2>
<p>Use a single prompt that contrasts naive answering with stepwise reasoning.</p>
<pre><code class="lang-js"><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">compareNaiveVsCoT</span>(<span class="hljs-params">question</span>) </span>{
  <span class="hljs-keyword">const</span> prompt = <span class="hljs-string">`
We will answer the same question in two ways.

Naive answer
Just give a direct answer without explanation.

Reasoned answer
Think step by step in two or three short lines, then provide a final line starting with "Answer:".

Question: <span class="hljs-subst">${question}</span>

Begin.`</span>;
  <span class="hljs-keyword">const</span> reply = <span class="hljs-keyword">await</span> chatCompletion(prompt);
  <span class="hljs-built_in">console</span>.log(reply);
}

<span class="hljs-comment">// Example</span>
compareNaiveVsCoT(
  <span class="hljs-string">"You have 48 candies and share them equally among 6 friends. How many candies per friend?"</span>
);
<span class="hljs-comment">/*
Expected shape:
Naive answer: 8
Reasoned answer:
48 candies shared among 6 friends means division.
48 ÷ 6 = 8.
Answer: 8
*/</span>
</code></pre>
<h2 id="heading-practical-tips">Practical tips</h2>
<ol>
<li><p>Start with a simple “think step by step” instruction</p>
</li>
<li><p>If results are messy, add a structure with labeled steps</p>
</li>
<li><p>If the model still struggles, include one or two worked examples</p>
</li>
<li><p>Keep explanations concise by setting limits on step count or sentence length</p>
</li>
<li><p>Use a final explicit line for the answer so it is easy to parse in code</p>
</li>
</ol>
<h2 id="heading-summary">Summary</h2>
<p>Chain of Thought turns a quick guessing model into a steadier reasoner by guiding each step. You do not change the architecture. You just prompt better. Begin with a plain instruction, add structure when needed, and combine with a few examples for tricky tasks.</p>
]]></content:encoded></item><item><title><![CDATA[Prompt Engineering 101]]></title><description><![CDATA[Understanding Why System Prompts Matter
When interacting with an AI model, you usually set the tone and behavior using a system prompt, it's the invisible guide at the start of each conversation. Think of it as greeting the model with: “You are helpf...]]></description><link>https://blog.thatsmanmeet.com/prompt-engineering-101</link><guid isPermaLink="true">https://blog.thatsmanmeet.com/prompt-engineering-101</guid><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[AI]]></category><category><![CDATA[genai]]></category><category><![CDATA[#PromptEngineering]]></category><category><![CDATA[Prompt]]></category><dc:creator><![CDATA[Manmeet Singh]]></dc:creator><pubDate>Fri, 15 Aug 2025 13:41:57 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/5uNgZE6KfZo/upload/47da5b7db61335e1367c3bef6e98866a.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-understanding-why-system-prompts-matter">Understanding Why System Prompts Matter</h2>
<p>When interacting with an AI model, you usually set the tone and behavior using a system prompt, it's the invisible guide at the start of each conversation. Think of it as greeting the model with: “You are helpful and concise.” That cue influences how the AI replies. A system prompt can define role, tone, format, or even the rules of the game. For example:</p>
<pre><code class="lang-text">You are an assistant that writes short fairy tales for children.
You answer in friendly, imaginative sentences.
</code></pre>
<p>Here, you assign role and style, making sure the AI stays on track. Systems like Microsoft’s have used similar prompts to control the output format and tone.</p>
<hr />
<h2 id="heading-zero-shot-prompting">Zero-Shot Prompting</h2>
<p><strong>What it is</strong>: You directly ask the model to perform a task no examples provided. It relies entirely on its training and your instruction.</p>
<p><strong>When to use</strong>: For simple, well-understood tasks (e.g. translations, summarization, classification)</p>
<p><strong>Code example</strong>:</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">zero_shot</span>(<span class="hljs-params">prompt</span>):</span>
    <span class="hljs-keyword">return</span> chat_completion(<span class="hljs-string">f"Classify this as positive or negative: <span class="hljs-subst">{prompt}</span>"</span>)

<span class="hljs-comment"># Usage</span>
result = zero_shot(<span class="hljs-string">"I am so happy with this product!"</span>)
</code></pre>
<p><strong>Why it works</strong>: If the model has seen the task in training, it can often do it well even without examples.</p>
<hr />
<h2 id="heading-few-shot-prompting">Few-Shot Prompting</h2>
<p><strong>What it is</strong>: You provide a few examples along with instructions. The model imitates the pattern.</p>
<p><strong>When to use</strong>: For structured tasks or when precise formatting is needed (e.g. JSON, templated outputs).</p>
<p><strong>Code example</strong>:</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">few_shot</span>(<span class="hljs-params">prompt</span>):</span>
    examples = <span class="hljs-string">"""
Example 1: Convert to passive voice:
The cat chased the mouse. → The mouse was chased by the cat.

Example 2: Convert to passive voice:
The chef cooked the meal. → The meal was cooked by the chef.

Now convert to passive:
"""</span> + prompt
    <span class="hljs-keyword">return</span> chat_completion(examples)
</code></pre>
<p>This helps the model mimic exact transformations because it sees examples first.</p>
<hr />
<h2 id="heading-chain-of-thought-prompting">Chain-of-Thought Prompting</h2>
<p><strong>What it is</strong>: You ask the model to show its reasoning step by step. This helps it break down complex tasks.</p>
<p><strong>When to use</strong>: For multi-step logic, math problems, or complex decision-making.</p>
<p><strong>Code example</strong>:</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">chain_of_thought</span>(<span class="hljs-params">prompt</span>):</span>
    <span class="hljs-keyword">return</span> chat_completion(<span class="hljs-string">f"<span class="hljs-subst">{prompt}</span> Explain your reasoning step by step."</span>)

<span class="hljs-comment"># Usage</span>
chain_of_thought(<span class="hljs-string">"If a train travels 60 miles in one hour, how far in 3 hours?"</span>)
</code></pre>
<p><strong>Why it works</strong>: The model gives intermediate reasoning, which often improves accuracy, especially on reasoning benchmarks.</p>
<hr />
<h2 id="heading-persona-based-prompting">Persona-Based Prompting</h2>
<p><strong>What it is</strong>: You ask the model to adopt a persona or role like a teacher, scientist, or storyteller. This can influence tone, vocabulary, and style.</p>
<p><strong>When to use</strong>: When you want responses from a specific voice or perspective.</p>
<p><strong>Code example</strong>:</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">persona_response</span>(<span class="hljs-params">prompt</span>):</span>
    role = <span class="hljs-string">"You are a kind, patient teacher explaining to a child."</span>
    question = <span class="hljs-string">"Explain what a rainbow is."</span>
    <span class="hljs-keyword">return</span> chat_completion(<span class="hljs-string">f"<span class="hljs-subst">{role}</span>\n<span class="hljs-subst">{question}</span>"</span>)
</code></pre>
<p>Some research shows that adding a persona may help in certain tasks, but results vary. In some studies, persona-based prompts outperformed Chain-of-Thought and few-shot in reasoning tasks, while others found no real improvement in factual performance when adding social roles.</p>
<hr />
<h2 id="heading-bringing-it-all-together">Bringing It All Together</h2>
<p>When you prompt well, the model works better. Here is how the pieces fit:</p>
<ul>
<li><p><strong>System prompt</strong>: sets the foundation role, tone, rules.</p>
</li>
<li><p><strong>Zero-shot</strong>: go direct when tasks are simple and clear.</p>
</li>
<li><p><strong>Few-shot</strong>: show examples when you need structure or examples.</p>
</li>
<li><p><strong>Chain-of-Thought</strong>: use for logic or multi-step problems.</p>
</li>
<li><p><strong>Persona-based</strong>: adopt special voice or style, but test its impact.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Explaining Vector Embeddings to Mom]]></title><description><![CDATA[Hey Mom, today I want to tell you about something called vector embeddings. You might think that this is some rocket science concept from the world of AI but In fact, it’s a lot like things you already understand from everyday life.
Imagine a Giant M...]]></description><link>https://blog.thatsmanmeet.com/explaining-vector-embeddings-to-mom</link><guid isPermaLink="true">https://blog.thatsmanmeet.com/explaining-vector-embeddings-to-mom</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[#chairs]]></category><category><![CDATA[vector embeddings]]></category><dc:creator><![CDATA[Manmeet Singh]]></dc:creator><pubDate>Wed, 13 Aug 2025 11:39:37 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/ANuuRuCRRAc/upload/16930968616f522e66268a0c84fe9c51.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hey Mom, today I want to tell you about something called <strong>vector embeddings</strong>. You might think that this is some rocket science concept from the world of AI but In fact, it’s a lot like things you already understand from everyday life.</p>
<h2 id="heading-imagine-a-giant-map-of-everything">Imagine a Giant Map of Everything</h2>
<p>Think of all the words, pictures, or songs in the world as points on a giant map. On this map, things that are <strong>similar</strong> are placed <strong>closer together</strong>, and things that are very different are far apart.</p>
<p>For example:</p>
<ul>
<li><p>“Apple” and “Banana” are close together because they are both fruits.</p>
</li>
<li><p>“Apple” and “Car” are far apart because they are very different.</p>
</li>
</ul>
<p>That map is what computers use when they turn things into <strong>vectors</strong> which are just lists of numbers that help the computer know where each thing belongs on the map.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755084902443/ef1178fe-c0ea-4b9f-a7c8-c0faa49a6f3e.png" alt class="image--center mx-auto" /></p>
<p>In the image above, we can clearly see that whenever I say "France," the first word that usually comes to mind is "Eiffel Tower." Mom, have you ever wondered why? It's because our minds are good at forming relationships between different words. So, even though France is a country and not a monument, and on the vector map they are kept separate, this is the beauty of vector embeddings. With the help of these maps, we can still infer that there's a connection between "France" and "Eiffel Tower."</p>
<h2 id="heading-numbers-that-capture-meaning">Numbers That Capture Meaning</h2>
<p>A vector is basically a string of numbers like <code>[0.2, 0.5, 0.8]</code>. At first glance, it looks random but these numbers <strong>encode meaning</strong>.</p>
<p>For example:</p>
<ul>
<li><p>Words that mean similar things will have vectors that point in similar directions.</p>
</li>
<li><p>Pictures of cats will have vectors that are closer to each other than pictures of dogs.</p>
</li>
</ul>
<p>The computer doesn’t “understand” like we do, it just notices patterns in the numbers.</p>
<h2 id="heading-why-this-is-useful">Why This Is Useful</h2>
<p>When we give a query to a Transformer, It becomes so much easier for a GPT to understand the context of query and how each token are related to one another even if one surface they don’t look the same. With the tokens placed on the vector maps, it is easier to find the relationship between different words hence enabling GPT to provide better outputs as a response.</p>
<h2 id="heading-a-simple-analogy">A Simple Analogy</h2>
<p>Imagine you have a box of chocolates. Each chocolate has a tag: flavor, sweetness, color. If you want a chocolate that is <strong>similar</strong> to your favorite, you just look for chocolates whose tags are close to your favorite chocolate. That’s what vector embeddings do they give each item a “tag” that’s really a bunch of numbers, so the computer can find similar things easily.</p>
<h2 id="heading-wrapping-it-up">Wrapping It Up</h2>
<p>So, Mom, vector embeddings are basically a way to turn messy, complicated things; words, pictures, music into numbers so computers can <strong>understand similarity</strong>. Think of it as a giant invisible map where everything has a spot, and things that are alike naturally cluster together.</p>
]]></content:encoded></item><item><title><![CDATA[What is Tokenization in GPT?]]></title><description><![CDATA[When we were just kids in school, we started learning about first language by learning Alphabets, then words, then sentences. Whenever we have a conversation with someone, our mind automatically breaks the sentence into individual words and try to an...]]></description><link>https://blog.thatsmanmeet.com/what-is-tokenization-in-gpt</link><guid isPermaLink="true">https://blog.thatsmanmeet.com/what-is-tokenization-in-gpt</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[#chairs]]></category><category><![CDATA[Tokenization]]></category><category><![CDATA[AI]]></category><dc:creator><![CDATA[Manmeet Singh]]></dc:creator><pubDate>Wed, 13 Aug 2025 11:22:03 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1755082467677/47f6d2ff-ad3e-4dd1-a9b6-1fa577126ad6.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When we were just kids in school, we started learning about first language by learning Alphabets, then words, then sentences. Whenever we have a conversation with someone, our mind automatically breaks the sentence into individual words and try to analyze what each word means. Isn’t this cool right?</p>
<p>What if I told you, this is the same mechanism behind all the AI software that we know and commonly use in our everyday life. So, let’s dive deep into what this process of tokenization is.</p>
<h2 id="heading-tokenization">Tokenization</h2>
<p>Machines unlike humans cannot understand the entire text given to it as an Input as a whole. Machines are more suitable to work and operate with numbers. So, to make the process of working with our human language a lot easier, the query is first tokenized.</p>
<p><strong>Tokenization</strong> is a process of breaking down a given query into individual words known as <strong>tokens</strong> and then converting those tokens into numbers.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755082908231/072caf36-04a4-440c-8ea1-5989a471495a.png" alt class="image--center mx-auto" /></p>
<p>Let’s assume we have a sentence like “Hello How are you?”. So this sentence will be broken into individual words known as tokens first.</p>
<p><strong>Tokens : [“Hello“, “ “, “How“, “ “, “are“, “ “, “you“, “?“ , “EOS“]</strong></p>
<p>Here:</p>
<ul>
<li><p>Spaces are tokens as well.</p>
</li>
<li><p>EOS stands for End of Sequence, marking the end of sentence.</p>
</li>
</ul>
<h3 id="heading-converting-to-numbers">Converting to Numbers</h3>
<p>Since, Machines can’t directly work with the tokens, then each of the token is further converted into a hardcoded number. It is a number that have been given to the model during the training phase.</p>
<pre><code class="lang-bash">    Hello → <span class="hljs-string">"342"</span>
    How → <span class="hljs-string">"542"</span>
    are → <span class="hljs-string">"2412"</span>
    you → <span class="hljs-string">"1412"</span>
    ? → <span class="hljs-string">"112"</span>
</code></pre>
<p>Now after this process the token list looks something like</p>
<p><strong>Tokens: [342, 542, 2412, 1412, 112, EOS]</strong></p>
<h3 id="heading-special-characters">Special Characters</h3>
<p>Now you might be wondering that in the original tokens array before converting to number, there were also Spaces as tokens. Also what’s that <code>EOS</code> at the end of the array? Well these are Special Characters or Special Tokens.</p>
<ol>
<li><p><strong>Spaces</strong> → Spaces are part of the actual text and hence there could either be a special token associated for spaces or they can be included with the other tokens as well.</p>
</li>
<li><p><strong>End of Sequence (EOS)</strong> → EOS tells the tokenizer that the query that we have given as an input is now complete or in other words this marks the ending of a sentence, just like full stop in english language.</p>
</li>
</ol>
<p>There are a lot of Special Tokens and different models and tokenizers might have less or more special characters during the tokenization process.</p>
<h3 id="heading-how-gpt-use-tokens">How GPT use tokens?</h3>
<p>Well GPT use tokens to help predict the next tokens based on the token it has analyzed so far. It keeps predicting the next tokens until End of Sequence (EOS) is retrieved by the GPT.</p>
<pre><code class="lang-bash">User : <span class="hljs-string">"The Boy is"</span>
GPT Predicts : <span class="hljs-string">"running"</span>
Sequence: <span class="hljs-string">"The Boy is running"</span>
GPT Predicts : <span class="hljs-string">"fast"</span>
GPT Predicts : <span class="hljs-string">"in"</span>
GPT Predicts : <span class="hljs-string">"the"</span>
GPT Predicts: <span class="hljs-string">"Market"</span>
At last: <span class="hljs-string">"The Boy is running fast in the Market "</span> + [EOS]
</code></pre>
<hr />
<p><strong>In short:</strong> Tokenization is how AI takes our natural language, slices it into manageable parts, and turns it into numbers hence making it possible for machines to “understand” and respond to us.</p>
]]></content:encoded></item><item><title><![CDATA[GPT Explained for 5 year old]]></title><description><![CDATA[Remember 2020, the year when ChatGPT was released? The whole world was amazed, and for most people, it seemed like some kind of magic that could answer any question. The technical documentation was hard to understand at first glance. However, if you ...]]></description><link>https://blog.thatsmanmeet.com/gpt-explained-for-5-year-old</link><guid isPermaLink="true">https://blog.thatsmanmeet.com/gpt-explained-for-5-year-old</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[generative ai]]></category><category><![CDATA[AI]]></category><dc:creator><![CDATA[Manmeet Singh]]></dc:creator><pubDate>Tue, 12 Aug 2025 08:24:40 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/9Y4ronQmPjk/upload/9b629296004fb9fa179e7be5d44cd9e9.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Remember 2020, the year when ChatGPT was released? The whole world was amazed, and for most people, it seemed like some kind of magic that could answer any question. The technical documentation was hard to understand at first glance. However, if you take a closer look and try to understand how this amazing technology works, you'll quickly see the magic behind it.</p>
<h2 id="heading-transformers">Transformers</h2>
<p>Transformer by very definition means something that will transform something from one state to another. In other words, it will convert an Input to some another form.</p>
<p>E.g Take example of a Juice Maker Machine. We put the fruits inside the machine and in return we get the juice from the machine. Here, the Juice Machine is working as a Transformer.</p>
<p>So, in simpler words, Transformer takes input and returns output in a desired form. In the Image below the Input of <code>Type A</code> get’s converted to <code>Type B</code> by the Transformer.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754966762419/fa1a1a2e-4da7-4273-8196-94200b595a01.png" alt="Transformers" class="image--center mx-auto" /></p>
<h2 id="heading-meaning-of-gpt">Meaning of GPT</h2>
<p>So, now that we know what Transformers are, now how does this concept fit into the equation of AI, especially in products like ChatGPT. First let’s understand the word <code>GPT</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754966678202/ac9c3c50-9b14-4c7c-8446-112381ad0095.png" alt="Meaning of GPT" class="image--center mx-auto" /></p>
<p>In simple terms, <strong>GPT</strong> stands for <strong>Generative Pre-trained Transformer</strong>:</p>
<ol>
<li><p><strong>Generative</strong> → It Generates text, numbers etc.</p>
</li>
<li><p><strong>Pre-trained</strong> → It has been already trained by it’s creator using huge library of text, books, internet articles etc.</p>
</li>
<li><p><strong>Transformer</strong> → It takes input as previous word and outputs next word.</p>
</li>
</ol>
<p>Now if we look at a product like <code>ChatGPT</code> we can see that the <code>GPT</code> is the real technology, the models that does all the things while the prefix <code>Chat</code> Symbolizes that we can have a conversation with this Transformer.</p>
<p>Now we know that what <code>GPT</code> stands for. Now it’s time to see what is the mechanism behind this awesome technology.</p>
<h2 id="heading-fancy-next-word-predictor">Fancy Next Word Predictor</h2>
<p>Let’s take example of the a classroom. We are taught counting when we were kids in the school. So, if I ask you to tell me what would be the next number of <strong>3</strong>? You will instantly answer <strong>4</strong>. If I ask for next, you will answer <strong>5</strong>. Maybe I ask you what comes after <strong>A</strong>? You will reply <strong>B</strong>.</p>
<p>Similarly, In another scenario, let’s say I call you on your mobile, what’s the first thing you would say? It will most probably be <strong>“Hello?”.</strong></p>
<p>In both of the above examples, we can clearly see that our mind are already trained to predict and tell what would come next and as in above examples, we are fast to reply. Same is the concept and working of the models like <strong>GPT</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754967723202/1af089bf-2d97-43b4-98ad-89548906ba47.png" alt class="image--center mx-auto" /></p>
<p>Hence, all GPT does is it will take previous word, text, number and will predict the next one of either same or different types.</p>
<p>Now, the GPT model will not give the entire output at once. No instead it will output one token at a time and then the same token will be fed as an Input back to the GPT Transformer.</p>
<p><strong>Token</strong> could be anything like <code>text</code>, <code>number</code>, <code>letter</code>, <code>word</code> etc. anything that the Transformer can parse and work with. Now, I would be using the word <strong>Token</strong> instead of words, numbers, etc</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754968088484/c2747f9a-92a8-46c5-845f-f8611fc72723.png" alt class="image--center mx-auto" /></p>
<p>So, the output of the Transformer will be fed back into the It again as Input. This process will keep going until the some ending character like <code>&lt;EOF&gt;</code> is encountered.</p>
<p>In ChatGPT, when you say Hello, It will print back “Hi, How are you?”.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Input</strong></td><td><strong>Output</strong></td></tr>
</thead>
<tbody>
<tr>
<td>Hello</td><td>Hi,</td></tr>
<tr>
<td>Hello Hi,</td><td>Hello Hi, How</td></tr>
<tr>
<td>Hello Hi, How</td><td>Hello Hi, How are</td></tr>
<tr>
<td>Hello Hi, How are</td><td>Hello Hi, How are you? &lt;EOF&gt;</td></tr>
<tr>
<td>&lt;EOF&gt; Detected</td><td>Ends Printing</td></tr>
</tbody>
</table>
</div><p>Hence in simpler terms, this is how Transformers work. Hence they are nothing but predicting next words just like how your android/iOS keyboard will print next word when typing out.</p>
<p>Hence it’s nothing just a <strong>Fancy Next Word Generator.</strong></p>
<h2 id="heading-how-gpt-read-and-understand-everything-you-say">How GPT Read and Understand Everything You Say</h2>
<p>Now, we will learn how a Transformer understands your query by going more low level. It is basically an encoder and decoder and utilize various steps and we will learn all those phases now.</p>
<h3 id="heading-tokenization-break-the-words">Tokenization → Break the words</h3>
<p>When we humans try to understand something we don’t understand the whole sentence as one. Instead we try to understand different words used in the sentence to understand the actual meaning of the thing being said to us. Our brain automatically breaks a big sentence into small chunks and analyze each and every part so we can understand it better.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754970636282/6524f370-b91c-4a17-aa5b-22d0a8ae110c.png" alt="tokenization" class="image--center mx-auto" /></p>
<p>Similarly, when the Transformer get some Input from the User, the Query will be broken into multiple tokens and each token is assigned a number which is used by the Transformer to further perform some operations, this process is called <strong>Tokenization</strong>.</p>
<h3 id="heading-vector-embeddings-group-tokens-by-meaning">Vector Embeddings → Group Tokens by Meaning</h3>
<p>When I say the word “Paris”, the first thing that might come to your mind will probably be “Eiffel Tower”, Similarly when I say something like “AI”, then “ChatGPT” might be the first thing that comes to your mind. So our mind has some words that are grouped together by some meaning, which makes it easier for us to relate to something.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754971172771/b989c693-9902-46c9-98e6-e49eae6e33ca.png" alt class="image--center mx-auto" /></p>
<p>Similarly, Transformer would take Tokens and would place them in a Vector Map, which can be 2D or 3D or even have more dimensions where similar meaning words are grouped together. “India” and “France” here are countries, hence they are placed together while “Eiffel Tower” and “India Gate” are monuments and are placed together which makes mapping easier between them.</p>
<p>In large LLMS, these maps are huge with log of dimensions which allow easy relationships between the tokens.</p>
<h3 id="heading-positional-encoding-right-token-at-right-place">Positional Encoding → Right Token at Right Place</h3>
<p>If I say “Hello, how are you?” and “Hello, are you how”, which one makes more sense? Obviously the first one, our brain tries to rearrange certain words in order to make something meaningful. Right? Our brain find meanings in words even by shuffling their positions.</p>
<p>Similarly, Transformers can try to rearrange the tokens based on the numbers assigned to them, so that they are positioned correctly and hence makes more sense and provide a better output for the user.</p>
<h3 id="heading-semantic-meaning-right-meaning">Semantic Meaning → Right Meaning</h3>
<p>If I say “Cat chase the mouse” and “Mouse chase the cat”, if you observe both these sentences have same number of words but the meaning of each sentence is completely different. So, right order is required to make a sense of meaning that feels right.</p>
<p>Similarly, Transformers don’t just look at the position but also tries to understand the meaning between the tokens based on the context. Hence by capturing the semantic meaning we can have the right output of the query given to the Transformer.</p>
<h3 id="heading-self-attention-dont-forget-the-neighbors">Self-Attention → Don’t forget the Neighbors</h3>
<p>When you hear a statement like “A Big Bank will not lend money to risky clients”, then how do you know that we are talking about a “Financial Bank” and not a “River Bank”? Well, you will say that because the words “lend money“, “risky clients“ are enough to tell you that we’re not talking about river banks.</p>
<p>Similarly, Transformers checks every token and its neighboring tokens as well to understand how different tokens relate to one another.</p>
<h3 id="heading-softmax-what-comes-next">SoftMax → What comes next?</h3>
<p>I have a small exercise for you. It’s called "complete a sentence." Here’s the sentence: “I’m going to ….” What came to your mind? The market, the gym, or somewhere else? Our brains find many words and choose what feels best.</p>
<p>Transformer does the same thing. When it is on current token it will predict all the tokens that could come next and then based on it would calculate the score into probabilities. The model would then pick the token with the highs probability and the process repeats again.</p>
<h3 id="heading-multi-head-attention-more-perspectives">Multi-Head Attention → More Perspectives</h3>
<p>You might be told by many people to think of a situation from different perspectives and Scenarios. It’s usually said, so that you can grasp something much better.</p>
<p>Well Transformer does kinda same thing. It looks at a sentence from multiple angles i.e. different relationships, syntax etc to get a bigger picture.</p>
<h3 id="heading-temperature-be-creative-number">Temperature → Be Creative Number</h3>
<p>If I give you a picture of a school and ask you to write an essay only using what you can see in the picture, then you would be following a rigid instructions and hence the creativity would be highly limited. But what If I told you to just “write an essay on School”. In this case, you don’t have any picture, so everything that comes out would be through your Imagination and it would be lot more creative.</p>
<p>Similarly, Transformers can be told to whether be more creative or more serious when following a prompt. This is done using a setting called as temperature. Hence, the lower the temperature, lesser would be creativity and higher the temperature, the higher will be the creativity.</p>
<h3 id="heading-summary">Summary</h3>
<p><strong>In short</strong>, GPT is like a supercharged “next-word guesser” with a brain full of books, articles, and conversations. It chops your message into tiny pieces (tokens), figures out what each one means, keeps them in the right order, looks at them from every angle, and then predicts what should come next. Hence by now you now have a good understanding of how GPT works and what is that magic behind all the AI that’s in trend these days.</p>
]]></content:encoded></item></channel></rss>