SystemExpertsSystemExperts
Pricing

Patterns

35 items

Horizontal Scaling Pattern

15mbeginner

Retry with Backoff Pattern

15mbeginner

Replication Pattern

25mintermediate

Caching Strategies Pattern

25mintermediate

Persistent Connections Pattern

20mintermediate

Load Balancing Pattern

20mintermediate

Fan-out Pattern

20mintermediate

Fan-in Pattern

20mintermediate

Circuit Breaker Pattern

20mintermediate

Eventual Consistency Pattern

25mintermediate

Queue-based Load Leveling Pattern

20mintermediate

Bloom Filters Pattern

20mintermediate

Time-Series Storage Pattern

20mintermediate

Bulkhead Pattern

20mintermediate

Batch Processing Pattern

20mintermediate

Write-Ahead Log Pattern

20mintermediate

API Gateway Pattern

20mintermediate

Backend for Frontend Pattern

20mintermediate

Sidecar Pattern

20mintermediate

Idempotency Pattern

20mintermediate

Rate Limiting Pattern

20mintermediate

Backpressure Pattern

20mintermediate

Pub/Sub Pattern

25mintermediate

Strong Consistency Pattern

30madvanced

Conflict Resolution Pattern

25madvanced

Leader Election Pattern

25madvanced

Consensus Protocols Pattern

30madvanced

CQRS Pattern

28madvanced

LSM Trees Pattern

25madvanced

Sharding Pattern

25madvanced

Event Sourcing Pattern

30madvanced

Stream Processing Pattern

25madvanced

Change Data Capture Pattern

25madvanced

Distributed Locking Pattern

25madvanced

Two-Phase Commit Pattern

25madvanced
System Design Pattern
API & Gatewaybffbackend-for-frontendapiclient-specificaggregationintermediate

Backend for Frontend Pattern

Client-specific API layers for different frontends

Used in: GraphQL, Mobile Apps, Web Apps|20 min read

Summary

Backend for Frontend (BFF) creates dedicated backend services for each client type (web, mobile, smart TV). Instead of one generic API serving all clients, each BFF is tailored to its client's specific needs - aggregating data, transforming responses, and handling client-specific logic. This enables optimal API design per platform, independent deployment, and better separation of concerns. Netflix uses BFFs for different devices, Spotify has mobile and web BFFs. The pattern shines when clients have vastly different needs.

Key Takeaways

Client-Optimized APIs

Mobile needs less data (bandwidth), web can handle more. BFF returns exactly what each client needs, no over-fetching or under-fetching.

Independent Evolution

Mobile team owns mobile BFF, can iterate independently. Web changes don't affect mobile and vice versa. Faster development velocity.

Client-Specific Logic

Mobile offline sync, web real-time updates, TV simplified navigation - each BFF handles platform-specific requirements without polluting core services.

Backend for Frontend Pattern

Why separate BFFs?

Mobile BFF: - Minimal payload (bandwidth costs) - Aggregated endpoints (reduce round trips) - Offline sync support - Push notification handling

Web BFF: - Rich data for powerful UI - Real-time WebSocket support - SEO considerations - Server-side rendering support

TV BFF: - Simplified navigation data - Large media URLs - Voice command support - Low-power device optimization

Summary

Backend for Frontend (BFF) creates dedicated backend services for each client type (web, mobile, smart TV). Instead of one generic API serving all clients, each BFF is tailored to its client's specific needs - aggregating data, transforming responses, and handling client-specific logic. This enables optimal API design per platform, independent deployment, and better separation of concerns. Netflix uses BFFs for different devices, Spotify has mobile and web BFFs. The pattern shines when clients have vastly different needs.

Key Takeaways

Client-Optimized APIs

Mobile needs less data (bandwidth), web can handle more. BFF returns exactly what each client needs, no over-fetching or under-fetching.

Independent Evolution

Mobile team owns mobile BFF, can iterate independently. Web changes don't affect mobile and vice versa. Faster development velocity.

Client-Specific Logic

Mobile offline sync, web real-time updates, TV simplified navigation - each BFF handles platform-specific requirements without polluting core services.

Avoid Generic API Trap

Generic APIs try to serve everyone, end up serving no one well. BFF embraces different needs explicitly.

Duplication Trade-off

Some logic duplicated across BFFs. Accept this for flexibility, or extract shared logic to common libraries.

Team Structure Alignment

BFF aligns with Conway's Law - mobile team builds mobile BFF, web team builds web BFF. Clear ownership.

Pattern Details

Backend for Frontend Pattern

Why separate BFFs?

Mobile BFF: - Minimal payload (bandwidth costs) - Aggregated endpoints (reduce round trips) - Offline sync support - Push notification handling

Web BFF: - Rich data for powerful UI - Real-time WebSocket support - SEO considerations - Server-side rendering support

TV BFF: - Simplified navigation data - Large media URLs - Voice command support - Low-power device optimization

Trade-offs

AspectAdvantageDisadvantage

Premium Content

Sign in to access this content or upgrade for full access.