Skip to main content

🔌 Client-Server Architecture

Almost every app you use — the web, your phone, your smart speaker — is built on one simple idea: some programs ask, and other programs answer. This lesson unpacks that model, traces how it evolved over fifty years, and shows the rendering patterns that modern apps layer on top of it.

🎯 Learning Objectives

By the end of this lesson, you will be able to:

  • Define client and server and describe the division of responsibilities between them
  • Trace the evolution of the model from mainframes to microservices and serverless
  • Identify the components and types of clients and servers in a real system
  • Walk through the request-response cycle and the protocols and data formats it uses
  • Compare the four main rendering patterns — MPA, SPA, SSR, and JAMstack

Estimated Time: 30–40 minutes  •  Difficulty: Beginner

Hands-on: Reverse-engineer the architecture of a real web app using your browser's Network tab.

In This Lesson

The Essence of the Model

Client-server architecture divides a system into two roles. Clients request services; servers provide them. That's the whole idea — and it's powerful precisely because it's so simple. A single server can answer many clients at once, and a client doesn't need to know anything about how the server does its job, only how to ask.

  • Clients — web browsers, mobile apps, desktop programs, IoT devices, or even other servers.
  • Servers — always-on systems that hold resources and respond to requests over a well-defined protocol (usually HTTP for the web).
flowchart LR C1[Web browser] -->|Request| S[Server] C2[Mobile app] -->|Request| S C3[Desktop client] -->|Request| S S -->|Response| C1 S -->|Response| C2 S -->|Response| C3 S --- DB[(Database)]

This split lets each side specialise: clients optimise for a smooth user experience, while servers optimise for processing power, data integrity, and security. They meet in the middle through a shared contract — the API.

The Library Analogy

Picture a public library, and the whole architecture falls into place:

LibraryArchitectureRole
PatronsClientsVisit to request and use resources; don't own the collection
The library buildingServerHolds resources, serves many patrons at once, enforces rules
Library cardAuthenticationIdentifies you and sets what you may access
Request slipsAPI callsThe standard way to ask for something
LibrariansServer processesLocate resources and apply policies
The shelvesDatabaseWhere the actual content is stored and organised

And just as many patrons can use one library at the same time without tripping over each other, client-server systems handle many concurrent clients. The library doesn't hand out its only copy of a rare book to be taken home — it keeps control of its resources — exactly as a server keeps control of its data.

How the Model Evolved

The client-server idea isn't new — it's been reinvented every decade as hardware and networks changed. Seeing the arc helps you understand why today's architectures look the way they do.

timeline title Evolution of client-server computing 1970s : Mainframes + dumb terminals 1980s : 2-tier client-server 1990s : 3-tier architecture 2000s : Web applications 2010s : Mobile & cloud 2020s : Microservices & serverless
  • Mainframe era (1970s): one central computer did all the work; "dumb terminals" were just screens and keyboards.
  • 2-tier (1980s): powerful PCs ran rich desktop apps that talked directly to a database server.
  • 3-tier (1990s): a middle logic tier appeared between presentation and data, improving scalability and maintainability.
  • Web apps (2000s): the browser became the universal client — no installation required.
  • Mobile & cloud (2010s): diverse devices, cloud backends, and standardised APIs (REST, GraphQL).
  • Microservices & serverless (2020s): backends split into small services and on-demand functions, with processing pushed to the edge.

📖 The three tiers

Presentation tier — the UI the user interacts with.
Logic tier — the application/business rules.
Data tier — storage and retrieval. Separating these three is still the backbone of most systems today.

Clients & Servers in Detail

"Client" and "server" are roles, not single machines. A real system has several kinds of each.

Types of clients and servers On the left, a column of client types; on the right, a column of server types, connected by request and response arrows through a central boundary. Clients Web browsers Mobile apps Desktop apps IoT devices API clients they ASK Servers Web servers App servers Database servers Auth servers Proxies / gateways they ANSWER request response
Figure 1 — Many kinds of clients talk to many kinds of servers. A single user action may touch a web server, an app server, an auth server, and a database server before a response comes back.

Common client types

  • Web browsers — Chrome, Firefox, Safari; render HTML/CSS and run JavaScript in a sandbox.
  • Mobile & desktop apps — native clients tuned for their platform.
  • IoT devices — resource-constrained hardware with a minimal client.
  • API clients — scripts and other servers with no UI at all (machine-to-machine).

Common server types

  • Web servers (Nginx, Apache) — accept HTTP connections, serve static files or proxy onward.
  • Application servers (Node, uWSGI, Tomcat) — run your business logic.
  • Database servers (PostgreSQL, MySQL, MongoDB) — store and retrieve data.
  • Auth servers (OAuth providers, identity services) — verify identity and issue tokens.
  • Proxies & load balancers — route traffic, cache, and hide the internal layout.

How They Communicate

Every interaction follows the same four-beat rhythm — the request-response cycle.

sequenceDiagram participant Client participant Server Client->>+Server: 1. Send request Note right of Server: 2. Process request Server-->>-Client: 3. Send response Note left of Client: 4. Process response

Protocols

The protocol is the shared language of the conversation:

  • HTTP/HTTPS — the primary web protocol; stateless, with HTTPS adding encryption.
  • WebSocket — a persistent, two-way connection so the server can push data (chat, live updates).
  • GraphQL — a query language letting clients ask for exactly the fields they need from one endpoint.
  • gRPC — a fast, binary RPC framework popular for service-to-service calls.

Data formats

And the format is how the message body is encoded. JSON dominates modern web APIs for being lightweight and human-readable; XML lingers in enterprise and SOAP systems; Protocol Buffers are a compact binary format used with gRPC; and HTML is returned when the server renders whole pages.

A concrete request and response

Here is a real HTTP exchange — a request for one product, and the server's JSON answer:

GET /api/products/42 HTTP/1.1
Host: example.com
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: max-age=3600

{
  "id": 42,
  "name": "Wireless Headphones",
  "price": 89.99,
  "inStock": true,
  "categories": ["electronics", "audio"]
}

You'll dissect every part of this exchange — methods, headers, status codes — in the next lesson.

Rendering Patterns

Where does the HTML get built — on the server, in the browser, or ahead of time? That single question defines the four dominant web architectures.

Multi-Page Application (MPA)

The server generates a complete HTML page for every navigation. Simple and SEO-friendly, but each click means a full page load. Think classic WordPress sites.

Single-Page Application (SPA)

The server sends an app shell once; from then on JavaScript fetches JSON and updates the page in place. App-like and responsive, but heavier initial load and extra SEO care. Think Gmail or Twitter.

sequenceDiagram participant Browser participant Server Browser->>+Server: Initial request Server-->>-Browser: App shell (HTML + JS) Note right of Browser: App runs in the browser Browser->>+Server: API request for data Server-->>-Browser: JSON Note right of Browser: View updates, no page reload

Server-Side Rendering with hydration (SSR)

The server renders the first HTML for a fast, SEO-friendly initial view, then JavaScript "hydrates" it into a live SPA. The best of both — at the cost of complexity. Think Next.js and Nuxt.

JAMstack

Pages are pre-built into static files served from a CDN, with dynamic bits added via APIs and client-side JavaScript. Extremely fast and secure, but not a fit for every app. Think Gatsby and Astro sites.

PatternHTML built…Great for
MPAOn the server, per requestContent sites, simple SEO
SPAIn the browserApp-like, highly interactive UIs
SSRServer first, then hydratedContent + interactivity + SEO
JAMstackAhead of time (build step)Fast, mostly-static sites

Advantages & Challenges

The client-server model earned its dominance for good reasons — but it isn't free of trade-offs.

✅ Advantages

  • Centralised data — one source of truth, backed up and secured in one place.
  • Specialisation — clients tuned for UX, servers tuned for processing.
  • Scalability — add servers and load balancers without touching clients.
  • Security — sensitive logic and secrets stay on machines you control.

⚠️ Challenges

  • Network dependency — no connection often means no functionality.
  • Complexity — distributed systems bring consistency and synchronisation headaches.
  • Bottlenecks — a server can become a single point of failure under load.
  • Coordination — client and server teams must agree on and version their API contract.

Modern trends — microservices, serverless, edge computing, and Backend-as-a-Service (Firebase, Supabase) — are all attempts to keep the advantages while chipping away at the challenges.

Hands-on Exercise

🏋️ Reverse-Engineer a Real App

Objective: Use nothing but your browser to deduce the architecture of an app you use daily (Gmail, Spotify, a news site — your pick).

Instructions:

  1. Observe the client. Does navigating reload the whole page, or does content swap in place? Does it work with JavaScript disabled? Any real-time features?
  2. Inspect the traffic. Open DevTools → Network tab, reload, and watch. Note the first document (HTML vs. app shell) and the follow-up calls (JSON API requests?).
  3. Draw a conclusion. Which rendering pattern is it — MPA, SPA, or SSR? What data format do the API calls use?
💡 Hint

A telltale sign of an SPA: the first request returns a small HTML file, then a burst of .js bundles, then repeated requests to /api/… that return JSON as you click around — with the URL bar changing but no full page reload flash.

✅ Example answer

App: a music streaming web player. Client behaviour: navigation swaps content instantly with no reload; disabling JavaScript leaves a blank shell. Network: one small HTML document, several JS bundles, then ongoing application/json calls to /api/… for playlists and tracks; a WebSocket stays open for playback state. Conclusion: a Single-Page Application talking to a JSON REST API, with WebSockets for real-time updates.

🎯 Quick Quiz

Question 1: In client-server architecture, which statement is true?

Question 2: A site sends a small HTML shell once, then fetches JSON and updates the page without full reloads. Which pattern is this?

Question 3: Which protocol is best suited to the server pushing live updates to a client without the client asking each time?

Summary & Quiz

🎉 Key Takeaways

  • Clients ask, servers answer — a simple split that lets each side specialise and lets one server serve many clients.
  • The model evolved from mainframes → 2-tier → 3-tier → web → mobile/cloud → microservices/serverless.
  • "Client" and "server" are roles; a real system has many kinds of each.
  • Every interaction is a request-response cycle over a protocol (HTTP, WebSocket, GraphQL, gRPC) using a format (usually JSON).
  • MPA, SPA, SSR, and JAMstack differ mainly in where and when the HTML is built.

📚 Further Reading

🚀 What's Next?

You've seen the shape of the conversation. Next we zoom all the way in on a single exchange in The HTTP Request/Response Cycle — the anatomy of every message that flows between client and server.

🎉 The map is in your head!

You can now recognise the architecture behind almost any app you use. Time to read the messages themselves.