Backend for Frontend (BFF)

One backend for each frontend.

“A dedicated backend service for a specific frontend interface.”

Optimization.

graph TD
    MobileApp -->|API| MobileBFF
    WebApp -->|API| WebBFF
    MobileBFF -->|Calls| S1[Service A]
    MobileBFF -->|Calls| S2[Service B]
    WebBFF -->|Calls| S1

When to use

  • Multiple clients: Mobile, Web, Watch, TV.
  • Different requirements: Mobile needs less data to save bandwidth.

Explanation

Instead of a generic “One API fits all” (which often over-fetches or under-fetches), create a layer specifically for the Mobile App that interacts with the downstream services and formats the response perfectly for Mobile.

Pros and Cons

Pros Cons
  • Optimized payloads
  • Code duplication (logic in multiple BFFs)
  • Faster FE development
  • Maintenance
  • Code example

    Conceptual