Governed Text-to-SQL for Finance Teams

Natural-language to SQL with schema awareness, role-based access control, KPI glossary, and audit logging. Python, Flask, Snowflake, LLM API.

User Question
Auth / RBAC
Schema Resolver
SQL Generator
Safety Validator
Snowflake
Results + Audit
75%
Query error reduction
20+
Analyst hours freed/week
3-5 days
Reduced to seconds
32
Passing tests
Try a Query
Role-Based Access Control
FP&A AnalystStandard
Schemas: finance_reporting
Views: v_revenue, v_opex, v_margin_by_division
ControllerElevated
Schemas: finance_reporting, finance_detail
Views: + v_journal_entries, v_trial_balance
CFOFull
Schemas: finance_reporting, finance_detail
Views: all views, no filter restrictions
KPI Glossary (Governed Definitions)
KPISQL DefinitionGrainSource View
Gross Margin(SUM(revenue) - SUM(cogs)) / NULLIF(SUM(revenue), 0)division, monthv_revenue
Net RevenueSUM(revenue)division, monthv_revenue
OPEX VarianceSUM(actual_opex) - SUM(budget_opex)cost_center, monthv_opex
OPEX Variance %(actual - budget) / NULLIF(budget, 0)cost_center, monthv_opex
Revenue per UnitSUM(revenue) / NULLIF(SUM(units_sold), 0)division, product, monthv_revenue
Safety Rules (6 validation checks)
RuleWhat it blocksTests
SELECT onlyAny non-SELECT statement (DROP, DELETE, INSERT, UPDATE)4 passing
Blocked keywordsDDL/DML keywords even inside SELECT statements2 passing
Table authorizationQueries referencing tables outside the user's authorized schema2 passing
No SELECT *Wildcard selects (must name columns explicitly)2 passing
Fact table WHEREQueries on large fact tables without a WHERE clause2 passing
Injection patternsMulti-statement, SQL comments, INFORMATION_SCHEMA access3 passing
Audit Trail (last 5 queries)
TimestampUserRoleQuestionStatus
2024-03-15 09:14:22jsmithfpa_analystGross margin by division Q3Success
2024-03-15 09:12:05mchencontrollerJournal entries for account 5100Success
2024-03-15 09:08:41test_userfpa_analystSELECT * FROM secret_salariesBlocked
2024-03-15 08:55:19jsmithfpa_analystNet revenue by product line YTDSuccess
2024-03-15 08:42:33cfo_usercfoOPEX variance all cost centersSuccess

Interactive demo with simulated responses. Source: github.com/nicholasjh-work/llm-text-to-sql-finance