Skip to main content

Backend For Frontend (BFF) Services

Backend for frontend (or BFF for short) services, as the name suggests, are the backend services that provide accessible APIs for a Frontend Service. They are responsible for providing the data and functionality that the frontend services need to present to the user. They are also responsible for translating requests from the frontend services into requests to the Business Services.

BFFs are not tied to a single Business Service, so have the power to combine data from multiple Business Services (also called aggregation) to provide a single, unified view of the data to the frontend service. This is useful for providing a consistent user experience across multiple frontend services, or for providing a single view of data that is spread across multiple Business Services.

BFFs are lightweight services that are designed to be stateless and horizontally scalable. They are also designed to be short-lived, so that they can be restarted at any time without losing any data. This makes them ideal for handling requests from frontend services, which are often stateless and short-lived themselves. Often you will find that a BFF is a simple proxy that forwards requests to the appropriate Business Service.

By separating the frontend requirements from the business requirements, BFFs allow the frontend services to be developed independently of the business services. This allows the frontend services to be developed more quickly, and also allows the frontend services to be developed by different teams to the business services. Furthermore, it allows the frontend services to be developed using different technologies to the business services, which can be useful for providing a consistent user experience across multiple frontend services. Finally, it allows BFFs to implement (and store if neccessary), frontend logic that is not part of the business logic, such as search preferences, user preferences, or user session management.

Service Architecture

Source

Requests and Responses

BFFs take requests from frontend services and translate them into requests to the business services. They then take the responses from the business services and translate them into a format that is suitable for the frontend services. This is because the frontend services are not designed to be aware of the business services, and so they are not designed to understand the data that the business services return. BFFs are not proxies - The BFFs are responsible for translating the data into a format that is suitable for the frontend services.