Skip to main content

RFQ to Quote Lifecycle

This page documents the full client-RFQ to quote-sent lifecycle as a series of paired flowcharts + sequence diagrams. Each stage of the workflow has both a structural view (decisions, branches, data stores) and an interaction view (HTTP calls, table writes, LLM invocations). The source of truth for these diagrams is vinmaketeam/brain-contracts/LIFECYCLE.mmd. This page renders them.
Color legend. Across every diagram: blue = AI step, yellow = human action, amber = human approval gate, green = data store, gray = external system, purple = input artifact.

Why we build an agent, not a thin wrapper

A pure model (ChatGPT.com, Claude.ai) applied to VinMake’s work is like sending a baby to do a merchandiser’s job. Smart on a single turn, useless across a hundred. We need professionals — consistent, dependable, accurate, high-agency. The four traits a merchandiser must have, and a thin wrapper never does: The agent route costs more engineering up front. What we get back is a system that grows from baby-grade to professional-grade over weeks — and stays there because the harness, contracts, and eval loop keep it there.

Baby → Professional

LangGraph workflows, not just .md skills

Inside the Baby → Pro bridge, “structured contracts” and “state per step” pull a specific weight: about 70% of Brain framework’s work lives in explicit LangGraph + Pydantic AI workflows, not in .md skill files inside a system prompt. Skill files are fine for single-prompt deterministic operations — summarize a style, find duplicates, classify an email. But they break consistency the moment a workflow needs state, retries, idempotency, typed handoffs between steps, or human approval gates in the middle. A BOM generation expressed as “you are a BOM extraction assistant…” in a system prompt produces a different shape every run. The same workflow expressed as LangGraph nodes with Pydantic outputs produces the same shape every run — and the eval harness can grade it. Rule of thumb. If the work needs to look the same on Monday and Friday, it goes in a LangGraph node. If it’s a one-shot transformation with no downstream consumers, a .md skill is fine.

Measuring consistency

You cannot ship a professional you cannot measure. Two axes split the measurement problem cleanly: debug (what just happened?) vs judge (was it any good?). Both have a NOW tool and a LATER tool — pick the cheap one until prod traffic justifies the spend.

Lifecycle overview

Six stages, three services, two humans, one client. The sequence diagram is the narrative view; the tree is the branching view.

Sequence

Tree

Stage 1 — Email intake

KG service polls Gmail every 30s, dedupes by gmail_message_id, downloads attachments to a Supabase bucket, runs OCR/embedding/entity-extraction. Brain framework pulls indexed emails, classifies (heuristic → LLM fallback), posts an Inbox card. Mai’s gate decides Task vs File vs Spam.
Task vs File. A Task is a blocking action that writes to CutMake (e.g. create Style row). A File is an indexed-but-no-action archive — still retrievable, no human gate.

Flowchart

Sequence

Stage 2 — Style record creation

Brain extracts fields via regex (hard refs) and LLM tool-use (prose), matches the client (exact domain → fuzzy name → past style_refs), drafts a Style record, asks Mai for any missing pieces, then writes to CutMake on approval. Brain owns this stage end to end; KG is read-only.

Flowchart

Sequence

Stage 3 — BOM generation

This is the workflow with the most LLM-heavy reasoning and the tightest cost discipline. BOM agent owns the work; Brain orchestrates and runs Mai’s reconfirm loop.
Hard cost cap. BOM agent enforces a per-request vision budget (default $2.00). Pathological PDFs with hundreds of images return partial: true with skipped_pages populated rather than running away with cost. Brain renders the partial BOM and asks Mai to fill the gaps.
Reconfirm rule. Every LOW-confidence line gates on Mai before the BOM can be approved. HIGH and MEDIUM lines do not gate. “If AI is guessing → always reconfirm” is a hard rule, not a heuristic.

Flowchart

Sequence

Stage 4 — True cost computation

Brain matches each BOM line to a supplier price (exact code → fuzzy on type/color/gsm), converts to base currency, adds MOQ surcharges, layers in overheads (labor SAM, freight zone, HS-code duty, defect allowance), then runs an anomaly check vs the prior 50 styles in the same category for the same client. Zean reviews.

Flowchart

Sequence

Stage 5 — Quotation drafting

Brain applies the client’s markup rule, fills terms (incoterms, payment, lead time, validity), renders the quotation PDF via Jinja+WeasyPrint, sanity-checks the unit price against the past 12 months of quotations to the same client. Zean reviews.

Flowchart

Sequence

Stage 6 — Client reply email

Brain pulls recent thread context via KG retrieval, detects tone (formal / casual / urgent), composes the reply with anchors the client used (style_ref, dates, specific questions), attaches the quote, shows Mai a draft. On send, Gmail outbound is re-indexed and linked to the RFQ thread.

Flowchart

Sequence