🔥 0
0
Lesson 8 of 8 30 min +300 XP

Capstone: The AI Shopping Assistant

You started with an idea - a customer asking, in plain Hindi-English, "wireless earbuds under 3000 with good battery, add the best one to my cart" - and a store that could not answer it. Now you have every piece needed to make that real. This capstone assembles them into the finished ShopKart AI shopping assistant and sets you up to ship it.

What you built

Trace the journey lesson by lesson and the whole system falls into place:

LessonPieceWhat it gave ShopKart
2Spring Boot APIProduct/Order model, repository, REST endpoints
3React storefrontProduct grid and ChatWidget UI
4Spring AI ChatClientA real conversation over /api/chat
5Tool callingThe agent - searchProducts, checkStock, placeOrder
6MCPTools shared across apps; remote tools consumed
7StreamingLive token-by-token typing in the widget

Each layer built on the one before, and none of it threw away your existing Spring Boot and React skills - the AI is a thin, powerful layer on top of a solid app.

The complete architecture

Here is the finished system, every component from this course in one picture.

The finished ShopKart AI assistant React 18 ProductGrid GET /products ChatWidget EventSource live typing Spring Boot 3.x + Spring AI Controllers: products, orders, chat, chat/stream (SSE) ChatClient - the agent loop system prompt + tool calling ShopKartTools (@Tool) search, checkStock, placeOrder MCP server publish tools MCP client remote tools Repositories + DB Product, Order, Customer LLM OpenAI (default) or Anthropic Claude reasons and requests tool calls HTTP/SSE API key on the server only. The agent loop turns one customer message into real actions on real data.

The end-to-end moment

Put it all together and here is the capstone interaction, exercising every layer at once:

  • Customer types "Find me good wireless earbuds under 1500 and order 1 for customer 100."
  • ChatWidget opens an SSE connection to /api/chat/stream.
  • The agent reasons and calls searchProducts("wireless earbuds", 1500) - a @Tool hitting ProductRepository.
  • It observes two matches, calls checkStock on the higher-rated boAt Rockerz 255 Pro, confirms 27 units.
  • It calls placeOrder(100, 6, 1), which runs OrderService.place(...), computes INR 1499, and drops stock to 26.
  • The final answer streams back token by token: "Done! I ordered 1 boAt Rockerz 255 Pro at INR 1499 - order #1 is placed."

One message. Three tool calls. Real data changed. Streamed live. That is a full-stack AI agent, and you built every line of it.

Deployment notes

Moving ShopKart from your laptop to production means a few concrete steps:

  • Package separately. Build the Spring Boot app as a JAR (or container) and the React app as static files. Serve the React build from a CDN or from Spring Boot's static resources, and point it at the deployed API URL rather than localhost:8080.
  • Secrets, not properties. The OPENAI_API_KEY must come from your platform's secret manager or environment, never a committed file. The same goes for any MCP server credentials.
  • Swap the in-memory repo for a database. The ProductRepository and order store were in-memory for teaching. In production, back them with JPA and a real database - the service interfaces stay the same, so the agent's tools do not change.
  • Real CORS. Replace the hard-coded localhost:5173 origin with your storefront's production domain, read from configuration.
  • Cost and rate limits. Every tool loop is one or more LLM calls. Set sensible model choices (a smaller model like gpt-4o-mini is plenty for a shopping assistant), and add rate limiting so a burst of traffic does not become a surprise bill.

Production readiness checklist

Before you ship ShopKart
  • API key and secrets loaded from the environment, never committed
  • Persistent database behind the repositories, with migrations
  • System prompt guardrails reviewed - stays on topic, INR currency, honest about unknowns
  • Write tools (placeOrder) require clear confirmation and validate inputs server-side
  • Errors returned to the agent as readable text, not raw exceptions
  • CORS locked to the production storefront origin
  • Rate limiting and a cost ceiling on LLM usage
  • Streaming works end to end (proxy buffering disabled) with a graceful drop fallback
  • Logging and tracing around tool calls so you can debug agent behaviour
  • MCP servers authenticate callers before exposing any write tools

Where to go next

You now have the full pattern for AI-powered full-stack apps. Natural next steps: add RAG so the agent can answer from product manuals and policy docs; give it conversation memory with Spring AI's ChatMemory advisor and a persistent store; add evaluation to catch when the agent picks the wrong tool; and layer in observability with Spring AI's built-in metrics. The architecture you built here - UI, API, agent, tools, MCP, streaming - is the same one that powers real production assistants. The domain changes; the shape does not.

On the job

When you demo this to a team, resist the urge to show the model doing something flashy and off-topic. The impressive part of a production agent is that it stays boring and reliable: it uses the right tool, quotes real prices, refuses to place an order the customer did not confirm, and admits when it does not know. Reliability is the feature. A shopping assistant that hallucinates a price or orders the wrong thing destroys trust faster than a slow one ever could.

Key takeaways

  • ShopKart is a complete full-stack AI agent: React storefront, Spring Boot API, Spring AI ChatClient, @Tool agent, MCP, and SSE streaming.
  • The agent loop turns a single customer message into real, data-backed actions - and every layer reuses the plain Spring Boot and React code you wrote first.
  • For production: externalize secrets, use a real database, lock down CORS, choose a cost-appropriate model, add rate limiting, and secure any MCP write tools.
  • Work through the readiness checklist before shipping - reliability and guardrails matter more than cleverness.
  • The same architecture generalizes: swap the domain, keep the shape - UI, API, agent, tools, MCP, streaming.

Congratulations - you have built a complete, production-shaped AI shopping assistant with Java, Spring Boot, React, and Spring AI. That is exactly the skill set the industry is hiring for.

Streaming Responses to React