Skip to content
API Design Learn/API Gateways & Aggregation
Browsing as a guest. Sign in to save your progress and earn XP as you complete chapters.

Backend for Frontend

4 min read

You'll learn to

  • -Explain the compromise a single shared API makes between web, mobile and partner clients
  • -Show a BFF trimming a mobile response and a web BFF combining services, with measured sizes
  • -Weigh BFF against GraphQL, and decide when the extra services are worth it

A single gateway API that serves every kind of client, a web app, an iOS app, an Android app, a partner integration, tends to collect compromises. There are fields the mobile app does not need but the web app does, and response shapes tuned for one client's screen that fight another's. Backend for Frontend (BFF) answers this by giving each client type its own dedicated backend layer, shaped around what that client needs.

An Analogy: One Menu for Everyone vs. a Waiter per Table

A restaurant with a single printed menu for everyone must serve the toddler, the diner with an allergy, and the food critic from one list. A restaurant that gives each table its own waiter, who knows what that table wants and brings only that, avoids the compromise. The price is more waiters. A BFF is a waiter per kind of client.

One Gateway, Many Compromises

A shared response trying to serve both a rich web dashboard and a lightweight mobile app
{
  "id": 501,
  "customer": { "id": 42, "name": "Ada Lovelace", "billing_address": {...}, "order_history_summary": {...} },
  "line_items": [...],
  "shipping_details": {...},
  "internal_fulfillment_notes": [...],
  "audit_trail": [...]
}
// mobile app needs maybe 4 of these fields; the rest is wasted bandwidth
// on every mobile request

A BFF Per Client Type

A mobile-specific BFF returning exactly what the mobile app needs
// GET /mobile-bff/orders/501
{
  "id": 501,
  "status": "shipped",
  "total": 149.99,
  "tracking_number": "1Z999AA10123456784"
}

Each BFF sits between its client and the underlying domain services, gathering and shaping data for that client alone. A mobile BFF might trim payloads hard for slow connections. A web-dashboard BFF might combine data from several services into one rich response, to cut round trips for a data-dense screen. Neither client compromises for the other any more. The demo measures it: one order object with everything in it, a mobile BFF that keeps four fields, and a web BFF that adds data from another service.

Press Run: the mobile BFF sends a small fraction of the shared response

The Real Cost: More Services to Maintain

A BFF per client type means more services to deploy, monitor and put on call. That is a genuine cost, not a free win. It earns its place when client needs have diverged enough that a shared API is an ongoing source of friction, not a one-off annoyance, and when each BFF can be clearly owned, often by the same team that owns the matching frontend, so the BFF and its client evolve together.

BFF vs. GraphQL: Overlapping, Not Identical

GraphQL attacks a similar problem, letting each client fetch exactly the shape it needs, from another side: one shared schema with queries chosen by the client, instead of several bespoke backends. GraphQL avoids the many-services cost of BFF. But it centralizes schema changes and resolver logic in one place, which brings back some of the shared-bottleneck coordination that BFF avoids. Neither is better in general. The choice depends on whether your team structure favors one shared schema everyone contributes to, or genuinely independent per-client backends.

A useful test before adopting BFF: is the pain really "different clients need different data shapes", or is it "our one API has grown badly designed for everybody"? BFF solves the first problem. For the second, it only relocates and multiplies it.

Interview Signal is part of Pro

See a real weak answer next to a real strong one for this exact topic.

Quiz is part of Pro

Test what you just read with a short quiz, and bank the XP.

Ready to Build This?

Design BFF Workshop in the API Design Lab's Full System Design act.

Discussion0

Join the Discussion

Sign in to leave comments, reply to others, or like insights.

Sign In to ScaleDojo

No comments yet. Be the first to start the thread!