Building a Personalized Product Customization System: Templates, Rule Engines, and Rendering
This article walks through the design of a personalized product customization system, using handbags and accessories as the primary scenario. It shows how to model products as a template-plus-options structure, turn craftsmanship constraints into declarative and executable rules, deliver what-you-see-is-what-you-get previews through layered rendering, and design a server-side architecture with key APIs. It also covers immutable configuration snapshots for traceability, observability, and cloud deployment, and closes with a checklist of common pitfalls. The core idea is to convert design freedom into constrained choices that are manufacturable, priceable, and deliverable.
1. Business Background and Problem Definition
In fashion retail, “personalization” is moving from a service reserved for a few high-end brands to a product capability that can be delivered at scale. Take handbags, luggage, and accessories as an example: the structural skeleton stays relatively stable, but dimensions such as the main material, color palette, hardware, size, lining, and engraving can be freely combined, easily producing hundreds of thousands to millions of possible variations.
If you stick with the traditional flow of offline discussions, hand-drawn sketches, and repeated confirmations, the problems cluster into four areas:
- High communication cost: Design and revisions bounce across multiple channels, and confirming a single option often takes several rounds of back-and-forth.
- High error rate: Mismatched sizes, materials, or process conditions lead to rework and delivery delays.
- Difficult quoting and scheduling: Custom items are non-standard products, so manual quoting is slow and it is hard to accurately commit to capacity and lead time.
- Loss of data assets: A customer’s design preferences and past configurations are scattered across individuals and cannot be accumulated into analyzable data.
Abstractly, the core tension in a personalization system is this: you must give users enough design freedom while ensuring that every “creation” is a legitimate combination that can be produced, priced, and delivered. So the key to system design is not piling on features, but converting “freedom” into “constrained choices”—through structured modeling, rule validation, and real-time feedback, so that users can see the final result and an accurate price before placing an order.
This article uses handbag and accessory customization as the typical scenario and covers the following layers:
- Data modeling
- Rule engine
- Rendering preview
- Order snapshots
- Cloud deployment
A checklist of common mistakes is included at the end for readers to self-review.
2. Domain Modeling: Abstracting a “Product” into “Template + Options”
2.1 From SKU-based Management to Configurable Products
Traditional e-commerce manages products by SKU, where each color maps to a single code. Personalization cannot follow this approach: the number of combinations grows multiplicatively, and creating a record for each one would quickly send the catalog out of control. A more reasonable approach splits a product into two layers:
- Style template: Defines the structural skeleton of the bag, such as a tote, bucket bag, or crossbody bag, determining the basic structure, required components, and mandatory dimensions.
- Option group: Organizes selectable values by dimension, such as “main material,” “color,” “hardware,” “size,” “lining,” and “engraving.” An option group can be single-select, multi-select, or “select at least N and at most M.”
- Option: Each option carries a price increment, rendering parameters, an associated inventory identifier, and extended attributes such as thickness, weight, and process notes.
The essence of this layering is to converge “design freedom” into an “enumerable combination space.”
2.2 Key Points of the Relationship Model
It is recommended to design at least a three-tier structure of “template—option group—option.” The template codes and option codes output externally should be globally unique and stable, which makes it easy to share links and integrate across systems.
-- Style template: prices are stored uniformly in minor currency units (cents) to avoid floating-point errorsCREATE TABLE style_template (template_id BIGINT PRIMARY KEY,code VARCHAR(32) NOT NULL UNIQUE, -- externally stable style codename VARCHAR(128) NOT NULL,base_price INT NOT NULL, -- base price (in cents)version INT NOT NULL, -- configuration version, incremented on publishstatus SMALLINT NOT NULL -- 0 draft / 1 published / 2 unpublished);-- Option group: min_count and max_count describe the selection count constraintsCREATE TABLE option_group (group_id BIGINT PRIMARY KEY,template_id BIGINT NOT NULL,code VARCHAR(32) NOT NULL,sort_order SMALLINT NOT NULL,min_count SMALLINT NOT NULL DEFAULT 1,max_count SMALLINT NOT NULL DEFAULT 1,UNIQUE (template_id, code));-- Option: price_delta is the increment over the base price; render_params holds rendering parametersCREATE TABLE option_item (option_id BIGINT PRIMARY KEY,group_id BIGINT NOT NULL,code VARCHAR(32) NOT NULL,name VARCHAR(128) NOT NULL,price_delta INT NOT NULL DEFAULT 0,render_params JSON, -- color, material, texture references, etc.stock_ref VARCHAR(64), -- associated fabric/hardware inventory identifierenabled BOOLEAN NOT NULL DEFAULT TRUE,UNIQUE (group_id, code));
There are four key points in this model design:
- Store amounts in the smallest currency unit: Record amounts as integers in cents and format them only at the presentation layer, fundamentally avoiding accumulated floating-point errors.
- Express prices as “base price + increment”: The total price is
base_price + Σ price_delta. When the base price is adjusted globally, there is no need to bulk-rewrite option data. - Separate code from name: Use stable codes for all external references, while names can be adjusted freely for localization and operational copy.
- Version the template: The version increments after a configuration template is published, ensuring that historical links, marketing content, and generated configurations always correspond to a definite structure.
2.3 Extensibility: Extended Attributes and Layered Rules
Craftsmanship constraints vary widely across styles. If you add a field for each style, the schema keeps bloating; if you cram everything into a free-text note, validation becomes impossible. A reasonable compromise is:
- Extended attributes: Use JSON fields to hold structured extended attributes, such as the maximum printable area in square centimeters or whether a chain strap is available.
- Layered rules: Rules fall into two categories:
- General rules: applicable to all styles, such as “custom engraving requires an additional production cycle.”
- Style-level rules: effective only for specific templates.
This keeps things flexible while ensuring validation logic stays unified and testable.
3. Constraint Rules: Turning Craftsmanship Experience into Executable Logic
3.1 Common Constraint Types
Typical constraints in handbag customization can be grouped as follows:
- Required constraints: For example, both size and main material must each have one selection.
- Mutual-exclusion constraints: For example, patent leather and embossing cannot coexist on the same component.
- Dependency constraints: For example, after choosing a genuine-leather main material, the lining can only be picked from silk or cotton-linen.
- Count limits: For example, custom engraving must not exceed 12 characters and cannot be all spaces.
- Derived-attribute constraints: The printed area must not exceed the coverage the style allows, and the finished weight must not exceed the strap’s recommended load.
- Inventory constraints: Whether the selected fabric and hardware currently have available stock or capacity.
3.2 Rule Expression: Declarative Over Hard-Coded
Rules should be data-driven. If if-else logic is scattered across frontend and backend code, adding a new craftsmanship rule often means changing multiple places and going through a full release cycle. It is recommended to describe rules with a unified JSON structure:
{"rules": [{"id": "R-001","type": "require","when": { "group": "material", "option": "leather_premium" },"then": { "group": "lining", "in": ["silk", "cotton_canvas"] },"message": "When premium genuine leather is selected, the lining is limited to silk or cotton-linen"},{"id": "R-002","type": "exclude","when": { "group": "finish", "option": "patent" },"then": { "group": "finish", "option": "embossed" },"message": "Patent leather and embossing cannot be used at the same time"},{"id": "R-003","type": "max_numeric","when": { "group": "size", "option": "mini" },"target": "print_area_cm2","max": 180,"message": "The mini style's printable area must not exceed 180 square centimeters"}]}
Keep the set of rule types small—covering most scenarios is enough. The calculation logic for derived attributes (such as deriving area from engraving and printing) is implemented in code for easier unit testing. Anything involving money is computed uniformly in cents.
3.3 Validation Algorithm
// Validate configuration legality: returns a list of issues, empty array means passfunction validate(config, rules) {const issues = [];const isOn = (cond) => Boolean(cond) &&config.selections.some((s) => s.groupCode === cond.group && s.optionCode === cond.option);for (const rule of rules) {const a = isOn(rule.when);const b = isOn(rule.then);if (rule.type === 'require' && a && !b) {issues.push({ ruleId: rule.id, message: rule.message });}if (rule.type === 'exclude' && a && b) {issues.push({ ruleId: rule.id, message: rule.message });}// max_numeric: numeric upper bound (e.g., printed area, engraving length)if (rule.type === 'max_numeric' && a) {const value = config.derived[rule.target];if (value > rule.max) {issues.push({ ruleId: rule.id, message: rule.message });}}}return issues;}
A single rule takes constant time, so the overall complexity is O(number of rules × cost per check). When the number of rules is manageable, the validation overhead is negligible.
3.4 Combination Explosion and Pruning
Suppose a template has m single-select dimensions and dimension i has n_i options. The theoretical number of combinations is the product of the option counts across dimensions. For example, 6 dimensions with 8 options each gives 8^6 ≈ 260,000 combinations, and adding multi-select dimensions multiplies it further. Obviously you cannot render all options at once, much less exhaustively validate each one. Common pruning techniques in practice include:
- Inverted index for rules: Build an index by “the option group a trigger belongs to.” Each selection then validates only the affected rules, avoiding a full scan.
- Instant frontend constraints: When the server returns a template, it also computes the set of available values for each dimension, greying out invalid options. Users never reach the point of “getting an error after submission.”
- Offline feasibility analysis: Before publishing a template, intersect all rules and count the feasible combinations for each value of each dimension. A count of 0 for an option indicates a rule conflict and should be blocked at publish time.
- Constraint propagation: For dependencies with a large impact, you can borrow the idea of “arc consistency” from constraint solving to repeatedly reduce the candidate set of each dimension until nothing changes, yielding a globally consistent set of available options.
// Precompute the set of available adjacent-dimension values for each optionfunction buildNeighborhood(template, rules) {const optionsByGroup = template.groups.flatMap((g) => g.options);const index = new Map();for (const option of optionsByGroup) {index.set(option.id, new Set(optionsByGroup.filter((other) =>other.groupId === option.groupId ||validate({ selections: [option, other], derived: {} },rules).length === 0).map((other) => other.id)));}return index;}
4. Rendering Preview: Letting Users See What They Get
4.1 Rendering Layers
It is recommended to split visualization into three layers:
- Structure layer: The base form of the style, described with a 3D model or parametric geometry.
- Material layer: Main material, color, and hardware, presented through PBR (physically based rendering) material parameters and textures.
- Detail layer: Engraving, printing, and decorative parts overlaid as independent layers, avoiding re-baking the entire texture.
4.2 From 2D Compositing to Lightweight 3D
- 2D compositing: Use the front view of the style as a base image and swap textures in the corresponding regions according to the options. Low cost and good compatibility, suitable for a mobile-first launch.
- Lightweight 3D: Use a low-poly model with normal maps to reproduce texture detail and support 360° rotation, for an experience closer to the real product.
- Fallback: For devices with weaker rendering capabilities, pre-generate multi-angle images and load them directly as the user switches views.
4.3 Color and Craftsmanship Fidelity
Colors that look different on screen from the physical product are a frequent cause of complaints for customized goods. It is recommended to:
- Produce all material textures in the sRGB color space;
- Show a standard color-card comparison in the interface and note that screens may differ;
- Provide physical close-up images of effects such as genuine-leather texture and patent-leather highlights as a reference.
4.4 Performance and Accessibility
- Tiered loading: Load a low-resolution preview image first, then load the detailed model once it becomes interactive.
- Lazy loading: Load engraving fonts and printing textures only when their corresponding step is activated.
- Accessibility: Provide a textual configuration summary for the canvas; support keyboard-only operation throughout; do not rely on color alone to indicate selected or disabled states; associate form controls with clear labels and include error messages.
5. Server-Side Architecture and Key APIs
5.1 Service Layers
- Catalog service: Provides template, option, rule, and pricing data. Read-heavy and write-light, suitable for multi-level caching.
- Configuration service: Handles validation, combination feasibility calculation, and configuration snapshot generation. This is where the core logic lives.
- Rendering service: Provides asset distribution and preview generation. Compute- or I/O-intensive, requiring elastic scaling.
- Quote and transaction service: Handles price calculation, inventory reservation, and order creation, requiring consistency and idempotency.
- Message queue: Used for asynchronous flows such as order confirmation and production scheduling synchronization, to smooth traffic peaks and decouple components.
5.2 API Conventions (Illustrative)
GET /api/templates/{templateCode}?version=7POST /api/configurations/validatePOST /api/configurations/{configId}/previewPOST /api/quotesPOST /api/orders # requires an idempotency key (Idempotency-Key)GET /api/orders/{orderNo}
Design principles:
- Cache catalog data by template version, and proactively invalidate it when a template is published.
- Keep the validation and preview APIs stateless so they can scale horizontally.
- Route all order-creation write APIs through an idempotency key to prevent duplicate orders caused by repeated clicks or network retries.
5.3 Quoting: Layered Calculation with Traceable Rules
A four-tier quoting structure is recommended:
- Base tier: The style’s base price.
- Option tier: The sum of price increments for the options selected across dimensions.
- Craftsmanship tier: Surcharges for custom processes such as engraving and printing.
- Service tier: Fees for delivery, express handling, and so on.
Example rules: engraving is free for up to 4 characters, with 2000 cents charged per character starting from the 5th; and each back-panel foil-stamped logo adds 3500 cents. Each tier’s calculation should retain its breakdown so that support staff can explain “why it costs this much.”
5.4 Inventory Reservation and Timeout Release
- Validate first, then reserve: Available stock and capacity must be validated in real time, and out-of-stock options are greyed out directly.
- Separate quoting from ordering: A quote has a validity period, for example 30 minutes, within which the price breakdown is locked.
- Reservations have a timeout: Configurations not paid within the timeout have their resources automatically released via delayed messages on the message queue.
5.5 Cross-Service Consistency
Placing an order often spans multiple services such as configuration, inventory, and orders. Common approaches include:
- Adopting a “reserve—confirm—release” model similar to TCC (Try-Confirm-Cancel);
- Or using Saga orchestration, pairing each forward step with a compensating action;
- Or using a local message table to guarantee eventual consistency, with a reconciliation job as a safety net.
6. Order Snapshots: Freezing the Design
After a user finishes designing, the most easily overlooked risk is that the template or options change later, making historical configurations impossible to reproduce. For example:
- A fabric is discontinued;
- An option is unpublished;
- An option’s price is adjusted.
Once this happens, after-sales traceability, dispute resolution, and quality analysis all become reactive. The solution is to generate an immutable “configuration snapshot” at order time and persist it alongside the order:
{"snapshotVersion": 1,"templateCode": "TOTE-2026A","templateVersion": 7,"selections": [{ "group": "material", "option": "leather_premium" },{ "group": "color", "option": "clay_pink" },{ "group": "hardware", "option": "gold_plated" },{ "group": "size", "option": "medium" },{ "group": "monogram", "option": "text", "value": "A&L" }],"derived": { "print_area_cm2": 96, "weight_g": 720 },"priceDetail": {"base": 59800,"options": 42000,"craft": 6500,"service": 0,"total": 108300,"currency": "CNY"}}
A snapshot contains six parts:
- Template version
- All options
- Derived attributes
- Price breakdown
- Currency type
- Snapshot version number
With a snapshot, the order is decoupled from the running template, and the user’s design can be fully reconstructed at any time. For features like “order again” and “share the same design,” you can also rebuild the configuration directly from the snapshot.
7. Observability and Continuous Optimization
7.1 Key Metrics
- Configuration completion rate and step-by-step drop-off rate;
- Selection rate for each option and number of rule triggers;
- Rendering first-frame time and preview API latency;
- Quote success rate and order success rate.
7.2 End-to-End Tracing
User selection, validation, rendering, quoting, and ordering should share the same request identifier, making it easy to trace from “a user reports that saving a design failed” down to the specific step.
7.3 Logging Conventions
- Structured logs that include the template code, version, and request identifier;
- No logging of sensitive personal information;
- Collect logs in a unified format and enable centralized search and analysis.
7.4 Monitoring and Alerting
Set reasonable thresholds based on metrics, for example:
- P95 latency of the preview API;
- Error rate;
- Proportion of rule-validation failures.
Also configure tiered alerts, forwarding important alerts to instant-messaging groups or an on-call system.
8. Cloud Deployment and Elasticity
An online customization system has two notable load characteristics:
- Traffic spikes during major promotions;
- Rendering tasks are compute-intensive.
In public cloud environments such as Baidu AI Cloud, you can combine general-purpose cloud services as needed:
- Stateless configuration and quoting services: deployed on a container platform, with automatic scaling based on metrics such as CPU and memory;
- Models and textures: stored in object storage and accelerated through a content delivery network to reduce origin bandwidth pressure;
- Hot catalog data: reads accelerated with a caching service;
- Orders and snapshots: relying on the high availability of a relational database;
- Asynchronous flows: traffic smoothing via a message queue;
- Operations: integrated with logging and monitoring/alerting services.
Security Baseline
- Upload APIs: User-uploaded assets require type whitelisting, size limits, and content moderation.
- Transmission security: Use HTTPS across the entire site.
- Authentication: Strict authentication and tiered authorization for admin configuration-publishing APIs.
- Storage security: Back up snapshots and order data regularly and rehearse recovery procedures.
- Compliance: Collect personal information following the principle of data minimization, and define a clear retention period.
9. Common Mistakes Checklist
- Creating a SKU for every combination: The catalog balloons and maintenance costs soar; use a “template + options” model instead.
- Hard-coding rules: Craftsmanship rules change frequently, so writing them in code leads to frequent releases and inconsistent rules between frontend and backend.
- Storing only an identifier on the order, not a snapshot: Once the template is adjusted, historical configurations cannot be reproduced.
- Ignoring screen color differences: A gap between experience and expectation directly triggers returns and complaints.
- Stocking only by style: Customization scenarios need inventory and capacity coordination across shared components such as main materials and hardware.
- Calculating amounts with floating-point numbers: Accumulated errors make reconciliation difficult.
- No end-to-end instrumentation: When conversion drops, it is impossible to locate the problem.
- Loading all high-definition assets at once: The mobile first screen loads slowly and users churn significantly.
10. Summary
The essence of a personalization system is trading “constraints” for “efficiency”. By abstracting products into templates and options, accumulating craftsmanship experience into configurable rules, implementing unified validation with a declarative rule engine, delivering what-you-see-is-what-you-get previews through layered rendering, and freezing the design result with configuration snapshots to ensure traceability, you can achieve stable production and fulfillment capability without sacrificing design freedom. This approach is not limited to handbags and accessories—it applies equally to furniture, footwear, jewelry, packaging, and other categories. The only differences lie in the types of constraints and the level of rendering detail.
