项目作品/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.