skip to content

For a retail-banking web app whose overview combines balances, cards and offers from three back-end services, should the frontend team build a BFF, and what would it own?

level: seniorimportance: should knowfreq 40%

answer

  1. three sources, one screen-shaped payload
  2. fan-out on the fast network
  3. compose and shape, no business rules
  4. owned and on-called by frontend
  5. overkill if the API already composes

basics

~20 s

Yes for this overview: three services with their own auth and error shapes, fanned in over phone networks. A frontend-owned BFF composes one screen-shaped payload and one error envelope; business rules stay in the services. Skip it if the API already serves that endpoint.

solid answer

~40 s

From the frontend's seat, this overview is the case for a BFF: three services, three auth paths, three error shapes, and a screen that wants one payload. A BFF owned by the frontend team exposes `GET /overview`, fans out to the three services on the internal network with a timeout per call, keeps only the fields the screen shows and returns one envelope with a status per section. It should own composition and shaping, not business rules: transfer limits and balance arithmetic stay in the services, or the two copies drift. It costs a deployable, a network hop and an on-call rota the frontend team now carries. If the API team already offers a screen-shaped overview, or the three services sit behind one origin with one error format, the BFF is overkill.

go deeper

for a junior

Recall that a BFF is a server the frontend team runs to give its own screens the payloads they need.

for a middle

Explain what the browser pays without one on this overview: three requests, three error shapes, and stitching and partial-failure logic in the bundle.

for a senior

Draw the line: composition, shaping and error mapping in the BFF, rules and data in the services, and name the conditions that make it overkill.

for a principal

Weigh a frontend-run server's operational cost against an API team shipping screen-shaped endpoints, and how either choice moves the cross-team seam.

## What the overview asks of the contract A **backend-for-frontend (BFF)** is a server-side layer built for one frontend's screens: it calls the back-end services and returns payloads shaped for that frontend. Here the question is not the pattern in general but this screen: the accounts overview of a **retail-banking web app**, which shows balances, cards and offers from three separate back-end services, each owned by another team, each with its own authentication and error format. ## Without a BFF: the browser does the fan-in The SPA can call the three services directly. What the client then pays: - three requests from a phone network instead of one, each with its own latency; - three authentication paths and, if the services live on different origins, cross-origin configuration for each; - three error shapes, so the client needs three interpreters and its own rules for what to show when one fails; - stitching logic in the browser, shipped and executed on every device, plus every field each service returns whether the screen shows it or not. None of this is fatal on its own. Together it pushes server concerns into the bundle and makes the overview the most fragile screen in the app. ## With a frontend-owned BFF 1. The frontend team runs a small service that exposes `GET /overview` to the SPA. 2. It calls balances, cards and offers in parallel on the internal network, each call bounded by its own timeout derived from the screen's load budget. 3. It keeps only the fields the overview renders and maps three error formats onto the one envelope the SPA already understands. 4. It returns a status per section, so one failed service degrades one part of the screen. Where the user's tokens are held when a server sits in the middle is a subject of its own; from the screen's point of view, the browser keeps one session with one origin. The fan-out still happens, but on a short, fast internal network instead of three trips over the user's mobile connection, and the bundle no longer carries the stitching code. ## How to argue it in the round 1. Name the screen's sources and owners: three services, three teams. 2. Price the browser fan-in: requests, error shapes, stitching, partial-failure rules. 3. Propose the BFF and state exactly what it owns and what it does not. 4. Say when you would drop it, before the interviewer asks. ## What it must not own - **Business rules.** Transfer limits, fee calculation and balance arithmetic stay in the services that own the money. A copy in the BFF answers faster until the day it disagrees with the real rule. - **Data of record.** The BFF may cache, but it never becomes the place balances live. - **Other consumers.** Once partners or other clients call it, its shape stops being the screen's to change. ## When it is overkill | Situation | Why a BFF adds little | |---|---| | The API team already serves a screen-shaped overview endpoint | Composition already happens server-side; a BFF only adds a hop | | The three services sit behind one origin with one session and one error format | The browser's fan-in is cheap and uniform | | There is one back-end service | Nothing to compose | | No one on the frontend team can run and on-call a server | The BFF becomes an unowned outage source | The costs are concrete: another deployable on the critical path of the most-visited screen, an extra network hop, monitoring, and a pager for a team that may have run only static assets until now. ## It moves the seam A BFF changes who negotiates with whom. The browser-to-BFF contract now sits inside one team, so changing the overview's payload is a change the frontend team plans alone, although the BFF and the SPA still deploy separately. The cross-team contract moves behind it: when the overview needs a new card attribute, the frontend team asks the cards team as a consumer of their API, then exposes the field to its own screen. The general pattern, and how it compares with a shared gateway, are neighbouring subjects; in a design round, the credit goes to arguing it from this screen's payload and failure modes.

  • The offers service is slow rather than down. What should the BFF do?
    Bound each upstream call with its own timeout so a slow offers call cannot hold balances and cards. When the timer fires, return the overview with offers marked unavailable and retryable, and let the screen fill that section later. The budget comes from the overview's target load time, not from each service's default timeout.
  • Once the BFF exists, how does adding a new card attribute to the overview play out between teams?
    The browser-to-BFF payload is the frontend team's own, so exposing the field there is an internal change. The BFF still needs the attribute from the cards service, so the cross-team request moves behind it: the frontend team asks the cards team for the field as a consumer of their API, waits until it is live, and only then shapes it into the overview.

  • Putting transfer limits or balance arithmetic in the BFF for faster answers
  • Growing the BFF into the general API every client and partner calls
  • Assuming a BFF removes the need for a contract with the services
  • Adding a BFF that no one on the frontend team can run or on-call
  • Treating three parallel browser calls as free because they run concurrently