FabricIQ Docs

Fabric IQ documentation

Fabric IQ Doc 3 — Product & Build Plan

Audience: Founders + eng building the sellable product. Companion: 01 Code & flows · 02 Gaps · Index


0. Two-line summary

Fabric IQ is a new multi-tenant garment SaaS (fabriciq.ai / xyz.fabriciq.ai) that rebuilds FactoryTracking’s MES on Postgres and ports FactoriQ’s Buy/Demand/Risk IQ, WhatsApp, and GST patterns — sold at ₹5,000/month (yearly ~₹50,000) with a hard access gate. First paid MVP is achievable in ~8 weeks; full vision ~20–24 weeks.

Can we build it? Yes — shop-floor E2E already runs locally; subscription E2E is standard Razorpay + webhook + tenant provision; WhatsApp/GST need Meta/NIC lead time but are proven patterns in FactoriQ.


1. Product definition

Two-line summary

One product for Indian garment/fabric manufacturers: buy materials intelligently, make on the floor with QR, talk on WhatsApp, invoice buyers with GST, and pay you a subscription for the software.

Positioning table

LayerToday’s sourceFabric IQ
Cut–sew–wash–QC–pack–dispatchFactoryTrackingCore Make (rebuild)
Buy / PO / vendorsFactoriQ BuyIQBuy IQ
Stock / locationsFT shallow + FQ deeperInventory intelligence
Demand / reorder AIFactoriQ DemandIQDemand IQ
Supplier riskFactoriQ RiskIQRisk IQ
WhatsApp opsFactoriQ Cloud/BaileysFirst-class channel
GST AR invoicesFactoriQ sell-sideFactory→buyer billing
SaaS ₹5k subscriptionFT soft Stripe/PaytmHard Razorpay gate

Pricing (initial)


2. Architecture (chosen)

Two-line summary

New monorepo — Next.js UI + Express/TypeScript API + PostgreSQL + Redis — FactoriQ-style tenancy; do not ship the Flask monolith.

flowchart LR
  subgraph public [Public]
    Mkt["fabriciq.ai marketing"]
    Rz[Razorpay]
  end
  subgraph tenant [Tenant]
    Sub["xyz.fabriciq.ai"]
    Phone["Floor phones"]
    WA["WhatsApp Cloud"]
  end
  subgraph plat [Platform]
    FE["Next.js"]
    API["Express API"]
    PG[(Postgres)]
    Redis[(Redis)]
    AI["AI service"]
  end
  Mkt --> Rz
  Rz --> API
  Sub --> FE
  Phone --> FE
  FE --> API
  API --> PG
  API --> Redis
  API --> WA
  API --> AI

Tenancy

Data

Why not evolve Flask?

Untested PG shim, no tests, secrets hygiene failure, Jinja UI bar, and FactoriQ modules are already TS/Python services — rewrite cost of MES domain is lower than forever maintaining the monolith.


3. End-to-end: SaaS subscription (buildable)

Two-line summary

Owner picks plan on marketing site → Razorpay charges → webhook creates tenant + admin → DNS already covers wildcard → owner logs into xyz.fabriciq.ai; every request checks subscription.

Detailed flow

sequenceDiagram
  participant Owner as FactoryOwner
  participant Web as MarketingSite
  participant Pay as Razorpay
  participant API as FabricAPI
  participant App as TenantApp

  Owner->>Web: View pricing Monthly or Yearly
  Owner->>Web: Start trial or Pay now
  alt Pay now
    Web->>Pay: Create subscription
    Pay->>Owner: Pay with UPI or card
    Pay->>API: Webhook subscription activated
  else Trial
    API->>API: Create tenant with 14 day trial
  end
  API->>API: Insert tenant slug and admin user
  API->>Owner: Email login link
  Owner->>App: Login on subdomain
  App->>API: Check subscription active
  alt Active or trial valid
    API-->>App: Allow MES
  else Lapsed
    API-->>App: Redirect to billing
  end

Implementation checklist

  1. Razorpay plans: plan_monthly_5000, plan_yearly_50000.
  2. Webhook signature verify; idempotent tenant create.
  3. Tables: tenants, subscriptions, subscription_events.
  4. Hard middleware on all app routes except marketing, signup, webhook, billing.
  5. Customer portal link to manage payment method.
  6. Dunning: WhatsApp/email 3 days before trial end (port FT daily-notifications idea).

Trial → paid conversion

Same checkout; on success set subscription_status=active, clear trial lock. No soft access after expiry.


4. End-to-end: factory shop floor (target Fabric IQ)

Two-line summary

Same MES loop as FactoryTracking, plus WhatsApp status pings and (Phase 3) GST invoice after dispatch.

Detailed flow

flowchart TD
  O["Customer order entered"] --> C["Create batch at CUTTING"]
  C --> Q["Print QR label"]
  Q --> S["Operator scans phone"]
  S --> MV["Move with sent qty"]
  MV --> WA1["WhatsApp stage alert"]
  MV --> RV["Receive with received qty"]
  RV --> ALERT{"Qty mismatch?"}
  ALERT -->|yes| FLAG["ALERT on dashboard"]
  ALERT -->|no| OK[OK]
  OK --> MORE{"More stages?"}
  FLAG --> MORE
  MORE -->|continue| MV
  MORE -->|QC| DEF["Log defect types"]
  DEF --> MORE
  MORE -->|PACK| PACK["Packing sheet"]
  PACK --> DISP[DISPATCH]
  DISP --> WA2["WhatsApp buyer Ready"]
  DISP --> GST["GST tax invoice PDF"]
  DISP --> REP["TV and reports"]

Stage pipeline (unchanged domain)

flowchart LR
  CUTTING --> STITCHING --> WASHING --> QC --> PACKING --> DISPATCH

Roles on the floor

RoleTwo-line
AdministratorFull access, users, billing, inventory.
SupervisorMove/receive any stage; targets; defects.
OperatorOnly batches in their department stage.
InspectorQC focus; defects.
Buyer (portal)Read-only own orders/status.

5. End-to-end: Buy + inventory (Phase 2 target)

Two-line summary

Demand or low stock creates a requisition; Buy IQ drafts a PO to a scored mill; WhatsApp sends it; GRN receives fabric into inventory; cutting consumes BOM.

flowchart TD
  LS[Low stock or Demand IQ] --> RQ[Requisition]
  RQ --> BI[Buy IQ vendor score]
  BI --> PO[Purchase order]
  PO --> WA[WhatsApp to mill]
  WA --> GRN[Goods receipt]
  GRN --> INV[Inventory ledger]
  INV --> BOM[BOM consume at CUTTING]
  BOM --> MES[Shop floor MES]

6. Phased delivery & timeline

PhaseWeeksOutcome (two-line)
0 Foundation1–2Repos, Postgres schema, auth, subdomain stub, Razorpay sandbox working.
1 Shop-floor MVP3–8Paid factory can run cut→dispatch + QR + basic stock/BOM + hard billing + WhatsApp alerts v1.
2 Buy + WA ops9–14Formal POs, fabric item fields, inbound WhatsApp floor/vendor.
3 Demand/Risk/GST15–20Demand IQ, Risk IQ, GST invoices, buyer portal polish.
4 Polish21–24Yearly UX, PWA, hardening, optional Tally.

First revenue: end of Phase 1 (~8 weeks). Full vision as described: ~20–24 weeks with 1–2 senior engineers + you.

Phase 0 detail

Phase 1 detail (sellable)

  1. Onboarding + roles
  2. MES recreate (create/move/receive/QR/defects/targets/dashboards)
  3. Inventory + style BOM
  4. Orders + thin buyer portal
  5. Razorpay monthly/yearly + hard gate
  6. WhatsApp Cloud: low_stock + stage_move + daily_brief templates
  7. Marketing site pricing page

Out of Phase 1: full BuyIQ, Demand/Risk, GST IRN, roll tracking, native app.

Phase 2–4

As in Doc 2 priority table (Buy IQ → WhatsApp inbound → Demand/Risk/GST → polish).


7. Target schema notes (Postgres)

Two-line summary

Port every Doc 1 table; rename company_idtenant_id; add subscriptions and WhatsApp/integration tables; add fabric attributes on items when Phase 2 starts.

New tables beyond FT

TableTwo-line purpose
subscriptionsRazorpay subscription id, status, period end, plan code.
subscription_eventsWebhook audit log.
whatsapp_templates / whatsapp_messagesOutbound/inbound log (from FQ patterns).
purchase_orders / purchase_order_linesFormal POs (Buy IQ).
customer_invoicesGST AR invoices.
risk_signals / demand_forecastsIQ modules.

Fabric item extensions (Phase 2)

On inventory_items or fabric_rolls: gsm, width_cm, composition, shade, lot_number, roll_barcode, meters.


8. Deployment strategy

Two-line summary

Cloudflare DNS/TLS in front; managed Postgres; app on Railway/Render/Fly or a VPS; staging + prod; never commit secrets.

ConcernChoice
DNS/TLSCloudflare proxy + wildcard
App hostRailway or Fly (or OCI if you prefer)
DBNeon or RDS Postgres + nightly backup
Files/QRObject storage (S3/R2) not local disk
ObservabilitySentry + /healthz + uptime
Envsdev / staging.fabriciq.ai / prod

9. Engineering rules


10. Risks & mitigations

RiskTwo-lineMitigation
Meta template approval delayBlocks WhatsApp alerts.Apply week 1; ship email fallback in Phase 1.
Wildcard TLS painSubdomains fail.Path /t/xyz fallback.
Scope creepPayroll/CAD delay launch.Enforce non-goals Doc 2.
Underestimate MES rewriteTimeline slips.Vertical slice week 3: login→batch→move→scan.
GST NIC complexityPhase 3 slips.Mock IRN first.

11. Success metrics (first 90 days post-MVP)

MetricTarget (example)
Paying factories5+
Batches moved / week / factoryMeasurable vs paper
WhatsApp alerts delivered>95% success
Trial→paid conversionTrack; improve onboarding
Critical bugs in MES qtyZero silent qty loss

12. Immediate next steps (after docs approved)

  1. Confirm domain fabriciq.ai + Cloudflare.
  2. Scaffold FabricIQ monorepo.
  3. Schema ADR + first migrations.
  4. Razorpay test subscription E2E.
  5. Vertical slice: subdomain login → create batch → move → QR scan.
  6. Start Meta Business verification in parallel.

13. FAQ

Is FactoryTracking deployed? No confirmed live URL; use as domain reference only. Is subscription E2E buildable? Yes — Razorpay + webhook + tenant + hard gate. Is shop-floor E2E buildable? Yes — already demoable locally; rebuild for production. Do we need FactoriQ monorepo as dependency? No — port patterns/modules into FabricIQ repos; keep products separate. HTML versions of these docs? Markdown is complete with Mermaid; say if you want matching single-file HTML next.


End of Doc 3.