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';
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.
http://info.cern.ch2. 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.
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:
- Browser Cache Check — The browser checks its local cache for a recent DNS record.
- OS Cache Check — If not found, the operating system's cache is checked.
- 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). - Root Nameserver — The resolver asks the root nameserver which TLD (Top-Level Domain) server to ask (e.g.,
.in). - TLD Nameserver — The TLD server points to the authoritative nameserver for the domain.
- Authoritative Nameserver — Returns the actual IP address to the resolver, which passes it back to your browser.
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 Type | File Extension | Description |
|---|---|---|
text/html | .html, .htm | HTML document |
text/css | .css | Stylesheet |
text/javascript | .js | JavaScript file |
text/plain | .txt | Plain text file |
image/jpeg | .jpg, .jpeg | JPEG image |
image/png | .png | PNG image |
image/svg+xml | .svg | Scalable Vector Graphic |
application/json | .json | JSON data |
application/pdf | PDF document | |
multipart/form-data | — | Form 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:
| Method | Purpose | Idempotent? | Body | Example |
|---|---|---|---|---|
| GET | Retrieve a resource | Yes | No | GET /students?sem=3 |
| POST | Create a new resource | No | Yes | POST /students with JSON body |
| PUT | Replace an existing resource fully | Yes | Yes | PUT /students/42 |
| PATCH | Partially update a resource | No | Yes | PATCH /students/42 |
| DELETE | Remove a resource | Yes | Maybe | DELETE /students/42 |
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.inresolve 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.
function drawWaterfall(timings) {
var phases = [
{ label: 'DNS Lookup', key: 'dns', color: 'var(--amber-500)' },
{ label: 'TCP Connection', key: 'tcp', color: 'var(--blue-500)' },
{ label: 'TLS Handshake', key: 'tls', color: 'var(--purple-500)' },
{ label: 'Response Wait', key: 'wait', color: 'var(--pink-500)' }
];
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.
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 byCache-Control: max-age.ETag— Entity tag (a hash of the resource). Used for conditional requests: browser sendsIf-None-Match: <etag>, server replies304 Not Modifiedif unchanged.Last-Modified— Timestamp of last change. Used withIf-Modified-Sincefor conditional GET.
HTTP Status Codes — Advanced Categories
| Code | Name | When |
|---|---|---|
| 100 | Continue | Client should continue sending body |
| 101 | Switching Protocols | Upgrade to WebSocket |
| 201 | Created | POST/PUT resource created |
| 204 | No Content | DELETE success, no response body |
| 301 | Moved Permanently | Resource moved — update bookmarks |
| 302 | Found (Temporary Redirect) | Temporary redirect, don't update bookmarks |
| 304 | Not Modified | Cached version still valid (ETag match) |
| 400 | Bad Request | Malformed syntax, invalid params |
| 401 | Unauthorized | Authentication required |
| 403 | Forbidden | Authenticated but not permitted |
| 429 | Too Many Requests | Rate limit exceeded |
| 502 | Bad Gateway | Upstream server returned invalid response |
| 503 | Service Unavailable | Server overloaded or under maintenance |