Case study · NDA — details on request
Natural-language assistant for corporate databases
An internal tool that lets a team ask several production databases questions in plain language and get the answer, the table and the exact SQL — behind a safety gate that makes changing the data impossible.
- Client
- Retail company, analytics team
- Role
- Architect & engineer
- Timeline
- Working MVP · designed for self-hosting
- Stack
- PythonFastAPIPostgreSQL + pgvectorMySQLSQL ServersqlglotReactTypeScriptVega-Lite
Problem
Every business question went through the one person who knew SQL and the schemas of several databases. Answers took days, and nobody could check how a number had been produced.
Self-hosting on the company's own GPUs was a requirement: customer data could not be sent to an external API.
Approach & architecture
- Researched natural-language-to-SQL approaches first and had the plan reviewed by a panel of five reviewers before implementation.
- Connectors for PostgreSQL, MySQL and SQL Server read schemas, keys and sample values into a catalogue; human-reviewed descriptions are kept apart from AI drafts.
- Every query is parsed and checked before it runs — SELECT only, allowed functions, enforced row limits — and a connection whose account can write is refused until a person accepts it.
- The LLM is reached through any OpenAI-compatible endpoint, so the same system runs on a cloud model or on local GPUs.
Result
Answers stream with the SQL, a sortable table, CSV export and charts; users mark good answers as verified to grow a trusted query library.
What made it robust
- An evaluation set with baselines and a gate command, so prompt or model changes cannot silently lower quality.
- Stored credentials encrypted with AES-256-GCM; read-only database role scripts for all three engines.
- 100+ automated tests.
Have a similar problem?
Tell me about it — I'll reply with an honest view of scope, approach and what a first milestone could look like.