Lesson 18: The Real Relationship Between Front-End and Back-End! — How Does a Complete Web Application Work?
Every website has two sides — the part you see on the screen, and the part that works behind it. In this lesson, you'll learn the difference between frontend and backend in plain words, and follow an online-store example to see how a complete web application works: where an order is saved, how a login is recognised, and how the shopkeeper gets notified.
Lesson No: 18
The Real Relationship Between Front-End and Back-End! — How Does a Complete Web Application Work?
By Tanzeel-ur-Rahman (CodeHubb & MindCrafts_AI) Farooka (Sargodha)
Assalamu Alaikum wa Rahmatullahi wa Barakatuh!
In the last lesson, we used AI to build a basic website prototype. It had buttons, forms, coloured boxes, a menu and text. We even opened it in our browser and looked at it.
But now an important question comes up:
Is our website complete just because we have made a good-looking web page?
Suppose we have built an online store. It has pictures of different products, prices, details and a buy button. A user likes a product, adds it to the Cart, and enters their information to place an order.
Now think about this:
- Where will the user's order be saved?
- Where will the product prices and availability come from?
- How will the user's account be created and kept safe?
- When the user logs in, how will the system know this is the right user?
- Once an order is complete, how will the shopkeeper be told?
- If the user opens the website again, how will they see their earlier order?
None of this happens just because we have put buttons and forms on a web page. It needs a system that works behind the screen.
This is where we meet two basic terms:
Front-End and Back-End
Today we will understand both from the beginning, and also see how they work together in a complete web application.
1. What Is the Front-End?
The front-end is the part of a website or web application that the user sees directly on their screen and interacts with.
For example, when you open a website on your mobile or computer, the things you see are generally part of the front-end:
- The website's logo and header
- The menu and navigation bar
- Pictures and videos
- Text and headings
- Various buttons
- The contact form
- Login and sign-up pages
- Product lists and prices
- The dashboard and various controls
All of these give the user a way to use the website.
A simple example:
When you walk into a shop, you see the signboard, the shelves, the products, the price tags and the counter. By looking at these, you decide what to buy and whom to talk to.
On a website, the front-end sits in front of the user in the same way.
But remember! The front-end is not just about looks. Its real purpose is to show information to the user, to take information from them, and to let them do different things.
2. How Is the Front-End Built?
Three technologies play the main part in building the front-end:
HTML — The structure of the website
HTML (HyperText Markup Language) sets out the basic parts of a web page and how they are arranged.
For example:
- Where will the heading go on the page?
- Where will the paragraph appear?
- Where will the picture be placed?
- Where will the forms and buttons be?
Just as walls, doors and rooms form the basic structure when a house is built, HTML builds the basic structure of a web page.
CSS — The look of the website
CSS (Cascading Style Sheets) makes a web page attractive and well organised.
For example:
- What will the colours be?
- What will the font be like?
- What will the size and design of the button be?
- How much space will there be between the different parts?
- How will the website look on mobile and on a computer?
If HTML is the structure of the house, then CSS is its paint, decoration and good looks.
JavaScript — Movement and function in the website
JavaScript makes a web page lively and Interactive.
For example:
- Something happening when a button is clicked
- A menu opening and closing
- A first check of the information in a form
- Content on the page changing
- Showing a result according to what the user does
In other words, HTML builds the structure, CSS makes it look good, and JavaScript adds different interactions and functions to it.
These three technologies are the foundation of the front-end. Later, technologies such as React, Vue and Next.js are also used in this field, and we will understand them further along the way.
3. What Is the Back-End?
The back-end is the part of a website or web application that works behind the scenes.
The user generally does not see it directly, but many of the website's important tasks are carried out through it.
For example:
- Creating the user's account
- Verifying the login
- Saving information
- Getting information from the database
- Receiving orders
- Connecting to the payment system
- Doing calculations according to business rules
- Getting an answer from an AI model
- Sending data back according to the user's request
A simple example:
You order food in a restaurant. You see the menu, the waiter takes your order, but the food is prepared in the kitchen.
You do not need to know how much spice the cook added, in what order the food was prepared, or what was done in the kitchen. You just need to receive your order in good condition.
On a website, the back-end works behind the scenes in the same way.
It receives the user's request, carries out the necessary work and sends back the result.
4. What Is the Back-End Made Of?
It is not right to think of the back-end as just one program or one server. It can be made up of several parts.
1. Back-End Language
This is the programming language in which the code for the server is written.
For example:
- Python
- JavaScript (through Node.js)
- PHP
- Java
- C#
In this course, we will learn to build the back-end with Python.
2. Back-End Framework
A framework is a collection of ready-made tools and rules that makes programming work more organised and easier.
The well-known back-end frameworks in Python are:
- Django
- Flask
- FastAPI
Further on, we will also understand their introduction and practical use.
3. Database
A database is a system for keeping information safely and in an organised way.
For example, the database of an online store might hold this information:
- Users' names and accounts
- Product details
- Product prices
- Order details
- Records of payments
Think of it this way: a database is an organised digital record room, where information can be stored and searched for as needed.
Well-known database systems include MySQL, PostgreSQL, SQLite and MongoDB.
4. Server
A server is the computer, or computing environment, where the back-end program runs, and which receives clients' requests and answers them.
A server does not have to be a very big computer. In small projects, an ordinary computer can work as a server, while large web applications use cloud servers and other modern systems.
5. What Are a Client and a Server?
These two terms will come up again and again in web development.
Client:
A client is the software or device that asks a server for some service or information.
For example:
- Your mobile
- Your laptop
- Google Chrome
- Firefox
- A mobile application
When you open a website on your mobile, your browser plays the role of the client.
Server:
The server receives the client's request, does the necessary work and sends back an answer.
Think of the relationship like this:
- The client asks.
- The server receives the question.
- The server does the necessary work.
- The server sends back the answer.
- The client shows the answer to the user.
This is the basic Request-Response Communication of the web.
6. What Are Request and Response?
Now we will understand a very important idea.
Request:
When a client sends the server a message or a request to get something done, it is called a Request.
For example:
- The user wants to log in.
- The user wants to see their profile.
- The user wants to search for a new product.
- The user wants to save an order.
For all of these tasks, the client can send a request to the server.
Response:
When the server processes the request and sends back an answer, it is called a Response.
For example:
- The login was successful.
- The password is wrong.
- The product you wanted was found.
- The order was saved successfully.
Let's understand this whole process through an example:
Suppose you log in to a website.
- You enter your email and password.
- The browser sends this information to the server.
- The server checks the information provided.
- If the information is correct, the server sends back a success response.
- The browser takes you to your account dashboard.
Here is an important point to remember: the password is verified securely on the back-end. Checking it only on the front-end is not enough for a secure login system.
7. How Do the Front-End and Back-End Communicate with Each Other?
So far we have understood the front-end and the back-end separately. But in real web development, the two have to be connected.
This connection is generally made through an API (Application Programming Interface).
In simple words, you can think of an API as a fixed way for two pieces of software to communicate.
Look at the waiter in the restaurant example.
The customer gives their order to the waiter. The waiter takes it to the kitchen and brings the prepared food back to the customer.
An API likewise becomes the means of communication between different parts of software, although technically its way of working is broader than this example.
For example:
- The front-end sends a request to the API.
- Through the API, the request reaches the back-end.
- The back-end does the necessary work.
- The back-end sends back an answer.
- The front-end shows the answer it has received to the user.
That is, the API is an important link between the front-end and the back-end.
Later in this course, we will understand APIs separately, with details and practical examples.
8. A Complete Example: How Does an Online Store Work?
Now we bring all these ideas together in one practical example.
Suppose you have built an online store and a user wants to buy a mobile phone from it.
Step 1: Opening the website
The user opens the website on their mobile. They see pictures, names and prices of products.
This is the work of the front-end.
Step 2: Viewing products
The user clicks on a mobile phone to see its details. The website asks the server for more information about this product.
Here a Request is sent.
Step 3: Getting the information
The back-end gets the relevant product's information from the database and sends back an answer.
Here a Response is received.
Step 4: Adding to the cart
The user clicks Add to Cart. Their choice is passed to the system, and the cart information is saved or updated as needed.
Step 5: Placing the order
The user enters their name, address and contact number and submits the order. The front-end sends this information to the back-end.
Step 6: Saving the order
The back-end checks the necessary information and saves the order in the database.
Step 7: Showing the confirmation
The server sends back a response that the order has been saved, and the front-end shows the user this message:
"Your order has been received successfully."
In this one example, we have seen the role of the front-end, the back-end, the server, the database, the API, the Request and the Response.
9. Can the Back-End Work Without a Front-End, and the Front-End Without a Back-End?
This is an important question.
Can there be a front-end without a back-end?
Yes!
A simple website can be built with just HTML, CSS and JavaScript. It can show information, the buttons can work, and some basic actions can take place.
For example, an introductory website or a simple portfolio for a business.
But when you need user accounts, permanent data storage, orders, shared information and secure business operations, a back-end is needed, or an outside back-end service can be used.
Can there be a back-end without a front-end?
Yes!
A back-end can also be a program that works through an API without any web page. Other applications or software can communicate with it.
For example, the back-end of a mobile application, which does not necessarily need a web front-end of its own.
So it is not right to think that the front-end and the back-end are always in the same place or in the same program. The two can be separate, and they can work with each other in different ways.
10. What Will We Learn Next in This Course?
In the first phase, we learned to build a basic front-end and prototype of a website with the help of AI.
Now, in the second phase, we will move towards making this website more functional.
In this phase, our attention will be on these topics:
- A basic introduction to Python and its practical use
- The basics of back-end programming
- The relationship between server and client
- Building and using APIs
- Connecting the front-end to the back-end
- An introduction to databases and saving information
- User accounts and the login system
- Connecting AI models to your own web application
We will understand these topics step by step. The aim is that the student should not stop at building a website's outward design, but should also understand the system that works behind it.
Today's Practical Exercise
Open the website you built in the previous phase on your computer.
Now look carefully at its different parts:
- Find all the buttons in it.
- Look at all the forms and the input fields in them.
- Enter some made-up information into one form and press the Submit button.
- Observe whether the information is really being saved anywhere, or whether only a message is appearing on the screen.
- Keep this question in mind: if thousands of users came to this website, where would their information be stored?
The aim of this exercise is not to build a back-end yet, but to understand the difference between a web page that only looks the part and a fully working web application.
Today's Task
In your notebook, choose one of these three applications:
- An online shopping store
- An online banking app
Now make two columns for it:
First column: Front-End
Write what the user sees and what things they can do.
Second column: Back-End
Write what work must be going on behind each of the user's actions.
For example, if you have chosen WhatsApp, the front-end might include the chat screen, the box for typing messages, pictures and call buttons, while the back-end might include delivering messages, verifying the account and other necessary systems.
Remember: the aim of this task is not just to make a list of things, but to try to understand the technical logic behind each action.
Lesson Summary
Today we understood that:
- The front-end is the part of a website that the user sees and uses.
- The back-end handles the data and business logic behind the scenes.
- The server receives requests and acts on them.
- The database keeps information safe and organised.
- The API is the means of communication between different parts of software.
- A Request is a request, and a Response is its answer.
Now tell us in the comments:
Do you now understand the difference between the front-end and the back-end? And in your view, in an online store, does the front-end or the back-end do the job of saving an order?
In the next lesson, we will step into the world of Python and understand why Python is used for back-end development.
Join the WhatsApp channel for all previous lessons, and check the comments for Lesson 17.
Tanzeel-ur-Rahman (CodeHubb & MindCrafts_AI)
#Lesson18 #FrontEnd #BackEnd #WebDevelopment #Python #API #Database #MindCraftsAI #CodeHubb