Skip to content

Command palette

Navigation, language and theme

enpl
All case studies

07 — Experience · public sector · code not public

Talking to a database in plain language — streaming Text-to-SQL

A service that turns a natural-language question into an SQL query, runs it and streams the answer in a format compatible with the Vercel AI SDK.

Problem

Non-technical people need answers from a database, but they don't write SQL.

What I built

  • A FastAPI service: natural-language question → LangChain and a local model (Ollama) generate an SQL query → the query runs → the model phrases the answer.
  • The answer is streamed (SSE) in a protocol compatible with useChat from the Vercel AI SDK.
  • A multi-stage Docker image and Traefik integration.

Outcome

  • A React / Next.js front end plugs into the service without a custom stream parser.
  • The model runs locally, so questions and query results never reach an external AI provider.

Facing a similar problem?

Describe your process — I'll tell you whether and how it can be solved.

Get in touch