#backend for frontend (bff) pattern
Explore tagged Tumblr posts
codeonedigest · 2 years ago
Text
Backend for Frontend Design Pattern for Microservices Explained with Examples
Full Video Link https://youtu.be/CRtVz_kw9qA Hello friends, new #video on #backendforfrontend #bff #designpattern for #microservices #tutorial for #api #developer #programmers with #examples are published on #codeonedigest #youtube channel
In this video we will learn about Backend for Frontend design pattern for microservices.   Backends for Frontends (BFF) is a microservice design pattern to handle the complexity of client-server communication where we have multiple user interfaces. This pattern suggests having a separate back-end service for each frontend to handle the specific needs of that interface. This pattern allows…
Tumblr media
View On WordPress
0 notes
himanshu123 · 11 days ago
Text
Modern API Design Patterns for Custom Applications 
Tumblr media
In today’s fast-paced digital ecosystem, building scalable, maintainable, and efficient applications is more crucial than ever. Custom software developers play a vital role in this transformation by leveraging robust API design patterns to ensure seamless communication between services, apps, and systems. APIs are no longer just bridges between applications—they are core components of modern software architectures, especially for businesses looking to offer highly tailored solutions. 
Let’s explore some of the most impactful API design patterns that are shaping how custom applications are being developed in 2025. 
1. RESTful API: Still the Foundation 
Although not exactly new, RESTful APIs continue to be a cornerstone in modern API architecture. They offer a straightforward approach to resource management using HTTP methods. The stateless nature of REST makes it ideal for scalable, modular application development. 
Custom applications—whether web platforms or mobile solutions—rely heavily on REST for simplicity and broad compatibility. By adhering to REST principles, developers ensure that applications remain loosely coupled and easy to maintain or scale. 
2. GraphQL: The Flexible Alternative 
For applications requiring complex data fetching with minimal overhead, GraphQL has emerged as a powerful alternative to REST. Unlike REST, which requires multiple endpoints for different resources, GraphQL uses a single endpoint and allows clients to request exactly the data they need. 
This precision is extremely valuable for frontend-heavy applications, such as SPAs (Single Page Applications) or mobile apps with bandwidth constraints. Custom software developers often use GraphQL to improve performance, reduce latency, and enhance the client experience. 
3. gRPC: High-Performance Communication 
Google’s gRPC is ideal for internal service-to-service communication. It’s especially useful in microservices architectures where speed and efficiency are critical. gRPC uses Protocol Buffers (Protobuf) for serialization, which is much faster than JSON. 
gRPC supports bi-directional streaming and strong typing, which is great for building real-time applications like messaging platforms, live dashboards, or financial trading systems. For developers building custom enterprise systems, gRPC offers both speed and type safety. 
4. API Gateway Pattern 
As applications become more complex, managing multiple APIs efficiently becomes essential. That’s where the API Gateway pattern shines. Acting as a single entry point for all client requests, an API gateway handles routing, load balancing, authentication, and even caching. 
This pattern simplifies client-side logic and secures backend services. For businesses offering multiple services or products through a single app, an API Gateway ensures smooth and secure communication without exposing internal architecture. 
5. Backend for Frontend (BFF) 
In multi-platform environments—where different interfaces like web, mobile, and IoT devices consume the same data—a Backend for Frontend (BFF) pattern is especially useful. Instead of one backend serving all clients, each client type has a specialized backend that caters to its unique needs. 
This design reduces the complexity of frontend logic and improves performance. For example, a mobile app might need a trimmed-down response compared to the desktop web version. BFF allows for tailored responses without burdening a single backend with all variations. 
Mobile App Considerations: Performance Meets Budget 
Modern APIs also influence project costs, especially in mobile development. Choosing the right pattern can save time, money, and resources. This is where a mobile app cost calculator comes in handy. It helps estimate the cost implications of different architectural choices and API strategies before writing a single line of code. 
If you're planning a mobile app and wondering how your API choices will affect the budget, try out a mobile app cost calculator to make data-driven decisions from day one. 
Want to tailor your app’s API strategy for better performance and scalability? Book an Appointment with our experts and get personalized guidance for your project. 
6. Event-Driven API Pattern 
Real-time and asynchronous systems benefit greatly from event-driven APIs. Instead of waiting for client requests, these APIs push updates when events occur. This is useful for applications like notifications systems, stock tickers, or order tracking platforms. 
Event-driven architecture typically uses tools like Kafka or WebSockets and is a powerful choice for building responsive, low-latency systems. It also enhances decoupling between services, improving maintainability and fault tolerance. 
7. OpenAPI (Swagger) for Standardization 
Standardization through tools like OpenAPI (formerly Swagger) helps ensure consistent API design across large teams. It allows developers to document APIs, generate client SDKs, and even auto-generate test cases. 
For businesses relying on teams of custom software developers, OpenAPI fosters better collaboration and faster onboarding by providing a single source of truth for how APIs are structured and behave. 
Wrapping Up: Building Future-Proof APIs 
As application ecosystems continue to evolve, so too must the APIs that support them. Whether you're building mobile apps, enterprise dashboards, or IoT integrations, the right API design pattern can significantly impact your product’s performance, scalability, and maintainability. 
From REST to GraphQL, and from API gateways to event-driven architectures, modern patterns provide flexibility to match a wide range of use cases. Investing in good API design not only enhances the developer experience but also delivers better end-user satisfaction. 
If you're considering building or upgrading your digital product, now is the time to embrace these modern API design patterns. They’re not just trends—they're foundational to how applications will be built in the future. 
Need help navigating these choices? We offer custom software development services tailored to your business needs. Reach out today and let's bring your vision to life. 
0 notes
nitor-infotech · 5 months ago
Text
Are you eager to delve into the core of web development? Join us as we explore Backend for Frontend (BFF), an intricate powerhouse that silently serves as an intermediary layer, tailoring data for distinct front-end clients, streamlining UI customization, and accelerating development. Further, learn how BFF stands as the unsung hero, elevating web development speed and performance. Stay confident and informed of the ever-evolving web development terrain with Nitor Infotech.
0 notes
sbelhadj · 5 months ago
Text
Backend for Frontend (BFF): A Practical Guide for Software Engineers
As modern apps grow more complex, the tools and patterns we use to build them need to evolve too. With microservices, cloud-native architectures, and an explosion of client devices—web, mobile, IoT, you name it—developers face the challenge of delivering fast, secure, and tailored user experiences. Enter Backend for Frontend (BFF), an architecture pattern designed to bridge the gap between…
0 notes
darinpantley · 9 months ago
Text
0 notes
altdigitaltechnologies · 9 months ago
Text
Ultimate Guide to Understand BFF in Web Development
Introduction
Suppose you’re planning a huge dinner party. You’ve got a fantastic menu planned, but your guests have different dietary needs and preferences. Do you make everyone wait while you prepare individual plates? Of course not! You’d assign tasks, ensuring vegetarians get their veggie delights while meat-lovers get their fill.
In web development, the “dinner party” is your complex web application, and the “guests” are your diverse frontends - web, mobile, and beyond. This is where BFF (Backend for Frontend) pattern comes in.
What is BFF in Web Development?
In web development, there’s a design pattern known as BFF, which stands for Backend for Frontend. This pattern is all about creating unique backend services that are specifically designed to meet the needs of individual front-end applications.
Here’s a simplified step-by-step process of how it works:
The frontend of an application makes a request for data, which is directed to an API in the BFF.
The BFF then communicates with the relevant microservices APIs to gather the necessary data.
Once the data is obtained, the BFF takes on the task of formatting this data to match the specific needs of the frontend.
Finally, this tailored data is sent back to the frontend.
The beauty of the Backend for Frontend pattern lies in its ability to streamline the data representation process. It takes on the responsibility of providing a focused interface for the frontend, reducing the amount of logic that needs to be handled on the frontend side.
Moreover, the BFF pattern enhances the user experience significantly. It allows for intelligent batching of calls to other backends or microservices and returns the data all at once, or in a more convenient format by transforming and formatting the data. This is particularly beneficial for mobile clients on slower networks, where establishing a connection can take several seconds.
Furthermore, the BFF pattern provides a means to separate the backend and frontend, which can lead to quicker product releases as frontend teams can have dedicated backend teams catering to their unique needs. This also means that the release of new features on one frontend does not impact others, and APIs can be maintained, modified, and even versioned for specific frontends with greater ease.
Why BFF?
The adoption of BFF has surged in recent years, and for good reason. Here’s why it is beneficial:
Suppose your web application has a complex backend API that returns a massive dataset. Now, consider a mobile app that only needs a specific subset of that data to function. A traditional approach would require the mobile app to download the entire dataset which leads to slow performance and unnecessary data transfer. BFF intercepts the request, retrieves only the relevant data from the backend, and sends it directly to the mobile app. This significantly reduces data transfer and streamlines communication, resulting in a faster and more responsive user experience on all platforms.
Gone are the days of one-size-fits-all functionality. BFF lets you customize data, features, and functionalities to the specific requirements of each frontend. Need a simplified dashboard for your mobile app while offering a feature-rich experience on the web platform? BFF allows you to create the perfect data presentation and functionality for each individual frontend, leading to a more engaging and intuitive user experience across the board.
By offloading backend complexities to the BFF layer, frontend developers gain the freedom to focus on what they do best: creating beautiful, interactive user interfaces. It’s like having a dedicated backend team handle all the database calls and API interactions, while frontend developers concentrate on building a user-centric interface - a true win-win situation.
The BFF pattern seamlessly integrates with microservice architectures. In a microservice environment, the backend is divided into smaller, independent services. BFF acts as a bridge between these services and the frontend, allowing for independent development and deployment of both backend services and BFFs. This modular approach facilitates agility and simplifies maintenance, making adapting your application to changing needs easier. 
But is BFF Right for You?
While BFF offers attractive benefits, it is important to recognize that it’s not a one-size-fits-all solution. Here are some important things to consider before adopting the BFF pattern:
For smaller-scale web applications with a single frontend, the overhead of managing and maintaining an additional layer (the BFF) might outweigh the potential gains. BFF truly shines in complex applications with multiple diverse frontends (web, mobile, smart TVs, etc.), where its ability to tailor experiences becomes a significant advantage.
Implementing and maintaining BFFs requires additional development resources. Before diving headfirst into the BFF world, ensure your team has the bandwidth to manage both the backend services and the BFF layer effectively. This might involve scaling your development team or considering outsourcing specific tasks.
BFF in Real-World Scenario
Let's revisit our dinner party analogy. Assume your BFF service as a team of waiters who understand your guests' needs. They fetch the right dishes, handle special requests, and ensure everyone has a delightful dining experience.
In a web application, the BFF might:
It aggregates data from multiple backend services into a cohesive response for a single frontend request. This eliminates the need for the frontend to make multiple API calls and simplifies data consumption.
It applies business logic specific to the frontend application. For example, a mobile app might require additional data validation or specific user interface formatting compared to the web platform. The BFF can handle these variations, ensuring the data presented to the frontend aligns perfectly with its needs.
It handles user authentication and authorization for that particular frontend. This offloads security concerns from the frontend, allowing developers to focus on building the user interface without worrying about building secure login systems from scratch.
Best Practices for BFF Implementation
Implementing BFF requires careful consideration and following best practices. Here are some best practices for implementing the BFF pattern:
Tailoring BFFs to Specific User Experiences: The BFF pattern is all about creating a unique backend service for each frontend application. This means that each BFF should be designed to cater to the specific needs of its corresponding frontend. It’s important to remember that the BFF should not take on more responsibilities than necessary. Its primary role is to serve its specific frontend client, and it should be designed with this in mind.
Reusing Existing Solutions: When implementing the BFF pattern, it’s crucial to avoid reinventing the wheel. If there are existing solutions that can be reused, they should be. This can save time and resources, and also ensure that the backend services are as efficient and effective as possible.
Avoiding the Fan-Out Antipattern: In some cases, a single request may fan out to multiple backend services. This is known as the fan-out antipattern and can lead to inefficiencies and potential bottlenecks. It’s important to be aware of this and design the BFF in a way that avoids this antipattern.
Consistent Error Handling: Errors are inevitable in any system. However, how these errors are handled can have a significant impact on the user experience. It’s important to ensure that error handling is consistent across the BFF. This can help to provide a seamless and positive user experience, even when things go wrong.
Leveraging TypeScript with a Node-based Server: Using a Node-based server allows you to leverage TypeScript, which can improve the reliability and maintainability of your code. TypeScript provides static typing, which can help to catch errors early in the development process, and also makes the code easier to read and understand.
Minimizing Coupling Between Frontend and Backend: To enhance flexibility and agility, it’s important to minimize the coupling between the frontend and backend. This can also simplify the codebase and improve scalability. Each component of the system should be able to operate independently as much as possible.
Modular, Reusable, and Shareable Approach: Each frontend and backend should be seen as components that can be reused and shared. This approach promotes modularity and reusability, which can lead to more efficient and maintainable systems.
Conclusion
In conclusion, the Backend for Frontend (BFF) pattern, a service we excel in at Alt Digital Technologies, is a game-changer in web development. It provides a custom-fit solution for data representation, enhancing user interaction and simplifying the development journey. Whether you’re grappling with intricate applications involving numerous microservices or contemplating expanding your frontend varieties, BFF could be your secret weapon to a more streamlined, resilient, and user-centric application. Keep in mind, that every architectural choice has its pros and cons. Therefore, it’s crucial to thoroughly evaluate your application’s unique requirements and limitations before embracing the BFF approach.
Ready to unlock the full potential of your web application with BFF? Contact Alt Digital Technologies today and let us guide you towards a more efficient and user-friendly digital future. Don’t wait, dive into the BFF pool with us!
0 notes
ericvanderburg · 2 years ago
Text
Backend For Frontend (BFF) Pattern
http://i.securitythinkingcap.com/SwswZm
0 notes
gleecus-techlabs-blogs · 2 years ago
Text
10 Essential Microservices Design Patterns
Database per service
Event driven architecture
CQRS (Command Quality Response Center)
Saga
BFF (Backends for Frontends)
Circuit breaker
API Gateway
Externalized configuration
Service Registry
Bulkhead pattern
0 notes
talentica-software · 2 years ago
Text
0 notes
hamesfrank · 2 years ago
Text
Backend for frontend architecture:
Backend for frontend architecture is an application architecture pattern that has gained popularity in recent years, particularly in the context of developing complex web and mobile applications. The BFF pattern focuses on enhancing the user experience by enabling a more efficient and tailored communication between the frontend and backend components of an application.
Tumblr media
1 note · View note
elyserollston · 6 years ago
Text
Leveraging microservices for your business, Part 3: The backend for frontend pattern is not your friend
In the “Leveraging microservices for your business” series, principal architect, Matt Bishop has been addressing areas of focus to help organizations and developers determine if microservices are the right business choice. Part one described microservices as architectural qualities, while part two went through the benefits and challenges of building a microservice ecosystem.
In this third and final installment, Bishop will address one of the most critical challenges microservice implementations face, the backend for frontend pattern. 
Quick recap
Adrian Cockcroft states microservices is a “loosely coupled service-oriented architecture with bounded contexts.” Loosely coupled architectures must have very little interaction with each other to fulfil their core business purposes. They share business identifiers as the logical thread through their combined capabilities. These capabilities are scoped by bounded contexts that represent independent, irreducible states of a business concern.
This architecture can deliver correctly-modeled business systems that are resilient, scalable and highly adaptable to business needs. Unfortunately, they are very difficult to consume as a client. The independent services usually have different API semantics to access their data and change their state. They are hard to discover and orchestrate to produce what the client wants, which is a cohesive consumer experience. The microservices solution is to create a new microservice—the BFF.
BFFs Are Not Your Friends
The Backend for Frontend (BFF) pattern pulls the necessary microservices together into a single experience for a specific consumer, like an iOS app or a progressive web app (PWA). Sam Newman, a well-known author and thought leader in the microservices architecture world, explains that a BFF microservice should be tuned to serve specific clients rather than be a general-purpose service for all clients. Each client needs different data, different actions and has different protocols, so they should not try to be shared, but rather copied and modified for each new client.
The BFF pattern has problems in practice, however. Often the responsibility to build a BFF falls to the client development team that will consume it. A client team is composed of software developers who are experts in front-end technologies. They are rarely competent to build server-side services that support their clients. Server-side code has completely different frameworks, semantics and concerns compared to client-side code. Many developers who have to write BFFs do not have the experience to create a BFF that will succeed in production, under load, and over the long term.
Another problem is that this team needs to fully understand the business rules and workflows in order to create the right BFF. In commerce, this is not a trivial undertaking. The good news is that this logic, which often lives in the client code, now lives on the server where it can be better managed and maintained. The bad news is that every new client team needs to know these rules and workflows as well. Their efforts are largely duplicated and often out-of-sync with each other.
These problems lead me to conclude that BFFs are costly, risky and an agility anti-pattern. BFFs throttle and constrain the microservices architecture at their gateway to the consumer by struggling to keep up with the microservices trying to deliver business value to the humans who need it.
Hypermedia to the Rescue
The general premise of the BFF microservice is wrong. Business logic and workflow orchestration must work the same way on all clients because the business itself provides the products and services to the customer. It would not be good if the Android app had different business rules than the iOS app. 
Agility demands that new features come to market as fast as possible, yet features must follow the valid business rules and workflows provided. A single shared API can provide this correctness and agility, but it must not bear the negative attributes pointed about in the BFF justifications. At Elastic Path, we have found that a Hypermedia API offers the best sharable experience that can be shaped by the clients to produce just the right amount of data and affordances for any given client experience.
The big difference between a Hypermedia API and other forms of REST are the links in the representations. Links point to related data, and they also point to relevant affordances. Links provide next-best actions at runtime, so the client does not have to know what that action should be. All the rules and logic that drive the links live in one place on the server.
A Hypermedia API client is reactive; it must know that linked data and actions are possible, and it must react to the links (or lack thereof) accordingly. A good example is the commerce checkout flow. When viewing a Cart resource, links will point to actions like adding or removing items from the cart, but will also offer links to provide payment. The client will find the known “checkout” workflow link to be missing and will not offer a Checkout button until the link appears. Instead, it will see the “payments” link and present “Add Payment” controls tied to the linked resource on the cart. Once payment method is established, the server will send a “checkout” link with the cart representation and the client can show the Checkout button.
Hypermedia’s control of link formation and presentation dramatically improve the time-to-market for a client app. An article by Shaun Maharaj shares the Hypermedia API client experience in great detail. Clients that are fast to build and deploy deliver the promised microservice agility all the way to the end consumer without risk of failure.
What about GraphQL?
If you are familiar with GraphQL, you will likely notice the similarities between links and GraphQL “connections.” This is a good comparison as they are the way data is linked together in a GraphQL query. 
Hypermedia formats often provide a similar querying and embedding pattern. HAL uses “_embedded” links and JSON-API offers an “includes” query to fetch aggregated data responses in a single request.
One important distinction between Hypermedia and GraphQL is when an action can occur. GraphQL Mutations are a flat, almost out-of-band concept for a client. They can learn what actions can be taken by looking at the Mutations list, but they do not know when they can be taken, and worse, they must rely on documentation and naming coincidence to actuate a Mutation. The client must operate defensively and make assumptions as to when a “Checkout” Mutation can be used. The client code must know that a “Provide Payment” Mutation must be first sent before checkout. And thus, the business logic makes its way back into the client where it does not belong.
GraphQL is a query language, meant for building views for a variety of client experiences. It is not a workflow orchestration API and is only a partial solution compared to Hypermedia.
The post Leveraging microservices for your business, Part 3: The backend for frontend pattern is not your friend appeared first on Get Elastic Ecommerce Blog.
Leveraging microservices for your business, Part 3: The backend for frontend pattern is not your friend published first on https://getyourcoupon.tumblr.com/
0 notes
codeonedigest · 2 years ago
Video
youtube
Backend For Frontend Design Pattern For Microservices With Examples Full Video Link   https://youtu.be/CRtVz_kw9qA              Hello friends, new #video on #backendforfrontend #bff #designpattern for #microservices #tutorial for #api #developer #programmers with #examples are published on #codeonedigest #youtube channel.  @java #java #aws #awscloud @awscloud @AWSCloudIndia #salesforce #Cloud #CloudComputing @YouTube #youtube #azure #msazure #codeonedigest @codeonedigest   #microservices #systemdesign #microservicesarchitecture #microservicestutorial #whataremicroservices #backendforfrontend #backendforfrontend(bff)pattern #backendforfrontendmicroservices #backendforfrontenddevelopers #backendforfrontendtutorial #backendforfrontendpattern #backendforfrontendpatternexample #backendforfrontendpatternvsapigateway #backendforfrontendpython #backendforfrontenddesignpattern #bffpattern #bffpatternmicroservices
1 note · View note
listiqueblog · 6 years ago
Text
Leveraging microservices for your business, Part 3: The backend for frontend pattern is not your friend
In the “Leveraging microservices for your business” series, principal architect, Matt Bishop has been addressing areas of focus to help organizations and developers determine if microservices are the right business choice. Part one described microservices as architectural qualities, while part two went through the benefits and challenges of building a microservice ecosystem.
In this third and final installment, Bishop will address one of the most critical challenges microservice implementations face, the backend for frontend pattern. 
Quick recap
Adrian Cockcroft states microservices is a “loosely coupled service-oriented architecture with bounded contexts.” Loosely coupled architectures must have very little interaction with each other to fulfil their core business purposes. They share business identifiers as the logical thread through their combined capabilities. These capabilities are scoped by bounded contexts that represent independent, irreducible states of a business concern.
This architecture can deliver correctly-modeled business systems that are resilient, scalable and highly adaptable to business needs. Unfortunately, they are very difficult to consume as a client. The independent services usually have different API semantics to access their data and change their state. They are hard to discover and orchestrate to produce what the client wants, which is a cohesive consumer experience. The microservices solution is to create a new microservice—the BFF.
BFFs Are Not Your Friends
The Backend for Frontend (BFF) pattern pulls the necessary microservices together into a single experience for a specific consumer, like an iOS app or a progressive web app (PWA). Sam Newman, a well-known author and thought leader in the microservices architecture world, explains that a BFF microservice should be tuned to serve specific clients rather than be a general-purpose service for all clients. Each client needs different data, different actions and has different protocols, so they should not try to be shared, but rather copied and modified for each new client.
The BFF pattern has problems in practice, however. Often the responsibility to build a BFF falls to the client development team that will consume it. A client team is composed of software developers who are experts in front-end technologies. They are rarely competent to build server-side services that support their clients. Server-side code has completely different frameworks, semantics and concerns compared to client-side code. Many developers who have to write BFFs do not have the experience to create a BFF that will succeed in production, under load, and over the long term.
Another problem is that this team needs to fully understand the business rules and workflows in order to create the right BFF. In commerce, this is not a trivial undertaking. The good news is that this logic, which often lives in the client code, now lives on the server where it can be better managed and maintained. The bad news is that every new client team needs to know these rules and workflows as well. Their efforts are largely duplicated and often out-of-sync with each other.
These problems lead me to conclude that BFFs are costly, risky and an agility anti-pattern. BFFs throttle and constrain the microservices architecture at their gateway to the consumer by struggling to keep up with the microservices trying to deliver business value to the humans who need it.
Hypermedia to the Rescue
The general premise of the BFF microservice is wrong. Business logic and workflow orchestration must work the same way on all clients because the business itself provides the products and services to the customer. It would not be good if the Android app had different business rules than the iOS app. 
Agility demands that new features come to market as fast as possible, yet features must follow the valid business rules and workflows provided. A single shared API can provide this correctness and agility, but it must not bear the negative attributes pointed about in the BFF justifications. At Elastic Path, we have found that a Hypermedia API offers the best sharable experience that can be shaped by the clients to produce just the right amount of data and affordances for any given client experience.
The big difference between a Hypermedia API and other forms of REST are the links in the representations. Links point to related data, and they also point to relevant affordances. Links provide next-best actions at runtime, so the client does not have to know what that action should be. All the rules and logic that drive the links live in one place on the server.
A Hypermedia API client is reactive; it must know that linked data and actions are possible, and it must react to the links (or lack thereof) accordingly. A good example is the commerce checkout flow. When viewing a Cart resource, links will point to actions like adding or removing items from the cart, but will also offer links to provide payment. The client will find the known “checkout” workflow link to be missing and will not offer a Checkout button until the link appears. Instead, it will see the “payments” link and present “Add Payment” controls tied to the linked resource on the cart. Once payment method is established, the server will send a “checkout” link with the cart representation and the client can show the Checkout button.
Hypermedia’s control of link formation and presentation dramatically improve the time-to-market for a client app. An article by Shaun Maharaj shares the Hypermedia API client experience in great detail. Clients that are fast to build and deploy deliver the promised microservice agility all the way to the end consumer without risk of failure.
What about GraphQL?
If you are familiar with GraphQL, you will likely notice the similarities between links and GraphQL “connections.” This is a good comparison as they are the way data is linked together in a GraphQL query. 
Hypermedia formats often provide a similar querying and embedding pattern. HAL uses “_embedded” links and JSON-API offers an “includes” query to fetch aggregated data responses in a single request.
One important distinction between Hypermedia and GraphQL is when an action can occur. GraphQL Mutations are a flat, almost out-of-band concept for a client. They can learn what actions can be taken by looking at the Mutations list, but they do not know when they can be taken, and worse, they must rely on documentation and naming coincidence to actuate a Mutation. The client must operate defensively and make assumptions as to when a “Checkout” Mutation can be used. The client code must know that a “Provide Payment” Mutation must be first sent before checkout. And thus, the business logic makes its way back into the client where it does not belong.
GraphQL is a query language, meant for building views for a variety of client experiences. It is not a workflow orchestration API and is only a partial solution compared to Hypermedia.
The post Leveraging microservices for your business, Part 3: The backend for frontend pattern is not your friend appeared first on Get Elastic Ecommerce Blog.
Leveraging microservices for your business, Part 3: The backend for frontend pattern is not your friend published first on https://goshopmalaysia.tumblr.com
0 notes
doloreshunter · 6 years ago
Text
Leveraging microservices for your business, Part 3: The backend for frontend pattern is not your friend
In the “Leveraging microservices for your business” series, principal architect, Matt Bishop has been addressing areas of focus to help organizations and developers determine if microservices are the right business choice. Part one described microservices as architectural qualities, while part two went through the benefits and challenges of building a microservice ecosystem.
In this third and final installment, Bishop will address one of the most critical challenges microservice implementations face, the backend for frontend pattern. 
Quick recap
Adrian Cockcroft states microservices is a “loosely coupled service-oriented architecture with bounded contexts.” Loosely coupled architectures must have very little interaction with each other to fulfil their core business purposes. They share business identifiers as the logical thread through their combined capabilities. These capabilities are scoped by bounded contexts that represent independent, irreducible states of a business concern.
This architecture can deliver correctly-modeled business systems that are resilient, scalable and highly adaptable to business needs. Unfortunately, they are very difficult to consume as a client. The independent services usually have different API semantics to access their data and change their state. They are hard to discover and orchestrate to produce what the client wants, which is a cohesive consumer experience. The microservices solution is to create a new microservice—the BFF.
BFFs Are Not Your Friends
The Backend for Frontend (BFF) pattern pulls the necessary microservices together into a single experience for a specific consumer, like an iOS app or a progressive web app (PWA). Sam Newman, a well-known author and thought leader in the microservices architecture world, explains that a BFF microservice should be tuned to serve specific clients rather than be a general-purpose service for all clients. Each client needs different data, different actions and has different protocols, so they should not try to be shared, but rather copied and modified for each new client.
The BFF pattern has problems in practice, however. Often the responsibility to build a BFF falls to the client development team that will consume it. A client team is composed of software developers who are experts in front-end technologies. They are rarely competent to build server-side services that support their clients. Server-side code has completely different frameworks, semantics and concerns compared to client-side code. Many developers who have to write BFFs do not have the experience to create a BFF that will succeed in production, under load, and over the long term.
Another problem is that this team needs to fully understand the business rules and workflows in order to create the right BFF. In commerce, this is not a trivial undertaking. The good news is that this logic, which often lives in the client code, now lives on the server where it can be better managed and maintained. The bad news is that every new client team needs to know these rules and workflows as well. Their efforts are largely duplicated and often out-of-sync with each other.
These problems lead me to conclude that BFFs are costly, risky and an agility anti-pattern. BFFs throttle and constrain the microservices architecture at their gateway to the consumer by struggling to keep up with the microservices trying to deliver business value to the humans who need it.
Hypermedia to the Rescue
The general premise of the BFF microservice is wrong. Business logic and workflow orchestration must work the same way on all clients because the business itself provides the products and services to the customer. It would not be good if the Android app had different business rules than the iOS app. 
Agility demands that new features come to market as fast as possible, yet features must follow the valid business rules and workflows provided. A single shared API can provide this correctness and agility, but it must not bear the negative attributes pointed about in the BFF justifications. At Elastic Path, we have found that a Hypermedia API offers the best sharable experience that can be shaped by the clients to produce just the right amount of data and affordances for any given client experience.
The big difference between a Hypermedia API and other forms of REST are the links in the representations. Links point to related data, and they also point to relevant affordances. Links provide next-best actions at runtime, so the client does not have to know what that action should be. All the rules and logic that drive the links live in one place on the server.
A Hypermedia API client is reactive; it must know that linked data and actions are possible, and it must react to the links (or lack thereof) accordingly. A good example is the commerce checkout flow. When viewing a Cart resource, links will point to actions like adding or removing items from the cart, but will also offer links to provide payment. The client will find the known “checkout” workflow link to be missing and will not offer a Checkout button until the link appears. Instead, it will see the “payments” link and present “Add Payment” controls tied to the linked resource on the cart. Once payment method is established, the server will send a “checkout” link with the cart representation and the client can show the Checkout button.
Hypermedia’s control of link formation and presentation dramatically improve the time-to-market for a client app. An article by Shaun Maharaj shares the Hypermedia API client experience in great detail. Clients that are fast to build and deploy deliver the promised microservice agility all the way to the end consumer without risk of failure.
What about GraphQL?
If you are familiar with GraphQL, you will likely notice the similarities between links and GraphQL “connections.” This is a good comparison as they are the way data is linked together in a GraphQL query. 
Hypermedia formats often provide a similar querying and embedding pattern. HAL uses “_embedded” links and JSON-API offers an “includes” query to fetch aggregated data responses in a single request.
One important distinction between Hypermedia and GraphQL is when an action can occur. GraphQL Mutations are a flat, almost out-of-band concept for a client. They can learn what actions can be taken by looking at the Mutations list, but they do not know when they can be taken, and worse, they must rely on documentation and naming coincidence to actuate a Mutation. The client must operate defensively and make assumptions as to when a “Checkout” Mutation can be used. The client code must know that a “Provide Payment” Mutation must be first sent before checkout. And thus, the business logic makes its way back into the client where it does not belong.
GraphQL is a query language, meant for building views for a variety of client experiences. It is not a workflow orchestration API and is only a partial solution compared to Hypermedia.
The post Leveraging microservices for your business, Part 3: The backend for frontend pattern is not your friend appeared first on Get Elastic Ecommerce Blog.
from https://www.getelastic.com/leveraging-microservices-for-your-business-part-3-the-backend-for-frontend-pattern-is-not-your-friend
0 notes
dougnroseno · 6 years ago
Text
Leveraging microservices for your business, Part 3: The backend for frontend pattern is not your friend
In the “Leveraging microservices for your business” series, principal architect, Matt Bishop has been addressing areas of focus to help organizations and developers determine if microservices are the right business choice. Part one described microservices as architectural qualities, while part two went through the benefits and challenges of building a microservice ecosystem.
In this third and final installment, Bishop will address one of the most critical challenges microservice implementations face, the backend for frontend pattern. 
Quick recap
Adrian Cockcroft states microservices is a “loosely coupled service-oriented architecture with bounded contexts.” Loosely coupled architectures must have very little interaction with each other to fulfil their core business purposes. They share business identifiers as the logical thread through their combined capabilities. These capabilities are scoped by bounded contexts that represent independent, irreducible states of a business concern.
This architecture can deliver correctly-modeled business systems that are resilient, scalable and highly adaptable to business needs. Unfortunately, they are very difficult to consume as a client. The independent services usually have different API semantics to access their data and change their state. They are hard to discover and orchestrate to produce what the client wants, which is a cohesive consumer experience. The microservices solution is to create a new microservice—the BFF.
BFFs Are Not Your Friends
The Backend for Frontend (BFF) pattern pulls the necessary microservices together into a single experience for a specific consumer, like an iOS app or a progressive web app (PWA). Sam Newman, a well-known author and thought leader in the microservices architecture world, explains that a BFF microservice should be tuned to serve specific clients rather than be a general-purpose service for all clients. Each client needs different data, different actions and has different protocols, so they should not try to be shared, but rather copied and modified for each new client.
The BFF pattern has problems in practice, however. Often the responsibility to build a BFF falls to the client development team that will consume it. A client team is composed of software developers who are experts in front-end technologies. They are rarely competent to build server-side services that support their clients. Server-side code has completely different frameworks, semantics and concerns compared to client-side code. Many developers who have to write BFFs do not have the experience to create a BFF that will succeed in production, under load, and over the long term.
Another problem is that this team needs to fully understand the business rules and workflows in order to create the right BFF. In commerce, this is not a trivial undertaking. The good news is that this logic, which often lives in the client code, now lives on the server where it can be better managed and maintained. The bad news is that every new client team needs to know these rules and workflows as well. Their efforts are largely duplicated and often out-of-sync with each other.
These problems lead me to conclude that BFFs are costly, risky and an agility anti-pattern. BFFs throttle and constrain the microservices architecture at their gateway to the consumer by struggling to keep up with the microservices trying to deliver business value to the humans who need it.
Hypermedia to the Rescue
The general premise of the BFF microservice is wrong. Business logic and workflow orchestration must work the same way on all clients because the business itself provides the products and services to the customer. It would not be good if the Android app had different business rules than the iOS app. 
Agility demands that new features come to market as fast as possible, yet features must follow the valid business rules and workflows provided. A single shared API can provide this correctness and agility, but it must not bear the negative attributes pointed about in the BFF justifications. At Elastic Path, we have found that a Hypermedia API offers the best sharable experience that can be shaped by the clients to produce just the right amount of data and affordances for any given client experience.
The big difference between a Hypermedia API and other forms of REST are the links in the representations. Links point to related data, and they also point to relevant affordances. Links provide next-best actions at runtime, so the client does not have to know what that action should be. All the rules and logic that drive the links live in one place on the server.
A Hypermedia API client is reactive; it must know that linked data and actions are possible, and it must react to the links (or lack thereof) accordingly. A good example is the commerce checkout flow. When viewing a Cart resource, links will point to actions like adding or removing items from the cart, but will also offer links to provide payment. The client will find the known “checkout” workflow link to be missing and will not offer a Checkout button until the link appears. Instead, it will see the “payments” link and present “Add Payment” controls tied to the linked resource on the cart. Once payment method is established, the server will send a “checkout” link with the cart representation and the client can show the Checkout button.
Hypermedia’s control of link formation and presentation dramatically improve the time-to-market for a client app. An article by Shaun Maharaj shares the Hypermedia API client experience in great detail. Clients that are fast to build and deploy deliver the promised microservice agility all the way to the end consumer without risk of failure.
What about GraphQL?
If you are familiar with GraphQL, you will likely notice the similarities between links and GraphQL “connections.” This is a good comparison as they are the way data is linked together in a GraphQL query. 
Hypermedia formats often provide a similar querying and embedding pattern. HAL uses “_embedded” links and JSON-API offers an “includes” query to fetch aggregated data responses in a single request.
One important distinction between Hypermedia and GraphQL is when an action can occur. GraphQL Mutations are a flat, almost out-of-band concept for a client. They can learn what actions can be taken by looking at the Mutations list, but they do not know when they can be taken, and worse, they must rely on documentation and naming coincidence to actuate a Mutation. The client must operate defensively and make assumptions as to when a “Checkout” Mutation can be used. The client code must know that a “Provide Payment” Mutation must be first sent before checkout. And thus, the business logic makes its way back into the client where it does not belong.
GraphQL is a query language, meant for building views for a variety of client experiences. It is not a workflow orchestration API and is only a partial solution compared to Hypermedia.
The post Leveraging microservices for your business, Part 3: The backend for frontend pattern is not your friend appeared first on Get Elastic Ecommerce Blog.
from Doug Rose Web Designing https://www.getelastic.com/leveraging-microservices-for-your-business-part-3-the-backend-for-frontend-pattern-is-not-your-friend
0 notes
altdigitaltechnologies · 1 year ago
Text
Ultimate Guide to Understand BFF in Web Development
Suppose you’re planning a huge dinner party. You’ve got a fantastic menu planned, but your guests have different dietary needs and preferences. Do you make everyone wait while you prepare individual plates? Of course not! You’d assign tasks, ensuring vegetarians get their veggie delights while meat-lovers get their fill.
In web development, the “dinner party” is your complex web application, and the “guests” are your diverse frontends - web, mobile, and beyond. This is where BFF (Backend for Frontend) pattern comes in.
What is BFF in Web Development?
In web development, there’s a design pattern known as BFF, which stands for Backend for Frontend. This pattern is all about creating unique backend services that are specifically designed to meet the needs of individual front-end applications.
Here’s a simplified step-by-step process of how it works:
The frontend of an application makes a request for data, which is directed to an API in the BFF.
The BFF then communicates with the relevant microservices APIs to gather the necessary data.
Once the data is obtained, the BFF takes on the task of formatting this data to match the specific needs of the frontend.
Finally, this tailored data is sent back to the frontend.
The beauty of the Backend for Frontend pattern lies in its ability to streamline the data representation process. It takes on the responsibility of providing a focused interface for the frontend, reducing the amount of logic that needs to be handled on the frontend side.
Moreover, the BFF pattern enhances the user experience significantly. It allows for intelligent batching of calls to other backends or microservices and returns the data all at once, or in a more convenient format by transforming and formatting the data. This is particularly beneficial for mobile clients on slower networks, where establishing a connection can take several seconds.
Furthermore, the BFF pattern provides a means to separate the backend and frontend, which can lead to quicker product releases as frontend teams can have dedicated backend teams catering to their unique needs. This also means that the release of new features on one frontend does not impact others, and APIs can be maintained, modified, and even versioned for specific frontends with greater ease.
Why BFF?
The adoption of BFF has surged in recent years, and for good reason. Here’s why it is beneficial:
Suppose your web application has a complex backend API that returns a massive dataset. Now, consider a mobile app that only needs a specific subset of that data to function. A traditional approach would require the mobile app to download the entire dataset which leads to slow performance and unnecessary data transfer. BFF intercepts the request, retrieves only the relevant data from the backend, and sends it directly to the mobile app. This significantly reduces data transfer and streamlines communication, resulting in a faster and more responsive user experience on all platforms.
Gone are the days of one-size-fits-all functionality. BFF lets you customize data, features, and functionalities to the specific requirements of each frontend. Need a simplified dashboard for your mobile app while offering a feature-rich experience on the web platform? BFF allows you to create the perfect data presentation and functionality for each individual frontend, leading to a more engaging and intuitive user experience across the board.
By offloading backend complexities to the BFF layer, frontend developers gain the freedom to focus on what they do best: creating beautiful, interactive user interfaces. It’s like having a dedicated backend team handle all the database calls and API interactions, while frontend developers concentrate on building a user-centric interface - a true win-win situation.
The BFF pattern seamlessly integrates with microservice architectures. In a microservice environment, the backend is divided into smaller, independent services. BFF acts as a bridge between these services and the frontend, allowing for independent development and deployment of both backend services and BFFs. This modular approach facilitates agility and simplifies maintenance, making adapting your application to changing needs easier. 
But is BFF Right for You?
While BFF offers attractive benefits, it is important to recognize that it’s not a one-size-fits-all solution. Here are some important things to consider before adopting the BFF pattern:
For smaller-scale web applications with a single frontend, the overhead of managing and maintaining an additional layer (the BFF) might outweigh the potential gains. BFF truly shines in complex applications with multiple diverse frontends (web, mobile, smart TVs, etc.), where its ability to tailor experiences becomes a significant advantage.
Implementing and maintaining BFFs requires additional development resources. Before diving headfirst into the BFF world, ensure your team has the bandwidth to manage both the backend services and the BFF layer effectively. This might involve scaling your development team or considering outsourcing specific tasks.
BFF in Real-World Scenario
Let's revisit our dinner party analogy. Assume your BFF service as a team of waiters who understand your guests' needs. They fetch the right dishes, handle special requests, and ensure everyone has a delightful dining experience.
In a web application, the BFF might:
It aggregates data from multiple backend services into a cohesive response for a single frontend request. This eliminates the need for the frontend to make multiple API calls and simplifies data consumption.
It applies business logic specific to the frontend application. For example, a mobile app might require additional data validation or specific user interface formatting compared to the web platform. The BFF can handle these variations, ensuring the data presented to the frontend aligns perfectly with its needs.
It handles user authentication and authorization for that particular frontend. This offloads security concerns from the frontend, allowing developers to focus on building the user interface without worrying about building secure login systems from scratch.
Best Practices for BFF Implementation
Implementing BFF requires careful consideration and following best practices. Here are some best practices for implementing the BFF pattern:
Tailoring BFFs to Specific User Experiences: The BFF pattern is all about creating a unique backend service for each frontend application. This means that each BFF should be designed to cater to the specific needs of its corresponding frontend. It’s important to remember that the BFF should not take on more responsibilities than necessary. Its primary role is to serve its specific frontend client, and it should be designed with this in mind.
Reusing Existing Solutions: When implementing the BFF pattern, it’s crucial to avoid reinventing the wheel. If there are existing solutions that can be reused, they should be. This can save time and resources, and also ensure that the backend services are as efficient and effective as possible.
Avoiding the Fan-Out Antipattern: In some cases, a single request may fan out to multiple backend services. This is known as the fan-out antipattern and can lead to inefficiencies and potential bottlenecks. It’s important to be aware of this and design the BFF in a way that avoids this antipattern.
Consistent Error Handling: Errors are inevitable in any system. However, how these errors are handled can have a significant impact on the user experience. It’s important to ensure that error handling is consistent across the BFF. This can help to provide a seamless and positive user experience, even when things go wrong.
Leveraging TypeScript with a Node-based Server: Using a Node-based server allows you to leverage TypeScript, which can improve the reliability and maintainability of your code. TypeScript provides static typing, which can help to catch errors early in the development process, and also makes the code easier to read and understand.
Minimizing Coupling Between Frontend and Backend: To enhance flexibility and agility, it’s important to minimize the coupling between the frontend and backend. This can also simplify the codebase and improve scalability. Each component of the system should be able to operate independently as much as possible.
Modular, Reusable, and Shareable Approach: Each frontend and backend should be seen as components that can be reused and shared. This approach promotes modularity and reusability, which can lead to more efficient and maintainable systems.
Conclusion
In conclusion, the Backend for Frontend (BFF) pattern, a service we excel in at Alt Digital Technologies, is a game-changer in web development. It provides a custom-fit solution for data representation, enhancing user interaction and simplifying the development journey. Whether you’re grappling with intricate applications involving numerous microservices or contemplating expanding your frontend varieties, BFF could be your secret weapon to a more streamlined, resilient, and user-centric application. Keep in mind, that every architectural choice has its pros and cons. Therefore, it’s crucial to thoroughly evaluate your application’s unique requirements and limitations before embracing the BFF approach.
Ready to unlock the full potential of your web application with BFF? Contact Alt Digital Technologies today and let us guide you towards a more efficient and user-friendly digital future. Don’t wait, dive into the BFF pool with us!
For more information visit Alt digital technologies
Tumblr media
1 note · View note