
Text-to-SQL tool — ask questions in plain English, get read-only SQL, results, Python analysis, and charts.
[English](README.md) | [中文](README.zh.md)

## Features
- **Natural language queries** — describe what you need, get SQL + results back
- **Auto analysis** — query results feed into Python for deeper analysis and chart generation
- **Semantic layer** — define business terms (GMV, AOV, etc.) so the generated SQL stays unambiguous
- **Schema relationship graph** — drag-and-drop table connections, QueryGPT picks the right join path
## How It Works
```mermaid
flowchart LR
query["Ask in plain English"] --> context["Understand intent using semantic layer + schema"]
context --> sql["Generate read-only SQL"]
sql --> execute["Execute query"]
execute --> result["Return results & summary"]
result --> decision{"Need charts or further analysis?"}
decision -->|Yes| python["Python analysis & charts"]
decision -->|No| done["Done"]
python --> done
execute -->|SQL error| repair_sql["Auto-repair & retry"]
sql -->|on retry| repair_sql
python -->|Python error| repair_py["Auto-repair & retry"]
repair_sql --> sql
repair_py --> python
```
## Screenshots


## Quick Start
### 1. Clone the repo
```bash
git clone https://github.com/MoonMao42/ReceiptBI.git
cd ReceiptBI
```
### 2. Run it
**macOS / Linux** — needs Python 3.11+ and Node.js LTS:
```bash
./start.sh
```
Or with Docker:
```bash
docker compose up --build
```
**Windows** — use [Docker Desktop](https://www.docker.com/products/docker-desktop/), or [WSL2](https://learn.microsoft.com/windows/wsl/install) + `./start.sh`.
### 3. Configure
Open `http://localhost:3000`:
1. Go to Settings and add a model (provider + API key)
2. Use the built-in demo database, or connect your own SQLite / MySQL / PostgreSQL
3. Optionally set a default model, default connection, and conversation context rounds
4. Start asking questions
> Ships with a built-in SQLite demo database (`demo.db`). A sample connection is auto-created on first launch.
## Tech Stack
- **Frontend**: Next.js 15, React 19, TypeScript, Zustand, TanStack Query
- **Backend**: FastAPI, SQLAlchemy 2.0, LiteLLM, Python 3.11+
- **Databases**: SQLite, MySQL, PostgreSQL