• ↑↓ pour naviguer
  • pour ouvrir
  • pour sélectionner
  • ⌘ ⌥ ↵ pour ouvrir dans un panneau
  • ←→ pour naviguer
  • esc pour rejeter
⌘ '
raccourcis clavier

The Problem

One backend serving web, iOS and Android ends up bloated — how do you tailor backend responses for each front end without duplicating logic?

Formal Definition

Per Wikipedia: “The Backend for Frontend pattern provides a separate backend service per front-end type that aggregates and shapes data for that UI.”

Explanation

Like a concierge for each hotel wing — web concierge and mobile concierge both call the same kitchens but pack the tray differently.

How It Works

  1. Identify front ends needing different shapes
  2. Create BFF service per front end
  3. BFF calls downstream microservices
  4. BFF aggregates and trims payload
  5. Front end calls only its BFF

Visual Explanation

bff_pattern A Web UI B BFF Layer A->B step 1 C Microservices B->C step 2

Semantic Network

semantic_bff_pattern THIS BFF Pattern REL1 Related THIS--REL1 related REL2 Prereq THIS--REL2 builds from

Key Properties

  • Reduces over-fetching for mobile
  • Lets each UI evolve independently
  • Adds operational overhead of extra service
  • Should not contain business logic

Real-World Example

 # BFF aggregates
def get_home(user_id):
    profile = users_svc.get(user_id)
    feed = feed_svc.get(user_id)
    return {'profile': profile, 'feed': feed[:10]}

Connections

Edge Cases & Gotchas

  • BFF per pixel — creating BFF per screen not per platform
  • Leaking domain logic into BFF — becomes monolith