Adding a Chatbot to the HDB Resale Dashboard
The HDB Resale Transaction Dashboard now has an LLM-powered chatbot — built with Groq for fast, conversational queries on Singapore's public housing resale data.
Quick context
A while back, I wrote about building the HDB Resale Transaction Dashboard — a Streamlit app that lets you explore Singapore HDB resale transactions interactively, with filters by town, flat type, price range, and time period. The data comes from data.gov.sg, with geocoordinates sourced via the OneMap SG API for map-based visualisation.
The dashboard is live at property.jarenkueh.com.
Since then, I've been iterating on it — and the latest addition is something I've been wanting to build for a while: a conversational chatbot that sits on top of the resale data.
Why a chatbot?
Dashboards are great for structured exploration. But sometimes you just want to ask a question in plain English:
- "What's the median price for a 4-room flat in Punggol over the last 12 months?"
- "Which towns have the highest price growth year-on-year?"
- "Show me the most expensive transactions in Queenstown this year."
Traditional filters can answer these, but a chatbot makes the interaction faster and more intuitive — especially for users who aren't sure exactly what filters to set or what to look for.
Why Groq?
I went with Groq for the LLM backend. The main reason is inference speed — Groq runs open-source models on their custom LPU hardware, and the response latency is noticeably faster than most hosted LLM APIs. For a chatbot embedded in a dashboard, that snappiness matters. Users expect near-instant replies when they're exploring data interactively.
The model handles natural language understanding and translates user queries into structured lookups against the underlying resale transaction dataset. It also generates natural language summaries of the results — so instead of just returning a table, it explains what the data shows.
How it works
The architecture is straightforward:
- User sends a message in the chat interface within the Streamlit app.
- The query is sent to Groq's API, along with a system prompt that provides context about the dataset schema — columns like town, flat type, storey range, floor area, resale price, lease commence date, and transaction month.
- The LLM interprets the intent and either generates a direct answer from its understanding of the data context, or constructs a structured query that the app executes against the dataset.
- Results are returned as a conversational response, sometimes accompanied by the relevant data table or chart.
The system prompt does the heavy lifting here — it needs to be precise about what fields exist, what values are valid (e.g., the exact town names HDB uses), and what kinds of aggregations make sense. Getting that right took more iteration than writing the actual integration code.
What I learned
A few practical observations from building this:
Prompt engineering is the real work. The Groq API integration itself is clean and fast. But getting the LLM to reliably interpret ambiguous queries ("expensive flats near the MRT") without hallucinating data that doesn't exist in the dataset — that required careful prompt design and guardrails.
Latency matters more than you think. In a dashboard context, even a 2–3 second delay feels slow. Groq's speed is a genuine differentiator here compared to other hosted LLM options I tested.
Keep the scope tight. I deliberately limited the chatbot to questions about the resale dataset. It's not a general-purpose Singapore property advisor. Constraining the scope made the responses much more reliable and reduced the risk of the model confidently making things up.
What's next
This is still a work in progress. A few things I'm looking at:
- Retrieval-Augmented Generation (RAG) to ground responses more firmly in the actual data, reducing hallucination risk further.
- Chart generation from chat — letting users ask for specific visualisations directly through the chatbot.
- Caching frequent queries to reduce API calls and improve response times for common questions.
If you want to try it out, head to property.jarenkueh.com. I'd appreciate any feedback — especially on queries where the chatbot gets things wrong, as that helps me improve the prompts.
You can also find the original write-up on the dashboard here on Medium.