Exova Academy

Module 1 — Web Fundamentals · 30 min

How the Web Works: Browser, Server, HTTP

You type an address, press Enter, and a page appears in under a second. Between those two moments, a dozen steps have run in sequence: resolving a domain name, opening an encrypted connection, sending a request, computing on the server, responding, then rendering in the browser. As long as you can't see those steps, every bug looks like black magic: "the page is blank," "the form does nothing," "it works on my machine." Once you can see them, you know where to look.

This lesson lays the foundation for the whole course. We are going to build TaskFlow, a team task management application: a user signs in, creates projects, adds tasks, assigns them to teammates, and tracks their progress. Before you write a single line of code, you need to know which pieces it is made of and how they talk to each other.

The three players: client, server, database

The web is built on a client-server model. The client (usually a browser) asks for something; the server (a program that runs continuously on a machine connected to the Internet) responds. Behind the server, a database stores information durably.

For TaskFlow, the split will be:

Piece Technology in this course Role in TaskFlow
Front end (client) HTML, CSS, JavaScript, then React Display tasks, react to clicks, submit forms
Back end (server) Node.js + Express, in TypeScript Check who is signed in, enforce the rules, expose an API
Database PostgreSQL Store users, projects and tasks
Infrastructure Linux VPS, nginx, HTTPS Make the application reachable from anywhere in the world

One rule shapes everything else: the browser can never be trusted. Anything that runs on the client can be read and modified by the user. Important checks (access rights, data validation) are therefore always done on the server.

%% titre: TaskFlow's overall architecture
%% narration: In this diagram, you can see that the browser never talks to the database directly. It always goes through nginx and then the Node.js API, which enforces the rules before reading from or writing to PostgreSQL.
flowchart LR
  nav["Browser (React)"] -- "HTTPS" --> nginx["nginx"]
  nginx --> api["Node.js + Express API"]
  api -- "SQL" --> db[("PostgreSQL")]
  nginx --> static["Static files"]
TaskFlow's overall architecture

What happens when you type an address

Take the address https://app.taskflow.dev/projects/12. It breaks down into several parts:

  • https: the protocol, here HTTP encrypted with TLS;
  • app.taskflow.dev: the hostname, which identifies a machine;
  • /projects/12: the path, which identifies a resource on that machine;
  • if there were any, ?filter=urgent would be the query string and #comments the fragment (never sent to the server).

Computers don't know names, they know IP addresses. So the browser first queries DNS (Domain Name System), the Internet's directory, which answers with something like 203.0.113.42. It then opens a TCP connection to that address on port 443, negotiates TLS encryption (the server proves its identity with a certificate), and finally sends its HTTP request.

%% titre: The journey of a web request
%% narration: This diagram shows the order of the exchanges: the browser first resolves the domain name with DNS, opens an encrypted connection, then sends its HTTP request and receives the server's response.
sequenceDiagram
  participant N as Browser
  participant D as DNS server
  participant S as Web server
  N->>D: What is the IP for app.taskflow.dev?
  D-->>N: 203.0.113.42
  N->>S: TCP connection and TLS handshake
  N->>S: GET /projects/12
  S-->>N: 200 OK and HTML page
The journey of a web request

Once the HTML arrives, the browser reads it from top to bottom. Every time it encounters a stylesheet, a script or an image, it fires off a new request. A modern page routinely triggers several dozen. That's why the Network tab of the developer tools is your best friend.

Anatomy of an HTTP request and response

HTTP is a text protocol that humans can read. A request looks like this:

GET /api/tasks?status=todo HTTP/1.1
Host: app.taskflow.dev
Accept: application/json
Authorization: Bearer eyJhbGciOi...

It contains a method (GET), a path, headers (key-value pairs that provide context) and, for some methods, a body. The response follows the same logic:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Cache-Control: no-store

[{"id":1,"title":"Write the requirements document","status":"todo"}]

Methods express intent:

Method Intent TaskFlow example
GET Read, without changing anything List the tasks in a project
POST Create Add a task
PATCH Partially update Mark a task as "done"
PUT Replace entirely Replace a project's full description
DELETE Delete Delete a task

Status codes sum up the result in three digits. Remember the families: 2xx success (200 OK, 201 Created, 204 No Content), 3xx redirect (301, 304 Not Modified), 4xx client error (400 bad request, 401 unauthenticated, 403 forbidden, 404 not found), 5xx server error (500, 502 Bad Gateway, 503). When you debug, the status code instantly tells you which side to look at.

One point to remember right now: HTTP is stateless. Each request is independent; the server doesn't remember the previous one. To know that a user is signed in, proof has to be sent with every request (a session cookie or a token), which we'll build in module 4.

Observing the web with curl and the browser tools

You don't need any code to start observing. Two tools are enough.

The browser's developer tools (F12, or Cmd+Option+I on a Mac), Network tab: reload a page and every request shows up with its method, status, size and duration. Click a row to see the full headers and the response body.

curl, a command-line HTTP client, installed by default on macOS, Linux and Windows 10+:

# Show only the response headers
curl -I https://example.com

# Show the full request and response (-v = verbose)
curl -v https://example.com 2>&1 | head -n 30

# Query a public API that returns JSON
curl -s https://jsonplaceholder.typicode.com/todos/1

The last command returns a JSON object representing a task, very close to what the TaskFlow API will return later. JSON (JavaScript Object Notation) is the standard exchange format between front end and back end: objects in curly braces, arrays in square brackets, strings in double quotes.

Common beginner pitfalls

  • Confusing static and dynamic. A static page is a file sent as is. A dynamic page is computed on every request. TaskFlow will combine both: a static front end that calls a dynamic API.
  • Thinking the server "sees" the page. The server sends text; the browser is what builds the display. A button that doesn't respond is almost always a client-side problem.
  • Ignoring the status code. A 401 isn't a server bug, it's a missing token. A 502 means nginx can't reach your application.
  • Forgetting the cache. If a change doesn't show up, do a hard reload (Ctrl+Shift+R) before digging any further.

Hands-on practice

Goal: dissect a real HTTP request and produce a cheat sheet you'll reuse throughout the course.

  1. Open a terminal and run curl -v https://jsonplaceholder.typicode.com/todos/1.
  2. In the output, find: the IP address contacted, the request line, three request headers, the status code, the response's Content-Type and the body.
  3. Run curl -s -o /dev/null -w "%{http_code}\n" https://jsonplaceholder.typicode.com/todos/999999 and write down the code you get.
  4. Open https://example.com in your browser with the Network tab open, and count the number of requests.
  5. Write a 10-to-15-line http-notes.md file that summarizes what you observed and explains, in your own words, why the browser must never access TaskFlow's database directly.

Deliverable: the http-notes.md file.

Show solution

Example of the expected notes:

# HTTP notes

- curl resolved jsonplaceholder.typicode.com to an IP ("Connected to ..." line).
- Request: `GET /todos/1 HTTP/2` (curl negotiates HTTP/2 when the server supports it).
- Headers sent: `Host`, `User-Agent: curl/...`, `Accept: */*`.
- Response: status 200, `content-type: application/json; charset=utf-8`.
- Body: {"userId":1,"id":1,"title":"delectus aut autem","completed":false}
- /todos/999999 returns 404: the resource doesn't exist, the error comes from the request.
- example.com: 1 to 2 requests (the HTML document, sometimes a favicon).

Why the browser doesn't talk to the database:
everything that runs in the browser can be modified by the user.
If it accessed PostgreSQL, it would need the database credentials:
anyone could read or erase every team's tasks.
The API acts as a gatekeeper: it checks identity, permissions and data
before every read or write.

Checkpoints: if you got HTTP/1.1 instead of HTTP/2, that's normal; it depends on your version of curl. If command 3 prints 404, you've understood what -w does: extract a single piece of information from the response, which is very handy in monitoring scripts.

Key takeaways

  • The web works client-server: the browser asks, the server responds, the database stores.
  • An HTTP request contains a method, a path, headers and sometimes a body; the response returns a status code, headers and a body.
  • The code families (2xx, 3xx, 4xx, 5xx) tell you immediately which side to look at when something breaks.
  • HTTP is stateless: authentication relies on proof sent with every request.
  • The browser can never be trusted: TaskFlow's rules will be enforced on the server.

Enjoyed this lesson?

Unlock all 40 lessons, the quizzes and the certificate.

Buy — $297