background
- preface
In recent years, with the change of technology wave after wave, the continuous refinement of the division of labor, and the increasingly close connection with the business, the front-end has bid farewell to the era of cutting diagram, experienced the era of class library complement browser difference; Experienced a variety of template engines to complement the template rendering era; Experienced the era of various mv; Step by step technology stack attributed to react, Vue family bucket; With the popularity of Node, the enhancement of mobile devices and the enhancement of HTML5 capabilities, the integration of terminal technology has been a trend. The separation of end and service is very important, which also puts forward higher requirements for data adaptation of service layer. The BFF(backend for frontend) mode helps us understand the separation of the front and back ends. Generally speaking, BFF means that the frontend renders the business logic and the backend provides underlying services, as shown in the following figure:
- The status quo
More front-end teams within Ali have tried BFF, mostly based on Begg or Midway, with nodeJS providing the ability to extract, aggregate and distribute data. The server side is more focused on the business domain.
We jump out of the technical stack to look at BFF. Some server-side teams have similar attempts, such as Taobao’s TQL, GraphQL is very popular at present. TQL is implemented based on GraphQL, and has made a lot of in-depth optimization.
- Analysis (
His shan zhishi
)
We have been talking about full stack development, but it is more in the BFF category, rather than the front and back end of a person to do; F data adaptation layer, is the key point of front and back end separation, but also where we can send force, so with TQL, or some personalized needs more step back to use Node to do data adaptation is not all right? Of course not, it is needless to say that egg is used alone. It is necessary to maintain the entire application and library table. If there are changes, it is necessary to go through the change release process. The advantages of TQL have been introduced earlier. Based on GraphQL, both the front and back ends are required to follow graphQL’s schema. In other words, to access TQL, both the front and back ends must be adapted accordingly. It is not appropriate to assume that our data is jData from dynamic Schema, or that some innovative business scenario data model has not been solidified.
- We hope to build a platform & crack ideas
We have learned more about BFF and the current technical solutions. To sum up, we find that the existing BFF technical solutions are based on the premise that data has been generated, and more importantly, they are adaptive to data query. What should we do if we meet new business or need to store some configuration information? Obviously we need back-end support (Node/Java), so we can either maintain a Node application or have Java support. Since the BFF model is correct, we can extend the B layer to accommodate all services (db is also a service), as shown in the following figure:
To sum up, the desired platform should have the following characteristics:
- Unified gateway: The front and back ends are separated. The server provides only atomic services. Therefore, a unified gateway is required to link the end consumption
- Service plug-in, the development of the current end is not only limited to UI rendering and interaction, the full stack and the integration of each end is the big front end so that we have more space to try, in addition to self-built technology projects can also owner some innovative business projects, which is also a variety of service needs
- Visual editing JS, for data extraction and cutting of different business logic, JS can be more flexible to achieve business logic, at the same time, editing, testing, release unified online completion
- Js plug-in is for code sharing to improve development efficiency
- Service orchestration, usually a request is not a service can meet, we need to orchestration of multiple services, at the same time need to have the parallel processing capability of multiple services
- Universal data storage: Data storage is a topic we can’t get away from, there is no need to maintain a back-end application to store data, the data storage as a core service plug-in
Crack the idea: