advanced
BFF
Use backend-for-frontend services to shape client-specific workflows while owning duplication, caching, auth, and contract drift.
A BFF shapes APIs for a specific client — mobile, web, partner — aggregating calls, adapting payloads, and handling client-specific auth and caching. It reduces chattiness for the UI but duplicates logic if every platform gets a divergent BFF without shared domain services.
Trade-off: optimized client experience versus multiple backends to maintain.
On interviews: compare BFF to generic API gateway; where aggregation stops and domain services start.
Common pitfalls: business rules in BFF; BFF per developer instead of per client type; no contract tests with frontend.
Checklist:
- One BFF per user experience surface, not per feature.
- Delegate invariants to domain services.
- Cache and batch reads for mobile latency.
- Version BFF with its client release cadence.