Skip to content

Beginner · How the web and backends work · topic 1 of 54 · 20 min

What is a backend?

Explanation

The backend is the part of an app that runs on a server, not on your phone. It stores data, checks rules and sends answers back to the app. When you book a train ticket, the screen you tap is the frontend; the computer that checks seats and saves your booking is the backend.

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".

Think of it like this: Think of a restaurant. The dining area with menus and tables is the frontend. The kitchen is the backend: you never see it, but it takes your order, cooks the food and sends it out. The waiter carrying orders between them is the network.

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

  1. You tap "Book" in the app.
  2. The app sends a request over the internet to the server.
  3. The backend code reads the request and checks it.
  4. It reads or writes the database.
  5. It sends a response (an answer) back, for example "Booked, PNR 1234567890".
  6. 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.

javascript
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' }));
A backend in its smallest form: request in, response out.
Tip: Rule of thumb: anything that must be trusted (prices, balances, who is logged in) is decided by the backend, never by the app on the phone. People can change the app; they cannot change your server.
Careful: Never put secret keys (payment keys, database passwords) in frontend code. Anyone can open the app or website and read them.

Words you learned

WordMeaning
FrontendThe part you see and touch (app screen, website)
BackendThe hidden part that runs on a server
ServerA computer that is always on and answers requests
RequestA message asking the server to do something
ResponseThe answer the server sends back

Watch the lesson

What is a backend? · 1/6

What is a backend?

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)

Task 1 · Code · Javascript

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.

Task 2 · Practice

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

Question 1

1.Where does the backend of an app run?

Question 2

2.Which job belongs to the backend?

Question 3

3.What is a response?

Question 4

4.Why must payment keys never be in frontend code?

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.