Shipped an AI Assistant for Rentify!
Spent the last 4 days taking the AI assistant in my Java 17 + Spring Boot car rental system from a basic, forgetful chatbot to a live, data-driven helper. It’s officially live today! The AI can answer beyond the Rentify app.
Here is how I built it (and the trade-offs I made):
1. Adding Conversational Memory
The initial prototype treated every message as a fresh start. I added a session-based chat history array on the frontend (app.js), so the assistant now retains context across the whole conversation.
2. Live Data via Context Injection
Instead of building out heavy function-calling, I chose a lighter pattern.
ChatController.java queries CarRepository and RentalRepository on every message, pulls live fleet availability, pricing, and revenue, and silently prepends it as a system message to OpenRouter. No more hallucinations—just real numbers.
3. The Scalability Trade-off
Running database aggregation queries on every single chat message is a bottleneck under heavy traffic. For this project's scope, it works perfectly. In a production environment, the proper fix would be caching frequently read data and computing revenue asynchronously.
4. Debugging LLM Context
During testing, a smaller free-tier model answered a revenue question with $0.00 while the dashboard showed thousands.
The culprit: I was injecting data as a second, separate system message alongside the personality prompt. The model struggled to reconcile the two. The fix: I merged everything into a single, cohesive system message and expanded the context to include full rental history records instead of just totals.
The Result
Ask the assistant, "What cars are available right now?" or "What's our total revenue?" and it answers with the exact live numbers pulled straight from the H2 database.
A solid few days of learning prompt design, state management across a stateless HTTP boundary, and finding the line between "good enough for now" and "production-ready."
Check out the updated live and repo link below!
https://web-production-377eb.up.railway.app/