Working With APIs

Frontend versus Backend

Learn about the frontend and backend of an application and the types of tasks that each end performs.

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 part is your frontend and which part is your backend. Generally, a good backend focuses on secure and efficient request processing and content management. A good frontend focuses on secure and efficient request gathering. It all depends on the needs of the service.

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, such as 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 Square APIs might have a frontend that users interact with to provide credit card information and a backend that use Square APIs to charge their cards for purchases.

The key concept 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 might be a human being, but in complex systems, the client might 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 render the form in the browser and validate input.

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

In more complex 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 an email address, the website frontend sends a request to the website backend to save the address. 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.




Idempotency >