Each product variant in Krafta has exactly oneDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/PloutusLab/krafta-web/llms.txt
Use this file to discover all available pages before exploring further.
PrintTemplate record that serves as the contract between the product catalog and the design editor. The template tells the Fabric.js canvas where to position the customer’s artwork on the product mockup, what shape to clip it to, and what minimum resolution to enforce before the design can be submitted to production.
PrintTemplate model fields
printAreaX, printAreaY, printAreaWidth, printAreaHeight) are expressed as percentages of the mockup image dimensions, not pixels. This ensures the template remains correct at any rendered size. A rotation value rotates the print area overlay clockwise in degrees; the default is 0. The shape field controls which clipping mask the editor applies — RECTANGLE for flat products like t-shirts and notebooks, ELLIPSE for round surfaces like mugs.
Minimal example
How the Fabric.js editor uses the template
When a customer opens the design editor, the application fetches the full product viaGET /api/catalog?id=<id> and reads the selected variant’s PrintTemplate. The editor mounts a Fabric.js canvas precisely over the element matched by either [id*='krafta-print-area'] or [id*='_x23_krafta-print-area'] in the SVG mockup. The dual selector handles SVG files that have been through an encoding pipeline that prefixes # characters as _x23_. The print area coordinates are converted from percentages to pixel positions at render time based on the displayed image size.
The canvas accepts customer uploads (PNG, JPG, PDF, SVG), rasterises them if necessary, and clips the result to the shape defined by the template. Any object dragged outside the print area boundary is flagged with a visual warning; the submit button remains disabled until all design objects are within bounds and DPI requirements are met.
SVG variable system
Products that have ansvgContent field use the Master Interactive SVG workflow. Within the SVG markup, any element whose id attribute contains the string krafta-var- (or the encoded form _x23_krafta-var-) is treated as an adjustable variable. The editor scans the loaded SVG for these elements using [id*='krafta-var-'] and [id*='_x23_krafta-var-'] and surfaces them as controls in the customization panel.
fill attribute in real time, and the live mockup preview reflects the change immediately without a round trip to the server.
File upload constraints
The editor enforces the following constraints on any file a customer attempts to upload:| Constraint | Value |
|---|---|
| Accepted formats | PNG, JPG, PDF, SVG |
| Maximum file size | 20 MB |
| SVG with scripts | Rejected — files containing <script> tags are refused with a 400 error |
| Validation method | Magic-byte check for PNG/JPG/PDF; text-content inspection for SVG |
DesignUpload.magicBytes). SVG files are validated by inspecting the text content for <svg or <?xml at the start of the file; any SVG containing a <script> tag is rejected outright rather than sanitised.
DPI check
Before a design is accepted for production, the effective DPI of the artwork at the actual print size is calculated using the formula:minDpi pixels per printed inch. With the default minDpi of 150, a design intended to cover a 10-inch print width must be at least 1500 pixels wide. If the calculated effective DPI falls below minDpi, the editor displays a resolution warning and blocks submission.
SurfaceTemplateVersion — advanced versioned templates
For complex or frequently-revised products, Krafta supports a versioned template system through SurfaceTemplateVersion. This model decouples the template configuration from the product variant so that a new version can be drafted and tested before replacing the published one.
templateKey is a human-readable slug that identifies a logical template across versions. The manifestJson field holds the complete rendering configuration, including layer order, blending modes, and print area definitions. Only one version per templateKey should have status: "PUBLISHED" at any given time; the rest are either in DRAFT or ARCHIVED.
MockupScene — composite rendering modes
Each SurfaceTemplateVersion can have multiple MockupScene records that describe how to composite the customer’s design onto the mockup using different rendering techniques:
| Mode | Description |
|---|---|
flat | Simple rectangular overlay; used for flat products like notebooks and posters |
cylinder | Cylindrical warp; used for mugs and bottles using displacementMapUrl |
mesh | Free-form mesh warp; used for apparel using displacement and highlight layers |
productMaskUrl isolates the printable surface from the background. shadowUrl and highlightUrl are blended on top of the customer’s design to add realistic depth and sheen.