項目作品/Gwyneth Prints
基於二進制STL體積定價與直接Cloudflare R2整合嘅按需3D打印平台。

全端3D打印服務與模型目錄電商平台。具備透過Cloudflare R2預簽名URL實現嘅直連雲端檔案上傳、用於精確體積計算與動態定價嘅自訂二進制STL幾何解析、多渠道付款對賬(Stripe、Ko-fi、FPS/PayMe手動收據)、管理員畫廊審核,以及帶有效期令牌嘅數碼STL檔案交付。
Key architectural decisions, concrete code implementations, and performance wins behind this project.
Handling large 3D model files (STL models up to 50MB) and payment receipts directly through standard Next.js serverless route handlers introduces heavy payload buffering, memory spikes, and route timeout limits.
Built a presigned URL generation workflow using AWS S3 SDK against Cloudflare R2 endpoints. Filenames are sanitized, MIME types are strictly validated (differentiating STL geometries from image/PDF receipts), and storage keys are partitioned under session user IDs (`uploads/{userId}/` and `receipts/{userId}/`) to enforce zero unauthorized cross-tenant file writes.
Pricing custom 3D prints dynamically requires computing exact model volume in cubic millimeters without requiring users to install native desktop slicer tools.
Implemented signed tetrahedron divergence theorem summation across binary STL facets directly in Node.js/TypeScript. After streaming the object securely from R2 and validating the 50MB payload threshold, the parser reads facet normal vectors and vertex coordinates directly from the IEEE 754 float buffer to compute precise volume in mm³.
Allowing authenticated digital goods distribution and secure model downloads without exposing long-lived access keys, private bucket URLs, or allowing unauthorized link sharing.
Engineered an S3-compatible client wrapper targeting Cloudflare R2 endpoints with scoped presigned URL generators (`getUploadPresignedUrl` with 300s TTL and `getDownloadPresignedUrl` with 60s single-use TTL), pairing digital downloads with database-persisted token hashes.
// community_discussion
Have thoughts, questions, or ideas regarding this system's architecture? Leave a comment below with your GitHub account.