An AI-assisted procurement ERP that turns a plain-English purchase request into RFQs, parsed supplier quotes, a ranked bid comparison, and a ready-to-approve Purchase Order.

Cut the 5-10 day manual purchasing cycle in manufacturing plants down to a single human approval click, while using LLMs safely. The core mission was to automate the repetitive work (typing specs, emailing vendors, transcribing PDF quotes, comparing bids) and keep a human in control of every commitment. I also wanted to design around real LLM failure modes, especially invented numbers that corrupt business data.
The problem Direct-material buying in plants (kraft paper, adhesives, inks, cartons) is slow and error-prone. Buyers chase quotes over phone and email, retype line items, HSN codes, GST and freight terms from PDFs into Excel, and often decide without checking what was paid last time. Worse, when a buyer reveals a budget, suppliers quote just under it (price anchoring). What I built Procura is a full-stack ERP where a plant manager types a request such as "Need 1,000 kg 250 GSM kraft paper and 500 kg brown paper by Friday, no budget". From there: - The request is parsed into a structured multi-item Bill of Materials. - Approved, active vendors are pulled from PostgreSQL by category. - Blind RFQ emails are drafted for human review, then sent via Resend. - Supplier replies arrive by webhook; quote PDFs are read with multimodal Gemini and stored as structured quotations. - Quotes are ranked by a 4-factor score (price, payment terms, on-time delivery, quality) and benchmarked against the Last Purchase Price. - The manager approves in one click, generating a Purchase Order and a signed, zero-login confirmation link for the supplier. Beyond the PO The system tracks a 6-stage lifecycle: PO issued, supplier confirmed, in transit (parsed from dispatch emails), 4-way Goods Receipt (ordered / received / damaged / accepted), QA inspection, and automatic closure when QA passes with zero balance. What I'm most proud of The guardrails. Missing budgets and deadlines stay NULL instead of being guessed. Unstated lead times are stored as NULL instead of a fabricated "7 days". The AI layer degrades gracefully: a multi-model Gemini fallback chain with timeouts, then a deterministic regex parser, so the pipeline never freezes.

- Next.js (App Router) + React: one codebase for server-rendered pages, API route handlers, and auth middleware, which keeps the full workflow easy to reason about and deploy. - Tailwind CSS: consistent enterprise UI with a single amber accent system, reusable modals, and skeleton loaders. - PostgreSQL + node-postgres (pg): procurement is deeply relational (PR to RFQ to quotation to PO), so I chose ACID guarantees, foreign keys, and JSONB where flexibility was needed. - Google Gemini API (multimodal): structured intent extraction from text and direct reading of quotation PDFs, with a model fallback chain for rate limits and outages. - Resend (email + inbound webhooks): sends RFQs and PO emails and receives supplier replies programmatically. - bcryptjs + Node crypto: password hashing, plus HMAC-SHA256 signed expiring links for secure zero-login supplier access. - Node.js (ESM JavaScript): one language across the stack.
Pattern: Monolithic Next.js (App Router) application. UI, REST route handlers, and middleware live in one codebase, backed by PostgreSQL. Request flow - Intake: natural-language prompt goes to `/api/ai-orchestrator`, where Gemini returns a strict JSON schema (nullable budget and deadline, items array). - Sourcing: parameterized SQL selects matching vendors and computes a Last Purchase Price benchmark. - Outbound: a human approves, then RFQ and rfq_vendor records are committed and emails dispatched via Resend. - Inbound: a Resend webhook (`email.received`) fetches attachments, runs multimodal Gemini OCR with intent classification (quotation vs dispatch notice), and writes to PostgreSQL. - Evaluation: weighted scoring ranks quotes, and a manager award creates the PO. - Supplier portal: HMAC-SHA256 signed links with a 7-day expiry (`timingSafeEqual` verification) let suppliers confirm orders without an account. Data layer: relational schema (PRs, RFQs, RFQ-vendors, quotations, purchase orders, vendors, users) with foreign keys linking each stage of the lifecycle. Security and access: bcrypt password hashing, cookie sessions, and middleware-enforced three-tier RBAC (Admin, Warehouse Officer, token-based Supplier). Resilience: Gemini model fallback chain with 5-second abort timeouts, ending in an offline regex rule engine.


Take a look at other adjacent software engineering and system architecture builds.