← Back to projects

Project Overview · Agentic AI + Data

UCSD Smart Analyst

An AI agent over 270,000+ volleyball points that answers coaches with real, validated stats and visualizations — the team-specific analysis general-purpose LLMs can't do.

The problem

Coaches need answers their data can prove.

UCSD's volleyball coaches wanted to ask real questions of their data — how an opponent sides out against a particular serve, how a lineup shifts win probability — but the numbers live in 270,000+ raw VolleyMetrics points. A normal dashboard can't answer open-ended questions, and a general-purpose LLM will confidently make up plausible-sounding stats.

Coaches needed something that could reason over the actual data and be trusted not to invent a number.

Architecture

An agent that queries the database, then checks its own work.

A coach asks in plain language. An OpenAI agent introspects the Postgres schema, writes a SQL query, runs it against Neon, and validates the result is correct before answering — retrying if the query is wrong. Only verified numbers reach the coach, rendered as stats and Plotly charts.

UCSD Smart Analyst architecture: coaches ask an OpenAI agent that calls schema-introspection, SQL-query, and validation tools against Neon PostgreSQL, retrying on invalid queries, then returns stats and Plotly charts.
Coach → OpenAI agent (schema introspection → SQL query → validate, retry if invalid) → Neon Postgres → stats + Plotly viz.

Key decisions

Why it's built this way.

Agent with tools, not a raw LLM

The model never guesses numbers. It calls SQL tools against the real database, so every answer is grounded in actual data instead of the model's imagination.

A correctness feedback loop

Each query is validated before results surface. An invalid query triggers a retry, not a wrong number handed to a coach who's about to make a decision on it.

Schema introspection

The agent reads the live schema, so it writes queries that match the actual tables and columns rather than hallucinating a field that doesn't exist.

Neon Postgres over 270k+ points

The agent collected, cleaned, and loaded VolleyMetrics data into a queryable relational store, turning a messy export into something you can actually ask questions of.

What shipped

Coaches ask; it answers with sourced stats.

Coaches ask questions in plain language and get back real, sourced stats and visualizations that general-purpose tools can't produce. Here's a walkthrough.

Challenges & what's next

Honest edges.

The hard part was trust: making the agent reliably produce correct SQL and catch its own mistakes before a coach ever saw a wrong number. The validation loop was the key — it's the difference between a demo and something coaches will actually rely on. Next: caching common queries for speed and a polished coach-facing chat UI.

Stack

  • Python
  • OpenAI API
  • Agentic tool-use
  • PostgreSQL · Neon
  • React
  • Next.js
  • Plotly