What is Backend Development?
The part of an app that runs on a server, not in the browser. It handles the logic, data and rules users should never see or control.
What is it?
On a shopping site, much of what you see runs in your browser: buttons animate, forms check your input, pages update. But some things can't safely happen on your device: charging your card, checking real stock, or checking your password. These must happen somewhere the user can't see or tamper with, and that can reach a shared database.
That place is a server: another computer, usually in a data center, that the browser sends requests to over the internet. The code running there is the backend. The code running in the user's browser is the frontend.
A backend usually does a few jobs:
- Stores and reads data, usually in a database.
- Applies business logic ("can this user cancel this order?").
- Talks to other systems, like payment providers or email services.
- Decides what to send back to the caller.
Explain like I'm 10
Think of a restaurant. The dining room (menu, table, the person taking your order) is the frontend: what you see and use. The kitchen is the backend: where the food is made, the fridge (database) is opened, and decisions about substitutions or sold-out items are made. You never walk into the kitchen; you send a request through a waiter and wait for a response.
Examples
A frontend action that needs a backend
// In the browser (frontend): the user clicks "Place Order"
button.addEventListener("click", async () => {
const response = await fetch("https://api.shop.com/orders", {
method: "POST",
body: JSON.stringify({ itemId: 42, quantity: 2 }),
});
const result = await response.json();
showConfirmation(result);
});The browser can't safely check stock or charge a card itself, so it sends a request to a server and waits for an answer.
What the backend does with that request
// On the server (backend): receiving that same request
app.post("/orders", async (req, res) => {
const { itemId, quantity } = req.body;
const item = await db.items.findById(itemId);
if (item.stock < quantity) {
return res.status(400).json({ error: "Not enough stock" });
}
const order = await db.orders.create({ itemId, quantity });
res.status(201).json(order);
});This code never runs on the user's device. It runs on the server, where it can be trusted to check real, shared, current data before deciding what happens.
How it works
A backend is a program like any other, but it waits for incoming requests instead of being opened by a user. When a request arrives, it does some work (reads a database, runs a calculation, calls another service) and sends a reply. It runs all the time and serves many users, often at once.
Why does it exist?
Code on a user's device can't be trusted: anyone with browser developer tools can inspect, change or skip it. Backends keep sensitive logic, shared data and trust checks on a server the business controls (owns or rents), not in every user's hands.
When to use it
Put logic on a backend when the app needs to store data beyond one visit, enforce a rule users can't bypass, keep a secret (like an API key or password hash), or let many users see the same shared state.
When not to use it
Purely visual behavior doesn't need a server round trip: animating a menu, checking a field isn't empty before submit, or remembering a UI preference for one session. Sending these to the backend when nothing shared or sensitive is involved just adds network delay.
Common mistakes
Assuming a rule is enforced because the frontend JavaScript checks it. A user can bypass frontend code entirely.
Thinking 'backend' means one technology. It's a role a program plays, not a language or framework.
Putting secrets (API keys, database passwords) in frontend code, where anyone can see them, instead of on the server.
Practice exercises
- Easy:
List three things a shopping app's backend needs to do that its frontend cannot safely do alone.
- Medium:
Explain, in your own words, why checking a discount code's validity should happen on the backend rather than in the browser.
- Hard:
Describe what could go wrong if a banking app calculated your account balance entirely in frontend JavaScript instead of on a backend.
Interview questions
What is backend development?
Building the part of an app that runs on a server: business logic, data storage and talking to other systems. The frontend, by contrast, runs in the user's browser.
Why can't sensitive business logic be trusted to run only in the browser?
Browser code runs on the user's own device, where dev tools can inspect, change or skip it. Anything that must be trusted, kept secret or checked against real shared data has to run on a server the business controls.
Give an example of something that must happen on a backend, and explain why.
Charging a payment. It needs a secret API key for the payment provider and the real, current price and total. None of that can be safely given to, or checked by, code on the customer's device.
What's the core difference between a frontend and a backend in terms of where the code executes and who controls that environment?
Frontend code runs on the user's device, which the user (or anyone with dev tools) fully controls. Backend code runs on a server the business owns or rents, so only the business can inspect or change it.
Why does checking whether an item is "in stock" need to happen on a backend rather than in the browser?
Stock is shared data that changes as other people buy. A browser only has the data it was last given, so only a backend talking to the live, shared database can give a trustworthy answer.
Using the restaurant analogy, why does a customer never walk into the kitchen themselves?
The kitchen is the backend, where the real work happens on shared resources like the fridge (the database). Letting customers control it directly would destroy consistency and trust, so requests go through a waiter (the network request) instead.
Why is it incorrect to say "backend" refers to one specific language or framework?
Backend is a role a program plays (handling requests, applying business logic, managing shared data), not a technology. Node.js, Python, Java, Go and many other stacks can fill it.
A backend trusts a `role: "admin"` value sent by the frontend in the request body to decide access. What's wrong with this?
Users can edit anything the frontend sends, so trusting a client-supplied role lets anyone make themselves admin. The backend must look up the user's real role from its own trusted data, like a session or database record.
Why does validating a form field in frontend JavaScript still have value even though it isn't a real security measure?
It gives the user instant feedback without a network round trip. But the backend must repeat the same check, because the frontend check can be bypassed.
What risk does hardcoding a database password directly into frontend source code create?
Frontend code runs in every user's browser, where dev tools show the full source. A secret there is visible to anyone who looks, so the password is effectively public.
If two users try to buy the last unit of an item at the same moment, why must the stock check happen on a shared backend rather than in each user's own browser?
Each browser only has its own, possibly stale, view of stock. Only a backend using one shared, authoritative database can see both attempts and let just one succeed.
What does it mean for a backend to "enforce a rule the user shouldn't be able to bypass," and why can't that same rule live only in frontend code?
The rule is checked somewhere the user can't tamper with or skip. Frontend code runs fully under the user's control, so a check there can be disabled, edited, or skipped by calling the backend directly.
Why does a backend typically need access to a shared database, while a purely frontend app usually doesn't?
A backend serves many users who all see and change the same data (orders, inventory, accounts). A frontend only shows and collects data for one user, and gets that data from the backend.
Name a UI behavior that doesn't need a backend round trip, and explain what makes it safe to keep client-side only.
Animating a menu, or checking a text field isn't empty before submit. These only affect the current user's screen, touch no shared data, and risk nothing if done in the browser.
Why is "the frontend already validated this" never a safe assumption for backend code to make?
A request can reach the backend without going through your frontend at all, via curl, Postman or a modified app. So the backend must validate anything it can't afford to get wrong.
Beyond "it's more secure," why must charging a credit card run on a backend rather than in the browser?
It needs a secret merchant API key that users must never see, and it must use the real, server-checked order total, not whatever amount the browser sends.
What's the practical consequence of a backend being the one thing every user's frontend talks to, rather than each user running their own private copy of the logic?
There's one place enforcing the rules and one shared source of truth, so all users see consistent results. A fix or rule change on the backend applies to everyone at once, without updating any user's device.
Why might a backend also be described as running on "a server," and is that a specific machine?
"Server" is a role (always listening for and answering requests), not specific hardware. It can be a physical machine, a virtual machine or a container, as long as it runs the backend and is reachable over the network.