In this lesson
The Big Idea
Whenever you watch a video or shop online, you are using a web application. What you see on the screen is only a small part of the story: behind it, other parts are working together. To make sense of them, the book offers a simplified teaching model with three tiers: a frontend that displays content and collects what the user enters, a backend that processes requests and applies the app's rules on the server, and a data layer that keeps data and provides it when needed. The tiers pass requests and results between them until the user gets what they asked for.
What Is a Web Application?
A web application is an application you usually use through a web browser such as Chrome, Edge or Firefox. You open the browser, type an address or tap a link, and the app runs in front of you. Familiar examples include:
- video watching and sharing services,
- online shopping sites,
- email on the web,
- maps on the web.
Notice the word "usually". The Arabic edition points out that some web apps can also be installed on the device, giving them an icon on your phone's or computer's home screen. So the browser is the normal way in, but not an absolute requirement.
What matters most in this lesson is that the screen is not the whole app. Behind the neat page there are other parts, running somewhere far from you, cooperating so that the right result reaches you in seconds.
The Three Tiers: A Simplified Teaching Model
In this teaching model, the book splits a web application into three main parts. That phrase matters: the model is a tool for understanding, and the real structure can differ from one app to another.
| Tier | Role | Examples | |---|---|---| | Frontend | The part the user sees and uses in the browser: shows content and takes what the user types or selects | search screen, product pages, input forms | | Backend | The part that runs on the server: processes requests and applies the app's rules | finding products that match the search, checking a login | | Database / data layer | Keeps data and provides it when needed | product information, user information, order history |
The frontend displays and collects
The frontend is the screen the user sees and interacts with directly in the browser. It has two big jobs:
- Display: it shows you content in an organised way, such as product photos and prices, or a list of videos.
- Collect: it takes what you type or choose, such as search words, a sign-up form or a tap on "Add to cart".
The frontend is the app's "face". When people say an app "looks nice" or "is easy to use", they are usually talking about it. But remember: on its own it doesn't know, for example, which products are in stock. It shows what it receives.
The backend decides and processes
The backend is the part that runs on the server, a distant computer that provides the service, not your own device. Users never see it, but it is the brains of the app. In the Arabic edition its role is to:
- process the requests that arrive from the frontend, and
- apply the app's rules: is the password correct? Is the product in stock? Who is allowed to see this post?
The book's two examples are finding products that match the search criteria and checking a login. Notice that these decisions are made on the server, not in the browser.
The data layer stores and retrieves
In this model, the database is the tier that keeps data and provides it when needed: it organises, stores and manages the data. Think product information, user accounts and past orders.
The Arabic edition adds an important detail: the data layer is not necessarily one single database. It may include:
- databases,
- file and object storage, such as uploaded photos and videos,
- a cache, which keeps a fast copy of data that is requested often,
- external data services the app relies on.
That is why the book sometimes says "data layer" rather than just "database": it is the wider idea of wherever the app's data is kept and fetched from.
How Do the Tiers Cooperate? The Journey of a Search
The tiers are only useful when they cooperate. In many web apps, the parts take the user's request, process it and then show the result. The book explains this with searching for a product in an online shop. Say you type "bluetooth headphones" into the search box:
- The frontend receives the search words you entered.
- The frontend sends the search words to the backend.
- The backend asks the data layer for the products that match the search phrase.
- The data layer returns the requested results to the backend.
- The backend prepares the results to send to the frontend.
- The frontend displays the search results on your screen.
Look at the shape of the journey: the request goes out from the user to the data layer (steps 1 to 3), then the result comes back to the screen (steps 4 to 6). Also notice that in this model the frontend never talks to the data layer directly; the backend is the go-between that asks for the data and prepares it.
A second example: posting a photo on a social app
The same idea works for sending, not just searching. When you post a photo:
- The frontend shows you the post screen, takes the photo and caption, and sends them.
- The backend receives the post on the server, applies the rules (for example, who is allowed to see it?) and asks for it to be saved.
- The data layer stores the photo and post data, ready to provide them when your friends open their timeline.
- The result then returns to the frontend, which shows you that your post is live.
This example is very close to the essay question on this lesson, so practise writing it as clear steps.
The Same Tiers in Familiar Services
This simplified model can be applied to many web apps to understand who does what, while remembering that real structures can differ. The book compares three familiar services:
| Service | Frontend (display & interaction) | Backend (processing & control) | Database (storage & management) | |---|---|---|---| | Video-sharing site | video player and search screens; taking user actions | choosing recommended videos; counting views | video data, user information, watch history | | Social network | timeline and post screens; sending what the user typed | choosing the audience for posts; controlling instant notifications | post data, follow relationships, messages | | E-commerce site | product lists and cart screens; taking orders | checking stock; sending payment requests and handling their results | product information, order history, customer information |
In the e-commerce row, the backend sends payment requests and handles their results: it contacts the payment side, waits for the answer (paid or declined) and then decides what happens next.
Why Separate the Responsibilities?
In its "Think as an Engineer" activity, the book describes a clinic that wants a web app where patients book appointments, check available times and view their past visits. How should the jobs be shared out?
- The booking form is seen and filled in by the patient: frontend.
- Checking available times means applying rules (is the doctor in? is the slot taken?): backend.
- Storing past visits is keeping and retrieving data: database.
The book contrasts two options: mixing display, processing and data responsibilities without clear separation, or organising them into clear tiers. The second is better, for reasons such as:
- Clarity: each part has a defined job, so anyone working on the app knows where to add or change things.
- Easier fault-finding: when something breaks, you know where to start looking.
- Changing one part without breaking the rest: you can redesign the booking page, for example, without touching how visits are stored.
Diagnosing a fault: the booking page opens, but no times appear
Suppose the booking page appears but shows no available times. The page loading means the frontend works at least partly. The missing times could come from:
- the frontend, which didn't send the request, or received the result but didn't display it;
- the backend, which didn't process the request, or applied a wrong rule that filtered out every slot;
- the data layer, which holds no recorded appointments, or returned nothing.
To be sure you need information: did the request reach the server? Did the data layer actually return any slots? Are any appointments recorded for that day at all? This step-by-step thinking is only possible because the responsibilities are clearly separated.
Try It Yourself
Common Mistakes
"The backend runs in the browser on the user's device"
This confuses the two sides. What runs in the browser and is seen by the user is the frontend.
The backend runs on the server, processing requests and applying the app's rules where the user can't see it.
"The web app is just the page I see"
The page is only the frontend. It can't, for example, work out which products match your search without something to process the request and something to hold the data.
In the simplified model, a web app works through three cooperating tiers: frontend, backend and data layer.
"The frontend takes data straight from the database"
In the model the book teaches, the request goes from the frontend to the backend, and the backend asks the data layer.
The backend is the go-between: it receives the request, asks for the data, prepares the result and sends it to the frontend.
"The database is what decides and applies the app's rules"
Applying rules, such as checking a login or checking stock, is processing and decision-making.
The data layer keeps and provides data; decisions and processing belong to the backend.
"Every web app is built from exactly these three tiers"
The Arabic edition presents the three tiers as a simplified teaching model.
The model helps us understand, but real structures can differ, and some apps have no traditional database at all.
Key Points
- A web application is usually used through a browser, and some can be installed on the device. Examples: video, shopping, email and map services.
- The book explains web apps with a simplified teaching model of three tiers; real structures can differ from app to app.
- Frontend: what the user sees in the browser; it displays content and collects input.
- Backend: runs on the server; it processes requests and applies the app's rules, such as searching and checking logins.
- Data layer: keeps data and provides it; it may include databases, file storage, a cache and external data services.
- In a product search: the frontend receives and sends, the backend asks the data layer, the data layer returns results, the backend prepares them and the frontend displays them.
- The same tiers appear in video, social and shopping services; what changes is the work inside each tier.
- Organising responsibilities into clear tiers makes an app easier to understand, change and troubleshoot.
FAQ
What is the difference between frontend and backend, in short?
The frontend is what you see and use in the browser: it displays content and collects what you type or choose. The backend runs on the server where you can't see it: it processes requests and applies the app's rules, such as checking a login or finding matching products.
Is the database part of the backend?
In the model the book teaches, it is a separate third tier called the data layer, whose job is to keep data and provide it. The backend asks it for data and receives the results, but in this lesson they are two tiers with different roles.
If a question asks who searches for matching products, do I choose the backend or the database?
Following the book's steps, the backend processes the search request and asks the data layer for matching products, while the data layer stores the products and returns them. So if the question is about processing the search, answer backend; if it is about where the products are stored, answer database. Read the verb in the question carefully.
Does every website have a database?
Not necessarily. The Arabic edition of the book notes that the three tiers are a simplified teaching model and that some apps may have no traditional database at all, keeping their data in other ways such as file storage or external data services.