INTELLIQUERY
A Next.js + FastAPI platform that lets non-technical users query relational databases in plain English, built on a template-first SQL pipeline with an OpenAI-to-Gemini fallback and layered safety checks.


DB_ENGINES
5
EXECUTION
READ_ONLY
SQL_GEN
TEMPLATE+LLM
CACHING
TTL+LRU
ABOUT_THE_PROJECT
IntelliQuery lets people who can't write SQL still get answers from a database. Connect PostgreSQL, MySQL, SQL Server, SQLite, or CockroachDB, ask something like "top 10 customers by revenue last month", and get validated SQL, live results, a chart, and an AI summary grounded in real statistics.
Common questions are answered by a deterministic template engine with zero LLM tokens; the rest go through a schema-aware LLM chain (OpenAI with Gemini fallback). Every query passes a SELECT-only validator and runs in a read-only transaction with timeouts and row caps.
SYSTEM_ENVIRONMENT_MATRIX
Key_Challenges
- [ ERR_01 ]Containing hallucination: prompts are grounded in the real schema, and a repair pass fixes queries that reference tables or columns that don't exist.
- [ ERR_02 ]One auth across two runtimes: Better Auth creates sessions in Next.js, and FastAPI validates the same tokens against a shared PostgreSQL.
- [ ERR_03 ]Cache correctness: schema changes invalidate cached SQL, failing queries evict themselves, and empty results are never cached.
Key_Learnings
- [ LN_01 ]Trustworthy AI features need verification around the model, not just better prompts.
- [ LN_02 ]Deterministic fast paths cut more cost and latency than any prompt tuning did.
- [ LN_03 ]Layered defenses work: each check catches what the previous one misses.
//SYSTEM_COMPILE_COMPLETE
Have questions about this framework implementation or structural logic?