← All selected work

Governed AI analytics

NL2SQLAgent

A self-service analytics interface that turns natural-language questions into inspectable SQL without allowing generated queries to modify the warehouse.

ScopePortfolio build using a seeded synthetic warehouse and a local SQLite database.

synthetic warehouse
1.03M rows
query latency
<250 ms
LLM inference latency
7–15 s
  • FastAPI
  • LangChain
  • SQLite
  • React
  • Server-Sent Events
  • ECharts

01 / Context

The problem

Business users need answers without writing SQL, while engineering still needs guardrails against destructive queries, opaque model behavior, and answers without visible evidence.

02 / Architecture

How the system fits together

  1. 01Questionnatural language
  2. 02Agentschema inspection
  3. 03SQL generatorquery + explanation
  4. 04Read-only guardreject writes before execution
  5. 05SQLite warehouse1.03M synthetic rows
  6. 06Answer + chartSSE streaming

Supporting systems

  • Session memorylast 10 conversation rounds
  • EChartsbar, line, pie, table
Synthetic warehouse · provider-pluggable LLM path

03 / Engineering

What I built

  • Built a FastAPI and LangChain query path that inspects the schema, generates SQL, validates it, executes it, and explains the result.
  • Added defense-in-depth read-only controls that reject write and schema-changing statements before execution.
  • Streamed thinking, text, SQL, data, chart, and completion events to a React interface over Server-Sent Events.
  • Built session persistence, context memory, chart heuristics, table and chart views, and deterministic end-to-end checks.
  • Tested the application against a 1,028,160-row synthetic sales warehouse with indexed query paths.

04 / Evidence

Measured outcomes

05 / Demo

Product evidence

NL2SQLAgent interface showing a question, generated SQL, explanation, and revenue chart
The interface exposes the generated SQL and updates the chart while the answer streams in.

06 / Boundaries

Trade-offs and limitations

  • The warehouse is synthetic and the local SQLite setup is not a production data platform.
  • End-to-end latency depends on the configured LLM provider; authentication and multi-tenant authorization are outside this portfolio build.

07 / Sources

Inspect the work