The system
The services and what each one owns
One backend is the source of truth. The web app renders it; the workers consume its queues, each owning one part of the work so a slow render never holds up an order.
Web app
Next.js on Vercel, beside the backend’s region
- Server components render each page; server actions write
- Sign-in and sessions; mints the short-lived token the backend trusts
- Owns no domain data - everything goes through the API
Tensor-Core API
Go service: the source of truth
- Every route guarded by a permission, checked against a verified JWT
- Costing engine, registry, orders, batches, fulfilment, integrations
- Enqueues work for the workers inside the same database transaction
Production worker
Orders in, jobs and models out
- Shopify order sync (quick and full)
- Job creation and OpenSCAD model generation
- Customer-facing personalisation links
Batch worker
The print bed’s whole lifecycle
- Plans beds, locks them, dispatches to printers
- Fleet sync and print completion from BambuBuddy
Slice worker
Bambu Studio, headless
- Costs every uploaded design
- Slices merged plates for the printer
Agent & report workers
Scheduled jobs that talk to people
- Abandoned-checkout calls and WhatsApp follow-ups
- Accounts report by email
- Retention: removes data past 30 days, keeping a daily summary
The pipeline
An order’s journey, step by step
Every order follows the same path, and every step is done by a named part of the system - nothing waits on someone remembering to press a button.
- 1
Order arrives
The production worker pulls Shopify every minute for orders updated since its last pull, and in full every 10 minutes. Imports are idempotent upserts on the Shopify id.
Production worker · Shopify
- 2
Jobs are created
Each line becomes one job per printed part, matched to its registry product by SKU. Bundle items become their own jobs, named for what they print.
Job-creation queue
- 3
The customer confirms
Products that need it send a WhatsApp link with a preview; the customer checks their name before anything prints.
Personalisation-link worker · WhatsApp
- 4
The model is rendered
OpenSCAD renders the part’s design file with the customer’s fields as variables, producing a coloured 3MF that is measured and stored in S3.
Model-generation queue · OpenSCAD
- 5
Beds are planned
Waiting jobs are grouped by material, colour and nozzle, oldest order first, and packed onto the smallest machine class whose bed fits them.
Batch worker
- 6
The plate goes to a printer
The merged plate is laid out for the chosen machine, sliced in Bambu Studio and queued on the printer through BambuBuddy.
Batch worker · Slice worker · BambuBuddy
- 7
Printed, checked, packed
BambuBuddy’s print history marks the bed printed; each job then passes assembly, QC and packaging stations.
Batch worker · Stations
- 8
Shipped and followed
The parcel ships through Delhivery with tracking; failed deliveries surface as NDR actions and returns as reverse pickups.
API · Delhivery
Algorithms
The decisions Tensor makes, and how
Packing a bed, choosing a printer, pricing a design and keeping the store in sync are all rules in code - deterministic, tested and explainable.
Guillotine bin packing (Best-Area-Fit)
Places each part in the free rectangle that leaves the least area, splitting the remainder guillotine-style. Parts go largest first, and the planner tries several orderings and keeps the best, because the packer is order-sensitive.
Colour-first FCFS batching
Jobs are grouped by material, colour and nozzle, oldest order first. A bed locks once it holds 3+ units and a printer is free, up to 5 units, with one bed per machine; priority flags do not jump the queue.
Bed-class escalation
A bed starts on the class its unit count asks for and is promoted P2S → H2C → A2L until every part physically fits, so a large part never empties a bed.
Overhang-area orientation scoring
Scores each candidate resting face by the mesh area that would overhang downward (Tweaker-style) and recommends the least-support orientation.
Slicer-based costing with price ladders
Design CP is computed from the slicer’s grams and minutes; the selling price snaps up to the brand’s ladder, and money rounds half-to-even, matching the original spreadsheet to the paisa.
Parametric rendering
Each order field is mapped to a declared OpenSCAD variable and passed with -D; a file that does not declare a mapped variable is refused, because OpenSCAD would otherwise ignore it silently.
Incremental sync with overlap
Each quick pull asks only for orders updated since the previous pull began, less a two-minute overlap; a failed pull falls back to the two-day window so nothing is missed.
Summarise-then-delete retention
Each expired trading day (noon to noon IST) is rolled up into a summary before its rows are deleted, jobs before orders, so a crash leaves a summarised day rather than a lost one.
Engineering
The practices it is built on
The rules the codebase holds itself to, so the numbers stay right and the floor keeps moving.
Authorization lives in the backend
Every route is guarded by a named permission against a verified EdDSA JWT. No roles means no access - it fails closed - and a role change is enforced through a permissions version checked on each request.
The slicer is the source of truth
Time, filament and cost come from the slicer, never from an estimate; the costing engine is pure code with no database or I/O, tested against the spec’s own numbers.
Typed data end to end
SQL is written by hand and compiled to typed Go with sqlc - no ORM. Every API response the web app reads is validated with Zod, and every form and server action re-validates its input.
Work happens on queues
Background work runs on River, a Postgres-backed job queue: enqueued in the same transaction as the data it belongs to, retried with bounded attempts, deduplicated by key.
Idempotent by design
Order imports upsert on the Shopify id, job creation locks the order, and every sweep is safe to re-run - a retry costs time, never duplicates.
Secrets encrypted at rest
Store and integration credentials are sealed with AES-256-GCM in the database; service-to-service calls use a shared secret compared in constant time.
Migrations and real-database tests
The schema is versioned with goose migrations, and the integration suite runs against a real PostgreSQL before every release.
Fast by default
Pages stream a skeleton at once; the open product loads alone; sessions reuse a short-lived token; design files are cached in memory by version; the web app runs next to the backend.
Tech stack
What it is made of
Mainstream, well-supported tools at every layer - and one database for both the data and the work queues.
Frontend
- Next.js 16App Router, server components and actions
- React 19The interface
- TypeScript 5Strict typing across the app
- Tailwind CSS 4Styling on design tokens
- ZodValidates every response and form
- TanStack Query · Recharts · three.jsData fetching, charts and 3D previews
- Better AuthSessions, and the JWT + JWKS the backend verifies
- pnpmPackage manager
Backend
- Go 1.25The API and every worker
- GinHTTP routing and validation
- pgx · sqlc · goosePostgreSQL driver, typed queries, migrations
- RiverPostgres-backed job queue for the workers
- OpenSCADParametric model rendering
- Bambu StudioHeadless slicing
Data & infrastructure
- PostgreSQLThe one database for data and queues
- Amazon S3Design files, models and plates
- DockerEvery service as a container
- VercelHosts the web app
- CaddyTLS and routing in front of the API