DEV Community

Cover image for Building an AI Procurement Copilot with Gemini, RAG & LangGraph
Vaishali Sonker
Vaishali Sonker

Posted on

Building an AI Procurement Copilot with Gemini, RAG & LangGraph

Building an AI Procurement Copilot with Gemini, RAG & LangGraph

Turning scattered procurement data into intelligent decisions

What if a procurement manager could simply ask:

β€œWhich vendor should we choose?”

…and get an answer backed by vendor history, contracts, quotations, purchase data, and company policies?

That question led me to my Google Gen AI Cohort project β€” an AI Procurement & Vendor Intelligence Platform.


🚨 The Problem

Procurement looks simple from the outside:

Send an RFQ β†’ Receive quotations β†’ Compare β†’ Select a vendor.

But in a real organization, things get much more complicated.

A company may receive quotations from multiple vendors in the form of PDFs or spreadsheets. Contracts may contain dozens of pages of important clauses. Historical purchases may be stored in databases, while vendor performance is spread across previous orders and ratings.

For example:

Vendor Price Delivery Warranty
Vendor A β‚Ή39 Lakh 15 days 2 years
Vendor B β‚Ή38 Lakh 40 days 1 year
Vendor C β‚Ή41 Lakh 10 days 5 years

If we only look at price, Vendor B appears to be the best choice.

But what if Vendor B has a poor delivery record?

What if Vendor C has consistently delivered high-quality products for the last three years?

What if Vendor C's contract has better payment and warranty terms?

This leads to the real problem:

Procurement is not just a price-comparison problem. It is a decision-making problem.


πŸ’‘ The Idea

My goal is to build an AI Procurement Copilot that connects different sources of procurement information and helps teams make faster, more informed decisions.

Instead of manually searching through multiple systems, a procurement manager could ask:

  • β€œCompare the vendors for RFQ #1024.”
  • β€œWhich vendor has the best delivery history?”
  • β€œAre there any risky clauses in Vendor A's contract?”
  • β€œWhy is this quotation more expensive than our previous purchases?”
  • β€œHow much did we spend with Vendor C last year?”
  • β€œWhich contracts expire in the next 60 days?”

The AI would retrieve the relevant information, analyze it, and explain the result.

This is not intended to be just another chatbot.

It is an AI layer over a real business workflow.


πŸ—οΈ Architecture

The planned architecture looks like this:

                    USER
                      β”‚
                      β–Ό
                React Frontend
                      β”‚
                      β–Ό
                 FastAPI API
                      β”‚
                      β–Ό
                  LangGraph
                      β”‚
                Planner Agent
                      β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β–Ό           β–Ό           β–Ό
      Contract      Vendor      Analytics
       Agent        Agent         Agent
          β”‚           β”‚             β”‚
          β–Ό           β–Ό             β–Ό
      Pinecone    PostgreSQL    PostgreSQL
          β”‚           β”‚             β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β–Ό
                    Gemini
                      β”‚
                      β–Ό
                Final Response
Enter fullscreen mode Exit fullscreen mode

The system combines two major types of data:

Structured Data

Stored in PostgreSQL:

  • Vendors
  • Products
  • RFQs
  • Quotations
  • Purchase Orders
  • Invoices
  • Payments
  • Vendor Ratings

Unstructured Data

Processed and indexed for retrieval:

  • Contracts
  • Vendor quotations
  • Warranty documents
  • Company policies
  • Procurement documents

This combination allows the AI to work with both business data and documents.


πŸ€– Why Gemini?

Gemini acts as the reasoning and language layer of the system.

It can be used for:

  • Understanding user questions
  • Document understanding
  • Structured information extraction
  • Contract summarization
  • Vendor comparison
  • Risk identification
  • Recommendation generation
  • Negotiation-draft generation

However, I don't want the model to simply generate answers from its internal knowledge.

Instead, the model should receive the right business context before generating an answer.

That's where RAG, databases, and tools become important.


πŸ“„ Document Intelligence

Procurement involves a huge amount of documentation.

For example, a vendor quotation might contain:

Vendor: ABC Industries
Product: Industrial Steel Sheet
Quantity: 5,000
Total Price: β‚Ή39,00,000
Delivery: 15 days
Warranty: 2 years
Payment Terms: 60 days
Enter fullscreen mode Exit fullscreen mode

The system can process the document and extract structured information such as:

{
  "vendor": "ABC Industries",
  "product": "Industrial Steel Sheet",
  "quantity": 5000,
  "total_price": 3900000,
  "delivery_days": 15,
  "warranty_years": 2,
  "payment_days": 60
}
Enter fullscreen mode Exit fullscreen mode

This information can then be stored in PostgreSQL.

The goal is to convert unstructured documents into useful business data.


πŸ”Ž RAG for Contract Intelligence

One of the most important parts of this project is Retrieval-Augmented Generation (RAG).

Imagine a company has a 70-page vendor contract.

A procurement manager asks:

β€œCan we cancel the order before dispatch?”

Instead of asking an LLM to guess the answer, the contract can be processed and indexed.

The workflow becomes:

Contract PDF
     ↓
Text Extraction
     ↓
Chunking
     ↓
Embeddings
     ↓
Pinecone
Enter fullscreen mode Exit fullscreen mode

When the user asks a question:

User Question
     ↓
Embedding
     ↓
Vector Search
     ↓
Relevant Contract Sections
     ↓
Gemini
     ↓
Grounded Answer
Enter fullscreen mode Exit fullscreen mode

This allows Gemini to generate an answer based on the relevant contract information.

RAG therefore becomes more than a chatbot featureβ€”it becomes a way of giving AI access to an organization's private knowledge.


πŸ—„οΈ PostgreSQL + SQL Agent

Not every question requires RAG.

Consider:

β€œHow much did we spend with Vendor A last year?”

That's a database question.

The workflow can be:

Natural Language Question
          ↓
       SQL Agent
          ↓
      PostgreSQL
          ↓
     Query Result
          ↓
        Gemini
          ↓
    Natural Language Answer
Enter fullscreen mode Exit fullscreen mode

This allows procurement teams to interact with structured business data using natural language.

Instead of manually writing SQL queries or searching through dashboards, they can simply ask the question.


🧠 Multi-Agent System with LangGraph

As the platform grows, a single agent handling every task becomes difficult to manage.

Different tasks require different tools.

That's why I plan to use LangGraph to orchestrate specialized agents.

Contract Agent

Handles:

  • Contract questions
  • Clause retrieval
  • Contract summarization
  • Risk detection

Tools: RAG + Pinecone + Gemini

Vendor Agent

Handles:

  • Vendor history
  • Quality ratings
  • Delivery performance
  • Vendor comparison

Tools: PostgreSQL + business rules

Analytics Agent

Handles:

  • Spend analysis
  • Historical purchases
  • Cost comparisons
  • Procurement analytics

Tools: PostgreSQL + SQL

Planner Agent

The Planner Agent coordinates the workflow.

For example:

β€œCompare Vendor A and Vendor B and tell me which contract has better terms.”

This may require both:

Planner
   β”œβ”€β”€ Vendor Agent
   └── Contract Agent
Enter fullscreen mode Exit fullscreen mode

LangGraph can coordinate these agents and combine their outputs.


πŸ† Vendor Intelligence

Price should not be the only factor when selecting a vendor.

The platform can maintain historical information such as:

Vendor A

Total Orders: 152
On-Time Delivery: 98%
Average Quality: 4.8/5
Rejected Orders: 3
Average Delay: 1.4 days
Enter fullscreen mode Exit fullscreen mode

Now, when Vendor A submits a new quotation, the AI can consider both:

Current quotation + Historical performance

For example:

Vendor A is slightly more expensive than the cheapest quotation, but it has a 98% on-time delivery rate and an average quality rating of 4.8/5 across 152 previous orders.

This gives procurement teams more context before making a decision.


πŸ“Š AI-Powered Vendor Ranking

The platform can use a configurable scoring model.

For example:

Price            β†’ 30%
Delivery         β†’ 25%
Quality          β†’ 20%
Vendor History   β†’ 15%
Contract Terms   β†’ 10%
Enter fullscreen mode Exit fullscreen mode

The weights can be customized according to company requirements.

The system could produce:

Vendor Price Delivery Quality Overall
Vendor A 90 95 92 92
Vendor B 98 65 70 78
Vendor C 85 98 97 93

The AI can then recommend Vendor C and explain:

Vendor C provides the best overall value because of its strong delivery performance, high quality rating, and better warranty terms, despite having a slightly higher price.

The important part is not only the recommendation.

It is the reasoning behind the recommendation.


⚠️ Price Anomaly Detection

Historical procurement data can help identify unusual prices.

Suppose a company normally purchases a product for:

β‚Ή60,000–₹65,000

A new quotation arrives for:

β‚Ή95,000

The system can flag:

⚠️ This quotation is significantly higher than the historical price range for comparable purchases.

This doesn't automatically mean the vendor is overcharging.

There could be legitimate reasons:

  • Product specifications changed
  • Raw-material prices increased
  • Quantity changed
  • Urgent delivery was requested

The purpose of anomaly detection is to bring unusual cases to human attention.


πŸ“‘ Contract Risk Detection

The AI can identify clauses that may require additional review.

For example:

πŸ”΄ HIGH RISK
Automatic contract renewal

🟠 MEDIUM RISK
180-day payment period

🟠 MEDIUM RISK
Limited warranty coverage

πŸ”΄ HIGH RISK
Strict cancellation conditions
Enter fullscreen mode Exit fullscreen mode

The system can explain why each clause was flagged and provide the relevant contract context.

The final legal or procurement decision remains with the authorized human.


🀝 AI-Assisted Negotiation

Another feature I want to explore is AI-assisted negotiation.

Suppose company policy says:

Maximum Price: β‚Ή40 Lakh
Maximum Delivery: 25 Days
Minimum Warranty: 3 Years
Enter fullscreen mode Exit fullscreen mode

A vendor submits:

Price: β‚Ή42 Lakh
Delivery: 40 Days
Warranty: 1 Year
Enter fullscreen mode Exit fullscreen mode

The AI can identify the requirements that are not satisfied and generate a negotiation draft.

For example:

Thank you for your quotation. Based on our current procurement requirements, we would need a revised commercial proposal with delivery within 25 days and a minimum three-year warranty. We would also appreciate a revised price within our approved budget range.

The procurement manager reviews the message before sending it.

This is an important principle:

AI assists the employee; it doesn't blindly make the final business decision.


πŸ“ˆ Procurement Analytics

The platform can provide a dashboard with metrics such as:

  • Total Procurement Spend
  • Monthly Spend
  • Top Vendors
  • Active RFQs
  • Late Deliveries
  • Contract Renewals
  • Outstanding Invoices
  • Potential Savings

For example:

Total Spend       β‚Ή8.42 Cr
Active RFQs       27
Late Deliveries   8%
Potential Savings β‚Ή14.2 Lakh
Enter fullscreen mode Exit fullscreen mode

The dashboard provides the traditional interface while the AI provides a natural-language interface.


πŸ› οΈ Technology Stack

Layer Technology
Frontend React
Backend FastAPI
LLM Gemini
AI Orchestration LangGraph
AI Framework LangChain
Vector Database Pinecone
Relational Database PostgreSQL
Document Processing PyMuPDF / Docling
Authentication JWT / OAuth
Containerization Docker
Monitoring LangSmith

Each technology has a specific role.

The goal is not to use technologies simply because they are popular, but because they solve a real problem in the architecture.


πŸ” Security & Human-in-the-Loop

Enterprise procurement data can be sensitive.

It may contain:

  • Vendor pricing
  • Contracts
  • Financial information
  • Purchase history
  • Internal policies

A production system would therefore need:

  • Authentication
  • Role-based access control
  • Company-level data isolation
  • Secure document storage
  • Audit logs
  • Encryption
  • Permission-based agent actions

For important decisions, the workflow should remain:

AI Analysis
     ↓
Human Review
     ↓
Approval
     ↓
Business Action
Enter fullscreen mode Exit fullscreen mode

The AI provides intelligence and recommendations while authorized employees remain responsible for important decisions.


🚧 Challenges I Expect

Building this system comes with several interesting engineering challenges.

1. Document Extraction

PDFs can contain tables, scanned pages, inconsistent layouts, and complex formatting.

2. RAG Accuracy

Retrieving the wrong contract section can produce an incorrect answer.

Chunking, embeddings, metadata, retrieval strategies, and reranking will all matter.

3. SQL Safety

AI-generated SQL must be validated and restricted to prevent destructive operations.

4. Hallucinations

The AI should never invent vendor prices, contract clauses, or purchase history.

Important answers need to be grounded in actual data.

5. Agent Complexity

More agents don't automatically mean a better system.

The workflow needs to remain understandable, reliable, and observable.


πŸŽ“ What I Am Learning

This project is helping me move from experimenting with individual GenAI APIs toward thinking about complete AI applications.

Through this project, I want to explore:

  • Gemini
  • Prompt Engineering
  • Structured Outputs
  • Function Calling
  • RAG
  • Embeddings
  • Vector Databases
  • LangChain
  • LangGraph
  • Multi-Agent Systems
  • SQL Agents
  • Document Processing
  • PostgreSQL
  • FastAPI
  • AI Evaluation
  • Deployment

But the biggest lesson is not a technology.

It is a change in mindset.

Instead of asking:

β€œWhat chatbot can I build?”

I am learning to ask:

β€œWhat real business workflow can AI improve?”


πŸš€ What's Next?

The first MVP will focus on:

Vendor Management
       ↓
RFQ Management
       ↓
Quotation Analysis
       ↓
Contract RAG
       ↓
Vendor Ranking
       ↓
Procurement Analytics
Enter fullscreen mode Exit fullscreen mode

After that, the platform could expand into:

  • Automated RFQ generation
  • Invoice matching
  • Supplier risk intelligence
  • Predictive procurement
  • Demand forecasting
  • ERP integrations
  • Advanced procurement automation

The long-term vision is to turn this into a complete AI-powered procurement operating platform.


🌟 Final Thoughts

The AI Procurement & Vendor Intelligence Platform is my exploration of what happens when Generative AI is connected to a real business workflow.

Gemini provides the reasoning capability.

LangGraph provides orchestration.

RAG provides access to unstructured knowledge.

Pinecone provides semantic retrieval.

PostgreSQL provides structured business data.

FastAPI provides the backend.

React provides the user experience.

Together, these technologies can form something much more useful than a chatbot:

An AI copilot that helps procurement teams understand information, identify risks, compare vendors, and make better purchasing decisions.

The biggest idea I am taking away from this project is:

The future of GenAI isn't just about asking AI questions. It's about giving AI access to the right data, the right tools, and the right business context.

That's what I want to explore during the Google Gen AI Cohort.

Let's build it. πŸš€

Top comments (0)