AI-Powered Natural Language to SQL Query Assistant with Real-Time Insights
Live Demo: querysense.onrender.com
Note: Backend may take 30 seconds to wake from sleep on first request (free tier)
QuerySense is a modern full-stack web application that transforms natural language questions into SQL queries using AI, executes them safely on a PostgreSQL database, and provides intelligent business insights in real-time.
Perfect for demonstrating full-stack development, AI integration, real-time features, and Docker deployment skills.
- π€ AI-Powered Query Generation - OpenRouter API integration (GPT-4, Claude, Gemini support)
- π Safe SQL Execution - Sandboxed execution with validation and timeout protection
- β‘ Real-Time Updates - WebSocket notifications throughout query lifecycle
- π Interactive Results - Beautiful data tables with insights
- π‘ Business Insights - AI-generated actionable recommendations
- π₯ Role-Based Access - User and Admin roles with different permissions
- π Admin Dashboard - System analytics and query monitoring
- π¨ Premium Dark UI - Modern glassmorphism design with smooth animations
- π³ Docker Ready - Complete containerization with Docker Compose
- React 18 + TypeScript
- Vite (build tool)
- Framer Motion (animations)
- Socket.IO Client (real-time)
- Axios (HTTP)
- Node.js + Express
- TypeScript
- Socket.IO (WebSocket server)
- PostgreSQL + pg
- JWT authentication
- bcrypt (password hashing)
- Docker + Docker Compose
- PostgreSQL 15
- Nginx (production)
- Render.com (deployment)
# Clone repository
git clone https://github.com/YOUR_USERNAME/querysense.git
cd querysense
# Configure environment
cp .env.example .env
# Edit .env and add your OPENROUTER_API_KEY
# Launch with Docker
docker-compose up --build
# Access the app
# Frontend: http://localhost:5173
# Backend: http://localhost:3000Backend:
cd backend
npm install
npm run dev # http://localhost:3000Frontend:
cd frontend
npm install
npm run dev # http://localhost:5173User Account:
- Email:
demo@querysense.app - Password:
demo123
Admin Account:
- Email:
admin@querysense.app - Password:
admin123
Try asking:
- "Show me all customers from USA"
- "What are the top 5 best-selling products?"
- "Calculate total revenue by product category"
- "List all pending orders from the last week"
- "Which customers haven't ordered in 30 days?"
querysense/
βββ backend/ # Express API server
β βββ src/
β β βββ config/ # Database configuration
β β βββ cont rollers/ # Route handlers
β β βββ middleware/ # Auth, validation
β β βββ models/ # TypeScript interfaces
β β βββ routes/ # API endpoints
β β βββ services/ # Business logic (AI, SQL, WebSocket)
β β βββ index.ts # Server entry point
β βββ Dockerfile
βββ frontend/ # React SPA
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ pages/ # Main pages
β β βββ services/ # API, Socket.IO clients
β β βββ styles/ # CSS design system
β βββ Dockerfile
βββ database/
β βββ init.sql # Schema definition
β βββ seed.sql # Demo data
βββ docker-compose.yml # Service orchestration
- β SQL injection prevention
- β SELECT-only query execution
- β Query timeout limits (10s)
- β JWT authentication
- β Password hashing (bcrypt)
- β CORS protection
- β Environment-based secrets
See RENDER_DEPLOYMENT_GUIDE.md for complete deployment instructions.
Quick Deploy to Render:
- Push to GitHub
- Create Render account
- Deploy database, backend, frontend
- Done! (~15 minutes)
Alternative Options:
- Play with Docker: PWD_QUICKSTART.md
- Netlify + Render: NETLIFY_DEPLOYMENT.md
POST /api/auth/register- Register userPOST /api/auth/login- Login userGET /api/auth/profile- Get profile (protected)
POST /api/query- Submit new query (protected)GET /api/query/history- Get query history (protected)GET /api/query/:id- Get specific query (protected)
GET /api/admin/analytics- System analytics (admin only)GET /api/admin/users- All users (admin only)GET /api/admin/queries- All queries (admin only)
This project showcases:
- β Full-stack TypeScript development
- β AI/ML API integration
- β Real-time WebSocket communication
- β PostgreSQL database design
- β RESTful API development
- β Docker containerization
- β Authentication & authorization
- β Modern React patterns
- β Production deployment
- β Security best practices
Coming soon - deploy to Render first!
This is a portfolio project, but suggestions are welcome!
MIT License - Free to use for learning and portfolio purposes
Your Name
- GitHub: Aman Sharma
- OpenRouter for AI API access
- Render for free hosting
- PostgreSQL community
- React & Node.js ecosystems
β Star this repo if you found it helpful!
Built with β€οΈ for learning and demonstration