Sparkset is an AI-powered operational assistant that helps teams interact with databases using natural language. Ask questions like "How many orders were cancelled this week?" or "Show me users from Beijing" and get instant insights without writing SQL.
- ๐ค Natural Language to SQL: Convert plain English questions into optimized SQL queries using AI
- ๐ Multi-Datasource Support: Connect to MySQL databases (PostgreSQL and MongoDB coming soon)
- ๐ Schema Intelligence: Automatic schema synchronization and caching for faster queries
- ๐ฌ Conversation History: Keep track of all your queries and AI interactions
- ๐ Action Templates: Save and reuse successful queries as templates
- ๐๏ธ AI Provider Management: Support for OpenAI, Anthropic, and other AI providers with fallback strategies
- ๐ฅ๏ธ Web Dashboard: Beautiful, modern UI built with Next.js and shadcn/ui
- โก CLI Tools: Command-line interface for automation and technical users
Before you begin, ensure you have the following installed:
- Node.js 18+ (Download)
- pnpm 9+ (Installation Guide)
- MySQL 8.0+ (or PostgreSQL for future support)
- An AI provider API key (OpenAI or Anthropic)
- Clone the repository
git clone https://github.com/overtrue/sparkset.git
cd sparkset- Install dependencies
pnpm install- Set up your database
Create a MySQL database and configure the connection. You can use either approach:
Option 1: Use DATABASE_URL (recommended)
export DATABASE_URL="mysql://user:password@localhost:3306/sparkset"Option 2: Use individual environment variables
export DB_HOST=localhost
export DB_PORT=3306
export DB_USER=root
export DB_PASSWORD=yourpassword
export DB_NAME=sparkset- Run database migrations
# Navigate to server directory and run migrations
cd apps/server
node ace migration:run- Configure AI provider
Choose one of the following options:
Configure AI Providers:
AI providers are now configured through the database (Dashboard โ AI Providers) rather than environment variables.
# After starting the server, configure AI providers via:
# 1. Navigate to http://localhost:3333/ai-providers (Dashboard)
# 2. Add your AI provider with API key and configuration
# 3. Set the default providerSee AI Provider Configuration section for more details.
- Start the development servers
Open two terminal windows:
Terminal 1 - Server:
pnpm dev --filter @sparkset/serverThe API will be available at http://localhost:3333
Terminal 2 - Dashboard:
pnpm dev --filter @sparkset/dashboardThe Dashboard will be available at http://localhost:3000
- Try the demo (optional)
To load sample data for testing:
mysql -uroot -p123456 sparkset_demo < scripts/demo-seed.sqlVisit http://localhost:3000 to start using Sparkset!
The Dashboard provides a user-friendly interface for managing datasources, running queries, and viewing results.
- Add a datasource: Navigate to the datasources page and add your database connection details
- Sync schema: Click "Sync Schema" to cache your database structure for faster queries
- Ask questions: Use the query runner to ask natural language questions
- View results: See formatted results, generated SQL, and execution details
- Save templates: Save successful queries as reusable action templates
For programmatic access, use the REST API:
# Run a natural language query
curl -X POST http://localhost:3333/query \
-H "Content-Type: application/json" \
-d '{
"question": "How many orders were placed this week?",
"datasource": 1,
"limit": 10
}'
# List all datasources
curl http://localhost:3333/datasources
# Sync schema for a datasource
curl -X POST http://localhost:3333/datasources/1/sync
# Get conversation history
curl http://localhost:3333/conversationsSparkset is built as a monorepo using Turborepo for efficient builds and task orchestration:
sparkset/
โโโ apps/
โ โโโ api/ # AdonisJS REST API server
โ โ โโโ src/app/ # Controllers, services, validators
โ โ โโโ tests/ # API tests
โ โโโ dashboard/ # Next.js web application
โ โโโ src/app/ # Next.js pages and routes
โ โโโ src/components/ # React components
โโโ packages/
โ โโโ core/ # Core business logic
โ โ โโโ Query executor and planner
โ โ โโโ Action runner
โ โโโ ai/ # AI provider integration
โ โ โโโ Provider management
โ โ โโโ Prompt templates
โ โโโ db/ # Database layer
โ โ โโโ Repository interfaces
โ โโโ models/ # Shared TypeScript types
โ โโโ utils/ # Utility functions
โ โโโ config/ # Configuration management
โโโ scripts/ # Database seeds and utilities
apps/server: AdonisJS Server with controllers, services, and validators, contains repository interfaces and AI client implementationsapps/dashboard: Next.js application with shadcn/ui componentspackages/core: Core query execution and action processing logic, contains DBClient interfaces
# Recommended: Use DATABASE_URL
DATABASE_URL=mysql://user:password@host:port/database
# Alternative: Individual variables
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=yourpassword
DB_NAME=sparksetAI providers are now configured through the database rather than environment variables:
- Access Dashboard: Navigate to
http://localhost:3000/ai-providers(or your dashboard URL) - Add Provider: Click "Add AI Provider" and fill in:
- Provider name (e.g., "OpenAI Production")
- Provider type (openai, anthropic, deepseek, groq, moonshot, etc.)
- API Key (required)
- Base URL (optional, for custom endpoints)
- Default Model (optional)
- Set Default: Select one provider as the default
Supported Provider Types:
openai- OpenAI APIanthropic- Anthropic APIdeepseek- DeepSeek APIgroq- Groq APImoonshot- Moonshot/Kimi APIzhipu- Zhipu AI APIqwen- Alibaba Qwen APIopenai-compatible- Any OpenAI-compatible API
PORT=3333 # API server port
HOST=0.0.0.0 # API server host
SPARKSET_ENV=dev # Environment: dev, test, prod
LOG_LEVEL=info # Log level: debug, info, warn, error
API_KEY=your-api-key # Optional API key for authenticationNEXT_PUBLIC_API_URL=http://localhost:3333 # API server URLBuild all packages for production:
# Build all packages
pnpm build
# Start server (production)
cd apps/server
pnpm start
# Start Dashboard (production)
cd apps/dashboard
pnpm startDeploy to platforms like Railway, Render, or DigitalOcean:
- Set all required environment variables in your hosting platform
- Ensure your database is accessible from the hosting environment
- Run migrations:
cd apps/server && node ace migration:run - Build and start the services
The Dashboard can be deployed to Vercel:
cd apps/dashboard
vercel deploySet NEXT_PUBLIC_API_URL to your API server URL.
Sparkset now supports Docker deployment with multi-stage builds and Docker Compose orchestration.
Quick Start with Docker Compose:
# Copy environment variables template
cp .env.example .env
# Edit .env file with your configuration
# Then start all services
docker-compose up -d
# Run database migrations
docker-compose exec api node ace migration:run
# Access the application
# Dashboard: http://localhost:3000
# API: http://localhost:3333Build Docker Images:
# Build server image
docker build -f apps/server/Dockerfile -t sparkset/server:latest .
# Build Dashboard image
docker build -f apps/dashboard/Dockerfile \
--build-arg NEXT_PUBLIC_API_URL=http://localhost:3333 \
-t sparkset/dashboard:latest .For detailed Docker deployment instructions, see Deployment Guide.
Deploy to Kubernetes using the provided Helm Chart:
# Install with default values
helm install sparkset ./helm/sparkset
# Or use custom values
helm install sparkset ./helm/sparkset -f my-values.yamlFor detailed Helm deployment instructions, see Deployment Guide.
Ensure all required environment variables are set:
DATABASE_URL- Database connection stringOPENAI_API_KEYorANTHROPIC_API_KEY- AI provider credentialsNEXT_PUBLIC_API_URL- API server URL (for Dashboard)PORT- API server port (default: 3333)SPARKSET_ENV=prod- Environment identifier
# Run all tests
pnpm test
# Run tests for a specific package
pnpm --filter @sparkset/core test
pnpm --filter @sparkset/server test
# Run tests in watch mode
pnpm --filter @sparkset/core test --watch
# Run tests with coverage
pnpm test --coverageWe use ESLint and Prettier for code quality:
# Lint all code
pnpm lint
# Format all code
pnpm format
# Format specific files
pnpm prettier --write path/to/file.ts# Run all dev servers (API + Dashboard)
pnpm dev
# Run specific app
pnpm dev --filter @sparkset/server
pnpm dev --filter @sparkset/dashboard
# Run database migrations (after schema changes)
cd apps/server && node ace migration:run- Create a feature branch:
git checkout -b feature/your-feature - Make your changes
- Run tests:
pnpm test - Format code:
pnpm format - Lint code:
pnpm lint - Commit changes following conventional commits
- Create a Pull Request
See CONTRIBUTING.md for detailed development guidelines.
We welcome contributions from the community! Whether it's bug fixes, new features, or documentation improvements, your help makes Sparkset better.
Please read our Contributing Guide for details on:
- Development environment setup
- Code style and conventions
- Git workflow and branch naming
- Pull request process
- Testing guidelines
- Code review process
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests if applicable
- Ensure all tests pass (
pnpm test) - Format code (
pnpm format) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Thank you for contributing! ๐
- Contributing Guide - How to contribute to Sparkset
- Development Guide - Detailed development instructions
- Architecture Spec - Technical architecture and design decisions
- ไธญๆๆๆกฃ - Chinese documentation
Sparkset includes several security features to protect your data:
- SQL Safety: All generated SQL is validated to ensure read-only operations
- Dry-run Validation: Queries are tested before execution to prevent data modification
- Schema Caching: Reduces direct database metadata queries and potential attack surface
- Input Validation: All inputs are validated using Zod schemas
- SQL Injection Prevention: Parameterized queries and input sanitization
If you discover a security vulnerability, please do not open a public issue. Instead:
- Email security concerns to:
anzhengchao@gmail.com - Or open a private security advisory
We take security seriously and will respond promptly to all security reports.
Important Notice: All code in this project is generated by AI. Users are responsible for any issues that arise from using this software. This project is open-sourced for sharing and reference purposes only, and the authors bear no responsibility for any problems.
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Turborepo
- UI components from shadcn/ui
- AI integration via Vercel AI SDK
- Database management with AdonisJS Lucid
- ๐ Bug Reports: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
- ๐ง Email: anzhengchao@gmail.com
- ๐ Documentation: Check our docs and contributing guide
- Check existing Issues and Discussions
- Read the documentation
- Ask questions in GitHub Discussions
Made with โค๏ธ by overtrue and all contributors
โญ Star us on GitHub โข ๐ Read the Docs โข ๐ค Contribute