Working With APIs

Frontend vs. Backend

Learn about the frontend/backend model.

Why learn about frontend and backend?
Permalink Get a link to this section

The frontend–backend model is a way of sharing or organizing an application's workload.

When building applications, it is useful to know which is part is your frontend and which is your backend. Generally, a good backend focuses on secure and efficient request processing and content management, and a good frontend focuses on secure and efficient request gathering. But it all depends on the needs of the service.

The frontend–backend model
Permalink Get a link to this section

Every application (or service) has a frontend and a backed. The frontend is the part of the application that receives input from a client. The backend is the part of the application that processes information like processing a payment or looking up customer information. In most cases, the backend also returns the result of its processing to the frontend so it can be passed back to the client. For example, an application using the Square APIs might have a frontend that users interact with to provide credit card details and a backend that use Square APIs to charge their card for a purchase.

The key thing to understand is that the backend processes information and the frontend receives input from a client. A client is anything that makes a request of a service. In simple systems, the client may be a human being, but in complex systems, the client may be another piece of code. As an example, consider a simple system that includes a website with a basic form for collecting newsletter subscriptions.

  • The application (or service) is the website.

  • The client is the person visiting the website.

  • The frontend is the HTML, CSS, and JavaScript that renders the form in the browser and validates input.

  • The backend is the server code that processes the form results.

In more complicated systems, where work is distributed across multiple applications with specialized functionality, the backend of one service can become the client for the frontend of another service. For example, if the newsletter website stores the email addresses it collects in a database, the system now includes two services: the website and the database.

When the site visitor enters their email address, the website frontend sends a request to the website backend to save the address. But to complete the request, the website backend must send a request to the database frontend to update the table of email addresses. The website backend is the client for the database frontend.