Skip to content
Pixel
العربية

3-1Unit 3 · Web Applications

The Overall Structure of Web Applications

11 min readStart exercises
In this lesson
  1. The Big Idea
  2. What Is a Web Application?
  3. The Three Tiers: A Simplified Teaching Model
  4. How Do the Tiers Cooperate? The Journey of a Search
  5. The Same Tiers in Familiar Services
  6. Why Separate the Responsibilities?
  7. Try It Yourself
  8. Common Mistakes
  9. Key Points
  10. FAQ

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 simplified three-tier model of a web app A vertical diagram of four boxes: the user at the top, then the frontend, which displays content and collects input in the browser, then the backend, which processes requests and applies the rules on the server, then the data layer, which stores data and provides it when needed. Between each pair there is a down arrow and an up arrow: operate and input then display result, request then response, query then data. A note at the bottom says this is a simplified teaching model and real structures can differ. The three-tier structure of a web application User Frontend Displays & collects · in the browser e.g. search screen, product pages Backend Processes & applies rules · on the server e.g. checking a login Data layer (database) Stores data, provides it when needed e.g. products, users, orders operate / input display result request response query data A simplified teaching model: real apps may be structured differently
Each tier has a clear job: requests travel down and results travel back up.

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:

  1. Display: it shows you content in an organised way, such as product photos and prices, or a list of videos.
  2. 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:

  1. The frontend receives the search words you entered.
  2. The frontend sends the search words to the backend.
  3. The backend asks the data layer for the products that match the search phrase.
  4. The data layer returns the requested results to the backend.
  5. The backend prepares the results to send to the frontend.
  6. The frontend displays the search results on your screen.
How a product search flows through the three tiers A sequence diagram with four columns from left to right: user, frontend, backend and database. Step 1: the user enters search words in the frontend. 2: the frontend sends the search words to the backend. 3: the backend asks the database for matching products. 4: the database returns the results to the backend. 5: the backend prepares the results and sends them to the frontend. 6: the frontend shows the results on the user's screen. Solid arrows are requests going out; dashed arrows are results coming back. Example: searching for a product in an online shop User Frontend Backend Database ① enters search words ② sends the search words ③ asks for matching products ④ returns the results ⑤ prepares & sends results ⑥ shows results on screen Solid arrow: request going out · Dashed arrow: result coming back
The request travels right to the data layer, and the result comes back the same way.

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 |

The same tiers in different services A visual table comparing three services: video sharing, social network and e-commerce, across three tiers. Frontend: player and search screens; timeline and post screen; product lists and shopping cart. Backend: picking recommended videos and counting views; choosing who sees a post and controlling notifications; checking stock and handling payment requests and results. Database: videos, users and watch history; posts, messages and follow relationships; products, orders and customer information. Note at the bottom: the same three tiers appear in every service; what changes is the work inside each tier. Three services, the same three tiers Video sharing Social network E-commerce Frontend display & interaction Player & search screens Takes user actions Timeline & post screen Sends what you type Product lists & cart Takes orders Backend processing & control Picks recommended videos Counts views Chooses who sees a post Controls notifications Checks stock Payments & their results Database storage & management Videos, users, watch history Posts, messages, follow relationships Products, orders, customer info Same three tiers everywhere; what changes is the work inside each tier
Read it row by row: each row is one tier, but its jobs change from service to service.

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:

  1. Clarity: each part has a defined job, so anyone working on the app knows where to add or change things.
  2. Easier fault-finding: when something breaks, you know where to start looking.
  3. 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

Try
Which tier does the job?
A pharmacy in Mansoura has a web app for ordering medicines for delivery. Sort each task into the tier responsible for it in the simplified model.
Items (9)
Tap an item to select it, then tap the category it belongs to.
Nothing here yet
Nothing here yet
Nothing here yet
Try
Looking up an exam result
A student types his seat number into the school results site to see his marks. Put what happens between the tiers in order, from start to finish.
1. The backend asks the data layer for the marks for that number
2. The backend prepares the result to send to the frontend
3. The frontend shows the marks on the student's screen
4. The data layer returns the marks to the backend
5. The frontend sends the seat number to the backend
6. The frontend receives the seat number the student typed
Use the up and down buttons to move each step, then press Check.
Try
A clinic with no appointments
The situation
A dental clinic in Assiut has a booking web app. A patient opens the booking page and it looks normal, but the list of available times is completely empty, even though the dentist is working today. What is the best way to think about diagnosing the problem?
What would you do? You can try more than one choice.

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.

Done reading? Test yourself