A modern, AI-powered PostgreSQL query interface with multi-connection support, intelligent query assistance, and a beautiful Apple-inspired design.
- Multi-Connection Support: Manage multiple PostgreSQL connections with secure credential storage
- Connection Switching: Easily switch between different database connections
- Connection Testing: Validate connections before activation
- Database Browser: Explore database schemas, tables, columns, and relationships
- Multiple AI Providers: Support for OpenAI, Claude (Anthropic), and DeepSeek
- Query Completion: Intelligent SQL query auto-completion
- Error Fixing: Automatic error detection and suggested fixes
- Query Optimization: Performance optimization suggestions
- Query Explanation: Natural language explanations of complex queries
- Monaco Editor: Advanced SQL editor with syntax highlighting
- Real-time Validation: Query syntax validation before execution
- Query History: Track and manage query execution history
- Results Export: Export query results in CSV, JSON, or SQL formats
- Execution Statistics: Performance metrics and timing information
- Apple-Inspired Design: Clean, modern interface following Apple design principles
- Dark/Light Mode: Automatic or manual theme switching
- Responsive Layout: Works seamlessly on desktop and tablet devices
- Glass Morphism: Beautiful translucent UI elements with backdrop blur
- Smooth Animations: Framer Motion powered transitions and interactions
- Node.js (v18 or higher)
- npm or yarn
- PostgreSQL database(s) to connect to
-
Clone the repository
git clone <repository-url> cd PostgreSQL-AI-Query-Assistant
-
Install dependencies
# Install root dependencies npm install # Install all dependencies (server + client) npm run install-all
-
Environment Setup
Create a
.envfile in theserverdirectory:# Server Configuration NODE_ENV=development PORT=3001 CLIENT_URL=http://localhost:5173 # Database Encryption Key (generate with: node -p "require('crypto').randomBytes(32).toString('hex')") DB_ENCRYPTION_KEY=your_32_byte_hex_encryption_key_here # AI Provider API Keys (optional - can be configured in UI) OPENAI_API_KEY=your_openai_api_key_here ANTHROPIC_API_KEY=your_anthropic_api_key_here DEEPSEEK_API_KEY=your_deepseek_api_key_here # Default AI Settings DEFAULT_AI_PROVIDER=openai DEFAULT_AI_MODEL=gpt-3.5-turbo
-
Start the application
# Development mode (starts both server and client) npm run dev # Or start separately: # Terminal 1 - Server npm run server # Terminal 2 - Client npm run client
-
Access the application
- Open your browser to
http://localhost:5173 - The server runs on
http://localhost:3001
- Open your browser to
-
Navigate to the Connections page
-
Click "Add Connection"
-
Fill in your PostgreSQL connection details:
- Name: Friendly name for the connection
- Host: Database server hostname/IP
- Port: Database port (default: 5432)
- Database: Database name
- Username: Database username
- Password: Database password
- SSL: Enable SSL connection if required
-
Test the connection before saving
-
Activate the connection to start querying
-
Navigate to AI Settings
-
Select your preferred AI provider:
- OpenAI: Requires OpenAI API key
- Claude: Requires Anthropic API key
- DeepSeek: Requires DeepSeek API key
-
Configure model settings:
- Model: Choose the specific model variant
- Max Tokens: Maximum response length (100-4000)
- Temperature: Creativity level (0.0-2.0)
-
Test your configuration
-
Save the settings
PostgreSQL-AI-Query-Assistant/
βββ server/ # Backend Node.js/Express server
β βββ src/
β β βββ routes/ # API route handlers
β β βββ services/ # Business logic services
β β βββ middleware/ # Express middleware
β β βββ utils/ # Utility functions
β βββ package.json
βββ client/ # Frontend React application
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ pages/ # Page components
β β βββ hooks/ # Custom React hooks
β β βββ stores/ # Zustand state management
β β βββ styles/ # CSS and styling
β βββ package.json
βββ package.json # Root package.json
- Express.js: Web framework with TypeScript
- PostgreSQL Client:
pglibrary for database connections - AI Integration: OpenAI, Anthropic, and DeepSeek SDKs
- Security: Helmet, CORS, rate limiting, credential encryption
- Validation: Zod schemas for request validation
- React: UI framework with TypeScript
- Vite: Build tool and development server
- Tailwind CSS: Utility-first CSS framework
- Zustand: Lightweight state management
- Framer Motion: Animation library
- Monaco Editor: Advanced code editor
- React Query: Server state management
# Development
npm run dev # Start both server and client in development mode
npm run server # Start only the backend server
npm run client # Start only the frontend client
# Production
npm run build # Build the frontend for production
npm start # Start the production server
# Utilities
npm run install-all # Install dependencies for all packages- Credential Encryption: Database passwords are encrypted at rest
- API Key Protection: AI provider keys are securely stored
- CORS Configuration: Proper cross-origin request handling
- Rate Limiting: API endpoint protection
- Input Validation: Comprehensive request validation
- SQL Injection Prevention: Parameterized queries
- Query Optimization: AI-powered performance suggestions
- Connection Pooling: Efficient database connection management
- Result Pagination: Large result set handling
- Query Timeout: Configurable execution timeouts
- Execution Metrics: Detailed performance statistics
- Use Ctrl/Cmd + Enter to execute queries
- Enable AI Assistant for real-time suggestions
- Use the Database Browser to explore table structures
- Validate queries before execution to catch syntax errors
- Ask natural language questions about your data
- Request query optimizations for better performance
- Get explanations for complex SQL queries
- Use error fixing suggestions when queries fail
- Test connections before activating
- Use descriptive names for easy identification
- Keep multiple connections for different environments
- Monitor connection status in the sidebar
GET /api/connections- List all connectionsPOST /api/connections- Create new connectionPUT /api/connections/:id- Update connectionDELETE /api/connections/:id- Delete connectionPOST /api/connections/:id/connect- Activate connectionPOST /api/connections/test- Test connection
POST /api/query/execute- Execute SQL queryPOST /api/query/validate- Validate query syntaxPOST /api/query/explain- Get query execution planGET /api/query/history- Get query history
GET /api/ai/providers- List AI providersPOST /api/ai/providers- Configure AI providerPOST /api/ai/assist- Get AI query assistancePOST /api/ai/chat- Chat with AI about queries
GET /api/database/schemas- List database schemasGET /api/database/tables- List tablesGET /api/database/tables/:name/columns- Get table columnsGET /api/database/structure- Get complete database structure
We welcome contributions! Please see our contributing guidelines for details on:
- Code style and standards
- Pull request process
- Issue reporting
- Feature requests
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Check the Issues section for existing solutions
- Create a new issue with detailed information
- Include error messages, screenshots, and reproduction steps
- Database schema visualization
- Advanced query builder GUI
- Collaborative query sharing
- Query performance analytics
- Custom AI prompt templates
- Database backup/restore tools
- Multi-user authentication
- Query scheduling and automation
- Currently supports PostgreSQL only
- AI features require internet connection
- Some advanced PostgreSQL features may not be fully supported
Built with β€οΈ using modern web technologies and AI-powered assistance.