Course contentsShow
← System Design
Lesson 902 of 1,91923. API Gateway PatternFree lesson

Backend-for-Frontend (BFF) Pattern Overview

Understanding BFF as specialized API gateways per client type, addressing different client needs and experience requirements.

Backend-for-Frontend (BFF) Pattern Overview

What you'll learn: How the BFF pattern uses specialized API gateways tailored to specific client types, rather than forcing all clients through one generic gateway.

The Problem with One-Size-Fits-All Gateways

Traditional API gateways route all client types—mobile apps, web browsers, smart TVs, IoT devices—through the same interface. But here's the challenge: each client has vastly different needs. Mobile apps need minimal, battery-efficient payloads. Web dashboards want rich data for complex visualizations. IoT devices require ultra-lightweight responses.

Forcing every client through a single gateway creates awkward compromises. You either bloat mobile responses with unnecessary data or starve web clients of the information they need.

Understanding the BFF Pattern

The Backend-for-Frontend pattern creates dedicated API gateways for each client type. Think of it like specialized translators at the United Nations—rather than one translator struggling with every language pair, each translator specializes in specific languages and cultural contexts.

A BFF sits between each client application and your microservices backend:

  • Mobile BFF: Optimizes for limited bandwidth, touch interfaces, and offline capabilities
  • Web BFF: Aggregates data for rich dashboards and complex UI requirements
  • Smart TV BFF: Handles remote control navigation patterns and low-resolution constraints
  • Partner API BFF: Enforces third-party rate limits and compliance requirements

Each BFF speaks its client's language, transforming backend service responses into exactly what that specific client needs—no more, no less.

Benefits Over Generic Gateways

BFFs prevent the "lowest common denominator" problem. Frontend teams can evolve their BFF independently without impacting other clients. You avoid complicated conditional logic like "if mobile then simplify, else elaborate" scattered throughout your gateway layer.

Key Takeaway: The BFF pattern treats API gateways as client-specific interfaces rather than generic routers, allowing each frontend to get precisely the experience and data format it requires without compromise.