Skip to content
Start a project

AI agents and data · Sports

An AI sports analyst that answers plain-English questions with 99% accuracy

StatGPT is an AI sports analyst we built. Users ask in plain English and get stat tables with a short summary, from NBA, AFL, AFLW and cricket data. In the client's checks against Footywire and AFL Tables, 99% of answers were correct.

Product
StatGPT
Platform
Web app with chat and search, backed by an API
Stack
LangGraph agents, a NestJS query engine, OpenAI models, PostgreSQL with pgvector, Redis
Team
12 engineers plus PM, QA and design
Timeline
22 weeks for the chat agent, 81 weeks for the whole platform
Status
Private beta for investors
Answer accuracy
99%
The client's manual checks against Footywire and AFL Tables, Feb 2026
Median response time
2.9 s
Smoke test of 1,000 AFL questions, Feb 2026
Off-topic questions declined
90 of 100
Smoke test, Feb 2026

The challenge

NBA, AFL, AFLW and cricket player statistics sit in a PostgreSQL database: season, per-game, advanced and round-by-round tables.

People ask in everyday words, with nicknames, short forms and loose time ranges, while the data only answers exact queries.

A wrong number is worse than no answer, so every answer had to hold up against public stat sites.

Our approach

Two phases, one product

In 2025 we built a LangGraph agent on OpenAI models that writes SQL for NBA, AFL, AFLW and cricket questions. In 2026 we rebuilt AFL search as a query engine where the model plans the query and our code writes the SQL.

Worked examples before answers

896 worked SQL examples sit in pgvector, and a classifier picks the ones that match each question type before the model writes a query.

Deterministic SQL

In the 2026 engine the model returns a query plan, and our code validates it and writes parameterized SQL. A Redis cache answers repeat questions in about 40 ms.

What we built

  • A chat that turns plain-English questions into stat tables with a short summary, with memory for signed-in users.
  • Player stats analysis: season, per-game, advanced and round-by-round stats, plus head-to-head comparisons.
  • An AFL search engine that recognizes players, teams and venues, including 781 nicknames.
  • The platform around it: a NestJS API, a Next.js web app, an admin console, plans and daily request limits.
  • The data pipeline that loads NBA, AFL, AFLW and cricket statistics.

How it fits together

  1. People

    • Beta usersAsk in plain English, in chat or search
    • The client's teamPlans, limits and the admin console
  2. Apps

    • Next.js web appChat with memory for signed-in users, and search
    • Admin console
  3. Services

    • NestJS APIPlans and daily request limits
    • LangGraph agentsWrite and check the SQL for each question
    • AFL query engineThe model plans the query, our code writes the SQL
  4. Models and data

    • OpenAI models
    • PostgreSQL with pgvectorNBA, AFL, AFLW and cricket stats
    • Redis
    • Data pipelineLoads the statistics
How StatGPT answers a question

Services behind this work

Security and quality

  • The client checked answers by hand against Footywire and AFL Tables: 99% were correct.
  • Smoke tests ran 1,900 AFL questions in Feb 2026: core questions returned data 95 to 98% of the time, loosely phrased ones 81 to 86%.
  • Forecasts and off-topic questions are declined with a fixed message: 90 of 100 in testing.

Outcome

StatGPT answers plain-English sports questions with 99% accuracy in the client's own checks, in about 3 seconds.

It runs as a private beta for the client's investors, with AFL as the launch sport.

Have an agent, protocol or product to ship?

Send a short brief and we'll reply with times for a 30-minute scoping call.

Back to all shipped work