Beginner · How the web and backends work · topic 1 of 54 · 20 min
What is a backend?
Explanation
Two halves of every app
Most apps have two halves. The frontend is what you see and touch: buttons, forms, lists. The backend is hidden: it is a program running on a computer somewhere else, called a server.
A server is just a computer that stays on all the time and waits for requests. A request is a message from an app that says "please do this" or "please give me that".
What a backend does
- Stores data that must not be lost: users, orders, messages (in a database).
- Checks rules: is the password right? Is there enough money in the account? Is the seat still free?
- Does work the phone cannot or should not do: sending OTP SMS, charging a card, making a PDF ticket.
- Keeps secrets safe: payment keys and passwords never go to the phone.
One request, step by step
- You tap "Book" in the app.
- The app sends a request over the internet to the server.
- The backend code reads the request and checks it.
- It reads or writes the database.
- It sends a response (an answer) back, for example "Booked, PNR 1234567890".
- The app shows the answer on screen.
We can write this idea as a tiny JavaScript function. It takes a request object and returns a response object. Real backends are much bigger, but the shape is the same.
function handle(request) {
if (request.path === '/hello') {
return { status: 200, body: 'Hello from the backend!' };
}
return { status: 404, body: 'Not found' };
}
console.log(handle({ path: '/hello' }));
console.log(handle({ path: '/missing' }));Words you learned
| Word | Meaning |
|---|---|
| Frontend | The part you see and touch (app screen, website) |
| Backend | The hidden part that runs on a server |
| Server | A computer that is always on and answers requests |
| Request | A message asking the server to do something |
| Response | The answer the server sends back |
Watch the lesson
What is a backend? · 1/6
Every app you use has two halves. Today we meet the hidden half: the backend.
Prefer a video by a teacher? Find free videos on “what is backend development explained for beginners” on YouTube ↗
In real life: Ordering food on a delivery app
When you place an order on a food delivery app, the app sends your cart and address to the backend. The backend checks that the restaurant is open, works out the price with taxes and delivery fee, asks the payment service to charge you, saves the order in its database and tells the restaurant. Your phone only shows the result. If the backend did not check the price itself, anyone could change the app to pay 1 rupee for a biryani.
Practice (0/2 done)
Write a function handle(request) that returns { status: 200, body: "pong" } when request.path is "/ping", and { status: 404, body: "Not found" } for any other path.
Pick one app you use every day (a UPI app, a food app, IRCTC). Write 5 things its backend must do that the phone alone cannot do.
Quick quiz
Read more (free)
Pass the quiz (60% or more) or mark this topic as done when you are ready.
Your progress is saved on this device only.