Visualizing Client-Server, 3-Tier Architecture, and HTTP Protocols
Modern web applications separate concerns into three distinct layers. Each layer runs on its own infrastructure and communicates with the next via a network:
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.
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.
Presentation Tier
Application Tier (Apache/Nginx)
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';
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.chA URL (Uniform Resource Locator) identifies the location of a resource on the web. Every URL follows this structure:
scheme://host:port/path?query#fragment
beu-bih.ac.in)./api/students).? (e.g., ?sem=3&branch=cse).#. Never sent to the server — used only by the browser.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)';
}
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:
8.8.8.8 — Google DNS)..in).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) |
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 |
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)
Every HTTP request takes time. The waterfall chart below breaks down where that time is spent:
beu-bih.ac.in resolve to?" This requires a chain of queries (browser cache → OS cache → resolver → authoritative nameserver). Takes 20–120ms typically.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: '#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>';
});
}
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.
<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';
}
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.| 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 |