A Back end for frontend (BFF) is a new architectural pattern for microservices and domain-driven design. BFF will simplify the communication between the frontend and backend and make front end development easier.
What is a BFF?
BFF Architecture is used to improve and enhance user experience. A BFF layer consists of multiple backend services developed to address the needs .Basically it is a server responsible for communicating between services and front end.
Advantages
It simplifies the communication between the frontend and backend. This is especially valuable when you have an architecture with many microservices as the frontend only needs to communicate with one service that has an interface tailored to the use cases in the frontend.
Simplifies the communicati0n between the front end and backend when you have a architecture with my many microservices.
Multiple front end applications interfaces can call BFF backends in parallel and dedicated backend services respond faster.
Improved latency when your BFF is on the same network and the downstream services ensure low latency between them.
All the business logic and infrastructure details are stored on BFF. Only Front end communicates to BFF.
In BFF we can have server caching logic by caching the headers with cache database like Redis.
BFF backend systems can use any protocol like FTP, SOAP,REST or GraphQL to request data from microservices
Challenges in BFF
In BFF, a break down of single service can bring entire BFF system down.
Not Following best deployment practices can lead to unwanted deployments that will lead to slow response time and occupy more resources in the cloud.
Technologies use for the BFF :
Express
NestJS
GraphQL/Apollo
Express
Conclusion
In this post, we looked at what a BFF is and how it can benefit your architecture.
Basically, it is most beneficial when you have a microservice architecture and you want to simplify the frontend by only having it communicate with the BFF.