Meet the AI Shopping Agent That Can Recommend, Compare, and Place Orders
Preface
One-sentence positioning: A conversational e-commerce shopping guide AI Agent that can chat, recommend, and actually place orders.
| Dimension | Description |
|---|---|
| Tech Stack | Spring AI (Alibaba), RAG (Milvus / PgVector), Function Calling, MCP, Graph workflow, SSE streaming output |
| Core Highlights | Two-layer embedding semantic routing, RAG private knowledge Q&A, tool calls for order/return/review, order and cart UI snapshots |
| Suitable for | People who want to combine AI with e-commerce business deeply and showcase workflow orchestration skills |
| Deliverables | Complete source code + from-zero tutorial + 1-on-1 technical Q&A + resume coaching |
Why it's worth putting on your resume
- Rare completeness: from intent understanding and knowledge retrieval to transaction closure, all can be explained
- Demonstrates both AI capabilities (RAG / Function Calling / MCP / Graph) and business system design skills
- Can clearly explain "why semantic routing" and "why MCP is better than hardcoded tool calling" — such interview questions
More project practice at Java Assault Team website: susan.net.cn/project
1. Project Overview
Smart Product Recommendation Assistant is a next-generation e-commerce shopping guide platform built on cutting-edge generative AI technology.
The system uses conversational UI to deeply understand vague, complex shopping intents, combines a private product knowledge base (RAG) and real-time business data (MCP/Function Calling) to provide precise product recommendations, price comparison analysis, and supports a complete transaction loop: ordering, returning, reviewing, and cancelling orders.
The system uses a combined architecture of RAG (Retrieval-Augmented Generation) + Function Calling (tool calling) + MCP + Graph workflow:
- For questions that need understanding and recommendation, RAG improves answer relevance and explainability;
- For questions that need real data and business actions, tool calls and backend services ensure results are actionable and writable back.
- At the conversation entry, a light-weight embedding semantic router (two-layer routing) first classifies intents into "process/tool/recommendation/small talk" classes, then within process class determines the specific process type and enters Graph nodes for progression, making the process more controllable and resistant to natural language variation. Meanwhile, the project supports seamless integration with existing product/cart/order services via Feign + gateway, and provides conversation history and key UI snapshot capabilities (order cards, cart cards, confirmation cards, etc.), adapting to complex interactions and service fluctuations in real production scenarios.
1.1 Core Value
- Intent Understanding: Goes beyond traditional keyword search to understand scenario-based needs like "a birthday gift for a programmer boyfriend."
- Real-time Data: Uses Function Calling to query inventory and price fluctuations in real time, and execute core transaction operations like ordering, returning, reviewing, and cancelling.
- Private Knowledge: Based on RAG, precisely answers private-domain questions such as product specifications and after-sales policies.
- Standardized Interconnectivity: Uses MCP (Model Context Protocol) to standardize connections to multiple data sources.
2. Technology Stack Selection
| Module | Technology Choice | Description |
|---|---|---|
| Backend Framework | Spring Boot 3.5+ | Core Java ecosystem, stable high-concurrency support |
| AI Integration | Spring AI Alibaba | Unified AI access layer, shields underlying model differences, supports OpenAI/Claude/Ollama, etc. |
| LLM Model | Qwen / DeepSeek-V3 | SOTA models with strong reasoning capabilities |
| RAG Engine | Milvus / PgVector | High-performance vector databases, store product document embeddings |
| Data Protocol | MCP (Model Context Protocol) | Unified data source interaction protocol, connects product center, order center |
| Agent Capabilities | Function Calling / Skills | Gives LLM ability to execute external tools (check inventory, place order) |
| Frontend | Vue 3 + TailwindCSS | Modern responsive UI (prototype exists) |
| API Protocol | SSE (Server-Sent Events) | Streaming typewriter effect responses |
| Workflow | Graph workflow | Graph progression within process |
3. System Architecture Design
3.1 Overall Architecture Diagram (Mermaid)
3.2 Core Module Details
3.2.1 Intelligent Shopping Guide Agent Service (Spring AI Alibaba)
This is the brain of the system, responsible for orchestrating the entire conversation flow.
- Prompt Management: Dynamically loads scenario-specific system prompts, injects user profile and current context.
- Memory Management: Maintains multi-turn conversation context (ChatMemory), ensures AI remembers user budget preferences.
- Model Switcher: Through Spring AI's
ChatClientabstraction, supports switching between different underlying models.
3.2.2 RAG Engine (Retrieval-Augmented Generation)
Used to solve LLM hallucination and knowledge lag problems.
- Document Reader: Reads product detail pages, user reviews, and help docs from CMS.
- TokenTextSplitter: Splits long documents into 512/1024 token chunks by semantic meaning.
- Embedding: Uses
text-embedding-3-smallorbge-m3to convert text to vectors and store in Milvus. - Retrieval: When user asks, retrieves top-K relevant document chunks and injects into prompt context.
3.2.3 MCP & Function Calling
Gives AI "hands" and "eyes".
- Function Calling: Defines Java
Function<Request, Response>beans, exposed to LLM via@Toolannotation.getProductStock(skuId): checks real-time inventory.comparePrices(skuIdList): generates price comparison table.
- MCP Client: Implements MCP protocol, connects to external data sources (MCP Servers) through standardized JSON-RPC interface. This allows adding new data sources (e.g., third-party logistics queries) without modifying core agent code.
4. Key Process Design
4.1 User Shopping Consultation Process (RAG + Function Calling)
- User asks: "Recommend a keyboard suitable for a programmer, budget around 1000 yuan."
- Intent recognition: Agent analyzes intent as
RECOMMENDATION, extracts entitiesCategory: Keyboard,Target: Programmer,Budget: ~1000. - RAG retrieval:
- System searches vector store for "programmer keyboard", "mechanical keyboard 1000 yuan" related product descriptions and reviews.
- Recalls top 5 products: Keychron K2, NuPhy Air75, Logitech MX Mechanical, etc.
- Tool call (Function Calling):
- LLM decides to call
checkStock(productIds)to confirm whether recalled products are in stock. - LLM decides to call
getLatestPromotion(productIds)to get current promo prices. - LLM decides to call
getProductStock(skuId)to confirm inventory.
- LLM decides to call
- Generate answer:
- LLM combines static info from RAG (selling points, switch feel) and dynamic info from functions (inventory, real-time price).
- Generates streaming reply: "For you I recommend Keychron K2 Pro... Currently in stock at JD flagship store, promo price 988 yuan..."
4.2 AI Implementation of Core Transaction Loop (Order/Return/Review/Cancel)
This system wraps transaction operations as tools callable by AI, enabling a full conversational shopping experience.
4.2.1 Smart Checkout
- User intent: "Buy that Keychron keyboard for me, with red switches."
- Slot filling:
- AI identifies intent
PLACE_ORDER. - Checks required parameters:
Product=Keychron K2,Spec=Red Switch,Address=?,Payment=?. - If address is missing, AI asks back: "Please confirm shipping address, send to default home or company?"
- AI identifies intent
- Tool call:
- Once parameters are complete, calls
createOrder(skuId, addressId, paymentMethod).
- Once parameters are complete, calls
- Frontend interaction:
- AI returns Function Result not as plain text but as UI Component JSON.
- Frontend renders "order confirmation card" showing product, amount, address.
- User clicks "Confirm Payment" button on the card (secondary confirmation for safety).
4.2.2 Smart Cancellation
- User intent: "I don't want that keyboard anymore, cancel it."
- Context retrieval:
- AI calls
queryRecentOrders(userId, limit=1)to get latest order. - Finds order status
PENDING_SHIPMENT(not shipped), eligible for cancellation.
- AI calls
- Tool call:
- Calls
cancelOrder(orderId, reason="user voluntarily cancels").
- Calls
- Feedback: "Order 20231025 has been successfully cancelled; refund will be returned to original payment method."
4.2.3 Smart Return
- User intent: "The earphones I received yesterday have static noise, I want to return them."
- RAG assistance:
- AI retrieves "Electronics Return and Exchange Policy" from knowledge base.
- Confirms "quality issues support 7-day no-reason return".
- Tool call:
- Calls
checkOrderEligibleForReturn(orderId)to verify eligibility. - Calls
submitReturnRequest(orderId, type="QUALITY_ISSUE", desc="static noise").
- Calls
- Process guidance: "Return request submitted. Please send the item back to the following address... shipping costs borne by us."
4.2.4 Smart Review
- User intent: "Write a good review for the yoga pants I just got, they feel comfortable."
- Content generation:
- AI based on user keywords "comfortable to wear" and product features (RAG retrieval: skin-friendly, high elastic), automatically generates a quality review draft of about 50 words.
- Tool call:
- AI shows draft: "Very comfortable to wear, fabric is skin-friendly and breathable, no restriction during yoga moves, recommended! (Publish?)"
- After user confirms, calls
submitProductReview(orderId, rating=5, content=...).
4.2 Data Ingestion Process
- Source data monitoring: Monitors product database changes (Binlog) or scheduled task scanning.
- ETL processing: Cleans HTML tags, extracts key specification parameters.
- Document chunking: Splits product details into multiple chunks like "basic info", "specifications", "user reviews".
- Vectorization: Calls Embedding API to generate vectors.
- Upsert: Writes to vector database with Metadata (Category, PriceRange) to support hybrid retrieval.
4.3 AI-Driven Full Transaction Flow Design
This system not only supports information queries, but also implements end-to-end automation of ordering, returning, reviewing, and cancelling via Transactional Agents. Each flow has built-in Human-in-the-Loop (HITL) mechanisms for safety.
4.3.1 Order Placement
User command: "Buy the Keychron keyboard you recommended earlier, ship to company."
- Context parsing: Agent retrieves recently recommended product entity (Keychron K2 Pro, SKU: RGB-Red-Switch) from
ChatMemory. - Address matching: Calls
AddressBookServiceto get user-labeled "company" shipping address. - Order preview (Dry Run):
- Calls
previewOrder(sku, quantity, addressId)to calculate final price (including shipping, coupons). - HITL confirmation: AI outputs order card (with price details) and pauses execution, waiting for explicit user instruction ("confirm order" / "Yes").
- Calls
- Execute transaction: After user confirms, AI calls
createOrderAPI and returns order number and payment link.
4.3.2 Order Cancellation
User command: "Don't want that order anymore, cancel it."
- Intent recognition: Identifies intent as
CANCEL_ORDER. - Query status: Calls
listRecentOrders(limit=1)to get latest order, checks if status isPENDING_PAYMENTorPAID(not shipped). - Risk control:
- If order already shipped, AI automatically switches to "return/intercept" flow and informs user.
- If not shipped, AI asks for cancellation reason (optional) and requests second confirmation.
- Execute cancellation: After user confirms, calls
cancelOrder(orderId)and triggers refund process.
4.3.3 Return & Refund
User command: "These earphones are uncomfortable to wear, I want to return them."
- Eligibility check (RAG):
- AI extracts SKU, retrieves the product's "after-sales policy" doc from vector store.
- Determines if "7-day no-reason" or "no return after unsealing" conditions apply.
- Generate application:
- If eligible, AI calls
createReturnRequest(orderId, reason="discomfort when wearing"). - If not eligible (e.g., out of warranty), AI politely declines citing policy doc and suggests human customer service.
- If eligible, AI calls
- Logistics appointment: Calls
schedulePickup(address, time)to arrange courier pickup.
4.3.4 AI-Assisted Review
User command: "Keyboard arrived, great feel, help me write a good review."
- Sentiment analysis: Identifies user sentiment as
POSITIVE, keywords "great feel". - Content generation: AI based on keywords generates a quality review: "Keychron K2 Pro truly lives up to its name, red switches feel light, typing sound is crisp, perfect for long coding sessions, five-star recommendation!"
- User confirmation: Shows generated content, user can choose "publish directly" or "edit".
- Submit review: Calls
submitReview(orderId, content, rating=5).
FAQ
What is the Smart Product Recommendation Assistant?
It's a conversational e-commerce shopping guide AI Agent: users describe needs in natural language (e.g., "birthday gift for a programmer boyfriend"), the system understands intent, recommends products, compares prices, and supports a transaction loop of ordering, returning, reviewing, and cancelling.
What problem does RAG solve in shopping scenarios?
Product specs and after-sales policies are private knowledge LLMs don't know. RAG injects product docs and knowledge base chunks into the prompt via vector retrieval, making answers grounded and explainable.
How do Function Calling and MCP work together?
Function Calling is responsible for invoking business actions (check inventory, place order, return), MCP standardizes connections to multiple data sources (product center, order center). The former solves "can do things", the latter solves "can connect in".
Why is a light-weight embedding semantic router needed?
A user's utterance may contain multiple intents. The system first uses embedding for two-layer routing (coarse classify: process/tool/recommendation/small talk, then sub-classify process), then enters corresponding Graph nodes, making processes more controllable and resistant to natural language variation.
Can conversational shopping complete ordering, return, and review?
Yes. The project completes the full transaction loop: smart ordering, smart cancellation, smart return, smart review all have implementations, and uses SSE streaming output and UI snapshots like order cards to enhance interaction.
Is this AI shopping project suitable for a resume?
Yes. It simultaneously demonstrates AI capabilities (RAG, Function Calling, MCP, Graph orchestration) and business system design skills, and is a natural combination of "AI + business".
More project practice at Java Assault Team website: susan.net.cn/project