Frontend and backend
Every app has two halves that live in different places. Learn what each one does, how they talk, and the one rule that keeps your money and your data safe.
The lesson in text
Click a paragraph to hear it.01Two folders
You ask Claude Code to build a booking app. A few minutes later, your project has two folders. One is called frontend. The other is called backend. The agent talks about both as if you already knew the difference.
In this lesson, you'll learn what each half is, where each one actually runs, and how they talk to each other. And you'll learn the one rule that, when it's broken, costs real money.
Because that's what happened to Nadia. She owns a small hotel in Lisbon. Her sea-view suite costs €240 a night. Last Tuesday, a guest booked three nights, which should cost €720, and paid €7.20. And the booking system said everything was fine.
By the end of this lesson, you'll know exactly how that happened, and the question to ask your AI coder so it never happens to you.
02A restaurant
Think of a restaurant. There's the dining room: the tables, the menu, the waiter who takes your order. It's everything the guests see and touch.
And there's the kitchen. Guests never go in there. That's where the real work happens: the cooks follow the recipes, the fridge holds the food, and someone checks the bill before it goes out.
Between the two, there's a small window. The waiter passes order tickets through it, and plates come back. The dining room never cooks, and the kitchen never talks to the guests directly.
An app works the same way. The dining room is the frontend: everything the user sees and taps. The kitchen is the backend: the work nobody sees. And the window between them has a name you'll hear all the time: the API.
| Restaurant | Your app | Its job |
|---|---|---|
| Dining room | Frontend | What users see and tap: pages, buttons, forms |
| Kitchen | Backend | The work nobody sees: prices, rules, payments, emails |
| Fridge | Database | Where the facts are kept |
| The window | API | Where orders go in and answers come out |
03The frontend runs on the guest's device
Remember the HTML, CSS and JavaScript from lesson one? That's the frontend. HTML says what's on the page, CSS says how it looks, JavaScript says what happens when you tap.
Here's the part most people miss. The frontend doesn't run on your server. The browser downloads it, and it runs on the guest's own phone or laptop. Your code travels to their device and lives there.
- · HTML, CSS, JavaScript
- · Showing the page, reacting to taps
- · Quick checks for comfort ("email looks wrong")
- · The database
- · Prices, permissions, stock
- · Payments, emails, secret keys
That has a big consequence. Anything in the frontend can be read by anyone. Every browser has built-in developer tools. With two clicks, a curious guest can read your code, see every request it sends, and change it before it leaves.
So the frontend is like a dining room with glass walls. Perfect for showing things, taking orders, and reacting fast when someone taps. But you can't hide anything in it, and you can't trust what comes out of it.
When Claude Code mentions React, Vue or Svelte, those are tools for building the frontend. They make the dining room nicer to build. They don't change where it runs.
04The backend runs on your server
The backend is the code that runs on your server, the computer from lesson one that stays on in a data centre. Guests can't see it, and they can't change it.
That's why the important jobs live there. It reads and writes the database. It calculates prices. It decides who's allowed to do what. It takes payments, and it sends the confirmation emails.
It also keeps the secrets: the passwords and keys that let your app use other services, like the payment provider. A secret in the kitchen stays secret. A secret in the dining room is a secret no longer.
The backend can be written in almost any language: JavaScript, Python, Go and many others. Some tools, like Next.js, keep both halves in one project. But even then, each piece of code still runs on one side or the other, and that's the question that matters.
05How the two halves talk
So how does a tap in the dining room reach the kitchen? Through the API. When the guest taps Book, the frontend sends a request to the backend, exactly like the requests from lesson one.
Here, the request is a POST, because it sends something. It goes to an address like /api/bookings, and it carries a small message: which room, which dates. That message is written in a format called JSON: names and values, like a filled-in form.
POST /api/bookingssend something to the bookings address{ "room": "suite-12",which room "checkIn": "2026-11-12", "checkOut": "2026-11-15" }which dates201 Createdthe booking was saved{ "booking": "LIS48213", "total": 720 }the backend's own totalThe backend checks the dates, looks up the price in the database, saves the booking, and answers. Status code 201, which means created, plus another small JSON message: the booking number and the total.
In lesson one, the server sent back a whole web page. Many modern apps work differently: the frontend arrives once, then the two halves only exchange these small JSON messages. It's faster, and it's why the API is the heart of your app.
06The rule: never trust the dining room
Now back to Nadia's €7.20. Here's what the booking page did. It calculated the price in the frontend: €240 times three nights. Then it sent the total to the backend, along with the room and the dates.
And the backend trusted that number. So a guest opened the developer tools, changed the total from 720 to 7.20 before the request left their laptop, and the backend charged exactly what it was told.
Hiding the code doesn't fix it. Making it harder to read doesn't fix it either. Anything that runs on the guest's device can be changed by the guest.
The fix lives in the kitchen. The frontend sends only what the guest chose: the room and the dates. The backend looks up the real price in the database and calculates the total itself. Whatever number the browser sends is ignored.
It's not only about money. In another case, a Refund button was simply hidden from guests on the page. The backend never checked who was asking. Within twenty minutes, guests had sent thirty-eight refunds to themselves.
So here is the rule: the frontend can show and ask; only the backend decides. Prices, permissions, stock, anything that matters is checked in the backend, every time. Checks in the frontend are there for comfort, to catch typos quickly. Checks in the backend are there for truth.
07Secrets stay in the kitchen
The same logic applies to secret keys. If your payment key or your AI key ends up in the frontend, it's shipped to every visitor. Automated programs scan public code all day looking for keys, and they often find them within minutes.
Some keys are made to be public. A payment provider like Stripe gives you a publishable key for the browser, and a secret key for the server. The first can show a payment form. Only the second can move money.
Watch for one detail in projects built with Next.js: any setting whose name starts with NEXT_PUBLIC_ is copied into the frontend, on purpose. A secret with that prefix is no longer a secret. It's worth asking your agent to list every one.
| Key | Lives | Why |
|---|---|---|
| Stripe publishable key | Browser | Made to be public: can only show a payment form |
| Stripe secret key | Server only | Can move money |
| AI provider key (OpenAI, Anthropic…) | Server only | Anyone holding it spends your credit |
| Database password | Server only | Opens every booking and every account |
| NEXT_PUBLIC_… settings (Next.js) | Copied into the browser | Fine for public values, a leak for secrets |
08Where to look when it breaks
Knowing the two halves also tells you where to look when something breaks. Developer tools have a tab called Network. It shows every request between the frontend and the backend, with its status code.
If you tap a button and no request appears at all, the problem is in the frontend: the dining room never sent the order. If the request appears with a 500, the backend crashed: the problem is in the kitchen.
And if the request comes back 200 with the right data, but the page still shows the wrong thing, the kitchen did its job and the dining room served it badly. Back to the frontend.
| You see | Look at | Ask Claude Code |
|---|---|---|
| You tap, and no request appears | Frontend | Why doesn't the button send the request? What does the browser console say? |
| The request comes back 500 | Backend | What does the server log say at that moment? |
| The request comes back 404 | Either | Does the frontend call the right address, and does the backend have that route? |
| 200 with the right data, wrong page | Frontend | The data is right; why does the page show it wrong? |
09Your job as lead
You don't need to write either half. But when Claude Code builds a feature, three questions keep you in charge. First: where does this run, on the guest's device or on our server?
Second: does the backend calculate every price and check every permission itself, or does it trust something the browser sent? Third: is any secret key reachable from the frontend?
If the answers are "on the server", "the backend decides" and "no", you're in good shape. If not, you've just found the next €7.20 before a guest did.
Let's recap. The frontend is the dining room: it runs on the guest's device, anyone can read it, and it shows and asks. The backend is the kitchen: it runs on your server, it keeps the secrets, and it decides. The API is the window between them. Below the video, you'll find the text, the diagrams and the questions. See you in lesson three, where we visit the server itself.
Check yourself
0/10 answered1Where does the frontend of a web app run?
2In the restaurant picture, what is the API?
3Nadia's suite (3 nights, €720) was paid €7.20. What was the real cause?
4Claude Code suggests hiding the price calculation by making the JavaScript hard to read. Does that fix the €7.20 problem?
5A Refund button is hidden for guests in the page, but guests still sent 38 refunds. What was missing?
6Which of these belongs in the backend?
7In a Next.js project, Claude Code names a setting NEXT_PUBLIC_PAYMENT_SECRET. What's wrong?
8You tap Book. The Network tab shows no request at all. Where is the problem?
9The request comes back with status 500. Where do you look first?
10Claude Code finishes a checkout feature. Which question best keeps you in charge?
Save your progress — create a free account
Free. No card. Your finished lessons follow you to any device, and you can ask questions in the community.
Create my free accountEvery lesson is free while we build. Lock in €9/month for later.
The first 100 members keep the founding price for as long as they stay. Reserving is free: no card, nothing is charged.
See the founding offer