FabricIQ Docs

Fabric IQ documentation

Fabric IQ — Visual flows

Purpose: See every major flow as a diagram — what exists today, what is missing, what we add, and the full Fabric IQ end-to-end after build. Theme: FabricIQ blue + orange + black. Related: 01 Code · 02 Gaps · 03 Plan


How to read this page

  1. Today = FactoryTracking as it runs now.
  2. Gap = broken or missing for a real garment SaaS.
  3. Add = what Fabric IQ ports from FactoriQ or builds new.
  4. After = the complete loop once Phases 0–3 ship.

A. Stage pipeline (today — works)

flowchart LR
  C[CUTTING] --> S[STITCHING]
  S --> W[WASHING]
  W --> Q[QC]
  Q --> P[PACKING]
  P --> D[DISPATCH]

Summary: Six garment stages. Batches sit in current_stage and advance one step at a time.


B. Shop-floor batch loop (today — works)

flowchart TD
  create["Create batch at CUTTING"] --> qr["Generate QR label"]
  qr --> scan["Phone scan logs presence"]
  scan --> move["POST move with sent qty"]
  move --> recv["POST receive with received qty"]
  recv --> check{"Qty matches?"}
  check -->|yes| ok[Status OK]
  check -->|no| alert[Status ALERT]
  ok --> next{"More stages?"}
  alert --> next
  next -->|yes| move
  next -->|at QC| defect["Log typed defects"]
  defect --> next
  next -->|DISPATCH| done["Reports and TV dashboard"]

Summary: QR proves presence; move/receive is the real handoff; defects are separate from missing pieces.


C. Signup and login (today — works, soft billing)

flowchart TD
  signup["POST signup"] --> company["Insert companies trial 14 days"]
  company --> admin["Insert Administrator user"]
  admin --> sess["Set session company_id"]
  sess --> onboard["Onboarding checklist"]
  login["POST login"] --> find["Find user by username"]
  find --> hash["Check password hash"]
  hash --> sess2["Session with role and department"]
  sess2 --> home["Home dashboard"]

Summary: Multi-tenant by company_id. Trial starts at signup but expired trials can still use the MES today.


D. Orders and buyer portal (today — thin)

flowchart LR
  add["Add customer order"] --> pending[Pending]
  pending --> link["Link production batch"]
  link --> floor["Shop floor MES"]
  floor --> ready["Ready or Dispatched"]
  buyer["Create buyer login"] --> portal["Buyer portal"]
  ready --> portal

Summary: Brand sees order status only. No GST invoice, no WhatsApp ready ping yet.


E. Inventory reorder (today — manual WhatsApp)

flowchart TD
  item["Inventory item"] --> txn["IN OUT RESERVED ledger"]
  item --> bom["Style BOM"]
  bom --> reserve["Production order reserve"]
  txn --> low{"On hand at or below reorder?"}
  low -->|yes| draft["Open wa.me draft to supplier"]
  draft --> log["Log purchase_requests"]

Summary: No formal PO, no Meta Cloud send, no inbound mill reply tracking.


F. SaaS billing (today — soft gate)

sequenceDiagram
  participant Admin
  participant App as FlaskApp
  participant Pay as StripeOrPaytm
  Admin->>App: Open billing page
  Admin->>App: Start checkout
  App->>Pay: Create payment session
  Pay->>App: Webhook or callback
  App->>App: Set subscription active
  Note over App: Soft gate only MES still open if trial expired

Summary: Payment UI exists; access is not hard-blocked when unpaid.


G. What is missing vs what we add

flowchart TB
  subgraph today [Today FactoryTracking]
    T1[Shop floor MES]
    T2[QR scan]
    T3[Thin inventory BOM]
    T4[Soft Stripe Paytm]
    T5[wa.me draft only]
  end

  subgraph missing [Missing or weak]
    M1[Hard subscription gate]
    M2[Subdomain xyz.fabriciq.ai]
    M3[Formal PO Buy IQ]
    M4[WhatsApp Cloud alerts]
    M5[Demand IQ Risk IQ]
    M6[GST tax invoice]
    M7[Postgres production stack]
    M8[Fabric roll shade GSM]
  end

  subgraph add [Fabric IQ adds]
    A1[Razorpay hard gate]
    A2[Wildcard tenancy]
    A3[Buy IQ from FactoriQ]
    A4[WhatsApp templates inbound]
    A5[Demand and Risk IQ]
    A6[GST IRN e-way]
    A7[Next.js Express Postgres]
    A8[Fabric item ontology]
  end

  T1 --> A7
  T2 --> A7
  T3 --> A8
  T4 --> A1
  T5 --> A4
  M1 --> A1
  M2 --> A2
  M3 --> A3
  M4 --> A4
  M5 --> A5
  M6 --> A6
  M7 --> A7
  M8 --> A8

Summary: Keep MES domain logic; replace stack and soft billing; port FactoriQ IQ + WhatsApp + GST.


H. Gap-to-feature map (swimlane)

flowchart LR
  subgraph gap [Gap]
    G1[No hard paywall]
    G2[No WhatsApp bot]
    G3[No PO document]
    G4[No GST invoice]
    G5[No demand forecast]
  end

  subgraph fix [We add]
    F1[Razorpay middleware]
    F2[Meta Cloud templates]
    F3[Buy IQ POs]
    F4[Customer invoices GST]
    F5[Demand IQ]
  end

  G1 --> F1
  G2 --> F2
  G3 --> F3
  G4 --> F4
  G5 --> F5

I. Subscription E2E after Fabric IQ (buildable)

sequenceDiagram
  participant Owner as FactoryOwner
  participant Web as fabriciq.ai
  participant Pay as Razorpay
  participant API as FabricAPI
  participant App as xyz.fabriciq.ai

  Owner->>Web: Choose Monthly 5000 or Yearly
  Web->>Pay: Create subscription
  Pay->>Owner: Pay with UPI or card
  Pay->>API: Webhook subscription activated
  API->>API: Create tenant slug and admin
  API->>Owner: Email login link
  Owner->>App: Login on subdomain
  App->>API: Check subscription active
  alt Active or valid trial
    API-->>App: Allow full product
  else Lapsed
    API-->>App: Redirect to billing
  end

Summary: Pay → provision xyz.fabriciq.ai → hard gate on every request.


J. Shop floor E2E after Fabric IQ (Phases 1–3)

flowchart TD
  order["Customer order in app"] --> batch["Create batch CUTTING"]
  batch --> label["Print QR"]
  label --> scan["Operator scans"]
  scan --> move["Move with sent qty"]
  move --> waFloor["WhatsApp supervisor alert"]
  move --> recv["Receive qty check"]
  recv --> loop{"Next stage?"}
  loop -->|yes| move
  loop -->|QC| defects["Log defects"]
  defects --> loop
  loop -->|DISPATCH| ready["Mark Ready"]
  ready --> waBuyer["WhatsApp buyer Ready"]
  ready --> gst["GST tax invoice PDF"]
  ready --> tv["TV and analytics"]

Summary: Same MES core, plus WhatsApp and GST after dispatch.


K. Buy to Make to Sell — full Fabric IQ loop

flowchart TD
  demand["Demand IQ or low stock"] --> req["Requisition"]
  req --> buyiq["Buy IQ vendor score"]
  buyiq --> po["Purchase order"]
  po --> waMill["WhatsApp to mill"]
  waMill --> grn["Goods receipt GRN"]
  grn --> stock["Inventory intelligence"]
  stock --> cut["CUTTING consumes BOM"]
  cut --> sew["STITCHING WASHING QC PACK"]
  sew --> ship["DISPATCH"]
  ship --> invoice["GST invoice to brand"]
  ship --> risk["Risk IQ updates vendor score"]
  invoice --> saas["Factory pays Razorpay for Fabric IQ"]

Summary: This is the product story: buy fabric → make garments → invoice brand → you get subscription revenue.


L. Phased delivery as a flow

flowchart LR
  P0["Phase 0 Foundation"] --> P1["Phase 1 MES plus billing plus WA alerts"]
  P1 --> P2["Phase 2 Buy IQ plus inbound WA"]
  P2 --> P3["Phase 3 Demand Risk GST"]
  P3 --> P4["Phase 4 Polish PWA"]
PhaseWeeksShips
01–2Repos, Postgres, auth, subdomain stub, Razorpay sandbox
13–8First paying cut→dispatch factory
29–14Procurement + WhatsApp ops
315–20IQ + GST
421–24Hardening

M. Data model spine (today)

flowchart TB
  companies["companies tenant"] --> users["users staff"]
  companies --> batches["production_batches"]
  companies --> stages["factory_stages"]
  companies --> items["inventory_items"]
  companies --> orders["customer_orders"]
  batches --> moves["movement_history"]
  batches --> scans["scan_logs"]
  batches --> defects["defect_records"]
  items --> txns["inventory_transactions"]
  items --> bom["bill_of_materials"]
  orders -.->|"order_id"| batches

Summary: Everything hangs off the tenant. Batch is the production unit of work.


N. Before vs after access control

flowchart LR
  subgraph before [Today]
    B1[Trial expired] --> B2[MES still open]
  end
  subgraph after [Fabric IQ]
    A1[Trial expired] --> A2[Hard redirect billing]
    A3[Paid active] --> A4[Full product]
  end

*End of visual flows. Regenerate HTML with python3 docs/fabric-iq/_build_html.py.*