Jun 13, 2026

NF QueryGPT

bwai-trae-delhi

 

NF QueryGPT is an AI-powered natural language-to-SQL assistant built for NikahForever (a matrimonial platform). Its primary purpose is to allow non-technical team members—such as Product Managers, Customer Support, Operations, and Founders—to ask business-related questions about database data in plain English or Hinglish (e.g., "How many users registered from Delhi this month?") and receive instant visual results and data analysis without needing to write SQL or wait hours for a data analyst.

All AI-generated SQL queries are verified on the server before execution. The validation layer (lib/sql-validator.ts) blocks potentially harmful commands such as INSERT, UPDATE, DELETE, DROP, ALTER, TRUNCATE, REPLACE, CREATE, GRANT, REVOKE, EXEC, EXECUTE, and VACUUM. Only read-only queries using SELECT or WITH are allowed.

Query Protection

  • Execution Timeout: Queries are automatically cancelled after 10 seconds using AbortController, preventing long-running or stuck operations.
  • Row Limit: Query responses are restricted to 100 rows by default (MAX_ROWS_RETURNED) to avoid excessive data transfer.
  • Error Handling: All database errors are processed server-side, and only safe, sanitized error messages are returned to the client.

LLM Security

  • The system prompt strictly prevents generation of destructive SQL commands.
  • The model is instructed not to reveal sensitive data like phone numbers or email addresses unless specifically requested by the user.
  • Hinglish input is supported without compromising security.
  • With AMBIGUITY_THRESHOLD=7, vague or unclear requests trigger clarification prompts instead of immediate execution.

Data Privacy

  • The LLM receives only a limited, curated schema context rather than full database metadata.
  • Data processing remains entirely server-side; the client only receives final query results.

Infrastructure Security

  • API Keys: Groq and OpenRouter API keys are stored securely as environment variables in Vercel and are never exposed to frontend code.
  • Database Security: The Neon PostgreSQL connection uses sslmode=require to ensure encrypted communication.
  • Secure Deployment: Hosting on Vercel provides automatic HTTPS with SSL/TLS encryption.
 
 

Goals

  1. Democratize Data Access: Bridge the gap between non-technical business teams and databases by providing instant, self-serve answers.
  2. Translate Natural Language to SQL: Accurately map conversational queries (English and Hinglish) into precise SQLite read queries.
  3. Handle Ambiguity Safely: Prevent false assumptions by identifying ambiguous questions and asking clarifying follow-up questions instead of guessing.
  4. Ensure Security & Safety: Enforce read-only access strictly, blocking any query modifications (INSERTUPDATEDELETEDROPALTER) to prevent data corruption.
  5. Enhance User Experience: Present answers clearly using a modern chat interface complete with interactive data tables, collapsible SQL code inspection, and automatic chart visualizations (line/bar plots) for trends.

DEPLOYED LINK -https://nfsql.mohitdwivedi.in/chat

Give a star to encourage!Discussion
Start a new conversation!
Login to join the discussion