Overview
In this project, I designed an AI agent system enabling users working in finance to perform database queries without knowing SQL. The user writes the question in natural language ("Which were the top 10 best-selling products last month?"), the agent translates it to appropriate SQL, executes it, and presents the result in a suitable format.
Multi-Flow Architecture
Agents split into different flows on LangGraph:
- Intent classifier: Understands the question type (aggregation, comparison, time-series, lookup)
- Schema-aware SQL generator: Knows the database schema and produces SQL accordingly
- SQL validator: Performs syntax and logic checks before executing the generated SQL
- Executor: Runs the query in a secure sandbox (read-only)
- Output router: Decides how to present the result — table, chart, Excel, or AI commentary
Modular Output Layer
The same result can be presented in different formats based on user needs:
- Chart: Automatic chart generation for trend analyses
- Excel: Structured report for detailed inspection
- AI commentary: LLM-powered summary for "what do these results mean?" questions
Domain-Specific Training
Unlike generic Text-to-SQL, the agents were specifically prompt-tuned with financial terminology (current accounts, trial balance, tax items, etc.). This kept both accuracy and domain-appropriate SQL generation at a high level.
