The three tiers of a web application

A web application is split into three parts, called tiers. Each tier has one job and runs in a different place.

After you tap Place order in a food delivery app, the screen changes to Order confirmed and lists an order number, your two items and the total. The order number did not exist a moment ago. Several programs on different computers worked together to produce this screen.

Your phoneBrowser or app
The app's serverApplication server
Where orders are savedDatabase
Think first. Which part produced the list of items on that screen: the app on your phone, the app's server or the database? Write down your guess.
Most students cannot say which tier produced a given part of a page. The trace in "Follow one request" fills that gap. Ask a few students for their answers before anyone presses Play.

Every web application has these three tiers. Read the cards from left to right: the user's device, your server, then the database.

Tier 1

The browser

Presentation tier

Shows the page or app screen. Runs on the user's device, which you do not control.

Tier 2

The application server

Application tier

Applies the rules and holds the database password. Runs on your server.

Tier 3

The database

Data tier

Stores the data in tables. Only the application server may ask it questions.

More detail

Each tier is built with different tools. A framework is a ready-made toolkit for building the application tier. Pick one to see what you would write and where each tier runs. The steps a request takes are the same in every framework.

Framework

Press Play and watch one tap on View order travel through the three tiers and back.

request
response
query
rows
Part 1 of 12

Show the code
More detail

Look at the same part in two other ways: as the page's tree of elements, or as the user sees it.

Suppose the browser could talk to the database directly. The database password would then sit in code on the user's device, where anyone can read it and run any query, including one that lists every user's orders. So only the application tier holds the password, and it decides which requests the database may answer.

You can now say which tier should hold the database password and why.

More detail

AI tools can write much of this code for you. You still need to know where each tier runs and what passes between them, because that tells you where a check must happen. The browser is on a device the user controls, so a check made only there can be skipped.