> For the complete documentation index, see [llms.txt](https://yunaeecy.gitbook.io/wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yunaeecy.gitbook.io/wiki/need-to-remember/bff.md).

# BFF

Backend for Frontend

Credit:

{% embed url="<https://blog.bitsrc.io/bff-pattern-backend-for-frontend-an-introduction-e4fa965128bf>" %}

You self-contained APIs should be in the microservices layer.

BFF is a translation layer between the client and the services.

When data is returned from a service API, the purpose of it is to transform it into the data type specified by the client application.

The BFF will do the following.

* Call the relevant microservices APIs and obtain the needed data
* Format the data based on the frontend representation
* Send the formatted data to the frontend

If your application depends on microservices and consumes many external APIs and other services, it is better to use a BFF to streamline the data flow and introduce a lot of efficiency to your application.

Purpose of having a BFF is to provide your client a focused interface to connect with. For example, data consumption by a mobile UI could be different from data consumption by a browser. In that case, for better data representation, two BFFs can be used.

<figure><img src="https://206398537-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7fGxYFvZDLzWe4Z2ZOfR%2Fuploads%2FaG8ySAju91kZr7f2VAwJ%2Fimage.png?alt=media&amp;token=7c751d95-e763-4737-9a71-5f0b8e25a60d" alt=""><figcaption></figcaption></figure>
