Backends for Frontends Pattern — BFF

In this article, we are going to talk about Design Patterns of Microservices Architecture which is Backends for Frontends Pattern. As you know that we learned practices and patterns and add them into our design toolbox. And we will use these pattern and practices when designing microservice architecture.

By the end of the article, you will learn where and when to apply Backends for Frontends Pattern into Microservices Architecture with designing e-commerce application system with following KISS, YAGNI, SoC and SOLID principles.

Step by Step Design Architectures w/ Course

I have just published a new course — Design Microservices Architecture with Patterns & Principles.

In this course, we’re going to learn how to Design Microservices Architecture with using Design Patterns, Principles and the Best Practices. We will start with designing Monolithic to Event-Driven Microservices step by step and together using the right architecture design patterns and techniques.

Backends for Frontends Pattern

Backends for Frontends pattern basically separate API Gateways as per the specific frontend applications. So we have several backend services which’s 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 grouping the client applications according to their boundaries and split them different API Gateways.

A single and complex API Gateway ca be risky and becoming a bottleneck into your architecture. Larger systems often expose multiple API Gateways by grouping client type 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.

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

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

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

As you can see that we have understand 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 with adding more API Gateway pattern according to Backends for Frontends pattern BFF.

As you can see that we have added to 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.

Step by Step Design Architectures w/ Course

I have just published a new course — Design Microservices Architecture with Patterns & Principles.

In this course, we’re going to learn how to Design Microservices Architecture with using Design Patterns, Principles and the Best Practices. We will start with designing Monolithic to Event-Driven Microservices step by step and together using the right architecture design patterns and techniques.

--

--

Mehmet Ozkaya
Design Microservices Architecture with Patterns & Principles

Software Architect | Udemy Instructor | AWS Community Builder | Cloud-Native and Serverless Event-driven Microservices https://github.com/mehmetozkaya