<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: kundan</title>
    <description>The latest articles on DEV Community by kundan (@fullstacklabs).</description>
    <link>https://dev.to/fullstacklabs</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3976249%2Ff66d67a7-70ab-4b4f-8ceb-a9f0f2422893.png</url>
      <title>DEV Community: kundan</title>
      <link>https://dev.to/fullstacklabs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fullstacklabs"/>
    <language>en</language>
    <item>
      <title>What Happens When You Send a Message to ChatGPT ?</title>
      <dc:creator>kundan</dc:creator>
      <pubDate>Wed, 01 Jul 2026 15:26:16 +0000</pubDate>
      <link>https://dev.to/fullstacklabs/what-happens-when-you-send-a-message-to-chatgpt--3ema</link>
      <guid>https://dev.to/fullstacklabs/what-happens-when-you-send-a-message-to-chatgpt--3ema</guid>
      <description>&lt;h1&gt;
  
  
  How Does ChatGPT Actually Work?
&lt;/h1&gt;

&lt;p&gt;Every day, millions of people use ChatGPT to write emails, solve coding problems, summarize documents, and even learn new skills. You type a question, press Enter, and within a few seconds, ChatGPT gives you a detailed answer.&lt;/p&gt;

&lt;p&gt;It almost feels like you're talking to another human.&lt;/p&gt;

&lt;p&gt;The answer lies in something called a &lt;strong&gt;Large Language Model (LLM)&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is an LLM?
&lt;/h2&gt;

&lt;p&gt;Let's break the term down, one word at a time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Large
&lt;/h3&gt;

&lt;p&gt;"Large" doesn't mean the model is physically big. It means the model was &lt;strong&gt;trained on a massive amount of data&lt;/strong&gt; — books, research papers, documentation, websites, newspapers, and more. Generally speaking, the more (and more varied) data a model is trained on, the more capable it becomes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Language
&lt;/h3&gt;

&lt;p&gt;Humans communicate through language. We ask questions, explain ideas, and share opinions. Language models are designed to recognize the patterns in that language and generate text that sounds natural.&lt;/p&gt;

&lt;p&gt;Here's the important part: &lt;strong&gt;LLMs don't understand language the way humans do.&lt;/strong&gt; They learn statistical relationships between words — which words tend to follow which other words, in which contexts.&lt;/p&gt;

&lt;p&gt;For example, after training on millions of sentences, a model learns that in:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"I drink coffee every…"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;the most likely next word is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;morning&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The model isn't recalling a memorized sentence. It's recognizing a pattern it has seen play out millions of times before.&lt;/p&gt;

&lt;h3&gt;
  
  
  Model
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;model&lt;/strong&gt;, in this context, is simply a mathematical system trained to make predictions.&lt;/p&gt;

&lt;p&gt;Think of it like Netflix predicting which movie you'll want to watch next based on your viewing history. An LLM does something similar with text — it predicts what word (or piece of a word) should come next, based on everything that came before it.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Problems Do LLMs Solve?
&lt;/h2&gt;

&lt;p&gt;Traditional software relies on predefined rules or exact keyword matches. LLMs work differently — they understand the &lt;strong&gt;intent&lt;/strong&gt; behind your request, not just the literal words.&lt;/p&gt;

&lt;p&gt;For example, instead of matching keywords, ChatGPT can understand a prompt like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Suggest a gaming phone under ₹20,000 with a good camera."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;and actually reason about what "good camera," "gaming phone," and "under ₹20,000" mean together — something a simple keyword search never could.&lt;/p&gt;

&lt;p&gt;Today, LLMs are used for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Answering questions&lt;/li&gt;
&lt;li&gt;Writing and debugging code&lt;/li&gt;
&lt;li&gt;Translating languages&lt;/li&gt;
&lt;li&gt;Summarizing documents&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some of the most popular LLMs include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GPT&lt;/strong&gt; (used in ChatGPT)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Claude&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Gemini&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Where Do We Use LLMs?
&lt;/h3&gt;

&lt;p&gt;LLMs power a lot of tools you probably already use, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AI chatbots&lt;/li&gt;
&lt;li&gt;Coding assistants&lt;/li&gt;
&lt;li&gt;Content writing tools&lt;/li&gt;
&lt;li&gt;Translation services&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's a useful way to picture it: imagine someone who has read millions of books and articles. When you ask them a question, they answer using everything they've learned — not by running off to search the internet again.&lt;/p&gt;

&lt;p&gt;An LLM works the same way. It generates a fresh response based on patterns it learned during training, instead of copying text from a website.&lt;/p&gt;

&lt;p&gt;Now that we know what an LLM &lt;em&gt;is&lt;/em&gt;, let's look at what actually happens the moment you send a message to ChatGPT.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Happens When You Send a Message to ChatGPT?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: You Type a Prompt
&lt;/h3&gt;

&lt;p&gt;Everything starts with a &lt;strong&gt;prompt&lt;/strong&gt; — the message or question you send to ChatGPT. For example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Explain JWT authentication."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Write a Java program to reverse a linked list."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The better and more specific your prompt, the better the response you'll get back.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: The Model Receives Your Prompt
&lt;/h3&gt;

&lt;p&gt;When you hit Send, your prompt is sent to the model &lt;strong&gt;along with the recent conversation history&lt;/strong&gt;. This is what gives ChatGPT context.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;You:&lt;/strong&gt; My name is Kundan.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;…a few messages later…&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You:&lt;/strong&gt; What's my name?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ChatGPT:&lt;/strong&gt; Your name is Kundan.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;ChatGPT can answer correctly because your earlier message is still part of the conversation it's looking at — not because it "remembers" you across chats.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Text Is Converted into Numbers
&lt;/h3&gt;

&lt;p&gt;Computers don't understand English directly. Before ChatGPT can process your prompt, it converts your text into small chunks called &lt;strong&gt;tokens&lt;/strong&gt;, which are then represented as numbers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: The Transformer Understands the Context
&lt;/h3&gt;

&lt;p&gt;Those tokens are passed to a &lt;strong&gt;Transformer&lt;/strong&gt;, which analyzes how all the words in your prompt relate to one another. Instead of reading one word at a time in isolation, it looks at the entire sentence at once to understand context.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Generating the Response
&lt;/h3&gt;

&lt;p&gt;ChatGPT doesn't write a full paragraph in one go. It predicts &lt;strong&gt;one token at a time&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example, given:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The capital of India is…"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;the model predicts:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;New Delhi&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then it predicts the next token, and the next, and the next — repeating this process until the full answer is complete.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You type a prompt -&amp;gt; Sent with conversation history -&amp;gt; Text converted into tokens -&amp;gt; Transformer analyzes context -&amp;gt; Model predicts one token at a time -&amp;gt; Final response shown to you&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;flowchart LR
    A[You type a prompt] --&amp;gt; B[Sent with conversation history]
    B --&amp;gt; C[Text converted into tokens]
    C --&amp;gt; D[Transformer analyzes context]
    D --&amp;gt; E[Model predicts one token at a time]
    E --&amp;gt; F[Final response shown to you]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Why Everything Must Be Converted into Numbers
&lt;/h2&gt;

&lt;p&gt;AI models work by performing mathematical calculations. Since words aren't numbers, they need to be translated into a format the computer can actually compute with. This translation process begins with &lt;strong&gt;tokenization&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Tokenization
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What Are Tokens?
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;token&lt;/strong&gt; is a small piece of text. It can be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A whole word&lt;/li&gt;
&lt;li&gt;Part of a word&lt;/li&gt;
&lt;li&gt;A punctuation mark&lt;/li&gt;
&lt;li&gt;Even a single character&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Text&lt;/th&gt;
&lt;th&gt;Tokens&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Hello&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Hello&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Playing&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;Play&lt;/code&gt; + &lt;code&gt;ing&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ChatGPT&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;Chat&lt;/code&gt; + &lt;code&gt;G&lt;/code&gt; + &lt;code&gt;PT&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Different AI models may split the same word differently depending on how their tokenizer was built.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Is Tokenization Needed?
&lt;/h3&gt;

&lt;p&gt;Before ChatGPT can "understand" your prompt, it first converts your text into tokens. Each token is then assigned a unique &lt;strong&gt;token ID&lt;/strong&gt;, which becomes the number the model actually processes.&lt;/p&gt;

&lt;p&gt;Without tokenization, an AI model wouldn't have any way to work with language at all.&lt;/p&gt;

&lt;h3&gt;
  
  
  Words vs. Tokens
&lt;/h3&gt;

&lt;p&gt;A common misconception is that one word always equals one token. That's not true.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Word&lt;/th&gt;
&lt;th&gt;Tokens (Example)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;cat&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cat&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;cats&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;cat&lt;/code&gt; + &lt;code&gt;s&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;unbelievable&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;un&lt;/code&gt; + &lt;code&gt;believ&lt;/code&gt; + &lt;code&gt;able&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This is exactly why AI models measure input and output limits in &lt;strong&gt;tokens&lt;/strong&gt;, not words.&lt;/p&gt;




&lt;h2&gt;
  
  
  Transformers
&lt;/h2&gt;

&lt;p&gt;Once your text has been converted into tokens, it's passed to the &lt;strong&gt;Transformer&lt;/strong&gt; — the technology behind almost every modern LLM.&lt;/p&gt;

&lt;h3&gt;
  
  
  What Is a Transformer?
&lt;/h3&gt;

&lt;p&gt;A Transformer is a deep learning architecture introduced in 2017 in the paper &lt;em&gt;"Attention Is All You Need."&lt;/em&gt; Its job is to figure out how all the words in a sentence relate to one another.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Did Transformers Change AI?
&lt;/h3&gt;

&lt;p&gt;Older AI models processed text one word at a time and often "forgot" earlier words by the time they reached the end of a sentence.&lt;/p&gt;

&lt;p&gt;Transformers introduced &lt;strong&gt;self-attention&lt;/strong&gt;, which lets every token weigh its relevance against every other token in the sentence — all at once. This made AI dramatically better at understanding context.&lt;/p&gt;

&lt;h3&gt;
  
  
  How Does It Understand Language?
&lt;/h3&gt;

&lt;p&gt;Consider this sentence:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The trophy didn't fit in the suitcase because it was too big."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;What does "it" refer to — the trophy or the suitcase?&lt;/p&gt;

&lt;p&gt;A Transformer looks at the entire sentence at once and, using self-attention, figures out that "it" refers to the trophy, not the suitcase. This ability to resolve context is one of the biggest reasons ChatGPT feels genuinely intelligent rather than just a word-guessing machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Do Modern LLMs Use Transformers?
&lt;/h3&gt;

&lt;p&gt;Models like GPT, Claude, Gemini, Llama, and Mistral all use the Transformer architecture because it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Understands context better than older architectures&lt;/li&gt;
&lt;li&gt;Processes text efficiently by working on all tokens in parallel&lt;/li&gt;
&lt;li&gt;Scales well to billions of parameters&lt;/li&gt;
&lt;li&gt;Generates natural, human-like responses&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without Transformers, modern AI assistants like ChatGPT simply not be as powerful.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>chatgpt</category>
      <category>llm</category>
      <category>nlp</category>
    </item>
    <item>
      <title>Access token vs refresh token</title>
      <dc:creator>kundan</dc:creator>
      <pubDate>Tue, 09 Jun 2026 15:40:16 +0000</pubDate>
      <link>https://dev.to/fullstacklabs/access-token-vs-refresh-token-h4f</link>
      <guid>https://dev.to/fullstacklabs/access-token-vs-refresh-token-h4f</guid>
      <description>&lt;h2&gt;
  
  
  Refresh Token:-
&lt;/h2&gt;

&lt;p&gt;A Refresh Token is a long-lived token used to generate new access tokens without login the user again.&lt;/p&gt;

&lt;p&gt;Refresh tokens must be stored securely (server-side only)&lt;/p&gt;

&lt;p&gt;Once the Refresh token is expire user must login again (re-authentication need).&lt;/p&gt;

&lt;p&gt;Access tokens are short-lived token (15 minutes). When they expire, instead of making the user log in again, the app quietly uses the refresh token behind the scenes.&lt;/p&gt;

&lt;h2&gt;
  
  
  How refresh token works:-
&lt;/h2&gt;

&lt;p&gt;The user login and gets both an access token and a refresh token&lt;br&gt;
The app uses the access token to call APIs.&lt;br&gt;
After 15 min the access token expires the API returns a 401 Unauthorized error.&lt;br&gt;
The app sends the refresh token to the Authorization Server.&lt;br&gt;
The Authorization Server returns a fresh access token.&lt;br&gt;
The user never notices anything they stay logged in.&lt;/p&gt;

&lt;h2&gt;
  
  
  Analogy:-
&lt;/h2&gt;

&lt;p&gt;Your office keycard expires every day at midnight. Instead of going back to reception every morning, you have a special master card that automatically issues you a new keycard. The master card much longer, but is stored securely in HR (your server),not to our shirt.&lt;/p&gt;

&lt;h2&gt;
  
  
  Access Token:-
&lt;/h2&gt;

&lt;p&gt;An Access Token is a short-lived(15 min) token that allows a user to access protected resources.&lt;/p&gt;

&lt;p&gt;Access Token are stored in the HttpOnly cookies.&lt;/p&gt;

&lt;p&gt;Used to access APIs and protected routes and send in every request.&lt;/p&gt;

&lt;p&gt;Access token use the refresh token to get new Access Token.&lt;/p&gt;

&lt;p&gt;If someone steals an access token, the damage is limited because it expires quickly.&lt;/p&gt;

&lt;h2&gt;
  
  
  :- Why Do We Need Both?
&lt;/h2&gt;

&lt;p&gt;Why not just use one token?&lt;/p&gt;

&lt;p&gt;If we use only a long-lived access token:&lt;/p&gt;

&lt;p&gt;The user stays logged in for a long time.&lt;br&gt;
But if the token is stolen, the attacker can use it for a long period.&lt;/p&gt;

&lt;p&gt;If we use only a short-lived access token:&lt;/p&gt;

&lt;p&gt;Security improves.&lt;/p&gt;

&lt;p&gt;But users would have to log in repeatedly.&lt;/p&gt;

&lt;p&gt;Using both tokens gives us the best of both worlds:&lt;/p&gt;

&lt;p&gt;Access Token → Better security.&lt;br&gt;
Refresh Token → Better user experience.&lt;/p&gt;

&lt;p&gt;This balance is why modern applications use both&lt;/p&gt;

&lt;h2&gt;
  
  
  flow:-
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;User logs in
↓&lt;/li&gt;
&lt;li&gt;Backend verifies credentials
↓&lt;/li&gt;
&lt;li&gt;Backend generates:

&lt;ul&gt;
&lt;li&gt;Access Token&lt;/li&gt;
&lt;li&gt;Refresh Token
↓&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Backend sends both as HttpOnly cookies
↓&lt;/li&gt;
&lt;li&gt;Backend stores the refresh token hash in the database&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Later:-
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Access Token expires
↓&lt;/li&gt;
&lt;li&gt;Browser sends Refresh Token cookie
↓&lt;/li&gt;
&lt;li&gt;Backend verifies:

&lt;ul&gt;
&lt;li&gt;Is the refresh token valid?&lt;/li&gt;
&lt;li&gt;Is it expired?&lt;/li&gt;
&lt;li&gt;Does its hash match the one in the DB?
↓&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;If valid:

&lt;ul&gt;
&lt;li&gt;Generate a new Access Token&lt;/li&gt;
&lt;li&gt;(Often also generate a new Refresh Token)
↓&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Send new token back in HttpOnly cookies&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>api</category>
      <category>backend</category>
      <category>security</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
