Below the Fold

A designer’s path to creative technologist. Thirty days, ten minutes each, on how software actually gets made.

Screen, server, database A screen, a server box, and a database cylinder in a row, joined by lines, with a red arrow arcing from the screen to the server.

Frontend, backend, database

After today, you can name the three jobs inside almost every product and trace one tap from the screen to stored data and back.

Dip your toes 1 min

Above the infrastructure, the machines and networks underneath, almost every product splits its work three ways. The frontend is the app that shows things on your screen. The backend runs on the company’s servers, computers that answer many people at once, and decides who may see or change what. The database stores information safely and finds it fast. Add a show to My List on Netflix from your phone, and that evening it’s waiting on your TV. Neither device keeps the official copy. Each one asks the backend, which checks your account and fetches your list from the database. The backend also shapes what you see. Netflix picks artwork for each member, so two people with the same show saved can see different posters for it.

The full lesson 10 min

Why this exists

Add a show to My List on Netflix from your phone on the bus. That evening, turn on the TV, and the show is waiting in the same row. Your phone and your TV never talked to each other. So the list can’t live on either device. It has to live somewhere both of them can reach.

That one fact explains why, above the infrastructure, almost every product splits its work three ways. Something has to show the list on whatever screen you’re using. Something has to remember the list for years, for hundreds of millions of people. And something in between has to decide who gets to see or change which list. Netflix, Slack, your bank’s app, and most of what you use every day divide the work this way.

Each job needs different strengths, which is why they live in different places. Showing needs to be fast and close to your hand. Remembering needs to be safe and never lose anything. Deciding needs to happen somewhere the company controls, because the decisions protect everyone’s data, not only yours.

Show, decide, rememberThree columns labeled show, decide, and remember. Your phone and your TV both connect to Netflix’s backend, which connects to the database that holds My List.ShowDecideRememberYour phoneYour TVBackendDatabaseNetflix appNetflix appDecides accessHolds My List
Figure 1. Your phone and your TV each reach the same list through Netflix’s backend. Look at where My List lives: in the database, one place every device reaches through the backend.

The phone and the TV never keep the official copy. Each one asks for it when it needs it. It may keep a copy for a while, but the backend’s copy is the one that counts. Every change goes through the backend into the database. So a show you add on your phone is there the next time your TV asks.

What it is

The three jobs have familiar names. The frontend shows. The backend decides. The database remembers. What’s new today is how they talk.

The backend runs on servers. A server is a computer, or a program running on one, that answers requests from many clients at once. Remember that a client is any program that asks a server for something, like the Netflix app on your TV. The word “server” describes the role, not the hardware: it serves answers. A product the size of Netflix runs its backend on many servers at once, but for today, picture them as one.

The data lives in a database. A database is a program built to store information safely and find it fast, even while many requests read and change it at once. It keeps My List for every profile, along with accounts, viewing history, and the catalog of titles. A database can find one profile’s list among hundreds of millions in a few thousandths of a second.

The pieces talk in pairs of messages. A request is a message a client sends to a server, asking it to send something or do something. A response is the server’s answer, carrying what was asked for or an explanation of what went wrong. Between the backend and the database, the request has its own name. A query is a question sent to a database, asking for or changing specific stored records.

Here is a simplified version of what happens when you open My List.

  1. The app sends a request to Netflix’s backend: send me this profile’s list.
  2. The backend checks that the request comes from a signed-in account that owns this profile. Then it sends a query to the database.
  3. The database answers with rows: one row per saved title, with the date you added it.
  4. The backend turns those rows into a response the app can use: titles, artwork, and order.
  5. The app draws the row of posters on your screen.
Opening My List, step by stepThree stacked parts: the Netflix app, the backend, and the database. The app asks the backend for this profile’s list, the backend checks the account and queries the database, the database returns rows, the backend sends titles and artwork back, and the app draws the row.You open My ListFrontendBackendDatabaseThe Netflix app on your TVNetflix’s servers decideRemembers every profile’s list14235This profile’s list?Titles and artworkCheck, then queryRowsDraws the row
Figure 2. Opening My List on Netflix, five steps out and back. Look at the backend. It’s the only box that talks to both of the others, and it decides what goes in each direction.

Step 2 is the query. Databases are often asked questions in SQL (Structured Query Language). Netflix’s real storage is different, but here is roughly what such a question could look like, with made-up names:

SELECT title_id, added_at
FROM my_list
WHERE profile_id = 'p_48213'
ORDER BY added_at DESC;

Read it as a sentence. Get the title and the date added from the My List records, only for this one profile, newest first. The app never sees this query. It only sees the finished response in step 4. The backend builds that response from the rows and from other data it looks up along the way.

That building step does more than reformat. In step 4, the backend decides which artwork to send for each title. Netflix’s engineers described in a 2018 public talk how they pick artwork per member, based on what that person tends to watch.

Two people with the same show in My List can see different posters for it. The frontend draws whatever it’s told to draw. The deciding happened one layer down.

Changing data takes the same trip. When you add a show to My List, the app sends a request asking the backend to add one title. The backend checks the profile, then sends a query that writes a new row. The response is short, often little more than “done.” Only then can the app be sure the show is saved.

The whole trip, from tap to posters, usually takes a fraction of a second. Each step is fast on its own, but the steps happen one after another, and each one can fail. Day 9 covers how requests travel across the internet.

How it shows up in your work

When you spec out something new for a screen, two questions decide most of its size. Is the information already stored, or does the database need to start remembering something new? And is there a rule about who may see or change it? “Show the date each title was added” is a small change, because the date is already stored. The backend only has to send it.

“Show which friends saved this title” is different. It needs new stored data, new rules about privacy, and new drawing.

What three requests changeA grid with three requests as rows and frontend, backend, and database as columns. Bigger posters changes only the frontend layout. Showing the date added changes the frontend and the backend, and the date is already stored. Showing which friends saved a title changes the frontend, needs new privacy rules in the backend, and needs new data in the database.FrontendBackendDatabaseBigger postersShow the date addedShow friends who saved itNew layoutDraw the dateSend the dateDraw facesPrivacy rulesNew dataAlready stored
Figure 3. Three requests for the My List row, and which of the three jobs each one changes. Look at the one cell that needs new stored data. That’s what turns a small request into a large one.

The friends row is the expensive one, and not because of the drawing. The database has to start remembering something it never stored. The backend needs rules for which friends’ choices you’re allowed to see. Each of those is design work too, and you can shape it early: should friends be able to hide what they’ve saved?

At handoff, engineers often ask what data a screen needs before they build it. You can answer that better than anyone, because you know every field in the design. A list of fields per screen, marked “already exists” or “new,” saves a round of back and forth. It also surfaces the expensive ones early, while the design can still change.

Then there’s the wait. Every request is a round trip, and every round trip takes time and can fail. A screen that makes one request has one moment of waiting. A screen that needs five separate pieces of data might make five requests, and any of them can come back late or broken.

Ask how many requests a screen makes and which ones the screen can’t show anything without. Those are the ones where your loading and error states matter most.

The one thing people get wrong

The natural picture has the app reading your list straight from the database, because the screen and the data feel like one thing. But the app never touches the database. Every request goes through the backend, and that isn’t only tidiness. There are three reasons it has to work this way.

No direct path from the app to the databaseTwo boundaries. Inside your device is the Netflix app. Inside Netflix’s servers are the backend and the database. The app sends requests to the backend, and the backend queries the database using a password and access rules it keeps. A red dashed path from the app toward the database stops at the edge of Netflix’s servers, marked blocked.Your deviceNetflix’s serversBlockedFrontendBackendDatabaseNetflix appChecks requestsMy ListDatabase passwordAccess rules
Figure 4. The app can reach the backend, but it has no path to the database. Look at what only the backend holds: the database password and the rules for using it.

The first reason is the password. To connect to a database, a program needs its address and a password. Anything inside an app ships to every device that installs it, and anyone determined can dig it out. If the Netflix app held the database password, anyone could use it to read every profile’s list, or erase them. So the password lives only on the backend, inside Netflix’s servers.

The second reason is the rules. A database answers any well-formed query from a program that has its password. It doesn’t know that you should see your own list and nobody else’s. The backend adds that rule to every query, in step 2 of Figure 2.

Day 1 said the frontend can hide a button but only the backend can enforce the rule behind it. This is where the enforcing happens: between the request and the query.

The third reason is change. Netflix runs on smart TVs, game consoles, phones, and browsers, and many of those devices rarely update their apps. If every app spoke to the database directly, the team could never reorganize how data is stored without breaking old TVs. With a backend in the middle, the database can change shape while the backend keeps answering the same requests. The backend works as a stable go-between.

Some products seem to break this rule. Tools like Google’s Firebase let an app read and write data with no backend code from the team. Look closer, and the service runs its own backend, with security rules the team writes to decide who can read what. The three jobs are still there. Someone else is running the middle one.

Ask an engineer this

“When this screen loads, what does the app ask the backend for, and what does the backend ask the database?”

Bring it up while you’re both looking at a screen you designed, ideally one that feels slow or does a lot. Most engineers can name the requests the screen makes and the queries each one triggers. Watch for data that gets looked up more than once, or a screen that waits for something it doesn’t show right away. Then ask which of those steps is the slowest. You’ll come away knowing what your screen costs to load, and which design choices drive that cost.

Terms from today

Server
A computer, or a program running on one, that answers requests from many clients at once.
Database
A program built to store information safely and find it fast, even while many requests read and change it at once.
Request
A message a client sends to a server asking it to send something or do something.
Response
The server’s answer to a request, carrying either what was asked for or an explanation of what went wrong.
Query
A question sent to a database, usually written in a language like SQL, that asks for or changes specific stored records.
Next

Day 7: How a feature gets built

Ticket, branch, pull request, review, merge, deploy. One walkthrough of the loop every team runs.

6

Frontend, backend, database

All 30 days