Imagine you're building an e-commerce application with a microservices architecture. Your backend consists of several independent services:
Now suppose your application has three different clients: a web application, a mobile application, and an admin dashboard. Although all three clients use the same backend services, they have very different requirements.
The web application might display detailed product information, reviews, recommendations, and inventory status on a single page. The mobile application might need a smaller response containing only the product name, price, image, and availability to reduce bandwidth usage. The admin dashboard might need inventory levels, sales metrics, and product management information.
If every client communicates directly with the same backend APIs, it must handle multiple service calls, combine responses, and filter unnecessary data. Alternatively, you could build one shared API layer that handles everything. However, as client requirements grow, this shared layer can become complicated, with different endpoints and conditional logic for each client.
This is where the Backend for Frontend (BFF) Pattern becomes useful.