Decoupling Platform and Business Code in Xianyu's Item Publishing via the SWAK Framework
Xianyu refactored its item publishing and editing features using the self‑developed SWAK framework, first extracting business logic into isolated packages to separate platform code, then service‑izing the rental business via remote RPC, dramatically improving code clarity, reuse, team coordination, and system scalability.
In the development of business features, platform code and business code are often tightly coupled, making separation difficult and reducing code quality, team collaboration, and user experience. This article uses Xianyu's item publishing and editing functions as a case study to demonstrate how these problems were solved.
The improvement was carried out in two rounds. The first round aimed to separate the platform from the business and isolate business‑to‑business interactions. The second round further decoupled entire systems to boost team coordination efficiency.
During the first round, the original publishing and editing logic was extracted from the legacy application into a new item application using the self‑developed SWAK framework. After integrating SWAK, platform logic and business logic were separated, and each business (e.g., rental, free‑gift) was isolated as a package/tag, eliminating cross‑business coupling.
Key benefits of the SWAK‑based refactor include clear code logic, higher reuse, isolated variable logic per tag (reducing development and testing cost), and faster onboarding for new developers.
The second round focused on system‑level decoupling. Using the rental business as an example, previously a single feature required modifications in multiple applications (item, detail, transaction). By extracting rental into an independent service and exposing its functionality via remote RPC calls, the architecture aligns with Conway’s Law and is referred to as “business serviceization”.
The serviceization plan involved three steps: (1) isolate the rental business into its own service, (2) expose platform extension points as remote interfaces, and (3) enhance SWAK to register and invoke remote services. Exception handling strategies (IGNORE, SKIP, DEFAULT_VALUE) were added to manage RPC timeouts and connection errors.
To reduce the number of extension points, adjacent points were merged, shrinking the count from 17 to 6 while maintaining extensibility. The design also introduced a map‑based data‑object model that hides business‑specific DO definitions from the core platform, offering the best scalability for adding new services.
Overall, the two‑stage refactor achieved platform‑business decoupling and system‑level decoupling, significantly improving collaborative efficiency, stability, and the ability to support diverse business needs. The SWAK framework continues to evolve, with future work planned on parallel and asynchronous processing, testing automation, and monitoring.
Xianyu Technology
Official account of the Xianyu technology team
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.