← Site map Store ↗ ● api ? ops@makoauto.com

Overview

Orders today
Revenue today
last 7d: –
Orders in flight
queued / picking / assembling / shipped
AI jobs running
done 7d: –
Low-stock SKUs
reorder when ≤ threshold
Saved designs
lifetime

Orders by status

Low-stock alerts

PinFinishBayStockReorder at
Loading…

Orders

OrderCustomerPinsTotalStatusCreatedActions
Loading…

AI render queue

JobDesignCarProviderStatusProgressCreatedActions
Loading…

Saved designs

Pin inventory

PinCategoryFinishBayStockReorder ≤
Loading…

Settings read-only · config via backend/.env

Runtime

Providers set the corresponding env key to flip to "live"

ServiceModeEnv key

CORS allow-list FRONTEND_ORIGIN env

Architecture docs reference · fold open to read

Backend architecture specification (v1.0)

This is the engineering handoff that described the target backend shape. It remains the authoritative reference for the data model, integration surface, and end-to-end fulfillment flow.

1 · System architecture

The shape of things

Three tiers: the storefront, a custom Node service for configurator state + AI jobs, and Shopify for the classic commerce primitives (cart, checkout, payments, tax, fraud). Ops uses this console; customers see accounts via Shopify Customer Account API.

StorefrontConfigurator, catalog, AI preview, cart, account, tracking, admin console. All static HTML/JS in frontend/.
Makoauto API serviceNode + Fastify in backend/. Handles designs, AI jobs, inventory, orders. Talks to Shopify Admin API + AI providers + S3.
Shopify HeadlessProducts, cart, checkout, payments (Stripe / PayPal / Apple Pay), orders, customers, discounts, tax, fraud.
SQLite (dev) / Postgres (prod)Design docs, AI job records, pin inventory, order state — things Shopify doesn't model.
Redis + BullMQ (future)Queue for AI video renders (slow, bursty, retriable) and shipping-label printing.
S3 / R2 + CDNPin PNGs, rendered MP4 previews, customer design thumbnails, ML reference images.
AI provider routerAbstraction over Sora, Veo, Seedance. Cost + latency + content-policy routing.
Shipping (ShipStation / EasyPost)Rate shop UPS · USPS · DHL, print labels, track webhooks.
ObservabilitySentry, Grafana, PostHog analytics, logtail.
2 · Data model

Schema (SQLite · owned by us)

-- Pin SKUs (a tiny product catalog mirrored from Shopify)
CREATE TABLE pins (
  id                TEXT PRIMARY KEY,
  category          TEXT NOT NULL,
  label             TEXT NOT NULL,
  glyph             TEXT,
  image_url         TEXT,
  base_price_cents  INTEGER NOT NULL DEFAULT 300,
  created_at        TEXT DEFAULT (datetime('now'))
);

-- Finishes (silver/gold/black/rose) with per-SKU inventory
CREATE TABLE pin_variants (
  id            INTEGER PRIMARY KEY AUTOINCREMENT,
  pin_id        TEXT REFERENCES pins(id),
  finish        TEXT NOT NULL,
  bay_location  TEXT,
  stock_qty     INTEGER NOT NULL DEFAULT 0,
  reorder_point INTEGER NOT NULL DEFAULT 20,
  UNIQUE(pin_id, finish)
);

-- User's configurator state, one row per saved design
CREATE TABLE designs (
  id            TEXT PRIMARY KEY,
  customer_id   TEXT,
  frame_color   TEXT NOT NULL,
  plate_text    TEXT,
  finish        TEXT NOT NULL DEFAULT 'silver',
  placements    TEXT NOT NULL,   -- JSON { "0": { pin, finish }, ... }
  thumbnail_url TEXT,
  version       INTEGER DEFAULT 1,
  created_at    TEXT DEFAULT (datetime('now')),
  updated_at    TEXT DEFAULT (datetime('now'))
);

-- Orders + event-sourced status audit
CREATE TABLE orders ( id PRIMARY KEY, design_id, customer_email, ship_address,
  subtotal_cents, tax_cents, shipping_cents, total_cents, status, tracking_number, ...);
CREATE TABLE order_events ( id, order_id, from_status, to_status, note, actor, created_at );

-- AI renders — one row per generate request
CREATE TABLE ai_preview_jobs ( id, design_id, provider, prompt, car_spec, status,
  progress, output_url, cost_cents, error, created_at, finished_at );
3 · API surface

Endpoints exposed today

GET
/api/health — liveness probe + provider modes
GET
/api/pins — list catalog; ?category=&q=
GET
/api/pins/:id — single pin with per-finish stock
POST
/api/designs — upsert a design doc
GET
/api/designs — list saved designs
GET
/api/designs/:id — fetch a saved design
POST
/api/orders — create order (stub; Shopify replaces this)
GET
/api/orders — list orders
GET
/api/orders/:id — one order + event history
POST
/api/orders/:id/advance — queued → picking → assembling → shipped → delivered
POST
/api/ai/preview — enqueue an AI preview job
GET
/api/ai/preview — list render jobs
GET
/api/ai/preview/:jobId — poll status / progress / output
GET
/api/admin/stats — aggregated ops dashboard stats
PATCH
/api/admin/variants/:pin_id/:finish — adjust stock / reorder threshold / bay
4 · External services

What we do NOT build ourselves

💳 Payments

Shopify Checkout — we never handle PAN data. Stripe is the card gateway inside Shopify. PayPal / Shop Pay / Apple Pay all inherited.

📮 Shipping

EasyPost (or ShipStation) rate-shops UPS / USPS / DHL, prints labels, webhook flips status to delivered.

📽 AI video

Router picks Sora / Veo / Seedance by load, fallback on failure, per-user cost cap.

✉ Transactional email

Postmark or Resend. Order confirmation, preview ready, shipped + tracking, delivered + review.

5 · Fulfillment flow

From click to doormat

  1. Configurator autosaves placements to POST /api/designs every few seconds (debounced).
  2. AI preview: user submits car spec → job queued → worker renders → MP4 to CDN → SSE progress to the UI.
  3. Add to cart: API expands placements into Shopify variant_ids (one line per pin+finish), returns Shopify Checkout URL.
  4. Checkout: Shopify handles payment, tax, fraud. Webhook orders/paid hits our service.
  5. Order row created; email with AI preview sent; order appears in this console.
  6. Pick: staff opens picklist → walks bays → scans each pin (decrements stock_qty).
  7. Assemble: pins placed by hand, photographed for QC.
  8. Ship: EasyPost buys cheapest label; tracking number written back.
  9. Delivery webhook flips status; review email scheduled for +3 days.