vishal patel
UnderstoodIntermediateUpdated 2026-09-23

API Gateway & Backend-for-Frontend (BFF)

A single entry point that handles cross-cutting concerns (auth, rate limits, routing); BFFs go further with one tailored backend per client type.

gatewayedgeauthaggregation

The problem

With 40 services, clients shouldn't know 40 hostnames, and each service shouldn't re-implement auth, rate limiting, CORS and logging. Mobile also wants small payloads, while the web dashboard wants rich aggregates.

How it works

diagram

Gateway responsibilities: routing, TLS termination, authentication (validate the JWT once), rate limiting and quotas, request/response logging, CORS, caching, and API versioning.

BFF responsibilities: aggregate several service calls into one screen-shaped response, trim payloads for mobile, and handle client-specific auth flows.

Rules of thumb

  • No business logic in the gateway. It becomes a distributed monolith fast.
  • Pass identity downstream (a signed JWT or internal headers). Services still authorise.
  • The gateway is a single point of failure, so run it HA with sensible timeouts.
  • One BFF per experience, owned by the frontend team, not one per device model.
Use it when
  • Multiple services behind one public API
  • Different client types need different shapes
  • Centralised auth, quotas and observability at the edge
Avoid it when
  • A single backend — a reverse proxy is enough
  • Teams start pushing domain logic into the gateway

Cheatsheets

The whole topic on one page. Click to open full screen.

Sources & further learning

Videos, courses, docs and books I recommend for this topic.

Related topics