Project case study

DataLens

Schema-aware natural language to SQL. Introspects the database, validates the generated query, runs on read-only replicas, and auto-generates charts.

Private implementation; details are shared at an architectural level.

DataLens project

Problem

  • Operational teams needed data but could not write SQL
  • Existing BI tools required training nobody had bandwidth for
  • Data team was drowning in ad-hoc report requests

Constraints

  • Has to introspect the schema to avoid invalid queries
  • No destructive operations, ever
  • Ambiguous questions must ask for clarification, not guess
  • Results need usable visualisations, not raw tables

Architecture

  • Agent introspects the schema, generates SQL, and validates it against schema constraints
  • All queries run on read-only replicas
  • Visualisations auto-generated based on the shape of the result

Tradeoffs

  • Graph-based reasoning over straight text-to-SQL. Introspection, validation, execution, and visualisation are distinct stages that needed explicit state
  • Read-only replicas over prompt-only guardrails. Cannot trust a model to never generate a DELETE, however well the prompt is written
  • Auto-visualisation over raw tables. Results need to be readable to non-technical users

Outcome

  • Ops teams now self-serve most of their data questions
  • Data team backlog dropped noticeably

Tools and technologies

LangGraph · FastAPI · Next.js · Terraform