Case Study
Enterprise Analytics Copilot (Text-to-SQL)
AI agent that turns business questions into safe SQL queries, using LangGraph and a local LLM.

Overview
Text-to-SQL analytical copilot that converts natural-language questions into validated SQL queries, runs them on PostgreSQL and returns business answers in Portuguese.
Challenge
Business teams depend on analysts to answer simple data questions, creating bottlenecks. Exposing SQL generation to an LLM raises risks of injection, destructive operations and answers disconnected from the real data.
Solution
An orchestrated LangGraph pipeline was built (SQL generation → security validation → execution → formatting → answer), with real schema context, write-operation blocking and a local Llama 3.2 model via Ollama, containerized with Docker.
Impact
- Natural-language querying over a dimensional data warehouse
- Multi-layer security validation (SELECT/WITH only, anti-injection)
- Fully local, reproducible stack with no external API cost
Tech Stack
PythonLangGraphLangChainOllama / Llama 3.2PostgreSQLSQLAlchemyDocker