ChatSQL is an AI-powered, web-based tool that allows users to design, deploy, and optimize database schemas using natural language. It features a sophisticated multi-agent system with specialized agents for database design and performance optimization. Users can describe their database needs in plain English, and the system will generate optimized SQL schemas, deploy them to TigerData's PostgreSQL platform, and continuously monitor performance with zero-copy optimization testing.
- Multi-Agent Architecture: Specialized agents for design, optimization, and monitoring work together to deliver production-ready database solutions.
- Unified Agent Tools API: Secure, centralized API for all agent operations with built-in security and error handling.
- Natural Language to SQL: Describe your database needs in plain English and get AI-generated, optimized SQL schemas.
- Zero-Copy Optimization: Test performance improvements safely using TigerData's zero-copy fork technology without affecting production.
- Real-time WebSocket Communication: Live chat interface with instant agent responses and status updates.
- Interactive Schema Design: Design Agent analyzes requirements and generates optimized PostgreSQL schemas with proper indexing and constraints.
- Performance Optimization: Optimize Agent creates isolated test environments, applies optimizations, and merges successful changes.
- Real-time Monitoring: Track agent status, database performance metrics, and API health in real-time.
- Dual AI Provider Support: Choose between Google Gemini and OpenAI for schema generation with configurable API keys.
- WebSocket-Powered Terminal: Execute database operations with live streaming updates and progress indicators.
- API Endpoint Monitoring: Add and monitor external API endpoints with real-time health checks and response tracking.
The application features a sophisticated multi-agent system that transforms natural language into database operations through a unified tools API:
User Input → ChatSQL Interface (Port 3001)
↓
AI Provider (Gemini/OpenAI) → SQL Schema Generation
↓
Agent Orchestrator → Design Agent / Optimize Agent
↓
AgentToolsService API (/api/agents/tools)
↓
TigerData API → PostgreSQL Database Operations
↓
Response → Chat Interface (Database Results + Schema Visualization)
-
Design Agent: Converts natural language requirements into SQL schemas
- Analyzes user input for database needs
- Uses
call_apitool to inspect external data sources - Generates optimized table structures with proper data types
- Uses
execute_sqltool to deploy schemas to TigerData - Uses
get_schema_infotool to validate and inspect existing schemas
-
Optimize Agent: Enhances performance by testing modifications using zero-copy forks
- Monitors query performance metrics
- Uses
create_zero_copy_forktool to create isolated testing environments - Uses
execute_sqltool to test optimizations safely - Uses
delete_forktool to clean up test environments - Merges successful optimizations back to production
All 6 tools are accessible via POST /api/agents/tools:
| Tool | Purpose |
|---|---|
call_api |
Call external APIs for data inspection |
execute_sql |
Execute SQL queries with security protection |
create_zero_copy_fork |
Create TigerData forks for safe testing |
delete_fork |
Delete TigerData forks to clean up |
get_schema_info |
Inspect table schemas and metadata |
get_monitoring_data |
Get chart-ready performance data |
- Interactive Chart.js visualizations
- API response latency tracking
- Service health status monitoring
- Query performance metrics
- Auto-refresh every 30 seconds
- Test optimizations without production impact
- Automatic rollback on failures
- Performance comparison before merge
- Isolated testing environment
ChatSQL consists of a React frontend with a Node.js/Express backend featuring specialized AI agents for database design and optimization.
- Node.js 18+
- API key from Google (Gemini) or OpenAI
- TigerData account (for database deployment)
-
Clone and install dependencies:
git clone <repository-url> cd chatsql npm install cd server && npm install
-
Environment Configuration: Create a
.envfile in the server directory:TIGER_DATA_URL=your_tigardata_connection_string OPENAI_API_KEY=your_openai_api_key GOOGLE_API_KEY=your_google_api_key PORT=3002
-
Start the backend server:
cd server npm run dev -
Start the frontend (in a new terminal):
npm run dev
-
Open your browser to
http://localhost:3001
- Click the Settings icon (⚙️) in the top-right corner
- Configure your AI Provider (Google Gemini or OpenAI) and enter API keys
- Set up TigerData credentials for database deployment
- Add any external API endpoints you want to monitor
Start chatting with the agents! Try commands like:
- "Create a user management database"
- "Design an e-commerce schema with products and orders"
- "Optimize my database performance"
- "Add indexes to the users table"
- Frontend: React 18 with TypeScript
- Backend: Node.js/Express with WebSocket support
- Styling: Tailwind CSS with custom gradients
- AI Integration:
- Google Gemini API (
@google/generative-ai) - OpenAI API
- Google Gemini API (
- Database: TigerData PostgreSQL with zero-copy forks
- Real-time Communication: WebSocket for agent chat and status updates
- Visualization: Chart.js for performance metrics and API monitoring
- UI Components: Lucide React icons, Paper Design shaders
- Build Tools: Webpack 5, Babel, TypeScript compiler
├── src/ # React Frontend
│ ├── components/
│ │ ├── App.tsx # Main application component
│ │ ├── chat/
│ │ │ ├── ChatPanel.tsx # WebSocket chat interface
│ │ │ └── ChainOfThoughtLog.tsx
│ │ ├── layout/
│ │ │ ├── Header.tsx # App header with settings
│ │ │ ├── SettingsModal.tsx # Configuration modal
│ │ │ └── TabbedPanel.tsx # Right panel tabs
│ │ └── panels/
│ │ ├── TerminalPanel.tsx # Real-time terminal
│ │ ├── ApiMonitoringPanel.tsx
│ │ ├── ChartPanel.tsx # Performance charts
│ │ └── VisualSchemaViewer.tsx
│ ├── hooks/
│ │ ├── useChatLogic.ts # Chat state management
│ │ └── useMcpClient.ts # MCP client hook
│ ├── clients/
│ │ ├── AiService.ts # AI provider abstraction
│ │ └── MCPClient.ts # MCP communication
│ ├── services/
│ │ └── apiClient.ts # HTTP client utilities
│ ├── utils/
│ │ ├── constants.ts # App constants
│ │ └── sqlParser.ts # SQL parsing utilities
│ └── index.tsx # React entry point
├── server/ # Node.js Backend
│ ├── src/
│ │ ├── index.ts # Express server setup
│ │ ├── config/
│ │ │ └── environment.ts # Environment configuration
│ │ ├── agents/
│ │ │ ├── AgentOrchestrator.ts # Agent coordination
│ │ │ ├── DesignAgent.ts # Schema design agent
│ │ │ └── OptimizationAgent.ts # Performance optimization
│ │ ├── routes/
│ │ │ ├── agents.ts # Agent API endpoints
│ │ │ ├── chat.ts # Chat WebSocket routes
│ │ │ └── sql.ts # SQL execution routes
│ │ ├── services/
│ │ │ └── AgentToolsService.ts # Unified tools API
│ │ └── index.ts
│ └── package.json
├── database-server/ # Database MCP Server
│ ├── src/
│ │ └── index.ts # MCP server for DB operations
│ └── package.json
├── mcp-proxy/ # Legacy MCP Proxy
├── design_agent_prompt.md # Design Agent system prompt
├── optimize_agent_prompt.md # Optimize Agent system prompt
├── AGENT_TOOLS_INTEGRATION.md # Integration documentation
└── package.json # Root package.json
We welcome contributions! Please see our Contributing Guide for details on:
- Setting up a development environment
- Code style and testing guidelines
- Submitting pull requests
- Agent development best practices
This project is licensed under the MIT License - see the LICENSE file for details.
Ready to revolutionize database development? Experience the power of AI-driven database design with ChatSQL's multi-agent architecture! 🚀