Chat-BI is a natural-language analytics assistant that turns business questions into SQL, executes them against your database, and returns structured answers with charts and tables.
- Natural-language to SQL workflow backed by schema understanding and reusable SQL templates
- FastAPI backend with MySQL + Milvus integration
- Configurable LLM and embedding providers
- Modern React frontend with conversation history, i18n, and light/dark theme switching
- Local-first development flow using
uvfor Python andpnpmfor the web app
Frontend (React + TypeScript + Vite)
->
Backend API (FastAPI)
->
Business DB (MySQL) + System DB (MySQL)
->
Vector Store (Milvus)
->
LLM / Embedding Providers (OpenAI, DeepSeek, Ollama)
- The user asks a question in natural language.
- The system embeds the question and searches for matching SQL templates.
- If no good template exists, the backend generates SQL from schema context.
- The query runs against the business database with basic safety guards.
- The result is returned as natural-language text plus a chart/table payload.
- Newly generated templates can be stored for better future matching.
- Backend: Python 3.10+, FastAPI, SQLAlchemy, PyMilvus, OpenAI SDK
- Frontend: React 19, TypeScript, Tailwind CSS, Zustand, ECharts, Vite
- Storage: MySQL, Milvus
- Package managers:
uv(Python),pnpm(web)
The backend now uses a YAML-first configuration model.
- Copy the example file:
cp config.example.yaml config.yaml- Edit
config.yamland fill in the values you need:
debug: false
database:
host: localhost
port: 3306
user: root
password: admin123456
name: chat_bi
sys_name: chat_bi_system
milvus:
host: localhost
port: 19530
llm:
provider: openai
model: gpt-4.1
api_key: your_api_key_here
base_url: ""
embedding:
provider: openai
model: text-embedding-3-small
dim: 1536
api_key: ""
api_url: ""Environment variables can still override YAML values when needed.
uv sync
uv run python main.pyThe API will be available at http://localhost:13000.
cd web
pnpm install
pnpm devThe web app will be available at http://localhost:5173.
If you want MySQL + Milvus locally and run the app processes on your host machine:
cd deploy
docker-compose -f docker-compose-base.yaml up -dThis brings up:
- MySQL:
localhost:3306 - Milvus:
localhost:19530 - Attu:
http://localhost:19000
The repository also includes a full deployment flow:
make build
make upNotes:
- The compose files live under
deploy/. - The current backend runtime is YAML-first, but the provided deployment stack may still rely on environment-based wiring depending on how you deploy it.
- For active development, local development with
config.yamlis the most straightforward path.
- Frontend:
http://localhost:5173 - Backend API docs:
http://localhost:13000/docs - Milvus Attu:
http://localhost:19000
- What can I query right now?
- Show the daily sales trend for the last 30 days.
- What are the top 10 products by sales volume?
- Show the sales share by product category.
- Which products have inventory below 10?
python test/generate_test_data.py
python test/run_test_data.pyIssues and pull requests are welcome.
- Author: sumingcheng
- Repository: https://github.com/sumingcheng/chat-bi