Ctrip Hotel BFF Architecture Migration and Efficiency Boost with NestJS and Cloud Functions

The article outlines Ctrip Hotel's transition from a monolithic BFF model to a multi‑endpoint "one‑code‑many‑ends" architecture using NestJS, introduces a cloud‑function platform for improved performance and operational efficiency, and describes a dynamic gateway layer that further enhances front‑end flexibility across multiple client types.

Ctrip Technology
Ctrip Technology
Ctrip Technology
Ctrip Hotel BFF Architecture Migration and Efficiency Boost with NestJS and Cloud Functions

The article begins by describing the challenges faced by Ctrip Hotel's front‑end BFF layer during architecture migration and efficiency improvement, emphasizing the need to separate UI concerns from domain services as user demands become more diverse.

Two BFF patterns are compared: "one‑code‑one‑end", which provides a dedicated BFF per client but leads to monolithic, duplicated code, and "one‑code‑many‑ends", which shares a single BFF across multiple clients while handling UI differences internally, resulting in higher development efficiency.

Adopting the "one‑code‑many‑ends" approach, the team selected NestJS as the foundational framework, highlighting its modularity, built‑in dependency injection, TypeScript support, decorator‑based routing, microservice capabilities, testing tools, and seamless integration with other libraries.

To address the complexities of multi‑client BFF maintenance, a multi‑end strategy pattern was introduced, separating per‑client logic into independent strategy instances, reducing code coupling, enabling parallel execution, and simplifying view‑model consistency.

The article then details Ctrip's Node.js cloud‑function platform, covering its lightweight runtime, middleware ecosystem, trigger mechanisms, layer management, elastic scaling, blue‑green and gray‑release deployment, and monitoring tools, all of which accelerate function development and improve resource utilization.

By packaging the NestJS‑based BFF as a cloud‑function template, the team achieved faster cold‑start times, lower memory consumption, and better performance under identical QPS conditions.

Finally, a dynamic gateway layer is introduced to handle inter‑API composition, whitelist, gray‑release, and scenario‑based customization, further decoupling multi‑end view logic and enabling cross‑application UI dynamism.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

MicroservicesBackend DevelopmentFrontend ArchitectureBFFCloud FunctionsNestJS
Ctrip Technology
Written by

Ctrip Technology

Official Ctrip Technology account, sharing and discussing growth.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.