Design and Implementation of Extensible Hook Modules in the Luxury Platform
The Luxury strategy‑center platform solves extensibility by defining a unified hook interface using the Adapter pattern, schema‑driven forms, and flat key‑value outputs, allowing operators to configure third‑party integrations via visual mappings without code changes, cutting integration time to half a day and fostering reusable assets.
Introduction: Extensibility is a common technical challenge when building platforms and middle‑platforms. To cover more business scenarios, the Luxury strategy‑center platform of Xianyu designs reusable extension modules.
Background: Luxury is a fine‑grained strategy operation platform for all Xianyu business lines. A typical example is a red‑packet promotion displayed as a pop‑up card on the client.
Current situation: Third‑party service interfaces vary, making unified abstraction difficult. Early implementations hard‑coded each integration, leading to low reusability and high configuration cost for operators who must manually map hook outputs to UI placeholders.
Goals: easy‑to‑use mapping for operators, high extensibility to cover most business integrations, reusability of hooks, and gradual accumulation of reusable assets.
Technical solution: Adopt the Adapter pattern to abstract a hook interface. Third‑party services implement this interface, allowing the platform to treat all hooks uniformly. The adapter performs input‑output data mapping to a common model, hiding implementation differences.
Input construction: Instead of a two‑step call (fetching parameter schema then invoking), the client passes a rich context; the hook extracts needed fields, reducing call count.
Static configuration visualization: Use a schema‑driven form generator. Backend classes generate JSON schema; the frontend renders dynamic forms, enabling operators to configure hook parameters without code changes.
Output standardization: Enforce a flat key‑value structure for hook outputs. Nested structures are flattened (e.g., K_0_0) so operators can map simple placeholders to data.
Data‑mapping configurability: Extract mapping rules into static parameters, allowing the same hook to serve multiple middle‑platform scenarios without code changes.
Effect: Operators can independently configure hook‑to‑point mappings, reducing integration time to about half a day and covering many scenarios such as purchase incentives, content promotion, and activity interaction.
Conclusion: Designing extensible modules requires a well‑defined unified interface and protocol. Balancing extensibility with usability leads to a clear, maintainable architecture.
{
"type": "object",
"properties": {
"appId": {
"type": "integer",
"title": "app id",
"required": true
},
"callSource": {
"type": "string",
"default": "fleamarket",
"title": "call source",
"required": true
},
"tppParam": {
"type": "array",
"items": {
"type": "object",
"properties": {
"key": {
"type": "string",
"title": "tpp入参",
"required": true
},
"value": {
"type": "string",
"default": "${input.}",
"description": "支持从input或config从动态获取参数",
"title": "解析表达式",
"required": true
}
}
},
"description": "从input或config中根据mvel表达式获取参数,最后组装为kv结构的tppParam",
"title": "tpp请求param"
}
}
}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.