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
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
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
}
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
When the user asks a question:
User Question
β
Embedding
β
Vector Search
β
Relevant Contract Sections
β
Gemini
β
Grounded Answer
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
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
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
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%
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
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
A vendor submits:
Price: βΉ42 Lakh
Delivery: 40 Days
Warranty: 1 Year
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
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
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
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.
Top comments (0)