Backends for Frontends Pattern


Backends for Frontends Pattern (BFF Pattern)

In this tutorial, we are going to talk about Design Patterns of Microservices Architecture which is Backends for Frontends Pattern. We will use this pattern and practice when designing microservice architecture.

Backends for Frontends pattern basically separate API Gateways as per the specific frontend applications. So we have several backend services which are consumed by frontend applications and between them, we put API Gateway for handling to routing and aggregate operations.

But this makes a single-point-of-failure. So In order to solve this problem, BFF offers to create several API Gateways and group the client applications according to their boundaries and split them into different API Gateways.

single and complex API Gateway can be risky and become a bottleneck in your architecture. Larger systems often expose multiple API Gateways by grouping client types like mobile, web, and desktop functionality. BFF pattern is useful when you want to avoid customizing a single backend for multiple interfaces.

So we should create several API Gateways as per user interfaces. These API Gateways provide to best match the needs of the frontend environment, without worrying about affecting other frontend applications. The Backend for Frontends Pattern provides direction for implementing multiple gateways.

Backends for Frontends Pattern

Look at the image. There are 3 API Gateways, one for the Web, one for the Mobile, another for the Desktop applications.

So by following the “Backend for Frontend” (BFF) pattern, we have created 3 API gateways that can provide different APIs tailored for each client application type.

For example, in this image, a mobile client needs different API requirements and can be developed specific APIs into API Gateway Mobile services. In the example of different requirements, you can think product listing page, and think that listing productspagingsorting can differentiate some specific cases.

As you can see that we have understood the Backends for Frontends pattern, so now we can apply this pattern in our e-commerce architecture.

Design Backends for Frontends pattern BFF — Microservices Communications Design Patterns

We are going to iterate our e-commerce architecture by adding more API Gateway patterns according to Backends for Frontends pattern BFF.

Backends for Frontends Pattern

As you can see that we have added several API Gateways in our application. These API Gateways provide to best match the needs of the frontend environment, without worrying about affecting other frontend applications.

The Backend for Frontends pattern provides direction for implementing multiple gateways. Now we can continue with the other Microservices Communications Design patterns.

Backends for Frontends Pattern

Scroll to top