← BEUVAULT 100219 Course U1 U2 U3 U4 U5 U6

Unit 1: Network & Architecture Simulator

Visualizing Client-Server, 3-Tier Architecture, and HTTP Protocols

  • Explain the 3-tier web architecture (Client, Server, Database) and how data flows between them
  • Parse any URL into its components (scheme, host, port, path, query, fragment)
  • Describe the DNS resolution process from browser cache to authoritative nameserver
  • Identify HTTP methods (GET/POST/PUT/PATCH/DELETE) and their appropriate use cases

1. 3-Tier Web Architecture — Client, Server, Database

What is 3-Tier Architecture?

Modern web applications separate concerns into three distinct layers. Each layer runs on its own infrastructure and communicates with the next via a network:

  • Presentation Tier — The client (your browser). It renders the UI, handles clicks and keyboard input, and displays data to the user. Never talks directly to the database.
  • Application Tier — The web server (Apache, Nginx, Node.js). It receives HTTP requests, runs business logic, queries the database, and returns formatted responses (usually HTML or JSON).
  • Data Tier — The database (MySQL, PostgreSQL, MongoDB). It stores and retrieves persistent data. Only the application tier can talk to it.

How the data flows: You click a link → browser sends HTTP request → server processes it → server queries database → database returns results → server builds a response → browser renders the page. This is called the request-response cycle.

Try it yourself

Type any URL into the text box below and click "Send HTTP Request". Watch the animated packet travel from the Client through the Server to the Database and back. The terminal log shows each step in detail.

Client (Browser)

Presentation Tier

Web Server

Application Tier (Apache/Nginx)

Database

Data Tier (SQL/NoSQL)

<div class="architecture-board">
  <div class="node" id="clientNode">
    <h3>Client (Browser)</h3>
  </div>
  <div class="server-stack">
    <div class="node" id="serverNode">Web Server</div>
    <div class="node db-node" id="dbNode">Database</div>
  </div>
</div>

// Animate packet
packet.style.opacity = '1';
packet.style.left = '95%';
await delay(800);
packet.style.left = '0%';
packet.style.opacity = '0';
System initialized. Awaiting network request...

1. A Brief History of the World Wide Web

The Web is a system of interlinked hypertext documents accessed via the Internet. It was invented by Sir Tim Berners-Lee in 1989 while working at CERN. His vision was a collaborative system where researchers could share documents seamlessly across the globe.

1989Tim Berners-Lee proposes the World Wide Web at CERN.
1990First web server and browser (WorldWideWeb) created.
1991First website goes live: http://info.cern.ch
1993Mosaic browser released — first to display images inline. The web goes mainstream.
1994Netscape Navigator launched. W3C founded to standardize web technologies.
1995JavaScript created by Brendan Eich. Internet Explorer launched. CSS proposed.
1999HTML 4.01 standardized. XML and XHTML emerge as stricter alternatives.
2005AJAX (Asynchronous JavaScript & XML) coined — dynamic web apps become possible.
2008Google Chrome launched with a high-performance JS engine (V8).
2014HTML5 becomes official W3C recommendation — video, audio, canvas natively supported.
2020+HTTP/2 & HTTP/3 (QUIC protocol) widely adopted. WebAssembly enables near-native performance in browsers.

2. URL Structure — Anatomy of a Web Address

A URL (Uniform Resource Locator) identifies the location of a resource on the web. Every URL follows this structure:

scheme://host:port/path?query#fragment

  • Scheme — The protocol used (HTTP, HTTPS, FTP). HTTPS encrypts all data via TLS/SSL.
  • Host — The domain name or IP address of the server (e.g., beu-bih.ac.in).
  • Port — The network port (default: 80 for HTTP, 443 for HTTPS). Usually omitted when using defaults.
  • Path — The specific resource location on the server (e.g., /api/students).
  • Query — Key-value parameters passed to the server, starting with ? (e.g., ?sem=3&branch=cse).
  • Fragment — A section within the page, starting with #. Never sent to the server — used only by the browser.

Live URL Parser

Type any URL below and watch it break down into components in real time.

Schemehttps Hostbeu-bih.ac.in Port443 Path/api/student/result Querysem=5&branch=cse Fragmentoverview
function parseURL() {
  const url = document.getElementById('urlParserInput').value;
  const parsed = new URL(url);
  document.getElementById('up-scheme').textContent = parsed.protocol.replace(':', '');
  document.getElementById('up-host').textContent = parsed.hostname;
  document.getElementById('up-path').textContent = parsed.pathname;
  document.getElementById('up-query').textContent = parsed.search.replace('?', '') || '(none)';
  document.getElementById('up-fragment').textContent = parsed.hash.replace('#', '') || '(none)';
}

3. DNS — How Domain Names Become IP Addresses

The Domain Name System (DNS) is the phonebook of the Internet. Humans remember names like beu-bih.ac.in, but computers communicate using IP addresses like 103.21.140.84. DNS translates one to the other.

When you type a URL and hit Enter, the browser follows these steps:

  1. Browser Cache Check — The browser checks its local cache for a recent DNS record.
  2. OS Cache Check — If not found, the operating system's cache is checked.
  3. Recursive DNS Resolver — If still not found, the query goes to your ISP's DNS resolver (or a public resolver like 8.8.8.8 — Google DNS).
  4. Root Nameserver — The resolver asks the root nameserver which TLD (Top-Level Domain) server to ask (e.g., .in).
  5. TLD Nameserver — The TLD server points to the authoritative nameserver for the domain.
  6. Authoritative Nameserver — Returns the actual IP address to the resolver, which passes it back to your browser.
DNS resolution diagram showing iterative query process
Figure: Iterative DNS resolution — the resolver queries root, TLD, and authoritative nameservers sequentially. (Lion Kimbro, CC BY-SA)

4. MIME Types — Telling the Browser What to Expect

MIME (Multipurpose Internet Mail Extensions) types tell the browser the nature of the content being served. The server includes a Content-Type header in the HTTP response. The browser uses this to decide how to render the data.

MIME TypeFile ExtensionDescription
text/html.html, .htmHTML document
text/css.cssStylesheet
text/javascript.jsJavaScript file
text/plain.txtPlain text file
image/jpeg.jpg, .jpegJPEG image
image/png.pngPNG image
image/svg+xml.svgScalable Vector Graphic
application/json.jsonJSON data
application/pdf.pdfPDF document
multipart/form-dataForm data (file uploads)

5. HTTP Methods & Status Codes

HTTP defines a set of request methods (also called verbs) that indicate the desired action for a resource. The most common ones are:

MethodPurposeIdempotent?BodyExample
GETRetrieve a resourceYesNoGET /students?sem=3
POSTCreate a new resourceNoYesPOST /students with JSON body
PUTReplace an existing resource fullyYesYesPUT /students/42
PATCHPartially update a resourceNoYesPATCH /students/42
DELETERemove a resourceYesMaybeDELETE /students/42
Idempotent means making the same request multiple times produces the same result. GET, PUT, and DELETE are idempotent — POST and PATCH are not.

HTTP Status Codes are grouped by category:
1xx — Informational (Request received)
2xx — Success (200 OK, 201 Created)
3xx — Redirection (301 Moved, 304 Not Modified)
4xx — Client Error (400 Bad Request, 403 Forbidden, 404 Not Found)
5xx — Server Error (500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable)

7. HTTP Request Waterfall — Timing Visualization

What Each Phase Means

Every HTTP request takes time. The waterfall chart below breaks down where that time is spent:

  • DNS Lookup — The browser asks a DNS server: "What IP address does beu-bih.ac.in resolve to?" This requires a chain of queries (browser cache → OS cache → resolver → authoritative nameserver). Takes 20–120ms typically.
  • TCP Connection — A three-way handshake (SYN → SYN-ACK → ACK) establishes a reliable connection between your browser and the server. Takes roughly one round-trip time (~30–80ms).
  • TLS Handshake — For HTTPS connections, the browser and server negotiate encryption keys. This adds 1–2 round trips of overhead (~50–250ms). This is why HTTPS feels slightly slower than HTTP on first load.
  • Request Send — Time taken to transmit the HTTP request bytes from client to server over the network.
  • Response Wait (TTFB) — Time to first byte. The server processes the request and starts sending back the response. This includes any database queries the server must run.

Click Simulate Request below to see a realistic timing profile. Notice which phases dominate — in practice, DNS and TLS are usually the slowest.

PhaseTime (ms)
function drawWaterfall(timings) {
  var phases = [
    { label: 'DNS Lookup', key: 'dns', color: '#f59e0b' },
    { label: 'TCP Connection', key: 'tcp', color: '#3b82f6' },
    { label: 'TLS Handshake', key: 'tls', color: '#8b5cf6' },
    { label: 'Response Wait', key: 'wait', color: '#ec4899' }
  ];
  phases.forEach(function (p) {
    var w = Math.round((timings[p.key] / maxTime) * 100);
    html += '<div style="width:' + w + '%;background:' + p.color + '"></div>';
  });
}

7. Interactive: HTTP Method Explorer

Select an HTTP method and see how the request structure changes. For GET, parameters go in the URL. For POST/PUT, the data goes in the request body.

// HTTP Request Preview

GET /api/students/42 HTTP/1.1
Host: beu-bih.ac.in
Accept: application/json
User-Agent: Browser/1.0
<select id="httpMethodSelect">
  <option value="GET">GET</option>
  <option value="POST">POST</option>
  <option value="PUT">PUT</option>
</select>
<input type="text" id="httpPathInput" />
<textarea id="httpBodyInput">...</textarea>

function showHttpExample() {
  const method = document.getElementById('httpMethodSelect').value;
  const path = document.getElementById('httpPathInput').value;
  bodyArea.style.display =
    (method === 'POST' || method === 'PUT' || method === 'PATCH')
      ? 'block' : 'none';
}

HTTP Caching

Browsers and intermediate proxies cache HTTP responses to reduce latency and server load. Two primary caching headers control this:

  • Cache-Control — Modern caching directive. Values: public (any cache), private (browser only), no-cache (revalidate), no-store (never cache), max-age=seconds (freshness lifetime).
  • Expires — Legacy absolute expiry date. Superseded by Cache-Control: max-age.
  • ETag — Entity tag (a hash of the resource). Used for conditional requests: browser sends If-None-Match: <etag>, server replies 304 Not Modified if unchanged.
  • Last-Modified — Timestamp of last change. Used with If-Modified-Since for conditional GET.

HTTP Status Codes — Advanced Categories

CodeNameWhen
100ContinueClient should continue sending body
101Switching ProtocolsUpgrade to WebSocket
201CreatedPOST/PUT resource created
204No ContentDELETE success, no response body
301Moved PermanentlyResource moved — update bookmarks
302Found (Temporary Redirect)Temporary redirect, don't update bookmarks
304Not ModifiedCached version still valid (ETag match)
400Bad RequestMalformed syntax, invalid params
401UnauthorizedAuthentication required
403ForbiddenAuthenticated but not permitted
429Too Many RequestsRate limit exceeded
502Bad GatewayUpstream server returned invalid response
503Service UnavailableServer overloaded or under maintenance