Phase 1 — Foundations lesson-0001

How the Web Works

Everything that happens before your server even receives a request.

The Big Picture

When you visit https://api.example.com/users, a chain of events fires across the planet in milliseconds. As a backend engineer, your code handles the final step. But understanding the whole chain is what makes you dangerous.

Browser Internet Your Server │ │ │ │──── DNS Lookup ────────►│ │ │◄─── Returns IP ────────│ │ │ │ │ │──── TCP Handshake ──────────────────────────────────►│ │◄─── SYN-ACK ───────────────────────────────────────│ │ │ │ │──── HTTP Request ───────────────────────────────────►│ │ │ [your code runs] │◄─── HTTP Response ──────────────────────────────────│ │ │ │

Step by Step

1

DNS Resolution

The browser asks a DNS server: "what IP address is api.example.com?" DNS is the internet's phone book — it translates human-readable names to machine-readable IPs like 93.184.216.34.

2

TCP Connection

The browser and server perform a 3-way handshake (SYN → SYN-ACK → ACK) to establish a reliable connection. TCP guarantees packets arrive in order and none get lost.

3

TLS Handshake (for HTTPS)

For HTTPS, after TCP, the client and server negotiate encryption. They exchange certificates and agree on a shared secret — all in ~1 round trip with TLS 1.3.

4

HTTP Request Sent

The browser sends a formatted HTTP message: the method (GET), the path (/users), headers (Content-Type, Authorization…), and optionally a body.

5

Your Server Responds

Your Node.js code reads the request, does its work (queries DB, business logic), and sends back an HTTP response with a status code, headers, and a body (usually JSON).

The Protocol Stack

The web runs on layers of protocols. As a backend dev, you'll work mostly at HTTP, but the layers below it matter when things go wrong.

LayerProtocolWhat it does
ApplicationHTTP / HTTPSThe message format your app speaks
TransportTCP / UDPReliable delivery and ordering of packets
InternetIPRouting packets across networks using addresses
LinkEthernet / Wi-FiPhysical transmission between nearby devices

Client vs Server

Client 🖥️

  • Initiates requests
  • Browser, mobile app, CLI tool
  • Receives and renders responses
  • Code runs on user's machine

Server 🖧

  • Listens for requests
  • Your Node.js process
  • Contains business logic & data access
  • Code runs on your machine (or cloud)
Key Insight
A server is just a program that listens on a port and responds to connections. Port 80 is the default for HTTP, 443 for HTTPS. When you run app.listen(3000) in Node.js, you're telling the OS to route traffic from port 3000 to your program.

What is Statelessness?

HTTP is stateless — each request is completely independent. The server has no memory of previous requests. This is a fundamental design decision:

🚫 The server does NOT remember you between requests.

Every request must carry all the info the server needs — via headers, tokens, cookies, or body data.

This is why authentication tokens (JWTs) exist — they let the client prove who they are on every request, since the server doesn't maintain a session by default.

🧠 Check Your Understanding


Go Deeper

Primary source: MDN — An Overview of HTTP — the canonical reference. Read the first three sections.

Video (10 min): DNS Explained — Computerphile

Something unclear? Ask your teacher: "Explain DNS to me like I'm 5" or "What's the difference between TCP and UDP?" — I'm here for follow-up questions.