๐ญ Kepler
An AI-powered data agent that lets you query databases using natural language. Ask questions in plain English and get SQL queries, validated results, and auto-generated visualizations.
โ๏ธ How It Works
- ๐ฌ You ask a question in natural language
- ๐ Kepler discovers relevant tables and recalls past learnings
- ๐ง The AI agent writes SQL, executes it read-only, and validates the results
- ๐ Results are displayed with suggested charts when appropriate
โจ Features
- ๐ฌ Natural language querying โ Ask questions in plain English, get SQL + results
- ๐ Schema discovery โ Automatic introspection of tables, columns, types, and sample data
- โ Smart validation โ Checks for zero rows, high NULL rates, suspicious aggregations
- ๐ง Persistent memory โ Learns corrections, schema notes, and patterns across sessions
- ๐ Query inference โ Upload historical SQL files for the agent to learn from
- ๐ ClickHouse support โ Connect to ClickHouse via
CLICKHOUSE_URL; SQLite used when unset - ๐ค CSV upload โ Import CSV files with automatic type inference (into SQLite or ClickHouse)
- ๐ Auto-generated charts โ Bar, line, pie, and area charts via Recharts
- ๐ Semantic search (RAG) โ Qdrant + Ollama embeddings for finding relevant context
- ๐ Annotations โ Domain experts can annotate tables and columns with business meaning
๐ ๏ธ Tech Stack
- Frontend: Next.js 16, React 19, Tailwind CSS 4, Recharts
- Backend: Next.js API routes, Better-sqlite3, ClickHouse, Vercel AI SDK
- AI: OpenAI GPT-4o with tool-based agentic workflow
- Vector search: Qdrant + Ollama (nomic-embed-text)
- Infrastructure: Docker Compose
๐ Quick Start
Prerequisites
- ๐ฆ Node.js 20+
- ๐ฆ pnpm
- ๐ An OpenAI API key
Local Development
# Install dependencies pnpm install # Configure environment cp .env.example .env # Edit .env and add your OPENAI_API_KEY # Start the dev server pnpm dev
The app will be available at http://localhost:3000. By default it runs in demo mode with sample e-commerce data (customers, products, orders).
๐ณ Docker Compose
# Set your API key export OPENAI_API_KEY=sk-... # Start all services (app + Qdrant + Ollama) docker compose up -d # Optional: run the enrichment sidecar for semantic search docker compose --profile enrich up -d
This starts three services:
| Service | Port | Purpose |
|---|---|---|
| ๐ญ kepler | 3000 | Next.js application |
| ๐๏ธ qdrant | 6333 | Vector database |
| ๐ค ollama | 11434 | Local embedding model |
๐ง Configuration
| Variable | Required | Default | Description |
|---|---|---|---|
OPENAI_API_KEY |
โ | โ | OpenAI API key |
KEPLER_MODE |
โ | demo |
demo seeds sample data, service uses existing DB |
QDRANT_URL |
โ | http://localhost:6333 |
Qdrant vector database URL |
OLLAMA_URL |
โ | http://localhost:11434 |
Ollama embedding service URL |
EMBEDDING_MODEL |
โ | nomic-embed-text |
Embedding model name |
CLICKHOUSE_URL |
โ | โ | ClickHouse HTTP URL (enables ClickHouse mode) |
CLICKHOUSE_DATABASE |
โ | default |
ClickHouse database name |
CLICKHOUSE_USER |
โ | default |
ClickHouse username |
CLICKHOUSE_PASSWORD |
โ | โ | ClickHouse password |
When CLICKHOUSE_URL is set, data queries run against ClickHouse. Internal tables (memories, query history, annotations) always stay in SQLite. Semantic search is optional โ if Qdrant/Ollama are unavailable, Kepler falls back to keyword-based schema matching.
๐งฐ Makefile
Run make help to see all available commands.
make setup # ๐๏ธ Full first-time setup: install deps, start infra, pull embedding model make up # ๐ Start infra + dev server with ClickHouse make dev # ๐ป Dev server with SQLite only make dev-ch # ๐ Dev server with ClickHouse make infra # ๐ณ Start infra services (ClickHouse, Qdrant, Ollama) make infra-stop # โน๏ธ Stop infra services make pull-model # ๐ฅ Pull the embedding model into Ollama make enrich # ๐ Run the RAG enrichment sidecar make build # ๐ฆ Production build make start # โถ๏ธ Production server (SQLite) make start-ch # โถ๏ธ Production server (ClickHouse) make clean # ๐งน Stop infra and remove volumes
๐ One-click from scratch
cp .env.example .env
# Edit .env and add your OPENAI_API_KEY
make setup
make up๐ Project Structure
src/
โโโ app/
โ โโโ page.tsx # ๐ Landing page
โ โโโ demo/page.tsx # ๐ฌ Chat interface
โ โโโ docs/ # ๐ Documentation pages
โ โโโ api/
โ โโโ chat/route.ts # ๐ง AI agent (streaming, tools)
โ โโโ schema/route.ts # ๐ Table schema endpoint
โ โโโ upload/route.ts # ๐ค CSV upload
โ โโโ queries/route.ts # ๐ Query history
โ โโโ memories/route.ts # ๐ง Memory CRUD
โ โโโ annotations/ # ๐ Annotation CRUD
โโโ components/ # ๐งฉ React components
โโโ lib/
โ โโโ db.ts # ๐๏ธ Database operations (SQLite + ClickHouse delegation)
โ โโโ clickhouse.ts # ๐ ClickHouse client + data functions
โ โโโ rag.ts # ๐ Qdrant vector search
โ โโโ enrichment.ts # โจ Table context builder
โ โโโ schema.ts # ๐ Schema formatting & scoring
โ โโโ types.ts # ๐ TypeScript interfaces
scripts/
โโโ enrich.ts # ๐ Enrichment pipeline
data/
โโโ kepler.db # ๐พ SQLite database
๐ Scripts
pnpm dev # ๐ป Start development server pnpm build # ๐ฆ Production build pnpm start # โถ๏ธ Start production server pnpm lint # ๐ Run ESLint pnpm enrich # ๐ Run the enrichment pipeline
๐ License
Private
