PostgreSQL via Prisma. Source of truth: backend/prisma/schema.prisma.
- Identity: Customer
- Catalog: CatalogItem, ProductTemplate, Model
- Quoting: Quote, Job
- Cart: Cart, CartLine
- Orders: Order, OrderLine
- Pricing: PricingProfile, QuoteRule
- Payment config: PaymentMethodConfig
- Production: ProductionQueue, ProductionQueueItem, PrinterAssignmentPayload
- Order support: ApprovalRequest, RevisionRequest, ReprintRequest, ProjectWorkspace, PinnedPartComment, AuditEvent
- Purpose: Registered user; owns orders, quotes, and carts.
- Key fields:
id(UUID),email(unique),password,name,createdAt,updatedAt. - Relations: One-to-many
orders,quotes,carts.
- Purpose: Sellable product or “upload my file” entry; used for storefront and quote entry.
- Key fields:
id,slug(unique),name,description,productTemplateId(optional FK),featured,sortOrder,active,imageUrl,createdAt,updatedAt. - Relations: Many-to-one
productTemplate(ProductTemplate, optional).
- Purpose: Admin-defined template; drives catalog items, models, and pricing profiles.
- Key fields:
id,name,description,active,createdAt,updatedAt. - Relations: One-to-many
models,catalogItems,pricingProfiles.
- Purpose: 3D model file metadata linked to a product template.
- Key fields:
id,productTemplateId,fileKey,format,displayName,createdAt. - Relations: Many-to-one
productTemplate(ProductTemplate).
- Purpose: Snapshot of one or more jobs with pricing; draft or locked when added to cart.
- Key fields:
id,sessionId,customerId(optional),status(draft | locked),totalPrice,currency,validUntil,createdAt,updatedAt. - Relations: Many-to-one
customer(Customer, optional); one-to-manyjobs.
- Purpose: Single quoted unit (options, quantity, unit price); belongs to a quote, then optionally to an order line after checkout.
- Key fields:
id,quoteId,orderLineId(optional),materialId,qualityId,toleranceClassId,quantity,turnaroundProfileId,unitPrice,feasibilityStatus,leadTimeDays,createdAt,updatedAt. - Relations: Many-to-one
quote(Quote), many-to-oneorderLine(OrderLine, optional).
- Purpose: Session- or customer-scoped container of cart lines (locked quote jobs).
- Key fields:
id,sessionId,customerId(optional),createdAt,updatedAt. - Relations: Many-to-one
customer(Customer, optional); one-to-manylines(CartLine).
- Purpose: One line per locked job in the cart; references quote and job by id, stores locked price.
- Key fields:
id,cartId,quoteId,jobId,quantity,lockedUnitPrice,currency. - Relations: Many-to-one
cart(Cart).
- Purpose: Post-checkout record; payment method/state, lifecycle stage, customer or guest.
- Key fields:
id,orderNumber(unique),customerId(optional),guestEmail(optional),paymentMethod,paymentState,lifecycleStage,createdAt,updatedAt. - Relations: Many-to-one
customer(Customer, optional); one-to-manylines,approvalRequests,revisionRequests,reprintRequests,auditEvents,projectWorkspaces.
- Purpose: One line per job in an order; snapshot of options and price at checkout.
- Key fields:
id,orderId,jobId,snapshot(JSON),quantity,lineTotal,createdAt. - Relations: Many-to-one
order(Order); one-to-manyjobs(Job),queueItems(ProductionQueueItem),printerAssignments(PrinterAssignmentPayload).
- Purpose: Admin-defined profile for quote rules (material/quality/turnaround → price, feasibility, lead time).
- Key fields:
id,name,productTemplateId(optional),active,createdAt,updatedAt. - Relations: Many-to-one
productTemplate(ProductTemplate, optional); one-to-manyrules(QuoteRule).
- Purpose: One rule per profile: conditions (material, quality, etc.) → unitPrice, currency, feasibilityRule, leadTimeDays, optional min/max quantity.
- Key fields:
id,pricingProfileId,materialId,qualityId,toleranceClassId,turnaroundProfileId,unitPrice,currency,feasibilityRule,leadTimeDays,minQuantity,maxQuantity,materialRecommendations. - Relations: Many-to-one
pricingProfile(PricingProfile).
- Purpose: Admin toggle and config per payment method (e.g. stripe, paypal, quote_request).
- Key fields:
id,method(unique),enabled,sortOrder,configJson,updatedAt. - Relations: None (standalone config table).
- Purpose: Named queue for production items (e.g. by printer or stage).
- Key fields:
id,name,active,createdAt,updatedAt. - Relations: One-to-many
items(ProductionQueueItem).
- Purpose: One order line in a queue; links to optional printer-assignment payload.
- Key fields:
id,queueId,orderLineId,status,printerAssignmentId(optional),createdAt,updatedAt. - Relations: Many-to-one
queue(ProductionQueue), many-to-oneorderLine(OrderLine), many-to-oneprinterAssignment(PrinterAssignmentPayload, optional).
- Purpose: JSON payload for production (e.g. for a Bambu connector); created per order line for “prepare” flow.
- Key fields:
id,orderLineId,payload(JSON),status,createdAt,updatedAt. - Relations: Many-to-one
orderLine(OrderLine); one-to-manyqueueItems(ProductionQueueItem).
- Purpose: Customer approval request for an order (e.g. design approval).
- Key fields:
id,orderId,requestedAt,dueAt,status,customerResponseAt,customerNotes,adminNotes,createdAt,updatedAt. - Relations: Many-to-one
order(Order).
- Purpose: Revision request for an order or order line.
- Key fields:
id,orderId,orderLineId(optional),type,customerNotes,status,fulfillmentNotes,createdAt,updatedAt. - Relations: Many-to-one
order(Order).
- Purpose: Reprint request for an order or order line.
- Key fields:
id,orderId,orderLineId(optional),type,customerNotes,status,fulfillmentNotes,createdAt,updatedAt. - Relations: Many-to-one
order(Order).
- Purpose: Workspace per order for collaboration (e.g. pinned parts and comments).
- Key fields:
id,orderId,name,createdAt,updatedAt. - Relations: Many-to-one
order(Order); one-to-manycomments(PinnedPartComment).
- Purpose: Comment on a workspace, optionally pinned to an order line or part index.
- Key fields:
id,workspaceId(optional),orderLineId(optional),partIndex(optional),authorId,authorType,body,createdAt,updatedAt. - Relations: Many-to-one
workspace(ProjectWorkspace, optional).
- Purpose: Generic audit log; optionally scoped to an order.
- Key fields:
id,entityType,entityId,action,actorId,actorType,oldValue,newValue,orderId(optional),createdAt. - Relations: Many-to-one
order(Order, optional). Index on(entityType, entityId, createdAt).
flowchart LR
subgraph identity [Identity]
Customer
end
subgraph catalog [Catalog]
CatalogItem
ProductTemplate
Model
end
subgraph quoting [Quoting]
Quote
Job
end
subgraph cart [Cart]
Cart
CartLine
end
subgraph orders [Orders]
Order
OrderLine
end
subgraph pricing [Pricing]
PricingProfile
QuoteRule
end
subgraph production [Production]
ProductionQueue
ProductionQueueItem
PrinterAssignmentPayload
end
Customer --> Order
Customer --> Quote
Customer --> Cart
ProductTemplate --> CatalogItem
ProductTemplate --> Model
ProductTemplate --> PricingProfile
PricingProfile --> QuoteRule
Quote --> Job
Cart --> CartLine
CartLine -.-> Quote
CartLine -.-> Job
Order --> OrderLine
Job --> OrderLine
OrderLine --> ProductionQueueItem
ProductionQueue --> ProductionQueueItem
OrderLine --> PrinterAssignmentPayload
ProductionQueueItem --> PrinterAssignmentPayload
Order --> ApprovalRequest
Order --> RevisionRequest
Order --> ReprintRequest
Order --> ProjectWorkspace
Order --> AuditEvent
-
Cart / checkout: User has a
Cart(bysessionIdorcustomerId).CartLinerows reference a lockedQuoteand specificJobids and storelockedUnitPrice/currency. At checkout, anOrderandOrderLinerows are created from the cart; cart is cleared. EachOrderLinestoresjobIdand asnapshot(JSON) of the job at checkout. -
Quote lock: When the user adds to cart, the quote’s
statusbecomeslocked. Jobs stay attached to the quote; cart lines referencequoteIdandjobId. After checkout, jobs can be linked toOrderLineviaorderLineId. -
Production: Admin adds an
OrderLineto aProductionQueueas aProductionQueueItem. A “prepare” flow creates aPrinterAssignmentPayloadfor that order line; the queue item can reference it viaprinterAssignmentId. The payload JSON is consumed by a future connector (e.g. Bambu Lab).