Flagship
Text-to-SQL for a nonprofit CRM
Plain-English questions answered from each organization's own live database, with every query checked before it runs.
Nonprofit CRM software
May to Jul 2026
Stack
AWS Bedrock AgentCore, Claude Sonnet, Amazon Neptune, Bedrock Knowledge Bases, Bedrock Guardrails, TypeScript, Node, MySQL, Terraform
Problem
Staff needed answers from CRM data without writing SQL or waiting on a report queue. Every organization has its own schema, questions are often ambiguous, and a wrong answer is worse than none, so every query had to be checked before it ran and every answer had to be measurable.
Built
An agent on AWS Bedrock AgentCore. A deterministic compliance gate runs before any model call and declines cross-organization asks, raw card or ID numbers, bulk exports, and out-of-domain questions. A rules-based classifier marks each question simple or ambiguous, and answers small talk, how-to questions, and the ten home-screen prompts with no model call at all. Retrieval runs two ways in parallel: a schema graph on Amazon Neptune, where business terms map to columns, tables, and domains with foreign-key expansion, and a Bedrock Knowledge Base over column and enum descriptions. Claude Sonnet writes the SQL through a single tool call, with session memory from AgentCore and a cached system prompt. The SQL is parsed to a syntax tree, recompiled, rewritten by eighteen deterministic rules, validated, and checked against an EXPLAIN cost threshold; expensive queries are detached to an export job. Execution goes through a tenant broker with a read-only session, one organization's schema, and a statement timeout. Results return as a value, a table, or a chart, with a plain-English summary from a smaller model.
Measured
94%of answers exact or correct on 100 golden questions
~5 centsof model cost per question
Graded end to end against golden SQL, each answer exact, correct, or wrong. Clarifications forced by the classifier fell from 59 to 30 of 143 questions as the glossary grew from 140 to 462 terms.
My part
Designed and built the engine's first version in June 2026: the classifier, graph and vector retrieval, the SQL validator, the executor, and the tenant broker. Later added the compliance gate and the cost gate with its export path. One of twelve engineers who have extended it since.