Ask questions in plain language, and it automatically retrieves data from your database and creates charts like bar graphs and pie charts for you.
⭐ If this project helps you, please give me a Star!
Frontend (React + TypeScript)
↓
Backend API (FastAPI + Python)
↓
┌─────────────────┬─────────────────┐
│ Business DB │ System DB │
│ (MySQL) │ (MySQL) │
└─────────────────┴─────────────────┘
↓
Vector Database (Milvus)
↓
AI Services (OpenAI)
-
Question vectorization: Convert user's natural language questions into vectors to find similar SQL query templates in the database.
-
Generate SQL queries: If no matching template is found, the system generates new SQL queries based on database structure and user questions.
-
Generate natural language answers: After executing SQL queries and retrieving data, the system converts structured data into easy-to-understand natural language responses.
-
Generate descriptions for new templates: The system saves newly generated SQL as templates and creates brief descriptions for future precise matching.
Backend: Python 3.10+ · FastAPI · SQLAlchemy · PyMilvus · OpenAI
Frontend: React 19 · TypeScript · Tailwind CSS · ECharts · Vite
Storage: MySQL · Milvus
Pie Chart: Monthly customer registration distribution

Line Chart: Sales trend analysis for the last 30 days

git clone https://github.com/sumingcheng/chat-bi.git
cd chat-biCopy and edit the environment configuration file:
cp .env-temp .envEdit the .env file and configure necessary parameters:
# Debug mode
DEBUG=False
DB_HOST=mysql
DB_PORT=3306
DB_USER=root
DB_PASSWORD=admin123456
DB_NAME=chat_bi
DB_SYS_NAME=chat_bi_system
MILVUS_HOST=milvus-standalone
MILVUS_PORT=19530
OPENAI_API_KEY=sk-
EMBEDDING_API_URL=http://172.19.221.125:11434/api/embeddings
EMBEDDING_MODEL=bge-m3# Execute in root directory and web directory
make build
# Return to root directory
make up# Install dependencies
uv sync
# Start backend service
python main.py # Successful startup display
⚡ root@DESKTOP-AETE0Q9 /data/chat-bi main docker logs -f f341b3959a99
INFO: Will watch for changes in these directories: ['/chat-bi']
INFO: Uvicorn running on http://0.0.0.0:13000 (Press CTRL+C to quit)
INFO: Started reloader process [1] using StatReload
INFO: Started server process [8]
INFO: Waiting for application startup.
2025-06-03 04:01:07 [INFO] app:57 - 🚀 Application starting...
2025-06-03 04:01:07 [INFO] app:58 - 📊 Checking database table status...
2025-06-03 04:01:07 [INFO] app:39 - ✓ Business database table 'category' exists
2025-06-03 04:01:07 [INFO] app:39 - ✓ Business database table 'customer' exists
2025-06-03 04:01:07 [INFO] app:39 - ✓ Business database table 'product' exists
2025-06-03 04:01:07 [INFO] app:39 - ✓ Business database table 'sales_order' exists
2025-06-03 04:01:07 [INFO] app:39 - ✓ Business database table 'order_item' exists
2025-06-03 04:01:07 [INFO] app:39 - ✓ Business database table 'sales' exists
2025-06-03 04:01:07 [INFO] app:49 - ✓ System database table 'sql_templates' exists
2025-06-03 04:01:07 [INFO] app:49 - ✓ System database table 'sql_template_params' exists
2025-06-03 04:01:07 [INFO] app:49 - ✓ System database table 'query_history' exists
2025-06-03 04:01:07 [INFO] app:63 - 📊 Initializing database tables...
2025-06-03 04:01:07 [INFO] app:68 - Initializing business database tables: ['category', 'customer', 'product', 'sales_order', 'order_item', 'sales']
2025-06-03 04:01:07 [INFO] app:71 - Business database table initialization completed
2025-06-03 04:01:07 [INFO] app:68 - Initializing system database tables: ['sql_templates', 'sql_template_params', 'query_history']
2025-06-03 04:01:07 [INFO] app:71 - System database table initialization completed
2025-06-03 04:01:07 [INFO] app:71 - ✅ Database table initialization completed
2025-06-03 04:01:07 [INFO] app:72 - 🎉 Chat-BI API started successfully!
INFO: Application startup complete.cd web
# Install dependencies
pnpm install
# Start development server
pnpm run devAfter successful startup, you can access:
- Frontend: http://localhost:8888
- Backend API Documentation: http://localhost:13000/docs
- Milvus Management Interface: http://localhost:19000
The project provides test data generation tools:
# Generate test data
python test/generate_test_data.py
# Run test queries
python test/run_test_data.pyWe welcome all forms of contributions!
- Author: sumingcheng
- Email: Contact via GitHub Issues
- Project Homepage: https://github.com/sumingcheng/chat-bi
