Dung (Donny) Nguyen

Senior Software Engineer

Backends For Frontends Pattern

The Backends For Frontends (BFF) design pattern is an architectural approach where different backends are created for each type of frontend (e.g., web, mobile, desktop). Each frontend has its own specialized backend that meets its specific needs, which allows for more efficient communication and reduces unnecessary data processing on the frontend side.

Key Characteristics of the BFF Pattern:

  1. Separation by Frontend: Each frontend (e.g., mobile app, web app) gets its own tailored backend service that aggregates data and handles business logic specific to that frontend.

  2. Simplified Frontends: By having a dedicated backend for each frontend, the frontends do not need to handle complex business logic or aggregate data from multiple services themselves.

  3. Performance Optimization: Each BFF can tailor the API responses to fit the needs of the respective frontend, optimizing payload sizes, response times, and other performance metrics.

  4. Security and Access Control: Each BFF can apply security and access control measures based on the frontend’s requirements, like enforcing specific OAuth flows or access tokens for mobile vs. web applications.

Example:

This design pattern works well in microservices architectures and for applications with multiple frontend types. However, it adds complexity due to the need to maintain multiple backend services.