انتقل إلى المحتوى
أمين أبوزيد
منشورBEG-002-L05

عرض عملي: تطبيق واحد بأجزاء كثيرة: تطبيق جوال وموقع ويب وbackend

  • الدرس 5 من 5
  • 16 دقيقة قراءة
  • مبتدئ
في هذا الدرس 11 موضوعات

هذا الدرس متاح حاليًا باللغة الإنجليزية فقط، ولم تُنشر نسخته العربية بعد.

Lesson Overview

This is a hands-on lesson. Until now you have read about five kinds of software, about services that keep running, and about the lifecycle. Here you will see these ideas in a real product: one account that you reach through a mobile app, through a website, and through a backend that you cannot see but can learn to recognize by what it does.

You will use any product that has both an app and a website and requires an account, such as a food-ordering service, a notes tool, a streaming service, or a shopping app. You do not need any special tools. A phone, a computer, and a browser are enough. An optional step shows how to peek at the conversation between a web page and its backend with your browser's developer tools.

In the restaurant picture, the phone app and the website are two different dining rooms. The backend is the single kitchen behind both.

Why this matters: the most common beginner confusion in this module is "the website is the backend". After this demo, you will be able to explain with evidence why that is wrong.

This lesson builds on all earlier lessons in this module. Please do not place real orders or make payments for the demo. Use actions that do no harm, such as browsing, adding to a basket, or creating a note.

Learning Objectives

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

  • Identify the pieces of a real product: the mobile app, the web frontend, and the backend.
  • Show that two frontends (app and website) display the same data from one backend.
  • Predict and observe what still works and what stops when the network is off.
  • Explain the difference between data stored on your device and data stored by the backend.
  • Correct the sentence "the website is the backend" and say why it is wrong.
  • Write a short description of what happens behind one app you use.
  • Optionally find evidence of the browser talking to a backend using developer tools.

Written Explanation

The plan of the demo

You will do the demo in five short steps. For each step, there is something to do, something to look for, and something to say, meaning the explanation you should be able to give.

text
  Step 1  Use the app            -> create something (a basket, a note, a favorite)
  Step 2  Open the website       -> the same thing appears
  Step 3  Name the pieces        -> app, website frontend, backend
  Step 4  Switch off the network -> what still works, what does not
  Step 5  The planned mistake    -> "the website is the backend": correct it

If you can follow along on your own devices, do so. If not, read each step and answer the questions as if you were watching it. Everything here must be hedged for your own product: apps differ, and what exactly appears or fails depends on how each product is designed. Describe what you observe, not what you expect.

Preparation

Choose a product that has:

  • A mobile app on your phone (or a tablet).
  • A website that you can open in a browser on a computer or the same phone.
  • An account that works in both.

Examples of the sort of thing that works: a notes or to-do tool, a music or video service where you can save a favorite, an online shop where you can add items to a basket without buying. Choose something where you can create a harmless item.

Write down the product name and the device you use. Open your notes tool or a piece of paper for observations. A table helps:

StepWhat I didWhat I sawWhat it shows

Step 1: Use the app and create something

On the mobile app, sign in and create something harmless: add an item to a basket, save a favorite, write a note called "Demo 1".

Look for: the item appears in the app straight away.

Say: the app on my phone is software installed on my phone. It displays what I created. But where is the item stored? So far, I only know that the app shows it. The next step provides evidence.

Step 2: Open the website with the same account

On a computer (or in your phone's browser), open the product's website and sign in with the same account.

Look for: whether "Demo 1" (or your basket item, or your favorite) appears here. If the product syncs, it will, although some products refresh only after a moment, or after you reload the page.

Say: I created the item on the phone and never typed it into the website. It still appears. So the item cannot be stored only on my phone, and it is not stored only in the browser. It is stored somewhere both can reach. That somewhere is the backend: a service on a server that keeps the data and gives it to whichever frontend asks.

If the item did not appear, write that down too. Possible reasons: the product does not sync that kind of item, you used a different account, it needs a refresh, or the sync is delayed. Do not force the conclusion. State what you saw.

Step 3: Name the pieces

Now say what each piece is. Fill in this table for your product:

PieceKind (from lesson 2)Where it runsWhat it does here
The app on my phoneMobileOn my phoneShows the screen, takes my taps, asks the backend for data
The website pageWeb frontendIn my browserShows the page, takes my clicks, asks the backend for data
The service that holds my account and itemsBackendOn a server I never seeStores the data, checks who I am, answers both

Draw the diagram on paper:

text
   Phone app -----\
                    >----  Backend  ---- stores the account and the items
   Website   -----/
   (browser)

Notice that you never saw the backend. You saw its effects. That is what it means for a backend to be hidden: it is the part behind the front, in the kitchen.

Step 4: Switch off the network

This step is about seeing which parts depend on the backend. Do it on the phone only. Ways to cut the connection differ between phones, so look in your phone's settings or quick-settings panel for options such as airplane mode, or turn off both mobile data and Wi-Fi. The menus differ between systems and versions, so use whatever your phone provides. Remember to turn the network back on afterward.

With the network off, try these in the app:

  1. Look at what you already see. Does the app still show "Demo 1"?
  2. Create something new. Does it let you? What message appears?
  3. Refresh or open another section. What happens?

Look for: some apps keep a copy of recent data on the phone and let you read it. Some let you write while offline and send it later when the connection returns. Others stop completely and show an error. Which of these does your product do?

Say: what still works lives on my device (recent data kept in storage or in RAM, and the app's own instructions). What stopped needs the backend. The pieces are separate, and the app needs the other piece to do all of its work. Different products make different choices about how much to keep on the device, and I only know my product's behavior from what I observed.

Now turn the network back on and watch the app. Does an item you tried to create while offline appear on the website? If it does, the app kept it and sent it to the backend once the connection returned. If it does not, the app did not keep it, or the attempt failed. Either result is informative: describe what you saw, without guessing at the cause.

Step 5: The planned mistake, and the correction

Here is a deliberate mistake, for you to catch. Imagine someone says:

"The website is the backend. I opened the website and I can see all my data, so the website is where my data lives."

Correct it with the evidence you have gathered.

  • The website is a web frontend. It runs in the browser, on your computer, and shows a page.
  • The phone app showed the same data, but the app is not the website. So the data does not live in either of them.
  • The data lives in the backend, a separate service on a server, which both the app and the website ask.
  • You can see the website. You never saw the backend. That alone shows they are different things.

If the speaker answers "but the website loads from a server", the answer is: yes, the page itself is downloaded from a server (a web server, as MDN describes it, software that waits for requests and answers them). But the part that stores and decides your data, the backend, is a different piece of software, even if the same company runs it, and sometimes even on the same machine. The word "backend" refers to what the software does (hold data and apply rules), not to where the page is downloaded from.

Optional: peek behind the website with developer tools

This extra step shows the website talking to its backend. It is optional and the exact menus depend on your browser and version, so look in your browser's menu for something called "Developer tools", "Web developer tools", or "Inspect". Many browsers also open them with a keyboard shortcut such as F12, but this varies, so check your browser's help.

  1. Open the tools and find the tab usually called Network. It lists the requests that the page makes.
  2. Reload the page with the tools open.
  3. Look at the list. You will see many requests: for the page, pictures, and styling. Some of them may bring your data, such as the list of items. Click an entry to see where it was sent and what status came back.
  4. Do not copy, share, or post what you see. Requests can contain personal information, such as account tokens. Treat everything you see as private.

Look for: the idea of request and response from lesson 3: your browser (the client) sends requests, and a server answers with responses. What you read in the list depends on the product, and I cannot predict which requests you will see. Describe what you see, and do not guess about what is not visible.

Examples

Example 1: a notes tool (simple)

You write "Buy milk" in the notes app on your phone. You open the notes website on your laptop, and "Buy milk" is there after a moment.

  • Pieces: phone app (mobile), website (web frontend), backend (stores notes).
  • Evidence for the backend: the note reached the laptop without you typing it. It is held by a service in the middle.
  • With the phone in airplane mode, you can still read recent notes, because the app kept a copy, but you may not see notes you wrote on the laptop a minute ago.

Example 2: an online shop (practical)

You add a pair of shoes to the basket on a shop's app, without buying. On the website, the basket shows the shoes.

  • The basket is data the backend holds for your account, so every frontend can show it.
  • The product pictures and layout are in the frontend, which downloads them to show.
  • Offline, the app might show the shop's home page from memory, but adding a second item may fail, since adding changes shared data and needs the backend.
  • Caution: do not press the pay button during a demo.

Example 3: a music service and a surprise (realistic)

You like a song on the phone app. On the website the heart icon next to the same song is filled in. You then switch your phone to airplane mode. The app still plays music you downloaded earlier. But the search box returns an error and the recommendations do not refresh.

What does this tell you?

  • The downloaded songs are data on the device, played by instructions on the phone, with no backend needed for that moment.
  • Search and recommendations need the backend, which holds the catalog of millions of songs that cannot fit on a phone, and applies the rules for what is suggested.
  • Which parts a particular service keeps on the phone is that service's design decision. One service may let you do much offline, another little. The lesson is the method: switch off the network and see what breaks, then reason about which piece it needed.

Backend Insight

This demo shows why companies invest in a backend even though users never see it.

  • One source of truth. The backend keeps one copy of the data, so the phone, the website, and any new frontend show the same facts. Without it, each frontend would have its own opinion.
  • Many frontends, one kitchen. Adding a new frontend later, for instance a tablet app or a partner's system, can reuse the same backend, since the backend only needs requests in the agreed form.
  • Offline is a design decision. Whether an app works without the network depends on how much data it keeps locally and how it later synchronizes with the backend. These are design choices with trade-offs, and they are made by engineers.
  • Failures are felt in the frontends. When the backend is down, the app and website may both look fine but show errors or empty content. This links to lesson 3: a service that is not running affects everyone who depends on it, while the frontends themselves are unharmed.
  • Evidence beats guessing. In backend work, you often work out what a hidden system does by watching what goes in and what comes out, which is what you practiced here.

Common Mistakes

Mistake 1: Calling the website the backend

  • Incorrect: "The website is the backend."
  • Correct: "The website is a web frontend that runs in my browser. The backend is a separate service on a server that stores the data and applies the rules."

This is the planned mistake of the demo and the most common error in the module.

Mistake 2: Assuming offline behavior is the same for every app

Some apps work offline for reading, some for reading and writing, and some not at all. Always observe and say "this product does X when offline", not "apps do X".

Mistake 3: Concluding the data is "on the phone" because the phone shows it

Showing data is not the same as holding the master copy. A phone can show a copy of data that really lives in the backend. A test is whether the same data appears on a second device.

Mistake 4: Sharing private information while exploring

Developer tools, screenshots, and notes can contain account names, tokens, or addresses. Keep them private and do not paste them into public places.

Mistake 5: Making real purchases or deleting real data in the demo

Use harmless actions: browsing, notes, favorites, items in a basket you can empty.

Exercises

Try each exercise yourself before opening the solutions.

Level A: Foundation

A1. Name the three pieces of software in this demo and say where each runs.

أظهر الحل A1

A1. The mobile app runs on the phone. The web frontend runs in the browser on the computer or phone. The backend runs on a server that the user does not see.

A2. An item created in the app also appears on the website. Which piece must hold the data?

أظهر الحل A2

A2. The backend. Both frontends ask it for the data, and it keeps the shared copy.

A3. True or false: the backend is the web page that you see in the browser.

أظهر الحل A3

A3. False. The page in the browser is the web frontend. The backend is a separate service on a server.

Level B: Application

B1. You switch your phone to airplane mode. The app shows your saved items but refuses to add a new one. Explain this using the words device, backend, and request.

أظهر الحل B1

B1. The app shows items that it has on the device, such as a copy kept after the last time it connected. Adding a new item needs a request to the backend, which must save the item for the account, and with no network the request cannot be sent. So reading works from the device, but adding fails.

B2. A classmate says: "I do not use any backend, I only use the website." Explain what is wrong with this statement.

أظهر الحل B2

B2. The website is a frontend, but it gets and saves its data by sending requests to a backend, so the person does use a backend indirectly, even without seeing it. It just happens through the website.

B3. Draw a diagram in words for an online notes service with a phone app, a website, and a backend. Mark where the notes are stored.

أظهر الحل B3

B3. For example:

text
  Phone app ----\
                  >---- Backend ---- notes are stored here
  Website   ----/

The notes are stored at the backend, and both frontends ask for them.

Level C: Challenge

C1. Design a short experiment, with steps and expected observations, to find out whether a product keeps a copy of your data on the phone. State what you would conclude from each possible result, and what you could not conclude.

أظهر الحل C1

C1. For example: create an item on the phone, wait, switch to airplane mode, and close and reopen the app. If the item is still shown, the app probably keeps a copy on the device (or caches it); if it disappears or the app is empty, it probably needs the backend to display it. You could not conclude where the master copy is from this alone, and you could not conclude that nothing is cached if a loading message shows up quickly. Repeat on the website with the second device to check that the master copy is elsewhere.

C2. A company's website goes down, but its phone app still works for everyone. Give two possible explanations in terms of the pieces of the product, and say what you would need to check to tell them apart. Hedge: you cannot know without more information.

أظهر الحل C2

C2. Two possible explanations. First, the part that delivers the website (the web frontend and the web server behind it) is broken, while the backend is healthy, so the app keeps working. Second, the website depends on a part of the backend that the app does not use, and only that part has failed. To tell them apart, check whether the backend answers requests that come from the app, and read the error the website shows (for example a page that fails to load at all versus a page that loads but cannot get its data). Without more information you cannot be sure which it is.

Mini Challenge

Write a one-paragraph description of what happens behind one app you use. This is also the written part of the module assessment.

  1. Choose an app that has a backend (a shop, a streaming service, a messaging app, a bank).
  2. Pick one action, such as "send a message" or "add to basket".
  3. Describe, in about five to eight sentences, what happens from your tap to the result on the screen: what your app does, what it sends, what the backend probably does (store, check, decide), and what comes back.
  4. Mark any sentence that you are guessing about with the word "probably".

Check your work: the paragraph names the app (frontend), the backend as a separate piece, and the request and response; it uses "probably" where you could not know; and it does not call the website the backend.

Summary & Next Lesson

Key takeaways

  • A single product is usually several pieces of software: a mobile app, a website (web frontend), and a backend.
  • If data created in one frontend appears in another, it is held by a shared backend.
  • The backend is hidden: you see its effects, not the service itself.
  • Switching the network off shows which parts depend on the backend. What the app does offline depends on the product's design.
  • The website is a frontend, not the backend. Correct this mistake whenever you hear it.
  • When you cannot see inside a system, observe, then reason, and say clearly what you did not verify.

Next lesson

This completes the module. Take the module quiz and do the lab, "Software around you": list ten pieces of software you used today, classify each, and mark which depend on a backend service. The next module continues the journey from here.

Self-check

  1. What are the three pieces in this demo?
  2. Why does a note made on the phone appear on the website?
  3. What did switching off the network show?
  4. Why is "the website is the backend" wrong?
  5. Why should you not share your developer tools screenshots?
أظهر الإجابات
  1. A mobile app, a web frontend (the website), and a backend.
  2. Both frontends ask the same backend, which stores the note for your account.
  3. Which parts needed the backend and which worked from data on the device. The result depends on how the product was designed.
  4. The website is a frontend running in the browser, while the backend is a separate service on a server that holds the data and rules.
  5. They can contain private information, such as account details or tokens.

References

  • MDN Web Docs, An overview of HTTP. Supports the client-server request and response model, in which the client starts the exchange and the server answers.
  • MDN Web Docs, What is a web server?. Supports the description of a web server as software that waits for requests and returns responses.
  • MDN Web Docs, What is JavaScript?. Supports the distinction between code running in the browser and code running on a server.
  • The demo steps, the tables, and the restaurant picture are this course's own teaching material. I did not verify any specific product's offline behavior, nor the exact menus or shortcuts for airplane mode or browser developer tools, which vary by system and version; the lesson therefore tells the learner to observe and describe rather than predict.

التطبيق

طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.

المختبر والتمارين الاختبار

تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.

اكتب للبحث في المستويات والمراحل والوحدات والدروس.