liveBook · Manning

Backend-for-frontend pattern

As explained in Grokking Software Architecture

A design pattern that provides a dedicated API tailored to a specific user interface or client.

A backend-for-frontend (BFF) is a dedicated, single-purpose API for a particular user interface. Instead of making every client use the same generic API, give each interface an adapter suited to its needs. section 6.4.3

For example:

  • A mobile BFF can strip heavy data to save battery and combine responses from multiple domains. section 6.4.3
  • A general-purpose Core API can use REST, while a warehouse app gets a GraphQL BFF tailored to performance needs. section 6.4.3

The tradeoff is clearer responsibility: the public API handles general access, while the warehouse BFF handles warehouse performance. A dedicated adapter adds flexibility without forcing every client into the same API. section 6.4.3

Figure 6.8 BFF uses a single-purpose API for each instance, allowing much more flexibility.

Shows how separate, single-purpose APIs provide flexibility for different interfaces. section 6.4.3

How Grokking Software Architecture covers it

How deep it goes
Defines the pattern and illustrates its responsibilities with mobile and warehouse examples.
Examples
Uses a mobile adapter that reduces data and a warehouse adapter built with GraphQL.
What you can do after
Evaluate whether a client with distinct needs warrants a dedicated API adapter.
How it connects
Connects REST, GraphQL, and the Single Responsibility Principle through client-specific API adapters.

Also explained in

Compare how 6 books explain backend-for-frontend pattern →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.