iluwatar / java-design-patterns

Design patterns implemented in Java
https://java-design-patterns.com
Other
88.28k stars 26.19k forks source link

Backends for Frontends pattern #300

Open iluwatar opened 8 years ago

iluwatar commented 8 years ago

Description: The Backends for Frontends (BFF) design pattern is intended to create separate backend services for different user interfaces or clients. This pattern is particularly useful when different clients (such as mobile apps, desktop applications, and web applications) have distinct needs and require tailored backend interactions. Implementing BFF helps to ensure that each client gets exactly the data it requires in the optimal format, improving performance and maintainability.

Main Elements of the Pattern:

  1. Client-Specific Backend: Each frontend has a dedicated backend service that caters to its specific needs.
  2. Data Aggregation: The BFF aggregates data from various sources and formats it appropriately for the frontend.
  3. Decoupling: This pattern decouples the frontend from the complexities of backend systems, providing a clean API tailored to the frontend's requirements.
  4. Optimized API: Each backend service provides an optimized API for its respective client, improving performance and user experience.

References:

Acceptance Criteria:

  1. Client-Specific Backend Services: Implement distinct backend services for at least two different clients (e.g., web and mobile).
  2. Data Aggregation: Ensure that the BFFs aggregate data from multiple services and format it specifically for their respective clients.
  3. Optimized APIs: Create clean and optimized APIs for each backend service to improve the performance and user experience of the respective frontends.
iluwatar commented 3 years ago

https://docs.microsoft.com/en-us/azure/architecture/patterns/backends-for-frontends

iluwatar commented 3 years ago

Link pointed out by @FuncGuy: https://blog.bitsrc.io/bff-pattern-backend-for-frontend-an-introduction-e4fa965128bf

javatlacati commented 2 years ago

uml: image

plantuml code:

@startuml
node mobile{
 component iosapp as "ios app"
 component androidapp as "android app"
}

node intranet{
 component desktop as "desktop app"
 component chatbot
}

component bff as "BFF server"{
 component iosbff as "ios BFF"
 component androidbff as "android BFF"
 component chatbotbff as "chatbot BFF"
 component desktopbff as "desktop BFF"
}

node intranetserv as "intranet  services server"{
 component ss as "supplier service API"
}

cloud onlypublic as "public cloud"{
 component cas as "customer authentication service API"
 component cs as "cart service API"
}

cloud cloudserv as "managed cloud"{
 component os as "order service API"
}

iosapp -- iosbff
androidapp -- androidbff
chatbot -- chatbotbff
desktop -- desktopbff

iosbff -- cas
androidbff -- cas
iosbff -- cs
androidbff -- cs
iosbff -- os
androidbff -- os
chatbotbff -- os
desktopbff -- os

chatbotbff -- ss
desktopbff -- ss
@enduml
iluwatar commented 8 months ago

https://microservices.io/patterns/apigateway.html

iluwatar commented 1 month ago

Updated task description