esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

Backends for Frontend: One Backend per Client Experience, Shaped for Its Screen

One shared backend for every app pushes bloated data and slow releases onto every team. A Backends for Frontend layer gives each client its own tailored API.

In short

Backends for Frontend gives each client experience, such as a phone app or a website, its own backend API shaped for its screen instead of one shared backend.

12 min readFree

What You Will Learn

This lesson explains Backends for Frontend, often shortened to BFF. It is a way to design the server side of an app. You will learn why one shared backend can cause trouble, how a BFF fixes that, what a BFF usually does, where it costs you something, and when it is not worth building. A worked example uses the home screen of a streaming app, so you can see the idea in use.

Key words

Client
The app a person actually uses, such as a web page, a phone app, or a TV app.
Backend
The server code that does the work behind the scenes, out of the user's sight.
API
Short for application programming interface. It is a set of rules that lets one program ask another for data, usually over the internet.
Payload
The data sent back in one reply, such as the fields and images in a response.
Round trip
One request sent over the network and one reply received back. Each round trip takes time.
Downstream service
A service that another part calls to get its data, such as a catalog of titles or a list of stock levels.
General-purpose API
One shared API built to serve every kind of client at once.
BFF
Backend for Frontend. A small backend built for one client experience.

What Is the Problem with One Shared Backend?

Many products start small. A team builds a website and one backend that the website calls. Later, the company adds a phone app. Then a smart-TV app. Each new client wants something a little different, but they all still call the same backend. This is the usual starting point for the problem that BFF solves. A first step is often to keep one shared API and add features to it over time. That works well when every client asks for nearly the same things. It works badly when the clients differ a lot.

Phones and websites differ in more than screen size. A phone has less room to show data, and many calls over the network can drain its battery and use up a limited data plan. The actions people take also differ. A shopper on a desktop may browse and order, while a shopper in a store may scan a barcode. So a phone wants different calls, fewer calls, and less data. Adding all of that to one shared API makes the API harder to understand and harder to change.

Teams also feel the pressure. A shared API is one deployable piece that many teams change at the same time. When it grows, a group is often created just to look after it. Frontend teams then have to ask that group for every change.

How Does a Shared Backend Hurt?

  • Bloated responses

    The shared API returns every field that any client might want. A phone then downloads data that its small screen never shows.

  • Extra round trips

    A client that needs several kinds of data may have to make several separate calls. Each call costs a round trip, so the screen loads more slowly.

  • Conflicting change requests

    One team's requested change can break another team's screen. Teams must agree before they merge changes, which takes time.

  • Slow releases

    Every client depends on the same shared code. One team's release can wait on others, so each team moves more slowly.

What Is the Solution of One BFF Per Client Experience?

The BFF idea is simple. Instead of one general-purpose backend for all clients, you build one backend for each type of client. A web app gets its own BFF. A mobile app gets its own. A TV app gets its own. Each BFF sits between its client and the shared services. The client talks only to its BFF, and the BFF talks to the downstream services. This layer, known as the backend-for-frontend (BFF) service, sits between the frontend client and the backend service.

The BFF is small on purpose. It serves one kind of screen, so it only needs the code for that screen. Backends for Frontends creates separate backend services for different types of clients, such as desktop and mobile. When you take this approach, a single backend service doesn't need to handle the conflicting requirements of various client types. Each client now gets an API shaped for its own needs. The BFF introduces a client-specific API layer that shapes, aggregates, and optimizes data for the consuming experience.

Who Owns Each BFF?

One useful point about BFFs is who owns them. The frontend team that builds a client should also build and run its BFF. That way the team can change the API as fast as it changes the screen. Each BFF is owned and shaped by the frontend team it serves. Sam Newman, in his write-up, cites Stewart Gleadow for a helpful rule, 'one experience, one BFF'. If two apps have very similar screens, one shared BFF can be enough. If they differ a lot, give each its own BFF. Team structure matters too. If iOS and Android have separate teams, separate BFFs usually make sense.

What Does a BFF Do on Each Request?

A BFF does a few clear jobs. It is easiest to see them as the steps of one request. The steps below describe a typical flow. Your own design may differ.

  1. 1

    Receive one request

    The client sends one request to its own BFF, asking for a whole screen of data instead of many small pieces.

  2. 2

    Call downstream services

    The BFF calls the services it needs. Where the calls do not depend on each other, it runs them at the same time to save waiting time.

  3. 3

    Trim and reshape

    The BFF combines the answers and keeps only the fields this screen uses. It transforms data into the exact shape the frontend needs and filters fields the client doesn't need, which reduces payload size.

  4. 4

    Handle client concerns

    The BFF deals with needs that belong to one client, such as payload size, the sign-in flow, and the protocol the client speaks. When you handle individual clients differently, you can optimize performance for a specific client's constraints and functionality.

  5. 5

    Return a fitted reply

    The BFF sends back one reply shaped for its screen. If one downstream service fails, the BFF can still return the parts that worked, with the missing part left out, rather than failing the whole screen.

Tip

Keep the BFF focused on its own client. Rules that every client shares, such as checking who a user is or limiting how often someone may call, are better placed in a gateway or a shared service. Microsoft's guidance says that cross-cutting features like monitoring and authorization should be handled separately. It's imperative that the BFF service contains only client-specific logic and behavior.

Worked Example: A Streaming Home Screen

Here is an illustrative example. It is made up to show the idea, and it is not a description of any real company's design. Imagine a streaming service with three downstream services. The catalog service knows the titles and their artwork. The recommendations service suggests shows for each viewer. The watch-history service remembers what each viewer has already watched. The home screen needs data from all three. The TV app and the phone app show the same home screen, but they need different data.

  1. 1

    Open on the TV

    A viewer opens the home screen on a smart TV. The TV app makes one call to the TV BFF.

  2. 2

    TV BFF gathers data

    The TV BFF calls the catalog, recommendations, and watch-history services. It builds long rows of titles and attaches large artwork, because a TV screen is big and the viewer scrolls with a remote.

  3. 3

    TV reply

    The TV BFF returns the rows and images in one reply. The TV app shows them without doing any extra work.

  4. 4

    Open on the phone

    A viewer opens the same home screen on a phone. The phone app makes one call to the mobile BFF.

  5. 5

    Mobile BFF trims

    The mobile BFF calls the same three services. It keeps fewer titles per row and uses small thumbnails, so the reply is smaller and saves data and battery.

The code below copies this idea in a tiny form. Both views read the same catalog item, but each one returns only what its screen needs. The numbers are made up for the demo.

Python
catalog_item = {"title": "Night Train", "artwork_px": 1920, "cast": ["Ana", "Ben"], "synopsis": "A long story."}

def tv_view(item):
    return {"title": item["title"], "image_px": item["artwork_px"], "cast": item["cast"], "synopsis": item["synopsis"]}

def mobile_view(item):
    return {"title": item["title"], "image_px": 320}

print(tv_view(catalog_item))
print(mobile_view(catalog_item))

Output

{'title': 'Night Train', 'image_px': 1920, 'cast': ['Ana', 'Ben'], 'synopsis': 'A long story.'}
{'title': 'Night Train', 'image_px': 320}

Notice what did not change. The catalog, recommendations, and watch-history services are the same for both clients. Only the two BFFs differ. A change to the TV screen touches the TV BFF and nothing else, so the phone team is not blocked.

Trade-Offs of Using BFFs

A BFF is not free. It solves real problems, but it also adds work. Before you add one, weigh the costs against the benefits.

  • More services to run

    Each BFF is a separate service with its own release cycle, monitoring, and security. Because of this separation, the security and authorization in the service layer that support one client can be tailored to the functionality provided by that client. That is a benefit, but you still have to run and watch each one.

  • One extra hop

    The client now talks to a BFF, and the BFF talks to the services. That extra step can add delay, so check the speed goals for each screen after you add one.

  • Duplicated logic

    Two BFFs may each write the same code for the same job, such as turning a raw record into a display label. Code duplication is a probable outcome of this pattern. Teams must decide when to copy code and when to share it.

  • Bloat over time

    A BFF shared by many kinds of clients can grow messy. Keeping one BFF for one kind of client helps avoid this.

When a BFF Is Overkill

BFFs fit when clients have clearly different needs. The pattern exists to avoid customizing one backend for several interfaces. The pattern may not suit you when interfaces make the same or similar requests, or when only one interface talks to the backend. In that case, a single shared API is simpler and cheaper to run. A BFF is also less useful when you use GraphQL with resolvers made for each frontend, because the client can then ask for the exact fields it needs. If you already use GraphQL with frontend-specific resolvers, separate BFF services may add no value.

Scale changes the answer too. For a small number of backend services, a BFF is a nice extra. For a larger system with many services, a BFF can become close to essential, because one screen may need data from many services.

Tip

Ask two questions before you build a BFF. Do the clients really need different data and calls? Is there a separate team for each client? If both answers are no, a shared API is probably enough.

Quick check

A shopping company's mobile app needs a tiny order summary on slow networks. Its web dashboard needs full order details and analytics. The two teams keep blocking each other's changes to one shared API. Which approach fits best?

Quick check

A small team builds one internal web page for staff. The page calls one backend, and no other app uses that backend. Should the team add a BFF?

Key Takeaways

  • The core idea

    Give each client experience its own backend. Each BFF returns data shaped for its own screen, and it calls the shared services underneath.

  • The main benefit

    Frontend teams can change their own API and release on their own schedule, with smaller payloads and fewer calls for each client.

  • The main cost

    You run more services, may add one network hop, and may copy some code between BFFs.

When you design a system, ask who the clients are and how different their screens are. If the answer is 'very different, and owned by different teams,' a BFF is worth considering. If the answer is 'almost the same,' keep one shared API.

Sources

How is this lesson?

Last updated on 18 November 2026

Learn with me

Every lesson is free. I add new ones as I learn. Have a question, or want help with your own work? Book a short call.