<?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: Juma Evans</title>
    <description>The latest articles on DEV Community by Juma Evans (@juma_evans_34e389ef539266).</description>
    <link>https://dev.to/juma_evans_34e389ef539266</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%2F3732908%2F19cec6b2-04a4-4223-b322-6ee75277321f.png</url>
      <title>DEV Community: Juma Evans</title>
      <link>https://dev.to/juma_evans_34e389ef539266</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/juma_evans_34e389ef539266"/>
    <language>en</language>
    <item>
      <title>JWT Authentication: A Backend Engineer's Mental Model</title>
      <dc:creator>Juma Evans</dc:creator>
      <pubDate>Mon, 03 Aug 2026 12:56:51 +0000</pubDate>
      <link>https://dev.to/juma_evans_34e389ef539266/jwt-authentication-a-backend-engineers-mental-model-4a1m</link>
      <guid>https://dev.to/juma_evans_34e389ef539266/jwt-authentication-a-backend-engineers-mental-model-4a1m</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Imagine you arrive at a hotel.&lt;/p&gt;

&lt;p&gt;At the reception, you show your ID and prove who you are. The receptionist then gives you a room key card.&lt;/p&gt;

&lt;p&gt;You don't need to show your ID every time you enter your room. Instead, you simply present the key card.&lt;/p&gt;

&lt;p&gt;The hotel doesn't need to ask your name again because the card itself proves that you already authenticated.&lt;/p&gt;

&lt;p&gt;JWT (JSON Web Token) works exactly like that.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Username and password = Your ID&lt;/li&gt;
&lt;li&gt;JWT = Hotel key card&lt;/li&gt;
&lt;li&gt;Server = Receptionist&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  What is JWT?
&lt;/h1&gt;

&lt;p&gt;JWT stands for &lt;strong&gt;JSON Web Token&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It is a compact string that proves a user has already logged in successfully.&lt;/p&gt;

&lt;p&gt;Instead of storing login sessions on the server, the server gives the client a signed token.&lt;/p&gt;

&lt;p&gt;The client sends this token with every request.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server verifies the token and allows access.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why Do We Need JWT?
&lt;/h1&gt;

&lt;p&gt;Without JWT, every request would require sending the username and password repeatedly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Browser
   |
Username
Password
   |
Server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That would be inefficient and insecure.&lt;/p&gt;

&lt;p&gt;Instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Login once

↓

Receive JWT

↓

Reuse JWT for every request
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Stateless Authentication
&lt;/h1&gt;

&lt;p&gt;JWT enables &lt;strong&gt;stateless authentication&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stateful Authentication
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Server
|
|-- Session #12345
|-- Session #91821
|-- Session #44211
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server stores every user's session.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stateless Authentication (JWT)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Server

(No session storage)

↓

Only verifies token signature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server doesn't remember users.&lt;/p&gt;

&lt;p&gt;The token remembers.&lt;/p&gt;




&lt;h1&gt;
  
  
  JWT Structure
&lt;/h1&gt;

&lt;p&gt;A JWT consists of three parts separated by periods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Header.Payload.Signature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
.
eyJzdWIiOiIxMjMiLCJuYW1lIjoiRXZhbnMiLCJyb2xlIjoiYWRtaW4ifQ
.
K6L6GQX....
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Think of it like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Envelope
Letter
Wax Seal
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Part 1 — Header
&lt;/h1&gt;

&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"alg"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"HS256"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"typ"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"JWT"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The header tells us:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which algorithm signed the token.&lt;/li&gt;
&lt;li&gt;What type of token it is.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Fields:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;alg&lt;/code&gt; → Signing algorithm&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;typ&lt;/code&gt; → JWT&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Common algorithms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HS256&lt;/li&gt;
&lt;li&gt;RS256&lt;/li&gt;
&lt;li&gt;ES256&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Part 2 — Payload
&lt;/h1&gt;

&lt;p&gt;The payload contains &lt;strong&gt;claims&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"user_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Evans"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"admin"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Think of it as your digital identity card.&lt;/p&gt;

&lt;p&gt;Typical information:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User ID&lt;/li&gt;
&lt;li&gt;Username&lt;/li&gt;
&lt;li&gt;Email&lt;/li&gt;
&lt;li&gt;Role&lt;/li&gt;
&lt;li&gt;Permissions&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Standard Claims
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Claim&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;sub&lt;/td&gt;
&lt;td&gt;Subject (User ID)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;exp&lt;/td&gt;
&lt;td&gt;Expiration Time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;iat&lt;/td&gt;
&lt;td&gt;Issued At&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;iss&lt;/td&gt;
&lt;td&gt;Issuer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;aud&lt;/td&gt;
&lt;td&gt;Audience&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"sub"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"42"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"admin"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"exp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1754440000&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Important
&lt;/h1&gt;

&lt;p&gt;The payload is &lt;strong&gt;NOT encrypted&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Anyone can decode it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JWT

↓

Base64URL Decode

↓

Payload
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Never store:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Passwords&lt;/li&gt;
&lt;li&gt;PINs&lt;/li&gt;
&lt;li&gt;Secret Keys&lt;/li&gt;
&lt;li&gt;API Keys&lt;/li&gt;
&lt;li&gt;Credit Card Numbers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;inside a JWT.&lt;/p&gt;




&lt;h1&gt;
  
  
  Part 3 — Signature
&lt;/h1&gt;

&lt;p&gt;The signature protects the token from tampering.&lt;/p&gt;

&lt;p&gt;The server computes something similar to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HMACSHA256(

Base64(Header)

+

Base64(Payload),

SecretKey

)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This produces the signature.&lt;/p&gt;

&lt;p&gt;The secret key &lt;strong&gt;never leaves the server&lt;/strong&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why the Signature Matters
&lt;/h1&gt;

&lt;p&gt;Suppose someone changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"admin"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The payload changes.&lt;/p&gt;

&lt;p&gt;Therefore the signature changes.&lt;/p&gt;

&lt;p&gt;Since the attacker doesn't know the server's secret key, they cannot generate a valid signature.&lt;/p&gt;

&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Server

↓

Verify Signature

↓

Invalid

↓

401 Unauthorized
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is why JWTs are tamper-evident.&lt;/p&gt;




&lt;h1&gt;
  
  
  Login Flow
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User

↓

POST /login

↓

Username

Password

↓

Server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Server:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Checks the database.&lt;/li&gt;
&lt;li&gt;Verifies the password.&lt;/li&gt;
&lt;li&gt;Generates a JWT.&lt;/li&gt;
&lt;li&gt;Returns it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"token"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"eyJhbGc..."&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The client stores the token.&lt;/p&gt;




&lt;h1&gt;
  
  
  Authenticated Request
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;GET /profile
Authorization: Bearer eyJhbGc...
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Server:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reads the Authorization header.&lt;/li&gt;
&lt;li&gt;Verifies the signature.&lt;/li&gt;
&lt;li&gt;Checks expiration.&lt;/li&gt;
&lt;li&gt;Extracts the user ID.&lt;/li&gt;
&lt;li&gt;Returns the requested resource.&lt;/li&gt;
&lt;/ol&gt;




&lt;h1&gt;
  
  
  Complete Request Lifecycle
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client

↓

Login

↓

Receive JWT

↓

Store JWT

↓

Send JWT

↓

Server verifies

↓

Access granted
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Where Should Tokens Be Stored?
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Browser
&lt;/h2&gt;

&lt;p&gt;Preferred:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Secure HttpOnly Cookies&lt;/li&gt;
&lt;li&gt;Memory (for SPAs)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Avoid storing long-lived access tokens in &lt;code&gt;localStorage&lt;/code&gt; because XSS attacks can expose them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mobile
&lt;/h2&gt;

&lt;p&gt;Use secure platform storage:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;iOS Keychain&lt;/li&gt;
&lt;li&gt;Android Keystore&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Token Expiration
&lt;/h1&gt;

&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"exp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1754440000&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Server checks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Current Time

↓

Expired?

↓

Yes

↓

401 Unauthorized
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expired tokens cannot be used.&lt;/p&gt;




&lt;h1&gt;
  
  
  Refresh Tokens
&lt;/h1&gt;

&lt;p&gt;Access tokens should have short lifetimes.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Access Token

15 Minutes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When expired:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client

↓

Refresh Token

↓

Server

↓

New Access Token
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Refresh tokens allow users to remain logged in without entering credentials repeatedly.&lt;/p&gt;




&lt;h1&gt;
  
  
  JWT vs Sessions
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;JWT&lt;/th&gt;
&lt;th&gt;Sessions&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Stateless&lt;/td&gt;
&lt;td&gt;Stateful&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No server-side session storage&lt;/td&gt;
&lt;td&gt;Server stores sessions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Easy to scale&lt;/td&gt;
&lt;td&gt;More difficult to scale&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Great for APIs&lt;/td&gt;
&lt;td&gt;Great for traditional web applications&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Client sends token&lt;/td&gt;
&lt;td&gt;Client sends session cookie&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  JWT in a Go (Gin) Backend
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Login Endpoint
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POST /login

↓

Validate Request

↓

Find User

↓

Compare Password Hash

↓

Generate JWT

↓

Return Token
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Protected Route
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET /users

↓

JWT Middleware

↓

Read Authorization Header

↓

Verify Signature

↓

Check Expiration

↓

Extract Claims

↓

Next()

↓

Handler Executes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Middleware Flow
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Incoming Request
       │
       ▼
Read Authorization Header
       │
       ▼
Token Present?
   │        │
  No       Yes
   │        ▼
401      Verify Signature
             │
      Valid? │
        │    │
       No   Yes
        │    ▼
      401  Check Expiration
               │
        Expired? │
          │      │
         Yes    No
          │      ▼
        401   Extract Claims
                   │
                   ▼
      Store User in Context
                   │
                   ▼
          Execute Next Handler
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Authentication vs Authorization
&lt;/h1&gt;

&lt;p&gt;Authentication answers:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Who are you?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Authorization answers:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What are you allowed to do?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Login

↓

Authentication

↓

JWT

↓

Authorization

↓

Access Granted
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Common Interview Questions
&lt;/h1&gt;

&lt;h2&gt;
  
  
  What is JWT?
&lt;/h2&gt;

&lt;p&gt;A signed JSON token used for stateless authentication.&lt;/p&gt;




&lt;h2&gt;
  
  
  Is JWT encrypted?
&lt;/h2&gt;

&lt;p&gt;No.&lt;/p&gt;

&lt;p&gt;It is Base64URL encoded and digitally signed, but not encrypted.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why can't users modify the payload?
&lt;/h2&gt;

&lt;p&gt;Because changing the payload invalidates the signature.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is the purpose of the signature?
&lt;/h2&gt;

&lt;p&gt;To guarantee integrity and authenticity.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why does JWT expire?
&lt;/h2&gt;

&lt;p&gt;To reduce the damage if a token is stolen.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is a Refresh Token?
&lt;/h2&gt;

&lt;p&gt;A long-lived credential used to request a new access token after the current one expires.&lt;/p&gt;




&lt;h2&gt;
  
  
  What happens if the signature is invalid?
&lt;/h2&gt;

&lt;p&gt;The server rejects the request with &lt;strong&gt;401 Unauthorized&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why is JWT called stateless?
&lt;/h2&gt;

&lt;p&gt;Because the server does not store user sessions.&lt;/p&gt;

&lt;p&gt;Every request contains all the information needed to authenticate the user.&lt;/p&gt;




&lt;h1&gt;
  
  
  Best Practices
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Always use HTTPS.&lt;/li&gt;
&lt;li&gt;Never store passwords inside JWTs.&lt;/li&gt;
&lt;li&gt;Keep access tokens short-lived (10–30 minutes).&lt;/li&gt;
&lt;li&gt;Use refresh tokens for long-lived sessions.&lt;/li&gt;
&lt;li&gt;Store refresh tokens securely.&lt;/li&gt;
&lt;li&gt;Validate the signature on every request.&lt;/li&gt;
&lt;li&gt;Validate the expiration (&lt;code&gt;exp&lt;/code&gt;) claim.&lt;/li&gt;
&lt;li&gt;Use strong signing algorithms.&lt;/li&gt;
&lt;li&gt;Rotate signing keys when appropriate.&lt;/li&gt;
&lt;li&gt;Implement token revocation if your application requires immediate logout or compromised-token handling.&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Key Takeaways
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;JWT stands for &lt;strong&gt;JSON Web Token&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;A JWT has three parts:

&lt;ul&gt;
&lt;li&gt;Header&lt;/li&gt;
&lt;li&gt;Payload&lt;/li&gt;
&lt;li&gt;Signature&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;The payload is readable by anyone who has the token.&lt;/li&gt;
&lt;li&gt;The signature protects against tampering.&lt;/li&gt;
&lt;li&gt;JWT enables stateless authentication.&lt;/li&gt;
&lt;li&gt;Access tokens should expire.&lt;/li&gt;
&lt;li&gt;Refresh tokens provide a secure way to obtain new access tokens.&lt;/li&gt;
&lt;li&gt;JWT authentication is commonly implemented using middleware in Go (Gin), Express.js, Spring Boot, ASP.NET, and many other backend frameworks.&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Final Mental Model
&lt;/h1&gt;

&lt;p&gt;Think of JWT like a hotel key card.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User
 │
 │ Login (Username + Password)
 ▼
Server verifies credentials
 │
 ▼
Issues a signed JWT
 │
 ▼
Client stores the token
 │
 ▼
Client sends the token with every request
 │
 ▼
Server verifies:
    ✔ Signature
    ✔ Expiration
    ✔ Claims
 │
 ▼
Access Granted
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server does &lt;strong&gt;not&lt;/strong&gt; need to remember the user.&lt;/p&gt;

&lt;p&gt;The signed token carries the identity, while the server only needs its secret (or public key, depending on the algorithm) to verify that the token is authentic and has not been altered.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>backend</category>
      <category>security</category>
    </item>
    <item>
      <title>Your Code Doesn't Run. A Translation of Your Code Does.</title>
      <dc:creator>Juma Evans</dc:creator>
      <pubDate>Sat, 01 Aug 2026 20:24:28 +0000</pubDate>
      <link>https://dev.to/juma_evans_34e389ef539266/your-code-doesnt-run-a-translation-of-your-code-does-32i5</link>
      <guid>https://dev.to/juma_evans_34e389ef539266/your-code-doesnt-run-a-translation-of-your-code-does-32i5</guid>
      <description>&lt;p&gt;Every time you write a program and hit run, something extraordinary happens before a single instruction executes. Your source code,the plain text(human-readable), gets transformed through several distinct stages into something a CPU can actually understand.&lt;/p&gt;

&lt;p&gt;Most developers never look at those stages. They trust the compiler the way they trust electricity: they know it works, they just don't know how.&lt;/p&gt;

&lt;p&gt;This article is about how it works.&lt;/p&gt;

&lt;p&gt;By the end, you'll understand every major stage a compiler goes through, what it's doing and why, and you'll never look at a compiler error the same way again.&lt;/p&gt;

&lt;h3&gt;
  
  
  What Is a Compiler, Really?
&lt;/h3&gt;

&lt;p&gt;A compiler is a program that reads a program written in one language and outputs an equivalent program in another language.&lt;/p&gt;

&lt;p&gt;Usually that means: read source code written by a human, output machine code understood by a CPU. But that's the end result of a pipeline, not a single step.&lt;/p&gt;

&lt;p&gt;Think of it like translating a novel from Swahili to English. You don't just look at the whole book and magically produce a translation. You read sentence by sentence, understand grammar, resolve meaning, restructure where necessary, then write the output. The compiler does something structurally similar, just with ruthless precision, because machines tolerate zero ambiguity.&lt;/p&gt;

&lt;h3&gt;
  
  
  The pipeline has roughly five stages:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Lexing&lt;/strong&gt; :— breaking source code into tokens&lt;br&gt;
&lt;strong&gt;Parsing&lt;/strong&gt;:— building a tree structure from those tokens&lt;br&gt;
&lt;strong&gt;Semantic Analysis&lt;/strong&gt; :— checking that the tree actually makes sense&lt;br&gt;
&lt;strong&gt;Intermediate Representation&lt;/strong&gt; :— translating to a language-neutral form&lt;br&gt;
&lt;strong&gt;Code Generation&lt;/strong&gt; :— producing the final machine code&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's walk through each one.
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Stage 1: Lexing (Also Called Tokenization)
&lt;/h3&gt;

&lt;p&gt;The very first thing a compiler does is read your source file as raw text and break it into tokens, the smallest meaningful units of the language.&lt;/p&gt;

&lt;p&gt;Take this line of Go:&lt;/p&gt;

&lt;p&gt;go&lt;br&gt;
x := 42 + y&lt;/p&gt;

&lt;p&gt;The lexer reads this character by character and groups them into:&lt;/p&gt;

&lt;p&gt;Token   Type&lt;br&gt;
x   Identifier&lt;br&gt;
:=  Operator&lt;br&gt;
42  Integer Literal&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Operator
y   Identifier&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Whitespace gets discarded. Comments get discarded. What's left is a flat stream of tokens, each labelled with its type.&lt;/p&gt;

&lt;p&gt;This is why your compiler doesn't care whether you write x:=42+y or x := 42 + y. Both produce the exact same token stream because the spaces were never meaningful to begin with.&lt;/p&gt;

&lt;h4&gt;
  
  
  When Lexing Fails
&lt;/h4&gt;

&lt;p&gt;If you type a character the language doesn't recognize  say, a @ symbol in Go where it isn't valid the lexer is the one that catches it. That "unexpected character" error you've seen this before? That's the lexer talking.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stage 2: Parsing — Building the AST
&lt;/h3&gt;

&lt;p&gt;A flat list of tokens isn't enough. 42 + y * 3 means something different from (42 + y) * 3. The parser's job is to take the token stream and build a tree that encodes structure and precedence.&lt;/p&gt;

&lt;p&gt;That tree is called an &lt;strong&gt;Abstract Syntax Tree&lt;/strong&gt;, or AST.&lt;/p&gt;

&lt;p&gt;For the expression x := 42 + y, the AST looks roughly like:&lt;/p&gt;

&lt;p&gt;AssignStatement&lt;br&gt;
├── Left: Identifier("x")&lt;br&gt;
└── Right: BinaryExpression(+)&lt;br&gt;
    ├── Left: IntLiteral(42)&lt;br&gt;
    └── Right: Identifier("y")&lt;/p&gt;

&lt;p&gt;Every node in the tree represents a construct in the language. Statements contain expressions. Expressions contain sub-expressions. Functions contain blocks. Blocks contain statements. The whole program becomes one giant tree, with the root at the top and leaves at the bottom.&lt;/p&gt;

&lt;h4&gt;
  
  
  Why a Tree?
&lt;/h4&gt;

&lt;p&gt;Because code is inherently hierarchical. A function contains statements. Statements contain expressions. Expressions contain sub-expressions. A flat list can't represent that nesting but a tree can.&lt;/p&gt;

&lt;p&gt;The parser uses the grammar rules of the language to this tree. Grammar rules are what define what valid code even looks like. If your tokens don't fit the grammar say, you write x := := 42 the parser rejects it. That's a "syntax error." Not a character problem (the lexer passed), but a structure problem.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stage 3: Semantic Analysis — Does This Actually Make Sense?
&lt;/h3&gt;

&lt;p&gt;A program can be grammatically valid and still be nonsense.&lt;/p&gt;

&lt;p&gt;go&lt;br&gt;
var x int = "hello"&lt;/p&gt;

&lt;p&gt;That's syntactically fine, it's a valid assignment statement. But it's semantically wrong. You're trying to put a string into an integer variable.&lt;/p&gt;

&lt;p&gt;Semantic analysis is where the compiler checks meaning, not just structure. This stage does several things:&lt;/p&gt;

&lt;p&gt;Type checking; are the types compatible? Is a function being called with the right argument types? Is a return value the right type?&lt;/p&gt;

&lt;p&gt;Scope resolution; when you write y, does y exist? Was it declared before it was used? Is it in scope here?&lt;/p&gt;

&lt;p&gt;Name binding; connecting every reference to a variable or function back to its declaration.&lt;/p&gt;

&lt;p&gt;Constant folding; if you write 2 + 3, the compiler can compute this at compile time and just treat it as 5. No need to calculate it every time the program runs.&lt;/p&gt;

&lt;p&gt;This is the stage that produces errors like "undefined variable", "cannot use string as int", and "function takes 2 arguments, got 3." These aren't syntax errors the structure was fine. The meaning was wrong.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stage 4: Intermediate Representation (IR)
&lt;/h3&gt;

&lt;p&gt;After semantic analysis, the compiler has a fully validated AST. Now it needs to translate that into something closer to machine code, but not quite machine code yet.&lt;/p&gt;

&lt;p&gt;This middle step is called Intermediate Representation, or IR.&lt;/p&gt;

&lt;p&gt;Why not go straight to machine code? Because different CPUs speak different machine languages. An x86 chip and an ARM chip have completely different instruction sets. If you went straight from AST to machine code, you'd need a separate compiler backend for every target architecture.&lt;/p&gt;

&lt;p&gt;IR solves this by being a neutral, low-level language that isn't tied to any specific CPU. The Go compiler uses its own internal IR. LLVM (used by Clang, Rust, and others) uses a well-known IR called LLVM IR.&lt;/p&gt;

&lt;p&gt;IR also enables optimization. Before generating final output, the compiler can analyze the IR and improve it:&lt;/p&gt;

&lt;p&gt;Remove code that can never be reached&lt;br&gt;
Eliminate variables that are assigned but never used&lt;br&gt;
Inline small functions to avoid call overhead&lt;br&gt;
Reorder instructions to keep the CPU pipeline busy&lt;/p&gt;

&lt;p&gt;These optimizations happen on the IR, not the source code, which is why they work the same regardless of which language you wrote the program in.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stage 5: Code Generation
&lt;/h3&gt;

&lt;p&gt;The final stage. The compiler takes the (now optimized) IR and translates it into actual machine code for a specific target architecture.&lt;/p&gt;

&lt;p&gt;Machine code is just numbers, binary instructions the CPU reads directly. For example, the instruction to move a value into a register on x86-64 might be encoded as 48 89 C3. The code generator knows the instruction set of the target CPU and emits the right bytes.&lt;/p&gt;

&lt;p&gt;The output is typically an object file, a binary file containing machine code, but not yet a complete program. Object files get passed to a linker, which combines them with other object files (and libraries) to produce the final executable.&lt;/p&gt;

&lt;p&gt;That final executable is what you actually run.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Putting It All Together&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's trace a simple Go program through the full pipeline:&lt;/p&gt;

&lt;p&gt;go&lt;br&gt;
package main&lt;/p&gt;

&lt;p&gt;import "fmt"&lt;/p&gt;

&lt;p&gt;func main() {&lt;br&gt;
    x := 10&lt;br&gt;
    y := 20&lt;br&gt;
    fmt.Println(x + y)&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Lexer: Reads the file, produces tokens: package, main, import, "fmt", func, main, (, ), {, x, :=, 10, ...&lt;/p&gt;

&lt;p&gt;Parser: Builds an AST. The root is a PackageDeclaration. It has an ImportDeclaration and a FunctionDeclaration. The function body contains two AssignStatements and a CallExpression.&lt;/p&gt;

&lt;p&gt;Semantic Analysis: Checks that x and y are declared before use. Checks that x + y produces an int. Checks that fmt.Println accepts an int. Resolves fmt to the imported package.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;IR Generation&lt;/strong&gt;: Translates the AST into a lower-level representation. The addition x + y becomes an ADD instruction. The function call becomes a CALL instruction with arguments set up correctly.&lt;br&gt;
**&lt;br&gt;
Optimization*&lt;em&gt;: In this case, the compiler might even compute 10 + 20 = 30 at compile time and replace the addition with a constant.&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Code Generation*&lt;em&gt;: Emits x86-64 (or ARM, depending on your machine) instructions. Produces an object file.&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Linker**: Combines the object file with the fmt package's compiled code. Produces the final binary.&lt;/p&gt;

&lt;p&gt;You type go run main.go. In milliseconds, all of that happens. Then your program prints 30.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What This Changes About Reading Errors&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once you understand the pipeline, compiler errors stop being mysterious.&lt;/p&gt;

&lt;p&gt;"unexpected token" → the lexer or parser failed. Your code's structure is wrong. Check syntax.&lt;/p&gt;

&lt;p&gt;"undefined: x" → semantic analysis failed. You used something that wasn't declared, or declared it in the wrong scope.&lt;/p&gt;

&lt;p&gt;"cannot use string as type int" → type checking failed. The types don't match. Semantic analysis caught it.&lt;/p&gt;

&lt;p&gt;"x declared and not used" → Go's compiler enforces this at the semantic analysis stage as a hard rule, not a warning. Unused variables indicate bugs or dead code, so Go refuses to compile.&lt;/p&gt;

&lt;p&gt;Each error is the compiler telling you exactly which stage it got to before it couldn't continue and what specifically went wrong.&lt;/p&gt;

&lt;h3&gt;
  
  
  Something worth noting on Interpreted Languages
&lt;/h3&gt;

&lt;p&gt;Not every language uses this full pipeline. Python, JavaScript (in some contexts), and Ruby are traditionally interpreted, instead of compiling to machine code ahead of time, an interpreter reads the source and executes it directly, often line by line.&lt;/p&gt;

&lt;p&gt;Interpreters still lex and parse. They build ASTs. But instead of generating machine code, they walk the AST and execute each node directly.&lt;/p&gt;

&lt;p&gt;The tradeoff: interpreted languages start faster (no compilation step) but run slower (no ahead-of-time optimization, no direct machine code). That's why Python is convenient for scripting but Go or C are used when performance matters.&lt;/p&gt;

&lt;p&gt;Modern JavaScript engines (V8 in Chrome, SpiderMonkey in Firefox) blur this line — they use JIT (Just-In-Time) compilation, which compiles hot code paths to machine code at runtime. It's a hybrid: interpret first, compile the parts that matter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why This Matters For Backend Engineers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You might be thinking: I write application code. I'm not building a compiler. Why does this matter?&lt;/p&gt;

&lt;h4&gt;
  
  
  A few reasons.
&lt;/h4&gt;

&lt;p&gt;You debug faster. When you know what a compiler error is actually telling you, you spend less time guessing and more time fixing.&lt;/p&gt;

&lt;p&gt;You write better code. Understanding what the compiler can and can't optimize helps you write code that performs well not through premature optimization, but through avoiding patterns that defeat the optimizer.&lt;/p&gt;

&lt;p&gt;You understand your tools. Every build system, linter, code formatter, and static analysis tool is, at its core, doing some version of what a compiler does. Understanding the pipeline makes all of those tools less magical and more predictable.&lt;/p&gt;

&lt;p&gt;You grow as an engineer. The engineers who built the systems you use every day databases, runtimes, operating systems understood this. Closing that gap between "I write code" and "I understand what runs my code" is part of what separates junior engineers from senior ones.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The One-Line Summary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Your source code is text. CPUs understand binary. A compiler is the translator that bridges that gap in five careful, well-defined stages, each building on the last.&lt;/p&gt;

&lt;p&gt;Lexing breaks text into tokens. Parsing builds structure. Semantic analysis checks meaning. IR enables optimization. Code generation produces the final output.&lt;/p&gt;

&lt;p&gt;Every time you compile, that entire process runs. Now you know what it's doing.&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>go</category>
      <category>backend</category>
      <category>beginners</category>
    </item>
    <item>
      <title>This is what building a Two-Node Lightning Network From Scratch looked like in one week.</title>
      <dc:creator>Juma Evans</dc:creator>
      <pubDate>Sat, 01 Aug 2026 19:29:09 +0000</pubDate>
      <link>https://dev.to/juma_evans_34e389ef539266/this-is-what-building-a-two-node-lightning-network-from-scratch-looked-like-in-one-week-22cf</link>
      <guid>https://dev.to/juma_evans_34e389ef539266/this-is-what-building-a-two-node-lightning-network-from-scratch-looked-like-in-one-week-22cf</guid>
      <description>&lt;p&gt;There's a version of learning Bitcoin where you read the whitepaper, nod along, and move on. Then there's the version where you're staring at a terminal at 11pm wondering why two nodes refuse to talk to each other then you actually understand the answer when you figure it out.&lt;/p&gt;

&lt;p&gt;We did the second version. This article is what came out of it.&lt;/p&gt;

&lt;p&gt;By the end of one week, I understood what Bitcoin actually is under the hood, why the Lightning Network exists, what a payment channel really means, and what it looks like to build all of this from zero, in a local test environment.&lt;/p&gt;

&lt;p&gt;No hype. No "Bitcoin is the future" takes. Just the engineering.&lt;/p&gt;

&lt;h3&gt;
  
  
  First: What Is Bitcoin, Actually?
&lt;/h3&gt;

&lt;p&gt;Before Lightning makes any sense, Bitcoin has to make sense. And I mean the technical version, not the investment version.&lt;/p&gt;

&lt;p&gt;Bitcoin is a distributed ledger :— a database that no single person owns or controls, replicated across thousands of computers around the world. Every 10 minutes or so, a new "block" of transactions gets added to this ledger. That chain of blocks is the blockchain.&lt;/p&gt;

&lt;p&gt;Here's the key property that makes it interesting: once a transaction is written into the chain, it is practically irreversible. There's no customer service desk. There's no refund button. The database is append-only, and changing historical records would require redoing an astronomically expensive amount of computational work.&lt;/p&gt;

&lt;p&gt;This is great for finality. It's terrible for speed.&lt;/p&gt;

&lt;p&gt;The Problem: Bitcoin Is Slow By Design&lt;/p&gt;

&lt;p&gt;Bitcoin's base layer processes roughly 7 transactions per second. Globally. For everyone.&lt;/p&gt;

&lt;p&gt;Visa handles tens of thousands per second. M-Pesa handles millions of transactions per day in Kenya alone. Bitcoin, as a base layer, cannot compete on throughput, and that's not a bug, it's a consequence of the tradeoffs that make it trust-less and decentralized.&lt;/p&gt;

&lt;p&gt;So what do you do if you want fast, cheap Bitcoin payments? You build on top of it. That's where Lightning comes in.&lt;/p&gt;

&lt;h3&gt;
  
  
  What Is the Lightning Network?
&lt;/h3&gt;

&lt;p&gt;The Lightning Network is Bitcoin's Layer 2 — a payment network that sits on top of Bitcoin and inherits its security without inheriting its slowness.&lt;/p&gt;

&lt;p&gt;The core idea is elegant: what if two people could transact with each other thousands of times, but only touch the blockchain twice?&lt;/p&gt;

&lt;p&gt;Once to open the channel. Once to close it.&lt;/p&gt;

&lt;p&gt;Everything in between happens off-chain, instantly, with near-zero fees.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Analogy That Made It Click For Me
&lt;/h3&gt;

&lt;p&gt;Imagine you and a colleague work in the same office and you frequently owe each other small amounts like lunch money, airtime, split bills. Every time you settle, you don't go to the bank. You keep a running tab. "I owe you 200, you owe me 350 net, you owe me 150." At the end of the month, one person pays the other. One transaction.&lt;/p&gt;

&lt;p&gt;A Lightning channel is that tab, except it's crypto-graphically enforced, so neither party can cheat. You put real Bitcoin into it when you open it. The channel tracks who owns what. When you're done, you close it and the final balances get written to the blockchain.&lt;/p&gt;

&lt;p&gt;Scale this to millions of people with overlapping channels, and you have a network where you can pay anyone, even without a direct channel to them just by routing through intermediate nodes.&lt;/p&gt;

&lt;h3&gt;
  
  
  What we Actually Built
&lt;/h3&gt;

&lt;p&gt;This was a structured bootcamp environment with a real set of goals:&lt;/p&gt;

&lt;p&gt;Compile Bitcoin Core from source (no sudo apt install shortcuts)&lt;br&gt;
Build a Bitcoin Explorer CLI in Go using only the standard library&lt;br&gt;
Set up a two-node Lightning Network with LND in regtest&lt;br&gt;
Fund channels, make payments, and observe what happens&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's take a tour of each stage.
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Part 1: Compiling Bitcoin Core From Source
&lt;/h3&gt;

&lt;p&gt;Most guides tell you to download a binary. We didn't do that. We compiled Bitcoin Core v31.99.0 directly from source code, without sudo privileges.&lt;/p&gt;

&lt;p&gt;Why does this matter? Because in production fintech systems, you often can't just trust a binary you downloaded. Compiling from source means you're running exactly what the code says — nothing added, nothing modified.&lt;/p&gt;

&lt;p&gt;The process taught me something I hadn't thought about before: software has dependencies on dependencies on dependencies. Getting Bitcoin Core to compile meant first ensuring the right versions of Boost, lib-event, and other libraries were present. The compiler errors are honest and they tell you exactly what's missing.&lt;/p&gt;

&lt;p&gt;Once compiled, I ran it in regtest mode.&lt;/p&gt;

&lt;h4&gt;
  
  
  What Is Regtest?
&lt;/h4&gt;

&lt;p&gt;Regtest (short for regression test) is a local, private Bitcoin network that only exists on your machine. You control everything: the mining, the blocks, the funds. You can mine 1000 blocks in a second. It's basically a sandbox.&lt;/p&gt;

&lt;p&gt;This is how you develop and test anything Bitcoin-related without spending real money or waiting for real confirmations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Part 2: Building a Bitcoin Explorer CLI in Go
&lt;/h3&gt;

&lt;p&gt;With Bitcoin Core running, I built a command-line tool in Go that could query it.&lt;/p&gt;

&lt;p&gt;Bitcoin Core exposes a JSON-RPC interface — you send it HTTP POST requests with JSON bodies, and it responds with blockchain data. Think of it as the node's API.&lt;/p&gt;

&lt;p&gt;Here's a minimal example of what that looks like in Go:&lt;/p&gt;

&lt;p&gt;go&lt;br&gt;
package main&lt;/p&gt;

&lt;p&gt;import (&lt;br&gt;
    "bytes"&lt;br&gt;
    "encoding/json"&lt;br&gt;
    "fmt"&lt;br&gt;
    "net/http"&lt;br&gt;
)&lt;/p&gt;

&lt;p&gt;type RPCRequest struct {&lt;br&gt;
    Method  string        &lt;code&gt;json:"method"&lt;/code&gt;&lt;br&gt;
    Params  []interface{} &lt;code&gt;json:"params"&lt;/code&gt;&lt;br&gt;
    ID      int           &lt;code&gt;json:"id"&lt;/code&gt;&lt;br&gt;
    JSONRPC string        &lt;code&gt;json:"jsonrpc"&lt;/code&gt;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;func callRPC(method string, params []interface{}) (map[string]interface{}, error) {&lt;br&gt;
    req := RPCRequest{&lt;br&gt;
        Method:  method,&lt;br&gt;
        Params:  params,&lt;br&gt;
        ID:      1,&lt;br&gt;
        JSONRPC: "1.0",&lt;br&gt;
    }&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body, _ := json.Marshal(req)

resp, err := http.Post(
    "http://localhost:18443/",
    "application/json",
    bytes.NewBuffer(body),
)
if err != nil {
    return nil, err
}
defer resp.Body.Close()

var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&amp;amp;result)
return result, nil
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;func main() {&lt;br&gt;
    info, _ := callRPC("getblockchaininfo", nil)&lt;br&gt;
    fmt.Println(info)&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;The constraint was standard library only, no external HTTP clients, no JSON helper packages beyond encoding/json. This was intentional. It forced me to understand exactly what was happening at the network level, not abstract it away.&lt;/p&gt;

&lt;p&gt;The explorer could query block height, fetch transaction details by ID, decode raw transactions, and display UTXO (Unspent Transaction Output) information. UTXOs are how Bitcoin actually tracks balances — not accounts, but unspent outputs you have the right to spend.&lt;/p&gt;

&lt;h3&gt;
  
  
  Part 3: Setting Up Two LND Nodes
&lt;/h3&gt;

&lt;p&gt;LND (Lightning Network Daemon) is the most widely used Lightning implementation, written in Go by Lightning Labs.&lt;/p&gt;

&lt;p&gt;I set up two nodes: Alice and Bob. Each one was a separate LND instance, each connected to the same local Bitcoin Core regtest node.&lt;/p&gt;

&lt;p&gt;The configuration looks roughly like this for Alice:&lt;/p&gt;

&lt;p&gt;ini&lt;br&gt;
[Application Options]&lt;br&gt;
datadir=/home/user/bootcamp-lnd/alice/data&lt;br&gt;
logdir=/home/user/bootcamp-lnd/alice/logs&lt;br&gt;
listen=0.0.0.0:9735&lt;br&gt;
rpclisten=0.0.0.0:10009&lt;br&gt;
restlisten=0.0.0.0:8080&lt;br&gt;
noseedbackup=true&lt;/p&gt;

&lt;p&gt;[Bitcoin]&lt;br&gt;
bitcoin.active=1&lt;br&gt;
bitcoin.regtest=1&lt;br&gt;
bitcoin.node=bitcoind&lt;/p&gt;

&lt;p&gt;[Bitcoind]&lt;br&gt;
bitcoind.rpchost=localhost&lt;br&gt;
bitcoind.rpcuser=your_rpc_user&lt;br&gt;
bitcoind.rpcpass=your_rpc_password&lt;br&gt;
bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332&lt;br&gt;
bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333&lt;/p&gt;

&lt;p&gt;Bob gets his own instance on different ports. Same structure, different directories, different ports.&lt;/p&gt;

&lt;p&gt;The ZMQ Issue (and Why It Matters)&lt;/p&gt;

&lt;p&gt;One thing that tripped me up: LND communicates with Bitcoin Core not just through RPC, but also through ZMQ (ZeroMQ) — a messaging protocol that lets Bitcoin Core push new block and transaction notifications to LND in real time.&lt;/p&gt;

&lt;p&gt;Without ZMQ configured correctly, LND would start but wouldn't know about new blocks. Payments would appear to hang. The fix was ensuring zmqpubrawblock and zmqpubrawtx were properly set on both the Bitcoin Core side and the LND config side, and that the ports matched.&lt;/p&gt;

&lt;p&gt;This is the kind of thing a tutorial glosses over. In practice, it's the difference between a working node and a node that silently does nothing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Part 4: Funding a Channel
&lt;/h3&gt;

&lt;p&gt;Once both nodes were running, I connected them:&lt;/p&gt;

&lt;p&gt;bash&lt;/p&gt;

&lt;h4&gt;
  
  
  Get Alice's node info
&lt;/h4&gt;

&lt;p&gt;lncli --rpcserver=localhost:10009 getinfo&lt;/p&gt;

&lt;h4&gt;
  
  
  Connect Alice to Bob (using Bob's pubkey@host:port)
&lt;/h4&gt;

&lt;p&gt;lncli --rpcserver=localhost:10009 connect &lt;a class="mentioned-user" href="https://dev.to/localhost"&gt;@localhost&lt;/a&gt;:9736&lt;/p&gt;

&lt;h4&gt;
  
  
  Open a channel from Alice to Bob, funding it with 1,000,000 satoshis
&lt;/h4&gt;

&lt;p&gt;lncli --rpcserver=localhost:10009 openchannel --node_key= --local_amt=1000000&lt;/p&gt;

&lt;p&gt;Opening a channel requires an on-chain transaction. So I mined a few blocks to confirm it:&lt;/p&gt;

&lt;p&gt;bash&lt;br&gt;
bitcoin-cli -regtest generatetoaddress 6 &lt;/p&gt;

&lt;p&gt;After 3 confirmations, the channel was active. Alice had 1,000,000 satoshis of outbound liquidity :- meaning she could send up to that amount to Bob. Bob had zero outbound liquidity toward Alice unless he funded his side too.&lt;/p&gt;

&lt;p&gt;This asymmetry is one of the most important (and often confusing) things about Lightning. Liquidity is directional. Having a channel doesn't mean you can pay in both directions, it depends on where the funds sit within that channel.&lt;/p&gt;

&lt;h3&gt;
  
  
  Part 5: Making a Payment
&lt;/h3&gt;

&lt;p&gt;With the channel open, Bob creates an invoice, essentially a payment request:&lt;/p&gt;

&lt;p&gt;bash&lt;br&gt;
lncli --rpcserver=localhost:10036 addinvoice --amt=50000 --memo="Coffee"&lt;/p&gt;

&lt;p&gt;This spits out a BOLT11 payment string :- a long encoded string that starts with lnbcrt... in regtest. It contains the amount, a payment hash, Bob's public key, and an expiry time.&lt;/p&gt;

&lt;p&gt;Alice pays it:&lt;/p&gt;

&lt;p&gt;bash&lt;br&gt;
lncli --rpcserver=localhost:10009 payinvoice &lt;/p&gt;

&lt;p&gt;This happens in under a second. No block confirmation required. The channel's internal balance shifts: Alice now has 950,000 satoshis, Bob has 50,000. The blockchain hasn't changed at all. That shift only gets recorded on-chain when the channel closes.&lt;/p&gt;

&lt;h4&gt;
  
  
  The LND REST API
&lt;/h4&gt;

&lt;p&gt;At the end of the bootcamp, I was also given access to a remote regtest LND node via its REST API, a taste of what integrating Lightning into a real backend looks like.&lt;/p&gt;

&lt;p&gt;LND exposes every operation through HTTP endpoints. To check node info:&lt;/p&gt;

&lt;p&gt;bash&lt;br&gt;
curl -k \&lt;br&gt;
  -H "Grpc-Metadata-macaroon: " \&lt;br&gt;
  &lt;a href="https://your-lnd-node/v1/getinfo" rel="noopener noreferrer"&gt;https://your-lnd-node/v1/getinfo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Macaroons are LND's authentication mechanism bearer tokens with baked-in permissions. The admin macaroon can do everything. The invoice macaroon can only create and read invoices. You'd use the invoice macaroon in a web server that generates payment requests, and never expose the admin macaroon to anything internet-facing.&lt;/p&gt;

&lt;p&gt;In Go, you'd integrate this with:&lt;/p&gt;

&lt;p&gt;go&lt;br&gt;
tr := &amp;amp;http.Transport{&lt;br&gt;
    TLSClientConfig: &amp;amp;tls.Config{InsecureSkipVerify: true}, // only for dev/regtest&lt;br&gt;
}&lt;br&gt;
client := &amp;amp;http.Client{Transport: tr}&lt;/p&gt;

&lt;p&gt;req, _ := http.NewRequest("GET", "&lt;a href="https://your-lnd-node/v1/getinfo" rel="noopener noreferrer"&gt;https://your-lnd-node/v1/getinfo&lt;/a&gt;", nil)&lt;br&gt;
req.Header.Set("Grpc-Metadata-macaroon", adminMacaroonHex)&lt;/p&gt;

&lt;p&gt;resp, err := client.Do(req)&lt;/p&gt;

&lt;p&gt;This is the pattern you'd use when building a payment backend on top of Lightning, creating invoices on demand, polling for payment confirmation, and triggering downstream actions (like unlocking content or marking an order as paid) when the payment settles.&lt;/p&gt;

&lt;h3&gt;
  
  
  What This Changes About How I Think
&lt;/h3&gt;

&lt;p&gt;Before this bootcamp, I understood Lightning conceptually. After it, I understand it structurally. There's a difference.&lt;/p&gt;

&lt;p&gt;A few things that specifically shifted:&lt;/p&gt;

&lt;p&gt;Settlement finality is not binary. On-chain Bitcoin is "final" after enough confirmations. Lightning is final the moment the HTLC (Hash Time Locked Contract) resolves. Different guarantees, different use cases. Knowing which one you need matters when you're designing a payment flow.&lt;/p&gt;

</description>
      <category>bitcoin</category>
      <category>go</category>
      <category>backend</category>
      <category>fintech</category>
    </item>
    <item>
      <title>How HTTPS Actually Works: TLS, Certificates, and Encryption</title>
      <dc:creator>Juma Evans</dc:creator>
      <pubDate>Fri, 24 Jul 2026 23:41:00 +0000</pubDate>
      <link>https://dev.to/juma_evans_34e389ef539266/how-https-actually-works-tls-certificates-and-encryption-41an</link>
      <guid>https://dev.to/juma_evans_34e389ef539266/how-https-actually-works-tls-certificates-and-encryption-41an</guid>
      <description>&lt;p&gt;&lt;strong&gt;Analogy&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you're sitting in a coffee shop.&lt;/p&gt;

&lt;p&gt;You connect to the free Wi-Fi.&lt;/p&gt;

&lt;p&gt;You decide to log into your bank account.&lt;/p&gt;

&lt;p&gt;Your browser sends your username and password over the network.&lt;/p&gt;

&lt;p&gt;Now imagine every person connected to that same Wi-Fi can read everything you're sending.&lt;/p&gt;

&lt;p&gt;Your password.&lt;/p&gt;

&lt;p&gt;Your balance.&lt;/p&gt;

&lt;p&gt;Your account number.&lt;/p&gt;

&lt;p&gt;Terrifying.&lt;/p&gt;

&lt;p&gt;Yet that's exactly how the early Internet worked.&lt;/p&gt;

&lt;p&gt;There was no encryption.&lt;/p&gt;

&lt;p&gt;No certificates.&lt;/p&gt;

&lt;p&gt;No secure connections.&lt;/p&gt;

&lt;p&gt;Just plain text traveling across the network.&lt;/p&gt;

&lt;p&gt;HTTPS was invented to solve this problem.&lt;/p&gt;

&lt;p&gt;But here's the fascinating part:&lt;/p&gt;

&lt;p&gt;Your browser has never met your bank's server before.&lt;/p&gt;

&lt;p&gt;So how do two complete strangers agree on a secret encryption key while an attacker is listening to every message?&lt;/p&gt;

&lt;p&gt;Let's find out.&lt;/p&gt;

&lt;p&gt;Before HTTPS&lt;/p&gt;

&lt;p&gt;HTTP sends everything as plain text.&lt;/p&gt;

&lt;p&gt;Imagine requesting a webpage.&lt;/p&gt;

&lt;p&gt;GET /login HTTP/1.1&lt;br&gt;
Host: bank.com&lt;/p&gt;

&lt;p&gt;username=alice&lt;br&gt;
password=myPassword123&lt;/p&gt;

&lt;p&gt;Anyone who intercepts this packet can read it.&lt;/p&gt;

&lt;p&gt;Wireshark.&lt;/p&gt;

&lt;p&gt;Hackers.&lt;/p&gt;

&lt;p&gt;Malicious Wi-Fi hotspots.&lt;/p&gt;

&lt;p&gt;ISPs.&lt;/p&gt;

&lt;p&gt;Nothing is hidden.&lt;/p&gt;

&lt;p&gt;HTTP provides functionality.&lt;/p&gt;

&lt;p&gt;It provides zero confidentiality.&lt;/p&gt;

&lt;p&gt;Enter HTTPS&lt;/p&gt;

&lt;p&gt;HTTPS is simply:&lt;/p&gt;

&lt;p&gt;HTTP&lt;/p&gt;

&lt;p&gt;+&lt;/p&gt;

&lt;p&gt;TLS&lt;/p&gt;

&lt;p&gt;Notice something important.&lt;/p&gt;

&lt;p&gt;HTTP didn't change.&lt;/p&gt;

&lt;p&gt;TLS wraps HTTP in encryption.&lt;/p&gt;

&lt;p&gt;Think of TLS as an armored truck carrying ordinary letters.&lt;/p&gt;

&lt;p&gt;The letters remain the same.&lt;/p&gt;

&lt;p&gt;The transport becomes secure.&lt;/p&gt;

&lt;p&gt;What Does HTTPS Actually Protect?&lt;/p&gt;

&lt;p&gt;HTTPS provides three major guarantees.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Confidentiality&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Nobody can read your data.&lt;/p&gt;

&lt;p&gt;Even if someone captures every packet...&lt;/p&gt;

&lt;p&gt;They see encrypted gibberish.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;/p&gt;

&lt;p&gt;password=OpenSesame&lt;br&gt;
They see:&lt;br&gt;
8FA91B4D928AC17C3D...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Integrity&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine a hacker intercepts:&lt;br&gt;
Transfer $100 and changes it to:&lt;/p&gt;

&lt;p&gt;Transfer $10,000&lt;/p&gt;

&lt;p&gt;TLS detects that the message was modified.&lt;/p&gt;

&lt;p&gt;The connection immediately fails.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Authentication&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;How do you know you're actually talking to your bank?&lt;/p&gt;

&lt;p&gt;Not a fake server pretending to be it?&lt;/p&gt;

&lt;p&gt;This is where certificates enter the picture.&lt;/p&gt;

&lt;p&gt;The Biggest Problem&lt;/p&gt;

&lt;p&gt;Imagine I want to send you a locked box.&lt;/p&gt;

&lt;p&gt;I lock it.&lt;/p&gt;

&lt;p&gt;Now...&lt;/p&gt;

&lt;p&gt;How do I safely send you the key?&lt;/p&gt;

&lt;p&gt;If I send the key with the box...&lt;/p&gt;

&lt;p&gt;Anyone can steal both.&lt;/p&gt;

&lt;p&gt;This is exactly the problem HTTPS had to solve.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Symmetric Encryption&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Symmetric encryption uses one secret key.&lt;/p&gt;

&lt;p&gt;Key&lt;br&gt;
↓&lt;br&gt;
Encrypt&lt;br&gt;
↓&lt;br&gt;
Ciphertext&lt;br&gt;
↓&lt;br&gt;
Decrypt&lt;br&gt;
↓&lt;br&gt;
Same Key&lt;/p&gt;

&lt;p&gt;Advantages:&lt;/p&gt;

&lt;p&gt;Extremely fast&lt;br&gt;
Perfect for large files&lt;br&gt;
Efficient&lt;/p&gt;

&lt;p&gt;Problem:&lt;/p&gt;

&lt;p&gt;Both sides need the same secret key.&lt;br&gt;
How do they agree on that key?&lt;br&gt;
Asymmetric Encryption&lt;/p&gt;

&lt;p&gt;Instead of one key...&lt;/p&gt;

&lt;p&gt;There are two.&lt;br&gt;
Public Key&lt;br&gt;
Private Key&lt;/p&gt;

&lt;p&gt;Anyone may know the public key.&lt;br&gt;
Nobody should ever know the private key.&lt;/p&gt;

&lt;p&gt;Think of it like a mailbox.&lt;br&gt;
Anyone can drop letters inside.&lt;br&gt;
Only the owner can open it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Not Encrypt Everything with RSA?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;RSA (or modern alternatives like Elliptic Curve Cryptography) is computationally expensive.&lt;/p&gt;

&lt;p&gt;Encrypting an entire Netflix movie with asymmetric encryption would be painfully slow.&lt;/p&gt;

&lt;p&gt;Instead HTTPS combines both worlds.&lt;br&gt;
Fast symmetric encryption.&lt;br&gt;
Safe asymmetric key exchange.&lt;/p&gt;

&lt;p&gt;The best of both.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Meet TLS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;TLS performs a handshake before any HTTP data is exchanged.&lt;/p&gt;

&lt;p&gt;This handshake establishes trust.&lt;/p&gt;

&lt;p&gt;Generates shared secrets.&lt;br&gt;
Chooses encryption algorithms.&lt;br&gt;
Verifies certificates.&lt;br&gt;
Only after all of this...&lt;br&gt;
Does HTTP begin.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 — Client Hello&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Your browser starts.&lt;br&gt;
Hello!&lt;/p&gt;

&lt;p&gt;I support:&lt;br&gt;
AES&lt;br&gt;
ChaCha20&lt;br&gt;
TLS 1.3&lt;/p&gt;

&lt;p&gt;Random Number&lt;/p&gt;

&lt;p&gt;Think of this as introducing yourself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2 — Server Hello&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The server replies.&lt;/p&gt;

&lt;p&gt;Great.&lt;/p&gt;

&lt;p&gt;Let's use:&lt;/p&gt;

&lt;p&gt;TLS 1.3&lt;/p&gt;

&lt;p&gt;AES-256&lt;/p&gt;

&lt;p&gt;Here's my certificate.&lt;/p&gt;

&lt;p&gt;Now comes the interesting part.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3 — Certificate&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The certificate contains information like:&lt;/p&gt;

&lt;p&gt;Domain&lt;/p&gt;

&lt;p&gt;Public Key&lt;/p&gt;

&lt;p&gt;Expiration Date&lt;/p&gt;

&lt;p&gt;Certificate Authority&lt;/p&gt;

&lt;p&gt;Digital Signature&lt;/p&gt;

&lt;p&gt;Notice...&lt;/p&gt;

&lt;p&gt;The server isn't saying:&lt;/p&gt;

&lt;p&gt;"Trust me."&lt;/p&gt;

&lt;p&gt;Instead it's saying:&lt;/p&gt;

&lt;p&gt;"Someone you already trust verified me."&lt;/p&gt;

&lt;p&gt;Certificate Authorities&lt;/p&gt;

&lt;p&gt;Browsers already trust organizations like:&lt;/p&gt;

&lt;p&gt;Let's Encrypt&lt;br&gt;
DigiCert&lt;br&gt;
GlobalSign&lt;br&gt;
Sectigo&lt;/p&gt;

&lt;p&gt;When a certificate is signed by one of these trusted authorities, the browser can verify that signature.&lt;/p&gt;

&lt;p&gt;It's similar to a passport.&lt;br&gt;
You don't personally know the passport holder.&lt;br&gt;
You trust the government that issued it.&lt;br&gt;
What If Someone Creates a Fake Certificate?&lt;br&gt;
Suppose an attacker generates a fake certificate for:&lt;/p&gt;

&lt;p&gt;bank.com&lt;/p&gt;

&lt;p&gt;The browser checks the digital signature.&lt;br&gt;
It doesn't match any trusted Certificate Authority.&lt;/p&gt;

&lt;p&gt;Immediately:&lt;br&gt;
Your connection is not private.&lt;br&gt;
The browser refuses the connection&lt;br&gt;
Key Exchange&lt;/p&gt;

&lt;p&gt;Now the browser knows it's talking to the real server.&lt;/p&gt;

&lt;p&gt;Both sides perform a key exchange (commonly using Elliptic Curve Diffie–Hellman Ephemeral (ECDHE) in TLS 1.3) to derive the same shared secret.&lt;/p&gt;

&lt;p&gt;Here's the remarkable part:&lt;/p&gt;

&lt;p&gt;Neither side ever sends the secret encryption key across the network.&lt;/p&gt;

&lt;p&gt;They independently calculate the same shared key using exchanged public information and their own private values.&lt;/p&gt;

&lt;p&gt;Even if someone captures every packet, they cannot derive the session key.&lt;/p&gt;

&lt;p&gt;This is one of the cleverest ideas in modern cryptography.&lt;/p&gt;

&lt;p&gt;Session Keys&lt;/p&gt;

&lt;p&gt;Once both sides derive the shared secret...&lt;/p&gt;

&lt;p&gt;RSA (or more accurately in modern TLS, the key exchange mechanism) has done its job.&lt;/p&gt;

&lt;p&gt;From this point onward...&lt;/p&gt;

&lt;p&gt;Everything uses symmetric encryption.&lt;/p&gt;

&lt;p&gt;Usually:&lt;/p&gt;

&lt;p&gt;AES-GCM&lt;br&gt;
ChaCha20-Poly1305&lt;/p&gt;

&lt;p&gt;Because they're much faster.&lt;/p&gt;

&lt;p&gt;Why HTTPS Is Fast&lt;/p&gt;

&lt;p&gt;Many developers assume HTTPS encrypts every message with RSA.&lt;/p&gt;

&lt;p&gt;It doesn't.&lt;/p&gt;

&lt;p&gt;RSA or ECDHE helps establish the secure session.&lt;/p&gt;

&lt;p&gt;After that...&lt;/p&gt;

&lt;p&gt;Symmetric encryption handles almost all application data.&lt;/p&gt;

&lt;p&gt;This is why HTTPS is nearly as fast as HTTP on modern hardware.&lt;/p&gt;

&lt;p&gt;What Happens Every Time You Visit a Website?&lt;/p&gt;

&lt;p&gt;The flow looks like this:&lt;/p&gt;

&lt;p&gt;Browser&lt;br&gt;
↓&lt;br&gt;
TCP Connection&lt;br&gt;
↓&lt;br&gt;
TLS Handshake&lt;br&gt;
↓&lt;br&gt;
Certificate Verification&lt;br&gt;
↓&lt;br&gt;
Key Exchange&lt;br&gt;
↓&lt;br&gt;
Shared Secret&lt;br&gt;
↓&lt;br&gt;
Encrypted HTTP&lt;br&gt;
↓&lt;br&gt;
Website Loads&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common Myths&lt;/strong&gt;&lt;br&gt;
"HTTPS encrypts the entire Internet."&lt;/p&gt;

&lt;p&gt;No.&lt;/p&gt;

&lt;p&gt;It encrypts the communication between your client and the server.&lt;/p&gt;

&lt;p&gt;"HTTPS hides which website I'm visiting."&lt;/p&gt;

&lt;p&gt;Not entirely.&lt;/p&gt;

&lt;p&gt;Your ISP can usually see the destination IP address and some metadata, although modern technologies reduce what is exposed.&lt;/p&gt;

&lt;p&gt;"The padlock means the website is safe."&lt;/p&gt;

&lt;p&gt;No.&lt;/p&gt;

&lt;p&gt;It only means the connection is encrypted and the certificate is valid.&lt;/p&gt;

&lt;p&gt;A phishing website can also have HTTPS.&lt;/p&gt;

&lt;p&gt;"HTTP is obsolete."&lt;/p&gt;

&lt;p&gt;Not completely.&lt;/p&gt;

&lt;p&gt;HTTP still exists.&lt;/p&gt;

&lt;p&gt;HTTPS is simply HTTP running over TLS.&lt;/p&gt;

&lt;p&gt;Real-World Examples&lt;/p&gt;

&lt;p&gt;Uses HTTPS:&lt;/p&gt;

&lt;p&gt;Online banking&lt;br&gt;
GitHub&lt;br&gt;
Gmail&lt;br&gt;
Amazon&lt;br&gt;
APIs&lt;br&gt;
Payment systems&lt;/p&gt;

&lt;p&gt;Without HTTPS:&lt;/p&gt;

&lt;p&gt;Passwords&lt;br&gt;
Cookies&lt;br&gt;
Tokens&lt;br&gt;
Credit card numbers&lt;/p&gt;

&lt;p&gt;would all travel in plain text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interview Questions&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;a.Why does HTTPS need certificates?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To verify the server's identity and prevent attackers from impersonating legitimate websites.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b.Why use both symmetric and asymmetric encryption?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Asymmetric encryption (or key exchange) solves the problem of establishing trust and securely deriving a shared secret. Symmetric encryption is then used because it's much faster for encrypting the actual data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c.Why is HTTPS built on TCP?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;TLS requires reliable, ordered delivery during the handshake and while exchanging encrypted records. TCP provides those guarantees.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d.Does HTTPS stop hackers?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It protects data in transit between you and the server.&lt;/p&gt;

&lt;p&gt;It does not protect against:&lt;/p&gt;

&lt;p&gt;Weak passwords&lt;br&gt;
SQL Injection&lt;br&gt;
XSS&lt;br&gt;
Malware on your computer&lt;br&gt;
Social engineering&lt;/p&gt;

&lt;p&gt;HTTPS solves one specific problem:&lt;/p&gt;

&lt;p&gt;Protecting communication while it's traveling across the network.&lt;/p&gt;

&lt;p&gt;Key Takeaways&lt;/p&gt;

&lt;p&gt;Every time you visit an HTTPS website, your browser and the server perform a carefully orchestrated dance before a single web page is loaded. They agree on encryption algorithms, verify the server's identity through a trusted certificate, securely derive a shared secret without ever transmitting it, and then switch to fast symmetric encryption for the rest of the session.&lt;/p&gt;

&lt;p&gt;The result is that even if someone intercepts every packet traveling across the network, they cannot read or modify the protected data without the session keys.&lt;/p&gt;

&lt;p&gt;That small padlock in your browser represents decades of cryptographic research working together to make everyday activities—like online banking, shopping, email, and APIs—secure enough to use over an untrusted Internet.&lt;/p&gt;

</description>
      <category>security</category>
      <category>networking</category>
      <category>webdev</category>
      <category>https</category>
    </item>
    <item>
      <title>TCP or UDP? Choosing the Right Protocol</title>
      <dc:creator>Juma Evans</dc:creator>
      <pubDate>Fri, 24 Jul 2026 23:00:46 +0000</pubDate>
      <link>https://dev.to/juma_evans_34e389ef539266/tcp-or-udp-choosing-the-right-protocol-1i98</link>
      <guid>https://dev.to/juma_evans_34e389ef539266/tcp-or-udp-choosing-the-right-protocol-1i98</guid>
      <description>&lt;p&gt;&lt;strong&gt;1. Analogy&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you're sending your friend a 500-page book.&lt;/p&gt;

&lt;p&gt;You have two delivery companies.&lt;/p&gt;

&lt;p&gt;The first guarantees every page arrives in order.&lt;br&gt;
If page 187 gets lost, they'll resend only page 187.&lt;/p&gt;

&lt;p&gt;The second company is incredibly fast.&lt;br&gt;
They throw pages onto trucks immediately.&lt;br&gt;
If page 187 disappears...&lt;/p&gt;

&lt;p&gt;They simply keep driving.&lt;/p&gt;

&lt;p&gt;Which company would you choose?&lt;/p&gt;

&lt;p&gt;The answer depends on what you're sending.&lt;/p&gt;

&lt;p&gt;That's exactly why the Internet has TCP and UDP.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why One Protocol Isn't Enough&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Different applications have different priorities.&lt;/p&gt;

&lt;p&gt;Imagine these scenarios:&lt;/p&gt;

&lt;p&gt;Downloading Ubuntu ISO&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Watching Netflix&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Video Calling&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Playing Valorant&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Sending Bank Transactions&lt;/p&gt;

&lt;p&gt;Should they all behave the same?&lt;/p&gt;

&lt;p&gt;Absolutely not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A.Meet TCP&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;TCP says:&lt;/p&gt;

&lt;p&gt;I refuse to lose data.&lt;/p&gt;

&lt;p&gt;Its priorities:&lt;/p&gt;

&lt;p&gt;✔ Reliability&lt;/p&gt;

&lt;p&gt;✔ Correct order&lt;/p&gt;

&lt;p&gt;✔ Error recovery&lt;/p&gt;

&lt;p&gt;✔ Flow control&lt;/p&gt;

&lt;p&gt;✔ Congestion control&lt;/p&gt;

&lt;p&gt;Not speed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How TCP Works&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before sending anything:&lt;/p&gt;

&lt;p&gt;TCP says:&lt;/p&gt;

&lt;p&gt;Let's introduce ourselves.&lt;/p&gt;

&lt;p&gt;This is the famous Three-Way Handshake.&lt;/p&gt;

&lt;p&gt;Client                  Server&lt;/p&gt;

&lt;p&gt;SYN  ------------------&amp;gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;----------------  SYN-ACK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;ACK  ------------------&amp;gt;&lt;/p&gt;

&lt;p&gt;Now both sides know:&lt;/p&gt;

&lt;p&gt;"I'm ready."&lt;/p&gt;

&lt;p&gt;Only then does data start flowing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;SYN&lt;br&gt;
ACK&lt;br&gt;
Sequence Numbers&lt;br&gt;
Sequence Numbers&lt;/p&gt;

&lt;p&gt;Imagine sending:&lt;/p&gt;

&lt;p&gt;Hello World&lt;/p&gt;

&lt;p&gt;TCP splits it.&lt;/p&gt;

&lt;p&gt;Packet 1&lt;/p&gt;

&lt;p&gt;Packet 2&lt;/p&gt;

&lt;p&gt;Packet 3&lt;/p&gt;

&lt;p&gt;Each receives a number.&lt;/p&gt;

&lt;p&gt;1&lt;/p&gt;

&lt;p&gt;2&lt;/p&gt;

&lt;p&gt;3&lt;/p&gt;

&lt;p&gt;If packet 2 disappears:&lt;/p&gt;

&lt;p&gt;1&lt;/p&gt;

&lt;p&gt;❌&lt;/p&gt;

&lt;p&gt;3&lt;/p&gt;

&lt;p&gt;The receiver says:&lt;/p&gt;

&lt;p&gt;"I got 1."&lt;/p&gt;

&lt;p&gt;"I got 3."&lt;/p&gt;

&lt;p&gt;"I'm still missing 2."&lt;/p&gt;

&lt;p&gt;TCP resends only packet 2.&lt;/p&gt;

&lt;p&gt;This is reliability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Acknowledgments&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every successful delivery receives an ACK.&lt;/p&gt;

&lt;p&gt;Packet&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;ACK&lt;/p&gt;

&lt;p&gt;No ACK?&lt;/p&gt;

&lt;p&gt;Resend.&lt;/p&gt;

&lt;p&gt;Simple.&lt;/p&gt;

&lt;p&gt;Flow Control&lt;/p&gt;

&lt;p&gt;Imagine:&lt;/p&gt;

&lt;p&gt;Sender:&lt;/p&gt;

&lt;p&gt;1000 Mbps&lt;/p&gt;

&lt;p&gt;Receiver:&lt;/p&gt;

&lt;p&gt;20 Mbps&lt;/p&gt;

&lt;p&gt;Without control:&lt;/p&gt;

&lt;p&gt;The receiver drowns.&lt;/p&gt;

&lt;p&gt;TCP asks:&lt;/p&gt;

&lt;p&gt;"How much can you handle?"&lt;/p&gt;

&lt;p&gt;Receiver answers:&lt;/p&gt;

&lt;p&gt;512 KB&lt;/p&gt;

&lt;p&gt;TCP obeys.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Congestion Control&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What if the Internet itself is busy?&lt;/p&gt;

&lt;p&gt;Highways become congested.&lt;/p&gt;

&lt;p&gt;TCP slows down.&lt;/p&gt;

&lt;p&gt;Not because the receiver is slow.&lt;/p&gt;

&lt;p&gt;Because the network is crowded.&lt;/p&gt;

&lt;p&gt;Explain:&lt;/p&gt;

&lt;p&gt;Traffic jam analogy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B.Meet UDP&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;UDP has one philosophy.&lt;/p&gt;

&lt;p&gt;Send it.&lt;/p&gt;

&lt;p&gt;That's it.&lt;/p&gt;

&lt;p&gt;No handshake.&lt;/p&gt;

&lt;p&gt;No acknowledgments.&lt;/p&gt;

&lt;p&gt;No retries.&lt;/p&gt;

&lt;p&gt;No ordering.&lt;/p&gt;

&lt;p&gt;No waiting.&lt;/p&gt;

&lt;p&gt;UDP in Action&lt;br&gt;
Packet 1&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Packet 2&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Packet 3&lt;/p&gt;

&lt;p&gt;Packet 2 disappears.&lt;/p&gt;

&lt;p&gt;UDP simply continues.&lt;/p&gt;

&lt;p&gt;1&lt;/p&gt;

&lt;p&gt;❌&lt;/p&gt;

&lt;p&gt;3&lt;/p&gt;

&lt;p&gt;4&lt;/p&gt;

&lt;p&gt;5&lt;/p&gt;

&lt;p&gt;6&lt;/p&gt;

&lt;p&gt;No resend.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Would Anyone Want That?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because sometimes waiting is worse than losing data.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a.Video Call&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine hearing:&lt;/p&gt;

&lt;p&gt;Hello...&lt;/p&gt;

&lt;p&gt;(wait 3 seconds)&lt;/p&gt;

&lt;p&gt;How...&lt;/p&gt;

&lt;p&gt;(wait)&lt;/p&gt;

&lt;p&gt;are...&lt;/p&gt;

&lt;p&gt;(wait)&lt;/p&gt;

&lt;p&gt;you?&lt;/p&gt;

&lt;p&gt;Terrible.&lt;/p&gt;

&lt;p&gt;Instead,&lt;/p&gt;

&lt;p&gt;if one audio packet disappears...&lt;/p&gt;

&lt;p&gt;Your brain barely notices.&lt;/p&gt;

&lt;p&gt;Speed matters more than perfection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b.Gaming&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Suppose you're playing FIFA.&lt;/p&gt;

&lt;p&gt;Every 16 milliseconds your position changes.&lt;/p&gt;

&lt;p&gt;If one packet disappears:&lt;/p&gt;

&lt;p&gt;Do you want the old position?&lt;/p&gt;

&lt;p&gt;No.&lt;/p&gt;

&lt;p&gt;You want the newest one.&lt;/p&gt;

&lt;p&gt;Old data is useless.&lt;/p&gt;

&lt;p&gt;UDP wins.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c.Live Streaming&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Watching football.&lt;/p&gt;

&lt;p&gt;Frame 246 disappears.&lt;/p&gt;

&lt;p&gt;Should Netflix stop?&lt;/p&gt;

&lt;p&gt;No.&lt;/p&gt;

&lt;p&gt;Show frame 247.&lt;/p&gt;

&lt;p&gt;Keep going.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d.DNS Uses UDP Too&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;DNS requests are tiny.&lt;/p&gt;

&lt;p&gt;Where is github.com?&lt;/p&gt;

&lt;p&gt;The answer is tiny too.&lt;/p&gt;

&lt;p&gt;If one packet gets lost:&lt;/p&gt;

&lt;p&gt;Just ask again.&lt;/p&gt;

&lt;p&gt;Using TCP would waste time establishing a connection for every lookup.&lt;/p&gt;

&lt;p&gt;That's why most DNS queries use UDP.&lt;/p&gt;

&lt;p&gt;When TCP Wins&lt;/p&gt;

&lt;p&gt;Downloading files.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;Linux ISO&lt;/p&gt;

&lt;p&gt;PDF&lt;/p&gt;

&lt;p&gt;ZIP&lt;/p&gt;

&lt;p&gt;Database backup&lt;/p&gt;

&lt;p&gt;One missing byte corrupts the entire file.&lt;/p&gt;

&lt;p&gt;TCP ensures:&lt;/p&gt;

&lt;p&gt;Nothing is lost.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common Applications&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;TCP&lt;/strong&gt;               &lt;strong&gt;UDP&lt;/strong&gt;&lt;br&gt;
HTTP                   DNS&lt;br&gt;
HTTPS                  VoIP&lt;br&gt;
SSH                Online Gaming&lt;br&gt;
FTP                Live Streaming&lt;br&gt;
Email                  DHCP&lt;br&gt;
Database Connections   NTP&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TCP vs UDP&lt;/strong&gt;&lt;br&gt;
Feature                 TCP                       UDP&lt;br&gt;
Connection           Yes                          No&lt;br&gt;
Reliable             Yes                          No&lt;br&gt;
Ordered Delivery     Yes                          No&lt;br&gt;
Error Recovery           Yes                          No&lt;br&gt;
Speed                    Slower                       Faster&lt;br&gt;
Header Size          20–60 bytes                8 bytes&lt;br&gt;
Best For             Files, APIs, Banking         Games, Calls&lt;br&gt;
How the OSI Model Fits&lt;/p&gt;

&lt;p&gt;TCP and UDP both live in:&lt;/p&gt;

&lt;p&gt;Layer 4&lt;/p&gt;

&lt;p&gt;Transport Layer&lt;/p&gt;

&lt;p&gt;Above them:&lt;/p&gt;

&lt;p&gt;HTTP&lt;/p&gt;

&lt;p&gt;HTTPS&lt;/p&gt;

&lt;p&gt;DNS&lt;/p&gt;

&lt;p&gt;SMTP&lt;/p&gt;

&lt;p&gt;Below them:&lt;/p&gt;

&lt;p&gt;IP&lt;/p&gt;

&lt;p&gt;Ethernet&lt;/p&gt;

&lt;p&gt;Wi-Fi&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interview Questions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a.Why doesn't TCP always replace UDP?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because reliability has a cost. Handshakes, acknowledgments, retransmissions, and congestion control all add latency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b.Why doesn't UDP replace TCP?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because some data must arrive intact and in order. Losing a byte in a bank transaction or software download is unacceptable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c.Can UDP be made reliable?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes. Applications can implement their own reliability mechanisms on top of UDP. A good example is QUIC, which runs over UDP and powers HTTP/3 by handling reliability and security in user space.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d.Why does HTTP/3 use UDP?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because it builds its own transport features on top of UDP, avoiding some of TCP's limitations—particularly connection setup delays and head-of-line blocking.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final Takeaways&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;TCP and UDP aren't competitors trying to replace one another. They solve different problems. TCP prioritizes reliability, ensuring data arrives completely, in order, and without corruption. UDP prioritizes speed and low latency, accepting occasional packet loss when timely delivery is more important than perfect delivery.&lt;/p&gt;

&lt;p&gt;The next time you're downloading a file, making a video call, joining an online game, or performing a DNS lookup, you'll know why the Internet chooses one protocol over the other.&lt;/p&gt;

</description>
      <category>networking</category>
      <category>backend</category>
      <category>tcp</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Understanding the OSI Model Through One Network Request</title>
      <dc:creator>Juma Evans</dc:creator>
      <pubDate>Fri, 24 Jul 2026 22:30:10 +0000</pubDate>
      <link>https://dev.to/juma_evans_34e389ef539266/understanding-the-osi-model-through-one-network-request-5f7o</link>
      <guid>https://dev.to/juma_evans_34e389ef539266/understanding-the-osi-model-through-one-network-request-5f7o</guid>
      <description>&lt;p&gt;&lt;strong&gt;The Hook&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every networking course begins with the same seven mysterious layers:&lt;/p&gt;

&lt;p&gt;Physical&lt;br&gt;
Data Link&lt;br&gt;
Network&lt;br&gt;
Transport&lt;br&gt;
Session&lt;br&gt;
Presentation&lt;br&gt;
Application&lt;/p&gt;

&lt;p&gt;Students memorize them.&lt;/p&gt;

&lt;p&gt;Developers ignore them.&lt;/p&gt;

&lt;p&gt;Network engineers live by them.&lt;/p&gt;

&lt;p&gt;But here's the problem:&lt;/p&gt;

&lt;p&gt;Most people never learn why these layers exist.&lt;/p&gt;

&lt;p&gt;In this article, we'll follow a single message;"Hello, Server!" as it travels through every OSI layer, crosses routers and switches, reaches another computer, and climbs back up the stack.&lt;/p&gt;

&lt;p&gt;By the end, you'll understand not just the names of the layers, but why the Internet couldn't exist without them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Story&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you open your browser.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com" rel="noopener noreferrer"&gt;https://github.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You press Enter.&lt;/p&gt;

&lt;p&gt;Now follow that request.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 7 : Application&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is where humans interact with software.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;p&gt;Browser&lt;br&gt;
WhatsApp&lt;br&gt;
Discord&lt;br&gt;
Gmail&lt;br&gt;
Spotify&lt;/p&gt;

&lt;p&gt;The browser creates:&lt;/p&gt;

&lt;p&gt;GET / HTTP/1.1&lt;br&gt;
Host: github.com&lt;/p&gt;

&lt;p&gt;Notice:&lt;/p&gt;

&lt;p&gt;No IP.&lt;/p&gt;

&lt;p&gt;No MAC address.&lt;/p&gt;

&lt;p&gt;No Ethernet.&lt;/p&gt;

&lt;p&gt;Just application data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 6 : Presentation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This layer asks:&lt;/p&gt;

&lt;p&gt;How should the data look?&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;p&gt;Encryption (TLS/SSL)&lt;br&gt;
Compression (gzip)&lt;br&gt;
Character encoding (UTF-8)&lt;br&gt;
Serialization (JSON, XML, Protocol Buffers)&lt;/p&gt;

&lt;p&gt;Here your HTTP request is encrypted into ciphertext before leaving your machine.&lt;/p&gt;

&lt;p&gt;Without this layer:&lt;/p&gt;

&lt;p&gt;Everyone on the network could read your passwords.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 5 : Session&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This layer manages conversations.&lt;/p&gt;

&lt;p&gt;Think of it as the meeting organizer.&lt;/p&gt;

&lt;p&gt;Responsibilities include:&lt;/p&gt;

&lt;p&gt;Opening communication&lt;br&gt;
Keeping it alive&lt;br&gt;
Reconnecting if interrupted&lt;br&gt;
Closing the session cleanly&lt;/p&gt;

&lt;p&gt;Modern TCP/IP doesn't expose this as a separate layer, but the concept still exists in many protocols.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 4 : Transport&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now things become interesting.&lt;/p&gt;

&lt;p&gt;Imagine sending a 100 MB video.&lt;/p&gt;

&lt;p&gt;Should it be one enormous packet?&lt;/p&gt;

&lt;p&gt;No.&lt;/p&gt;

&lt;p&gt;Transport breaks it into manageable pieces called segments.&lt;/p&gt;

&lt;p&gt;It also adds:&lt;/p&gt;

&lt;p&gt;Source port&lt;br&gt;
Destination port&lt;br&gt;
Sequence number&lt;br&gt;
Acknowledgments&lt;br&gt;
Error recovery&lt;/p&gt;

&lt;p&gt;Protocols:&lt;/p&gt;

&lt;p&gt;TCP&lt;br&gt;
UDP&lt;/p&gt;

&lt;p&gt;Analogy:&lt;/p&gt;

&lt;p&gt;A courier numbers every box before shipping.&lt;/p&gt;

&lt;p&gt;If Box #7 disappears...&lt;/p&gt;

&lt;p&gt;Only Box #7 is resent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 3 : Network&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now we need directions.&lt;/p&gt;

&lt;p&gt;The Network layer adds:&lt;/p&gt;

&lt;p&gt;Source IP&lt;/p&gt;

&lt;p&gt;Destination IP&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;192.168.1.10&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;140.82.121.3&lt;/p&gt;

&lt;p&gt;Routers read this information.&lt;/p&gt;

&lt;p&gt;Their only job is:&lt;/p&gt;

&lt;p&gt;Which road gets this packet closer to its destination?&lt;/p&gt;

&lt;p&gt;Think Google Maps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 2 : Data Link&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now the packet reaches your home Wi-Fi.&lt;/p&gt;

&lt;p&gt;The router doesn't care about IP first.&lt;/p&gt;

&lt;p&gt;It wants:&lt;/p&gt;

&lt;p&gt;MAC Address&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because devices communicate locally using hardware addresses.&lt;/p&gt;

&lt;p&gt;The frame now contains:&lt;/p&gt;

&lt;p&gt;Destination MAC&lt;/p&gt;

&lt;p&gt;Source MAC&lt;/p&gt;

&lt;p&gt;Payload&lt;/p&gt;

&lt;p&gt;Switches live here.&lt;/p&gt;

&lt;p&gt;They forward frames only to the correct device.&lt;/p&gt;

&lt;p&gt;This is why switches are much smarter than hubs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 1 : Physical&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Finally...&lt;/p&gt;

&lt;p&gt;Everything becomes electricity.&lt;/p&gt;

&lt;p&gt;Or light.&lt;/p&gt;

&lt;p&gt;Or radio waves.&lt;/p&gt;

&lt;p&gt;Bits become:&lt;/p&gt;

&lt;p&gt;101001011010011001&lt;/p&gt;

&lt;p&gt;Those bits travel through:&lt;/p&gt;

&lt;p&gt;Copper cables&lt;br&gt;
Fiber optics&lt;br&gt;
Wi-Fi radio&lt;br&gt;
Satellite signals&lt;/p&gt;

&lt;p&gt;Layer 1 doesn't know HTTP.&lt;/p&gt;

&lt;p&gt;It doesn't know IP.&lt;/p&gt;

&lt;p&gt;It doesn't even know bytes.&lt;/p&gt;

&lt;p&gt;It only knows:&lt;/p&gt;

&lt;p&gt;0&lt;/p&gt;

&lt;p&gt;1&lt;br&gt;
Encapsulation&lt;/p&gt;

&lt;p&gt;Here's the beautiful part.&lt;/p&gt;

&lt;p&gt;Each layer wraps the previous layer with its own information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Think of Russian nesting dolls.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Application Data&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Segment&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Packet&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Frame&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Bits&lt;/p&gt;

&lt;p&gt;Or like mailing a package:&lt;/p&gt;

&lt;p&gt;Letter&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Envelope&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Shipping Box&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Truck&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Road&lt;/p&gt;

&lt;p&gt;Each layer adds just enough information for the next part of the journey.&lt;/p&gt;

&lt;p&gt;At the Destination&lt;/p&gt;

&lt;p&gt;The server receives:&lt;/p&gt;

&lt;p&gt;Bits&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Frame&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Packet&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Segment&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Application Data&lt;/p&gt;

&lt;p&gt;Each layer removes the information added by its counterpart on the sender's side.&lt;/p&gt;

&lt;p&gt;This process is called &lt;strong&gt;decapsulation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Eventually GitHub receives:&lt;/p&gt;

&lt;p&gt;GET /&lt;/p&gt;

&lt;p&gt;and responds with HTML.&lt;/p&gt;

&lt;p&gt;Which Devices Work at Each Layer?&lt;br&gt;
Layer   Device&lt;br&gt;
7   Browser, Web Server&lt;br&gt;
6   TLS, SSL&lt;br&gt;
5   Session managers&lt;br&gt;
4   TCP, UDP&lt;br&gt;
3   Router&lt;br&gt;
2   Switch&lt;br&gt;
1   Cable, Fiber, Wi-Fi&lt;/p&gt;

&lt;p&gt;This table alone helps readers connect abstract layers to real-world hardware and software.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Was the OSI Model Invented though?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before the OSI model, networking vendors often built proprietary systems that worked only with their own hardware and software. There wasn't a common language for how devices should communicate.&lt;/p&gt;

&lt;p&gt;The OSI model introduced a layered architecture where each layer has a single responsibility and communicates only with the layers directly above and below it.&lt;/p&gt;

&lt;p&gt;This separation provides several advantages:&lt;/p&gt;

&lt;p&gt;Modularity: You can improve one layer without redesigning the entire stack.&lt;br&gt;
Interoperability: Devices from different vendors can communicate because they follow the same layer responsibilities.&lt;br&gt;
Troubleshooting: Network problems become easier to isolate. If you can't even establish a physical connection, there's no point debugging HTTP.&lt;br&gt;
Scalability: New technologies can be introduced within a layer without affecting the rest of the system.&lt;/p&gt;

&lt;p&gt;Although the Internet actually uses the simpler TCP/IP model, the OSI model remains one of the best conceptual tools for understanding how data moves across networks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A Developer's View of the OSI Model&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you're writing backend services or APIs, you interact with multiple layers—even if you don't think about them:&lt;/p&gt;

&lt;p&gt;You build REST or GraphQL APIs at the Application layer.&lt;br&gt;
HTTPS relies on Presentation layer concepts like encryption.&lt;br&gt;
Socket connections and ports depend on the Transport layer.&lt;br&gt;
IP addresses and routing involve the Network layer.&lt;br&gt;
Switches, Ethernet, and Wi-Fi operate at the Data Link and Physical layers.&lt;/p&gt;

&lt;p&gt;Understanding where a problem occurs makes debugging much faster.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Takeaways&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The OSI model isn't just a list to memorize for an exam—it's a way of thinking about networking. Every request you send travels down the stack, where each layer adds the information needed for its specific job. It crosses the network as electrical signals, light, or radio waves, then climbs back up the layers on the receiving machine until the original application data is reconstructed.&lt;/p&gt;

&lt;p&gt;Once you see networking as a journey through these seven layers rather than seven isolated definitions, concepts like routers, switches, TCP, IP, TLS, and HTTP start fitting together naturally.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>networking</category>
      <category>backend</category>
    </item>
    <item>
      <title>DNS Lookup Explained</title>
      <dc:creator>Juma Evans</dc:creator>
      <pubDate>Fri, 24 Jul 2026 22:04:46 +0000</pubDate>
      <link>https://dev.to/juma_evans_34e389ef539266/dns-lookup-explained-3e92</link>
      <guid>https://dev.to/juma_evans_34e389ef539266/dns-lookup-explained-3e92</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;What Really Happens When You Visit a Website?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You type google.com.&lt;/p&gt;

&lt;p&gt;Less than a second later you're watching YouTube, reading emails, or searching the web.&lt;/p&gt;

&lt;p&gt;It feels instant.&lt;/p&gt;

&lt;p&gt;But before your browser can even request a webpage, an entire conversation happens across the Internet.&lt;/p&gt;

&lt;p&gt;Your computer has one important question:&lt;/p&gt;

&lt;p&gt;"Where is google.com?"&lt;/p&gt;

&lt;p&gt;That question is answered by one of the oldest and most important systems on the Internet:&lt;/p&gt;

&lt;p&gt;DNS — the Domain Name System.&lt;/p&gt;

&lt;p&gt;Think of DNS as the Internet's phonebook.&lt;/p&gt;

&lt;p&gt;Instead of remembering IP addresses like&lt;/p&gt;

&lt;p&gt;142.250.190.46&lt;br&gt;
we remember names like;&lt;/p&gt;

&lt;p&gt;google.com&lt;/p&gt;

&lt;p&gt;DNS translates those human-friendly names into machine-friendly IP addresses.&lt;/p&gt;

&lt;p&gt;Let's see exactly how that happens.&lt;/p&gt;

&lt;p&gt;Why Do We Need DNS?&lt;/p&gt;

&lt;p&gt;Imagine if every person in your contacts list had no names.&lt;/p&gt;

&lt;p&gt;Instead of calling Mom, you'd have to memorize:&lt;/p&gt;

&lt;p&gt;+254712345678&lt;/p&gt;

&lt;p&gt;Now imagine doing that for every person you've ever met.&lt;/p&gt;

&lt;p&gt;Almost impossible.&lt;/p&gt;

&lt;p&gt;Computers have the same problem.&lt;/p&gt;

&lt;p&gt;They communicate using IP addresses.&lt;/p&gt;

&lt;p&gt;Humans communicate using names.&lt;/p&gt;

&lt;p&gt;DNS bridges that gap.&lt;/p&gt;

&lt;p&gt;The Journey Begins&lt;/p&gt;

&lt;p&gt;Suppose you enter:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com" rel="noopener noreferrer"&gt;https://github.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your browser doesn't know where GitHub lives.&lt;/p&gt;

&lt;p&gt;It starts asking around.&lt;/p&gt;

&lt;p&gt;The entire lookup looks something like this:&lt;/p&gt;

&lt;p&gt;You&lt;br&gt;
 │&lt;br&gt;
 ▼&lt;br&gt;
Browser Cache&lt;br&gt;
 │&lt;br&gt;
 ▼&lt;br&gt;
Operating System Cache&lt;br&gt;
 │&lt;br&gt;
 ▼&lt;br&gt;
Recursive DNS Resolver&lt;br&gt;
 │&lt;br&gt;
 ▼&lt;br&gt;
Root Name Server&lt;br&gt;
 │&lt;br&gt;
 ▼&lt;br&gt;
TLD Name Server (.com)&lt;br&gt;
 │&lt;br&gt;
 ▼&lt;br&gt;
Authoritative Name Server&lt;br&gt;
 │&lt;br&gt;
 ▼&lt;br&gt;
GitHub IP Address&lt;/p&gt;

&lt;p&gt;Let's visit each stop.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 — Browser Cache&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Your browser first checks:&lt;/p&gt;

&lt;p&gt;Have I visited GitHub recently?&lt;/p&gt;

&lt;p&gt;If yes...&lt;br&gt;
github.com&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;140.82.121.3&lt;br&gt;
Done.&lt;/p&gt;

&lt;p&gt;No Internet lookup needed.&lt;/p&gt;

&lt;p&gt;Every browser keeps a temporary DNS cache.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2 — Operating System Cache&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If the browser doesn't know...&lt;/p&gt;

&lt;p&gt;it asks the operating system.&lt;/p&gt;

&lt;p&gt;Windows, Linux, and macOS all maintain DNS caches.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;github.com&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;140.82.121.3&lt;/p&gt;

&lt;p&gt;Still no network request.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3 — Recursive Resolver&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If nobody knows...&lt;/p&gt;

&lt;p&gt;your computer asks a DNS resolver.&lt;/p&gt;

&lt;p&gt;Usually this belongs to:&lt;/p&gt;

&lt;p&gt;Your ISP&lt;br&gt;
Google DNS (8.8.8.8)&lt;br&gt;
Cloudflare (1.1.1.1)&lt;br&gt;
Quad9&lt;/p&gt;

&lt;p&gt;The resolver's job is simple:&lt;/p&gt;

&lt;p&gt;"Don't worry.&lt;br&gt;
I'll find the answer."&lt;/p&gt;

&lt;p&gt;This resolver does all the heavy lifting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4 — Root Name Server&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The resolver first asks a Root Server:&lt;/p&gt;

&lt;p&gt;Where is github.com?&lt;/p&gt;

&lt;p&gt;The root server replies:&lt;/p&gt;

&lt;p&gt;"I don't know GitHub...&lt;/p&gt;

&lt;p&gt;but I know who manages .com."&lt;/p&gt;

&lt;p&gt;Notice something important.&lt;/p&gt;

&lt;p&gt;The root server doesn't know every website.&lt;/p&gt;

&lt;p&gt;It only knows where to find top-level domains.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5 — TLD Name Server&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next stop:&lt;/p&gt;

&lt;p&gt;.com&lt;/p&gt;

&lt;p&gt;The resolver asks:&lt;/p&gt;

&lt;p&gt;Where is github.com?&lt;/p&gt;

&lt;p&gt;The .com server replies:&lt;/p&gt;

&lt;p&gt;"Ask GitHub's authoritative server."&lt;/p&gt;

&lt;p&gt;Again...&lt;/p&gt;

&lt;p&gt;No IP address yet.&lt;/p&gt;

&lt;p&gt;Just directions.&lt;/p&gt;

&lt;p&gt;Step 6 — Authoritative Name Server&lt;/p&gt;

&lt;p&gt;Finally the resolver reaches GitHub's own DNS server.&lt;/p&gt;

&lt;p&gt;Now it asks:&lt;/p&gt;

&lt;p&gt;What is github.com?&lt;/p&gt;

&lt;p&gt;The server replies:&lt;/p&gt;

&lt;p&gt;140.82.121.3&lt;/p&gt;

&lt;p&gt;Finally!&lt;/p&gt;

&lt;p&gt;Now the resolver returns the answer to your computer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7 — The Browser Makes the Real Request&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Only now can your browser send:&lt;/p&gt;

&lt;p&gt;GET /&lt;br&gt;
Host: github.com&lt;/p&gt;

&lt;p&gt;to&lt;/p&gt;

&lt;p&gt;140.82.121.3&lt;/p&gt;

&lt;p&gt;DNS lookup is finished.&lt;/p&gt;

&lt;p&gt;Only then does HTTPS begin.&lt;/p&gt;

&lt;p&gt;Visualizing the Entire Journey&lt;br&gt;
You&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Browser Cache&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;OS Cache&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Recursive Resolver&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Root Server&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;.com Server&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;GitHub Authoritative Server&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;IP Address&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Browser connects&lt;/p&gt;

&lt;p&gt;Notice that DNS itself doesn't deliver webpages—it only answers the question:&lt;/p&gt;

&lt;p&gt;"Which IP address should I connect to?"&lt;/p&gt;

&lt;p&gt;Recursive vs. Authoritative DNS&lt;/p&gt;

&lt;p&gt;These two are often confused.&lt;/p&gt;

&lt;p&gt;Recursive Resolver&lt;/p&gt;

&lt;p&gt;Think of it as your personal assistant.&lt;/p&gt;

&lt;p&gt;You ask one question.&lt;/p&gt;

&lt;p&gt;It does all the research.&lt;/p&gt;

&lt;p&gt;You&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Resolver&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;Internet&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;p&gt;Google DNS&lt;br&gt;
Cloudflare DNS&lt;br&gt;
ISP DNS&lt;br&gt;
Authoritative Server&lt;/p&gt;

&lt;p&gt;This server owns the official answer.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;github.com&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;140.82.121.3&lt;/p&gt;

&lt;p&gt;Nobody argues with the authoritative server.&lt;/p&gt;

&lt;p&gt;It's the source of truth.&lt;/p&gt;

&lt;p&gt;Why DNS Is So Fast&lt;/p&gt;

&lt;p&gt;The first lookup may take a few milliseconds.&lt;/p&gt;

&lt;p&gt;The second lookup?&lt;/p&gt;

&lt;p&gt;Almost instant.&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Caching.&lt;/p&gt;

&lt;p&gt;Once the resolver learns:&lt;/p&gt;

&lt;p&gt;github.com&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;140.82.121.3&lt;/p&gt;

&lt;p&gt;it stores the answer.&lt;/p&gt;

&lt;p&gt;The next thousand users can reuse it.&lt;/p&gt;

&lt;p&gt;This dramatically reduces Internet traffic.&lt;/p&gt;

&lt;p&gt;What Is TTL?&lt;/p&gt;

&lt;p&gt;Every DNS record has a value called:&lt;/p&gt;

&lt;p&gt;TTL&lt;/p&gt;

&lt;p&gt;Time To Live&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;TTL = 3600&lt;/p&gt;

&lt;p&gt;means&lt;/p&gt;

&lt;p&gt;Keep this answer for one hour.&lt;/p&gt;

&lt;p&gt;After that...&lt;/p&gt;

&lt;p&gt;the resolver asks again.&lt;/p&gt;

&lt;p&gt;TTL prevents outdated IP addresses from living forever.&lt;/p&gt;

&lt;p&gt;Common DNS Record Types&lt;/p&gt;

&lt;p&gt;DNS stores more than IP addresses.&lt;/p&gt;

&lt;p&gt;Here are the most common record types you'll encounter:&lt;/p&gt;

&lt;p&gt;Record  Purpose&lt;br&gt;
A   Maps a domain to an IPv4 address&lt;br&gt;
AAAA    Maps a domain to an IPv6 address&lt;br&gt;
CNAME   Points one domain to another domain&lt;br&gt;
MX  Specifies mail servers for email delivery&lt;br&gt;
TXT Stores text data, often used for verification and security (SPF, DKIM, DMARC)&lt;br&gt;
NS  Identifies the authoritative name servers for a domain&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;blog.example.com&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;CNAME&lt;/p&gt;

&lt;p&gt;↓&lt;/p&gt;

&lt;p&gt;hosting.example.net&lt;br&gt;
Try It Yourself&lt;/p&gt;

&lt;p&gt;On Linux or macOS:&lt;/p&gt;

&lt;p&gt;dig github.com&lt;/p&gt;

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

&lt;p&gt;nslookup github.com&lt;/p&gt;

&lt;p&gt;Example output:&lt;/p&gt;

&lt;p&gt;github.com&lt;/p&gt;

&lt;p&gt;140.82.121.3&lt;/p&gt;

&lt;p&gt;You can even ask specific DNS servers:&lt;/p&gt;

&lt;p&gt;dig @8.8.8.8 github.com&lt;/p&gt;

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

&lt;p&gt;dig @1.1.1.1 github.com&lt;/p&gt;

&lt;p&gt;This is a great way to compare responses from different resolvers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common Interview Questions&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;a.Why don't browsers connect directly using the domain name?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because network communication happens using IP addresses. DNS translates human-readable domain names into those addresses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b.What happens if DNS fails?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Your browser doesn't know where the server is.&lt;/p&gt;

&lt;p&gt;You'll typically see errors like:&lt;/p&gt;

&lt;p&gt;DNS_PROBE_FINISHED_NXDOMAIN&lt;/p&gt;

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

&lt;p&gt;Server not found&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c.Why are there multiple DNS servers?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The DNS hierarchy distributes responsibility. Root servers know top-level domains, TLD servers know authoritative servers, and authoritative servers know the actual records. This makes DNS scalable, resilient, and decentralized.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d.Does DNS happen every time I visit a website?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Not necessarily. Browsers, operating systems, and recursive resolvers cache DNS responses until the TTL expires.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Takeaways&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Whenever you type a domain name into your browser, a carefully orchestrated lookup begins. Your browser checks its cache, then your operating system, then a recursive resolver. If needed, that resolver consults the root servers, the appropriate top-level domain server, and finally the authoritative name server to obtain the correct IP address. The result is cached for future requests, allowing subsequent lookups to happen much faster.&lt;/p&gt;

&lt;p&gt;Without DNS, we'd have to remember numerical IP addresses for every website we visit. Instead, DNS provides a distributed, scalable naming system that makes the modern Internet usable.&lt;/p&gt;

&lt;p&gt;The next time you type github.com or google.com and the page loads almost instantly, remember that an entire network of DNS servers worked together in just a few milliseconds to answer one simple question:&lt;/p&gt;

&lt;p&gt;"Where can I find this website?"&lt;/p&gt;

</description>
      <category>programming</category>
      <category>backenddevelopment</category>
      <category>softwareengineering</category>
      <category>dns</category>
    </item>
    <item>
      <title>How the Internet Works: From Typing a URL to Seeing a Website</title>
      <dc:creator>Juma Evans</dc:creator>
      <pubDate>Sat, 04 Jul 2026 01:35:09 +0000</pubDate>
      <link>https://dev.to/juma_evans_34e389ef539266/how-the-internet-works-from-typing-a-url-to-seeing-a-website-3255</link>
      <guid>https://dev.to/juma_evans_34e389ef539266/how-the-internet-works-from-typing-a-url-to-seeing-a-website-3255</guid>
      <description>&lt;p&gt;Every day we open a browser, type a website address, and within a few seconds a webpage appears. It feels almost magical, yet behind that simple action is a chain of technologies working together seamlessly.&lt;/p&gt;

&lt;p&gt;If you've ever wondered what happens after pressing &lt;strong&gt;Enter&lt;/strong&gt;, this article is for you. We'll follow a single request from your browser all the way to the server and back while explaining the core concepts every backend developer should know.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Big Picture
&lt;/h1&gt;

&lt;p&gt;Imagine you type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://roadmap.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;into your browser.&lt;/p&gt;

&lt;p&gt;Several things happen almost instantly:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Your device connects to the Internet.&lt;/li&gt;
&lt;li&gt;The browser asks, "Where is roadmap.sh?"&lt;/li&gt;
&lt;li&gt;DNS translates the name into an IP address.&lt;/li&gt;
&lt;li&gt;The browser connects to the server.&lt;/li&gt;
&lt;li&gt;An HTTP request is sent.&lt;/li&gt;
&lt;li&gt;The server responds with HTML, CSS, JavaScript, and other resources.&lt;/li&gt;
&lt;li&gt;The browser renders the webpage.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's understand each step.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Is the Internet?
&lt;/h1&gt;

&lt;p&gt;The Internet is simply a massive network of interconnected computers.&lt;/p&gt;

&lt;p&gt;Every computer connected to the Internet can communicate with another computer using agreed-upon rules called &lt;strong&gt;protocols&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Think of it as an international postal system.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Computers are houses.&lt;/li&gt;
&lt;li&gt;IP addresses are street addresses.&lt;/li&gt;
&lt;li&gt;Routers are post offices.&lt;/li&gt;
&lt;li&gt;Packets are letters.&lt;/li&gt;
&lt;li&gt;Protocols are the rules everyone follows.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of sending one huge file, computers divide information into &lt;strong&gt;packets&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Each packet contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the sender's address&lt;/li&gt;
&lt;li&gt;the destination address&lt;/li&gt;
&lt;li&gt;part of the data&lt;/li&gt;
&lt;li&gt;instructions for reassembling everything&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Routers forward these packets until they reach their destination.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Is an IP Address?
&lt;/h1&gt;

&lt;p&gt;Every device connected to the Internet has an address.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;192.168.1.20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;172.217.170.110
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are called &lt;strong&gt;IP addresses&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Just like your home has a postal address, every computer has an IP address so other computers know where to send information.&lt;/p&gt;

&lt;p&gt;There are two common versions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;IPv4 (32-bit)&lt;/li&gt;
&lt;li&gt;IPv6 (128-bit)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Since the number of Internet-connected devices keeps growing, IPv6 was introduced to provide a much larger address space.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why Don't We Type IP Addresses?
&lt;/h1&gt;

&lt;p&gt;Imagine remembering this every time you wanted to visit GitHub:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;140.82.121.3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead we use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;github.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Humans remember names better than numbers.&lt;/p&gt;

&lt;p&gt;This is where domain names come in.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Is a Domain Name?
&lt;/h1&gt;

&lt;p&gt;A domain name is a human-friendly name that points to a server.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;github.com&lt;/li&gt;
&lt;li&gt;roadmap.sh&lt;/li&gt;
&lt;li&gt;google.com&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A domain itself doesn't contain a website.&lt;/p&gt;

&lt;p&gt;Instead, it's a label that maps to an IP address.&lt;/p&gt;

&lt;p&gt;Think of your phone contacts.&lt;/p&gt;

&lt;p&gt;You don't remember everyone's phone number.&lt;/p&gt;

&lt;p&gt;You save:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Alice
Bob
John
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your phone remembers the numbers.&lt;/p&gt;

&lt;p&gt;DNS works in almost exactly the same way.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Is DNS?
&lt;/h1&gt;

&lt;p&gt;DNS stands for &lt;strong&gt;Domain Name System&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It is often called the &lt;strong&gt;phonebook of the Internet&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Its job is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Convert a domain name into an IP address.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When you type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;roadmap.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;your browser doesn't know where that website lives.&lt;/p&gt;

&lt;p&gt;It asks DNS:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Can you tell me the IP address for roadmap.sh?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;DNS replies with something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;104.xxx.xxx.xxx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the browser knows exactly where to send its request.&lt;/p&gt;

&lt;p&gt;Without DNS, every website would have to be accessed using an IP address.&lt;/p&gt;




&lt;h1&gt;
  
  
  How DNS Works
&lt;/h1&gt;

&lt;p&gt;DNS resolution happens in several steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Browser Cache
&lt;/h2&gt;

&lt;p&gt;The browser first checks whether it already knows the IP address.&lt;/p&gt;

&lt;p&gt;If it does, no DNS lookup is needed.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Operating System Cache
&lt;/h2&gt;

&lt;p&gt;If the browser doesn't know, your operating system checks its own cache.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Recursive Resolver
&lt;/h2&gt;

&lt;p&gt;If the answer still isn't found, the request is sent to your Internet Service Provider (ISP) or another DNS resolver.&lt;/p&gt;

&lt;p&gt;Examples include Google's &lt;code&gt;8.8.8.8&lt;/code&gt; or Cloudflare's &lt;code&gt;1.1.1.1&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Root Name Servers
&lt;/h2&gt;

&lt;p&gt;If necessary, the resolver asks a root DNS server where to continue the search.&lt;/p&gt;

&lt;p&gt;The root server doesn't know the final answer but points the resolver in the right direction.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Top-Level Domain (TLD) Servers
&lt;/h2&gt;

&lt;p&gt;The resolver then contacts the server responsible for the domain extension.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;.com&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.org&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.net&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.ke&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  6. Authoritative Name Server
&lt;/h2&gt;

&lt;p&gt;Finally, the resolver reaches the authoritative DNS server, which stores the actual DNS records for the domain.&lt;/p&gt;

&lt;p&gt;It responds with the correct IP address.&lt;/p&gt;

&lt;p&gt;The browser caches the result for future requests.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Is Hosting?
&lt;/h1&gt;

&lt;p&gt;A website has to live somewhere.&lt;/p&gt;

&lt;p&gt;That "somewhere" is called &lt;strong&gt;hosting&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Hosting is a service that provides servers connected to the Internet so your application is available 24/7.&lt;/p&gt;

&lt;p&gt;When you deploy an application, you're copying your code onto a server that other people can reach.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a Go API&lt;/li&gt;
&lt;li&gt;a Node.js application&lt;/li&gt;
&lt;li&gt;a static HTML website&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hosting providers manage the hardware, networking, storage, and uptime.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Is HTTP?
&lt;/h1&gt;

&lt;p&gt;Now that we know where the server is, we need a language both the browser and server understand.&lt;/p&gt;

&lt;p&gt;That language is &lt;strong&gt;HTTP&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;HTTP stands for:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HyperText Transfer Protocol&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It defines how clients and servers communicate.&lt;/p&gt;

&lt;p&gt;The browser sends a request.&lt;/p&gt;

&lt;p&gt;The server sends a response.&lt;/p&gt;

&lt;p&gt;Simple.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Client-Server Model
&lt;/h1&gt;

&lt;p&gt;A browser is called the &lt;strong&gt;client&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The computer hosting your application is called the &lt;strong&gt;server&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Communication looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Browser
   |
HTTP Request
   |
Server
   |
HTTP Response
   |
Browser
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every website follows this pattern.&lt;/p&gt;




&lt;h1&gt;
  
  
  Anatomy of an HTTP Request
&lt;/h1&gt;

&lt;p&gt;An HTTP request contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Request method&lt;/li&gt;
&lt;li&gt;URL&lt;/li&gt;
&lt;li&gt;Headers&lt;/li&gt;
&lt;li&gt;Optional body&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="nf"&gt;GET&lt;/span&gt; &lt;span class="nn"&gt;/articles&lt;/span&gt; &lt;span class="k"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt;
&lt;span class="na"&gt;Host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;example.com&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Common methods include:&lt;/p&gt;

&lt;h3&gt;
  
  
  GET
&lt;/h3&gt;

&lt;p&gt;Retrieve data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;GET /users
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  POST
&lt;/h3&gt;

&lt;p&gt;Create new data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;POST /users
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  PUT
&lt;/h3&gt;

&lt;p&gt;Replace existing data.&lt;/p&gt;




&lt;h3&gt;
  
  
  PATCH
&lt;/h3&gt;

&lt;p&gt;Update part of existing data.&lt;/p&gt;




&lt;h3&gt;
  
  
  DELETE
&lt;/h3&gt;

&lt;p&gt;Remove data.&lt;/p&gt;




&lt;h1&gt;
  
  
  HTTP Responses
&lt;/h1&gt;

&lt;p&gt;Servers respond with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Status code&lt;/li&gt;
&lt;li&gt;Headers&lt;/li&gt;
&lt;li&gt;Body&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="k"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt; &lt;span class="ne"&gt;OK&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some common status codes are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;200 OK&lt;/li&gt;
&lt;li&gt;201 Created&lt;/li&gt;
&lt;li&gt;301 Moved Permanently&lt;/li&gt;
&lt;li&gt;400 Bad Request&lt;/li&gt;
&lt;li&gt;401 Unauthorized&lt;/li&gt;
&lt;li&gt;403 Forbidden&lt;/li&gt;
&lt;li&gt;404 Not Found&lt;/li&gt;
&lt;li&gt;500 Internal Server Error&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These codes tell the browser what happened.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Is HTTPS?
&lt;/h1&gt;

&lt;p&gt;HTTPS is simply HTTP with encryption.&lt;/p&gt;

&lt;p&gt;The extra "S" stands for &lt;strong&gt;Secure&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;HTTPS uses TLS (Transport Layer Security) to encrypt data between the browser and the server.&lt;/p&gt;

&lt;p&gt;Without HTTPS, anyone intercepting network traffic could potentially read usernames, passwords, or other sensitive information.&lt;/p&gt;

&lt;p&gt;Modern websites should always use HTTPS.&lt;/p&gt;




&lt;h1&gt;
  
  
  How Browsers Work
&lt;/h1&gt;

&lt;p&gt;Browsers do much more than display text.&lt;/p&gt;

&lt;p&gt;Once HTML arrives, the browser:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Parses the HTML.&lt;/li&gt;
&lt;li&gt;Builds the Document Object Model (DOM).&lt;/li&gt;
&lt;li&gt;Downloads CSS.&lt;/li&gt;
&lt;li&gt;Downloads JavaScript.&lt;/li&gt;
&lt;li&gt;Builds the CSS Object Model (CSSOM).&lt;/li&gt;
&lt;li&gt;Combines them into a render tree.&lt;/li&gt;
&lt;li&gt;Calculates layout.&lt;/li&gt;
&lt;li&gt;Paints pixels on the screen.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This process happens incredibly quickly, often in just a fraction of a second.&lt;/p&gt;




&lt;h1&gt;
  
  
  Putting It All Together
&lt;/h1&gt;

&lt;p&gt;Let's revisit what happens when you type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://roadmap.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Your browser checks its cache.&lt;/li&gt;
&lt;li&gt;DNS translates the domain into an IP address.&lt;/li&gt;
&lt;li&gt;The browser opens a connection to the server.&lt;/li&gt;
&lt;li&gt;HTTPS secures the communication.&lt;/li&gt;
&lt;li&gt;An HTTP request is sent.&lt;/li&gt;
&lt;li&gt;The server processes the request.&lt;/li&gt;
&lt;li&gt;HTML, CSS, JavaScript, and images are returned.&lt;/li&gt;
&lt;li&gt;The browser parses and renders the page.&lt;/li&gt;
&lt;li&gt;You see the website.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thousands of lines of code and decades of engineering make those few seconds feel effortless.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;Understanding networking isn't about memorizing acronyms—it's about understanding the journey of a request.&lt;/p&gt;

&lt;p&gt;Once you know how the Internet, DNS, hosting, HTTP, and browsers fit together, backend development becomes much less mysterious. Frameworks and libraries may change over time, but these fundamentals remain the foundation of every web application you build.&lt;/p&gt;

&lt;p&gt;The next time you press &lt;strong&gt;Enter&lt;/strong&gt; after typing a URL, you'll know exactly what's happening behind the scenes, from name resolution and secure communication to rendering pixels on your screen.&lt;/p&gt;

&lt;p&gt;Understanding these basics is one of the most valuable investments you can make as a software developer because every API, website, and distributed system ultimately builds upon them.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>computerscience</category>
      <category>networking</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Goroutines vs. Promises: Why Go and JavaScript Look at Concurrency Completely Differently</title>
      <dc:creator>Juma Evans</dc:creator>
      <pubDate>Mon, 25 May 2026 07:43:46 +0000</pubDate>
      <link>https://dev.to/juma_evans_34e389ef539266/goroutines-vs-promises-why-go-and-javascript-look-at-concurrency-completely-differently-24ja</link>
      <guid>https://dev.to/juma_evans_34e389ef539266/goroutines-vs-promises-why-go-and-javascript-look-at-concurrency-completely-differently-24ja</guid>
      <description>&lt;p&gt;Handling concurrency is one of the most critical decisions in modern software architecture. When applications need to handle thousands of simultaneous tasks—like serving HTTP requests, streaming data, or background processing. The design of a language’s concurrency model dictates how easily developers can write fast, safe, and maintainable code.&lt;br&gt;
​Go is famous for making concurrency a native, deeply integrated primitive through goroutines and channels. To truly appreciate Go's design, it helps to contrast it with JavaScript, which handles concurrency using a completely different philosophy: a single-threaded Event Loop fueled by asynchronous non-blocking I/O.&lt;br&gt;
​Here is an architectural deep dive into Go's multi-threaded concurrency engine and how it measures up against JavaScript's single-threaded asynchronous model.&lt;/p&gt;

&lt;p&gt;​&lt;strong&gt;&lt;em&gt;Part 1: The Foundations of Go Concurrency&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
​Go’s concurrency model is based on a paper by C.A.R. Hoare called Communicating Sequential Processes (CSP). The core philosophy of CSP in Go can be summarized by its most famous mantra:&lt;br&gt;
​&lt;strong&gt;"Do not communicate by sharing memory; instead, share memory by communicating."&lt;/strong&gt;&lt;br&gt;
​Instead of having multiple threads fight over the same piece of memory using complex locks, mutexes, and semaphores, Go encourages developers to run independent processes (goroutines) that pass data back and forth through safe conduits (channels).&lt;/p&gt;

&lt;p&gt;​&lt;strong&gt;&lt;em&gt;Primitives: Goroutines and Channels&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
​Go replaces heavy, operating system-level threads with goroutines.&lt;br&gt;
​Goroutines: They are incredibly lightweight, starting with a stack size of just a few kilobytes (typically 2KB), which can grow and shrink dynamically. Because they require so little overhead, a single Go application can easily spin up hundreds of thousands of concurrent goroutines without exhausting system memory.&lt;br&gt;
​Channels: These are typed pipelines that allow goroutines to synchronize and exchange data. By default, channels are unbuffered, meaning a sender will block until a receiver is ready to take the data, creating natural synchronization points without manual locks.&lt;br&gt;
​The Magic Under the Hood: The M:N Scheduler&lt;br&gt;
​Go achieves this high efficiency using its internal Go Runtime Scheduler, often referred to as the GMP Model:&lt;br&gt;
​G (Goroutine): Represents the goroutine, its stack, and current status.&lt;br&gt;
​M (Machine): Represents a physical, OS-level thread managed by the operating system kernel.&lt;br&gt;
​P (Processor): Represents a logical resource or context required to execute Go code. The number of Ps usually matches the machine's physical CPU cores.&lt;br&gt;
​The scheduler assigns multiple goroutines (G) onto a smaller pool of OS threads (M) via the logical processors (P).&lt;br&gt;
​If a goroutine performs a blocking action, such as waiting for a network response or a file read—the Go runtime is smart enough to swap out that blocked goroutine, move the remaining active goroutines to a different OS thread, and keep the CPU busy. This concept is known as work-stealing, and it happens completely automatically behind the scenes. &lt;/p&gt;

&lt;p&gt;​&lt;strong&gt;Part 2: Go Concurrency in Action&lt;/strong&gt;&lt;br&gt;
​Writing concurrent code in Go requires very little boilerplate. You simply prefix a function call with the go keyword.&lt;br&gt;
​Here is a practical pattern: a worker pool where multiple concurrent workers process jobs sent via a channel, and report their progress safely.&lt;/p&gt;

&lt;p&gt;package main&lt;/p&gt;

&lt;p&gt;import (&lt;br&gt;
    "fmt"&lt;br&gt;
    "sync"&lt;br&gt;
    "time"&lt;br&gt;
)&lt;/p&gt;

&lt;p&gt;// worker processes incoming jobs from the jobs channel&lt;br&gt;
func worker(id int, jobs &amp;lt;-chan int, results chan&amp;lt;- int, wg *sync.WaitGroup) {&lt;br&gt;
    defer wg.Done() // Signal completion when the worker exits&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for job := range jobs {
    fmt.Printf("Worker %d started job %d\n", id, job)
    time.Sleep(time.Millisecond * 100) // Simulating an I/O task
    results &amp;lt;- job * 2
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;func main() {&lt;br&gt;
    numJobs := 5&lt;br&gt;
    jobs := make(chan int, numJobs)&lt;br&gt;
    results := make(chan int, numJobs)&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var wg sync.WaitGroup

// Spin up 3 concurrent workers
for w := 1; w &amp;lt;= 3; w++ {
    wg.Add(1)
    go worker(w, jobs, results, &amp;amp;wg)
}

// Send jobs to the channel
for j := 1; j &amp;lt;= numJobs; j++ {
    jobs &amp;lt;- j
}
close(jobs) // Closing tells workers no more jobs are coming

// Wait for all workers to finish in the background
go func() {
    wg.Wait()
    close(results)
}()

// Collect all results
for res := range results {
    fmt.Printf("Result processed: %d\n", res)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Part 3: The Contender&lt;/strong&gt;&lt;br&gt;
 How JavaScript Handles Asynchrony&lt;br&gt;
​While Go provides a multi-threaded runtime that automatically abstracts away hardware limitations, JavaScript takes an entirely opposite approach. JavaScript's core philosophy is single-threaded simplicity driven by an Event Loop.&lt;br&gt;
​JavaScript operates on exactly one thread of execution (the main thread). It cannot natively execute two mathematical formulas simultaneously on different CPU cores. To prevent this single thread from freezing when downloading data or reading files, JavaScript relies on Asynchronous Non-Blocking I/O.&lt;/p&gt;

&lt;p&gt;​&lt;strong&gt;Primitives: Promises and Async/Await&lt;/strong&gt;&lt;br&gt;
​Instead of lightweight threads, JavaScript relies on Promises and state management.&lt;br&gt;
​&lt;strong&gt;Promises:&lt;/strong&gt; A Promise is an object representing the eventual completion (or failure) of an asynchronous operation. When a network request is fired, JavaScript leaves a Promise placeholder and immediately frees up the main thread to handle other UI interactions or requests.&lt;br&gt;
​&lt;strong&gt;Async/Await:&lt;/strong&gt; Syntactic sugar built over Promises. When you mark a function as async, it pauses execution inside that specific function when it hits an await keyword, returning control of the main thread back to the runtime execution engine until the background task is ready.&lt;/p&gt;

&lt;p&gt;​&lt;strong&gt;The Engine: The Event Loop&lt;/strong&gt;&lt;br&gt;
​Because JavaScript doesn't have a multi-threaded scheduler, it passes heavy lifting (like cryptography, network calls, or disk interactions) off to its container environment (the browser's Web APIs or Node.js background thread pool).&lt;br&gt;
​Once those background operations finish, they drop their callbacks into a Task Queue. The Event Loop constantly monitors the main thread. If the main thread is empty, it grabs the next task from the queue and executes it.&lt;br&gt;
​Let's look at how JavaScript achieves a similar worker execution strategy using Promises and Promise.all:&lt;br&gt;
// Simulating an asynchronous job&lt;br&gt;
async function worker(id, job) {&lt;br&gt;
  console.log(&lt;code&gt;Worker ${id} started job ${job}&lt;/code&gt;);&lt;/p&gt;

&lt;p&gt;// Simulating an I/O task (like a database query) using a non-blocking timeout&lt;br&gt;
  await new Promise(resolve =&amp;gt; setTimeout(resolve, 100)); &lt;/p&gt;

&lt;p&gt;return job * 2;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;async function main() {&lt;br&gt;
  const jobs = [1, 2, 3, 4, 5];&lt;/p&gt;

&lt;p&gt;// Map our jobs into an array of concurrent Promises.&lt;br&gt;
  // JavaScript kicks them all off immediately in the background.&lt;br&gt;
  const workerPromises = jobs.map((job, index) =&amp;gt; {&lt;br&gt;
    const workerId = (index % 3) + 1; // Distribute across 3 simulated workers&lt;br&gt;
    return worker(workerId, job);&lt;br&gt;
  });&lt;/p&gt;

&lt;p&gt;// Wait for all background tasks to finish and collect results&lt;br&gt;
  const results = await Promise.all(workerPromises);&lt;/p&gt;

&lt;p&gt;results.forEach(res =&amp;gt; {&lt;br&gt;
    console.log(&lt;code&gt;Result processed: ${res}&lt;/code&gt;);&lt;br&gt;
  });&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;main();&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Part 4: Head-to-Head Comparison&lt;/strong&gt;&lt;br&gt;
​To understand which paradigm fits a project best, we have to look at the architectural trade-offs between Go's implicit multi-threaded runtime and JavaScript's single-threaded execution queue.&lt;br&gt;
&lt;strong&gt;a. Primary Model &amp;amp; Execution Strategy&lt;/strong&gt;&lt;br&gt;
​&lt;strong&gt;The Go Way:&lt;/strong&gt; Uses Communicating Sequential Processes (CSP). Concurrency is handled by spinning up independent, lightweight threads (goroutines) that communicate safely by passing data through typed conduits called channels.&lt;br&gt;
​&lt;strong&gt;The JS Way:&lt;/strong&gt; Uses an Event-Driven Architecture. Concurrency is handled on a single main thread via an Event Loop that relies on Promises and callbacks to manage tasks asynchronously.&lt;/p&gt;

&lt;p&gt;​&lt;strong&gt;b. Hardware &amp;amp; CPU Utilization&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;​The Go Way:&lt;/strong&gt; Multi-threaded by default. Go’s built-in scheduler automatically distributes workloads across all available physical CPU cores, allowing for true, simultaneous hardware parallelism.&lt;br&gt;
​&lt;strong&gt;The JS Way:&lt;/strong&gt; Single-threaded by default. It executes code on only one CPU core. While it can handle thousands of tasks concurrently by overlapping wait times, it cannot execute tasks simultaneously on the same thread.&lt;br&gt;
​&lt;strong&gt;c. Task Mechanism &amp;amp; Memory Overhead&lt;/strong&gt;&lt;br&gt;
​&lt;strong&gt;The Go Way:&lt;/strong&gt; Driven by Goroutines, which are managed entirely by the Go runtime rather than the OS. They are incredibly lightweight, starting with a tiny memory footprint of just around 2KB per goroutine.&lt;br&gt;
​&lt;strong&gt;The JS Way:&lt;/strong&gt; Driven by Promises and Async/Await. These are not threads, but rather JavaScript object state machines that track the progress of a background task, carrying the memory overhead of the V8 JavaScript engine.&lt;/p&gt;

&lt;p&gt;​&lt;strong&gt;d. Handling Heavy Math and Computation&lt;/strong&gt;&lt;br&gt;
​&lt;strong&gt;The Go Way:&lt;/strong&gt; Excellent. Because it can utilize multiple CPU cores, heavy computations, data processing, or cryptography can run in the background without affecting or slowing down the rest of the application.&lt;br&gt;
​&lt;strong&gt;The JS Way:&lt;/strong&gt; Weak. Because everything runs on a single thread, any heavy mathematical calculation or CPU-bound task will completely freeze the Event Loop, stalling the entire application until the calculation finishes.&lt;/p&gt;

&lt;p&gt;​&lt;strong&gt;e.Inter-Task Communication&lt;/strong&gt;&lt;br&gt;
​&lt;strong&gt;The Go Way:&lt;/strong&gt; Features Native Typed Channels. This built-in primitive allows goroutines to pass data to one another seamlessly, acting as a natural synchronization barrier without needing manual memory locks.&lt;br&gt;
​&lt;strong&gt;The JS Way:&lt;/strong&gt; Relies on patterns like EventEmitters, Streams, or Async Generators. Because there is only one thread, tasks don't need to coordinate memory access, but streaming data requires using event-based libraries.&lt;/p&gt;

&lt;p&gt;​&lt;strong&gt;f.Task Control and Preemption&lt;/strong&gt;&lt;br&gt;
​&lt;strong&gt;The Go Way:&lt;/strong&gt; Supports Preemption. The Go runtime scheduler is highly intelligent; if it notices a single goroutine is acting greedily and hogging a CPU core for too long, it will forcefully pause it to give other tasks a turn.&lt;br&gt;
​&lt;strong&gt;The JS Way:&lt;/strong&gt; Has No Preemption. JavaScript code is strictly cooperative. If a function contains a long, synchronous loop that doesn't include an await keyword, it will hold the entire main thread hostage until it completes.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;True Parallelism vs. Non-Blocking Concurrency&lt;/strong&gt;
​The ultimate mechanical difference is Parallelism vs. Concurrency.
​Go is capable of parallelism. If you have an 8-core CPU processor, Go can run 8 different computing tasks at the exact same millisecond. If one goroutine goes rogue and gets stuck in an infinite mathematical calculation loop, Go's scheduler will forcefully step in (preemption), pause it, and use the other CPU cores to keep your application running smoothly.
​JavaScript is strictly concurrent but serial. It excels at waiting without locking things up. If 1,000 users request data from a database at once, JavaScript fires off all 1,000 queries to the OS database drivers immediately, moves on to do other things, and handles the results one by one as they crawl back. However, if you give JavaScript a heavy mathematical equation to calculate, it cannot delegate it to another core—the entire server or UI freezes completely until that calculation finishes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;​2. &lt;strong&gt;Synchronization and Data Safety&lt;/strong&gt;&lt;br&gt;
​Because Go shares memory across actual physical CPU threads, it introduces the danger of Data Races (two threads trying to change the exact same memory address at the same time). Go provides channels to prevent this, but if developers get careless, they must use manual mutex locks (sync.Mutex) or run Go's runtime race detector (go run -race) to find hidden multi-threading bugs.&lt;br&gt;
​JavaScript completely bypasses data races by design. Because everything ultimately executes on a single main thread, you never have to worry about two blocks of code altering a variable at the exact same millisecond. This completely eliminates a massive category of complex, hard-to-track multi-threading bugs.&lt;/p&gt;

&lt;p&gt;​3. &lt;strong&gt;Memory &amp;amp; Resource Footprint&lt;/strong&gt;&lt;br&gt;
​Go's goroutines are remarkably lightweight (~2KB), but they still carry the overhead of an active, multi-threaded runtime scheduler and an internal Garbage Collector that scans heap allocations across threads.&lt;br&gt;
​JavaScript's basic Promises are incredibly cheap state objects, but because JavaScript runs inside engines like Google's V8, its base memory baseline per application instance is significantly larger than a compiled, lean Go binary.&lt;br&gt;
​&lt;strong&gt;Conclusion: Which tool is right for the job?&lt;/strong&gt;&lt;br&gt;
​Choose Go if you are building data-intensive microservices, streaming platforms, heavy background computing tools, or high-throughput network APIs. Go gives your application the muscle to exploit your hardware's full multi-core capacity effortlessly.&lt;br&gt;
​Choose JavaScript if you are building fast I/O bound applications like standard CRUD web APIs, web sockets, or real-time chat apps where the vast majority of execution time is spent passing data back and forth from databases. JavaScript keeps code straightforward, predictable, and exceptionally easy to debug.&lt;br&gt;
​Both ecosystems solved the ancient problem of traditional, clunky OS multi-threading, Go by building a highly advanced multi-threaded coordination engine, and JavaScript by proving exactly how much you can achieve on a single thread if you just learn how to wait effectively.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>productivity</category>
      <category>javascript</category>
      <category>go</category>
    </item>
    <item>
      <title>Regulalar Expression</title>
      <dc:creator>Juma Evans</dc:creator>
      <pubDate>Wed, 13 May 2026 01:47:34 +0000</pubDate>
      <link>https://dev.to/juma_evans_34e389ef539266/regulalar-expression-1e8p</link>
      <guid>https://dev.to/juma_evans_34e389ef539266/regulalar-expression-1e8p</guid>
      <description>&lt;h2&gt;
  
  
  Mastering Regular Expressions in JavaScript: From Basics to Real-World Validation
&lt;/h2&gt;

&lt;p&gt;At first glance, a regex pattern looks like a cat walked across your keyboard,a chaotic string of slashes, brackets, and symbols. However, once you decode the syntax, it becomes one of the most powerful tools in your developer toolkit.&lt;br&gt;
Below is the break down of how regex works in JavaScript and build a robust pattern to validate something we use every day: &lt;strong&gt;email addresses&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a Regular Expression anyways?
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;Regular Expression&lt;/strong&gt; is an object that describes a pattern of characters. In JavaScript, you can create them in two ways:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Literal Notation:&lt;/strong&gt; /pattern/flags&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Constructor:&lt;/strong&gt; new RegExp('pattern', 'flags')
### The Core Building Blocks
Before we tackle the email login, we need to understand the "alphabet" of regex:&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Character Classes:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;\d: Matches any digit (0-9).&lt;/li&gt;
&lt;li&gt;\w: Matches any alphanumeric character (letters, numbers, and underscores).&lt;/li&gt;
&lt;li&gt;\s: Matches whitespace (spaces, tabs).&lt;/li&gt;
&lt;li&gt;.: The wildcard—matches any character except a newline.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Quantifiers:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;+: Matches 1 or more of the preceding element.&lt;/li&gt;
&lt;li&gt;*: Matches 0 or more.&lt;/li&gt;
&lt;li&gt;{n,m}: Matches between n and m times.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Anchors:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;^: Forces the match to start at the beginning of the string.&lt;/li&gt;
&lt;li&gt;$: Forces the match to end at the end of the string.
### Deep Dive: Validating an Email Address
When we log in to a platform, the first line of defense is ensuring the input actually looks like an email. Let’s build a regex for a standard email like &lt;a href="mailto:zone01.recode@company.co.ke"&gt;zone01.recode@company.co.ke&lt;/a&gt;.
#### 1. The Local Part (zone01 .recode)
We want to allow letters, numbers, dots, and underscores.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pattern:&lt;/strong&gt; ^[a-zA-Z0-9._%+-]+&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explanation:&lt;/strong&gt; We start at the beginning (^) and allow a set of characters inside the square brackets. The + ensures there is at least one character.
#### 2. The "@" Symbol
We just need the literal character.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pattern:&lt;/strong&gt; @
#### 3. The Domain (company)
Similar to the local part, but usually without the special symbols.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pattern:&lt;/strong&gt; [a-zA-Z0-9.-]+
#### 4. The TLD (.co.ke or .com)
We need a literal dot, followed by letters. Since a dot . is a wildcard in regex, we must &lt;strong&gt;escape&lt;/strong&gt; it with a backslash ..&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pattern:&lt;/strong&gt; .[a-zA-Z]{2,}$&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explanation:&lt;/strong&gt; This looks for a dot and at least two letters at the very end of the string ($).
#### Putting it all together:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;emailRegex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sr"&gt;/^&lt;/span&gt;&lt;span class="se"&gt;[&lt;/span&gt;&lt;span class="sr"&gt;a-zA-Z0-9._%+-&lt;/span&gt;&lt;span class="se"&gt;]&lt;/span&gt;&lt;span class="sr"&gt;+@&lt;/span&gt;&lt;span class="se"&gt;[&lt;/span&gt;&lt;span class="sr"&gt;a-zA-Z0-9.-&lt;/span&gt;&lt;span class="se"&gt;]&lt;/span&gt;&lt;span class="sr"&gt;+&lt;/span&gt;&lt;span class="se"&gt;\.[&lt;/span&gt;&lt;span class="sr"&gt;a-zA-Z&lt;/span&gt;&lt;span class="se"&gt;]{2,}&lt;/span&gt;&lt;span class="sr"&gt;$/&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;testEmail&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dev_user123@zone01.edu&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;emailRegex&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;testEmail&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Output: true&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Common Use Cases in Web Apps
&lt;/h3&gt;

&lt;p&gt;Beyond login forms, regex is used everywhere in full-stack development:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Password Strength:&lt;/strong&gt; Checking for at least one capital letter, one number, and one special character.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;URL Parsing:&lt;/strong&gt; Extracting slugs or IDs from a browser's address bar.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Scrubbing:&lt;/strong&gt; Removing formatting from phone numbers (e.g., changing +254 712-345-678 to 254712345678).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Search and Replace:&lt;/strong&gt; Swapping specific words across a whole document using the global /g flag.
### Helpful Methods in JavaScript
To use your patterns, you’ll mostly use these two methods:&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;regex.test(string)&lt;/strong&gt;: Returns true or false. Perfect for form validation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;string.match(regex)&lt;/strong&gt;: Returns an array of matches. Great for extracting information from a large block of text.
&amp;gt; &lt;strong&gt;Pro Tip:&lt;/strong&gt; Use tools like &lt;strong&gt;RegEx101&lt;/strong&gt; to test your patterns in real-time before putting them into your code. It provides a "flavor" setting—make sure to select &lt;strong&gt;ECMAScript (JavaScript)&lt;/strong&gt;.
&amp;gt; 
### Conclusion
Regex might feel like a steep climb, but it is a "learn once, use everywhere" skill. Whether you are working on a Go backend or a JavaScript frontend, the logic remains largely the same. Keep practicing by trying to validate other common inputs like phone numbers or postal codes!&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Docker Unlocked: What I Wish I Knew earlier.</title>
      <dc:creator>Juma Evans</dc:creator>
      <pubDate>Wed, 18 Feb 2026 20:20:02 +0000</pubDate>
      <link>https://dev.to/juma_evans_34e389ef539266/docker-unlocked-what-i-wish-i-knew-earlier-143f</link>
      <guid>https://dev.to/juma_evans_34e389ef539266/docker-unlocked-what-i-wish-i-knew-earlier-143f</guid>
      <description>&lt;p&gt;When I first heard about Docker, I thought it was something extremely complex that only senior developers used.&lt;/p&gt;

&lt;p&gt;Until recently, that is. When I finally started learning Docker, I found out how amazing it is, and I want to share what I've learned.&lt;br&gt;
If you're just starting out, this is for you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So…&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;1. What Is Docker?&lt;/strong&gt;&lt;br&gt;
Docker is a tool that lets you package your application with everything it needs to run:-dependencies, libraries, system tools, and your code;into something called a &lt;strong&gt;container&lt;/strong&gt;.&lt;br&gt;
&lt;strong&gt;2. What Problem Does Docker Solve?&lt;/strong&gt;&lt;br&gt;
Think of it like this:&lt;br&gt;
"It works on my machine" stops being an excuse.&lt;br&gt;
With Docker, if it works inside the container, it works everywhere. &lt;br&gt;
Before Docker, this is what used to happen:&lt;br&gt;
Developer X runs the application successfully.&lt;br&gt;
Developer Y tries to run it, and it breaks.&lt;/p&gt;

&lt;p&gt;Developer X tells Developer Y: “But it works on my machine!”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why?&lt;/strong&gt;&lt;br&gt;
Different environments:&lt;/p&gt;

&lt;p&gt;° Different operating systems&lt;br&gt;
° Different versions of NODE or Go or Python&lt;br&gt;
° Different installed dependencies&lt;/p&gt;

&lt;p&gt;Docker solves this by creating a consistent environment that travels with your application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. What Is a Container?&lt;/strong&gt;&lt;br&gt;
A container is like a lightweight, portable box for your application.&lt;br&gt;
But unlike a full virtual machine:&lt;/p&gt;

&lt;p&gt;° It starts fast—usually in seconds&lt;br&gt;
° It uses fewer resources&lt;br&gt;
° It's easy to share and move around&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How It Works:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You define how your application should run in a file called a Dockerfile (a blueprint for your environment).&lt;/li&gt;
&lt;li&gt;Docker uses that file to build an image (a snapshot of your app and everything it needs).&lt;/li&gt;
&lt;li&gt;Then that image runs as a container (the live, running version of your application).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When I first installed Docker, created my Dockerfile, built an image, and it actually worked…&lt;br&gt;
I felt like I unlocked a new level in development 😂.&lt;br&gt;
That was the moment I realized:&lt;br&gt;
This is how real-world applications are deployed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Every Beginner Should Learn Docker&lt;/strong&gt;&lt;br&gt;
Here is why I believe Docker is worth learning early:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It Makes You Think Like a Backend Engineer
You begin to understand:
° Ports and how applications communicate
° Services and how they connect
° Environment configurations
° How production setups differ from local development&lt;/li&gt;
&lt;li&gt;It Improves Your Project Structure
You naturally start organizing your apps better when you know they'll run in containers.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;🛠 Things That Confused Me at First&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;To be honest&lt;/em&gt;:&lt;br&gt;
° Images vs. Containers: I couldn't keep them straight. (Think of an image as a recipe and a container as the actual cooked meal.)&lt;br&gt;
° Dockerfile syntax: It looked scary at first glance.&lt;br&gt;
° Ports: Mapping ports from the container to my computer didn't make sense initially.&lt;/p&gt;

&lt;p&gt;But after building just one simple container for a Go app, everything started connecting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Next?&lt;/strong&gt;&lt;br&gt;
Now that I understand the basics, I plan to:&lt;/p&gt;

&lt;p&gt;° Containerize my Go projects&lt;br&gt;
° Learn Docker Compose (for running multiple containers)&lt;br&gt;
° Understand how containers are used in production&lt;/p&gt;

&lt;p&gt;One step at a time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;br&gt;
Imagine you bake a cake 🍰 at home.&lt;br&gt;
You pack:&lt;br&gt;
°The cake&lt;br&gt;
°The ingredients list&lt;br&gt;
°The exact oven settings&lt;br&gt;
°The instructions&lt;/p&gt;

&lt;p&gt;Then you put everything inside one box.&lt;br&gt;
Now, no matter where that box goes, Nairobi, Kisumu, or New York, anyone can open it and get the exact same cake.&lt;br&gt;
That is exactly what Docker does.&lt;/p&gt;

&lt;p&gt;It puts:&lt;br&gt;
. Your app&lt;br&gt;
. The tools it needs&lt;br&gt;
. The correct settings&lt;br&gt;
Inside one “box” called a container.&lt;br&gt;
So instead of saying:&lt;br&gt;
“It works on my machine.”&lt;br&gt;
You can confidently say:&lt;br&gt;
“It works everywhere.”&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
