How Frontend, Backend, and Database Work Together
The frontend shows what users see, the backend handles the logic, and the database stores the data. A web app works by passing requests and responses between these layers.
What happens when your app needs data?
- Someone clicks something on your site, or opens a page that has to load.
- The frontend sends a request to the backend — “here is what this person wants”.
- The backend decides what should happen: it checks the request, applies your rules, and works out what is needed.
- If data is involved, the backend reads it from the database, or writes something new into it.
- The backend sends the result back to the frontend.
- The frontend updates the screen, and the person sees the answer.
The three main layers
Your visitor — A real person in a browser or an app. They click, type or open a page — and that action is what sets everything to the right of it in motion.
The frontend — The part that runs in the browser: the pages, the buttons, the layout, the text. It shows what people see and collects what they do, then asks the backend for anything it does not already have.
The backend — Your app's logic, running on a server instead of in the browser. It receives requests from the frontend, checks whether they are allowed, works out what should happen, reads or writes the database when data is involved, and sends an answer back.
The database — Where information stays after the browser is closed: accounts, orders, posts, settings. The frontend never reaches it directly — the backend is what reads from it and writes to it, which is what keeps your data under your own rules.
Do you always need all three?
Not every project needs all three. A site that shows the same thing to everyone is a frontend and nothing else: the pages are already written, so there is no request to decide about and nothing to look up.
A backend and a database start earning their place the moment something on your site is different for different people, or has to still be there after the browser is closed.