# dataflow **Repository Path**: haibozhang2023/dataflow ## Basic Information - **Project Name**: dataflow - **Description**: dataflow - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-01-25 - **Last Updated**: 2026-01-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 🌊 DataFlow - 自然语言数据库查询平台
![DataFlow Logo](https://img.shields.io/badge/DataFlow-v2.1.0-00f2fe?style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTEyIDJMMiA3TDEyIDEyTDIyIDdMMTIgMloiIHN0cm9rZT0iI2ZmZiIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPHBhdGggZD0iTTIgMTdMMTIgMjJMMjIgMTciIHN0cm9rZT0iI2ZmZiIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPHBhdGggZD0iTTIgMTJMMTIgMTdMMjIgMTIiIHN0cm9rZT0iI2ZmZiIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9zdmc+) [![License](https://img.shields.io/badge/license-MIT-764ba2?style=for-the-badge)](LICENSE) [![Python](https://img.shields.io/badge/Python-3.11+-43e97b?style=for-the-badge&logo=python&logoColor=white)](https://www.python.org) [![LangChain](https://img.shields.io/badge/LangChain-1.x-f5576c?style=for-the-badge)](https://python.langchain.com) [![Docker](https://img.shields.io/badge/Docker-Ready-00f2fe?style=for-the-badge&logo=docker&logoColor=white)](https://www.docker.com) **用自然语言与数据库对话 | 支持 8 种 LLM | Docker 一键部署** [🚀 快速开始](#-快速开始) • [📖 文档](#-文档) • [🎨 功能特性](#-核心功能) • [🐳 Docker 部署](#-docker-部署)
--- ## 📸 界面预览 ### 🎨 主界面 - 未来主义设计
![主界面](https://via.placeholder.com/1200x600/0a0e27/00f2fe?text=DataFlow+主界面+-+深色主题+玻璃态射效果) *深色主题 + 玻璃态射效果 + 动态背景动画*
### 💬 对话查询 - 实时打字效果
![对话界面](https://via.placeholder.com/800x500/131829/43e97b?text=自然语言查询+-+实时对话+打字动画) *自然语言提问,AI 实时回答,支持上下文对话*
### ⚙️ 系统配置 - 可视化管理
![配置界面](https://via.placeholder.com/800x500/1a1f3a/f5576c?text=LLM+配置+-+8种提供商+可视化选择) *支持 8 种 LLM 提供商,可视化配置,配置持久化到数据库*
### 🗄️ 数据库设置 - 多数据库支持
![数据库配置](https://via.placeholder.com/800x500/0a0e27/764ba2?text=数据库配置+-+MySQL+PostgreSQL+SQLite) *支持 MySQL、PostgreSQL、SQLite,动态表单切换*
--- ## ✨ 核心功能 ### 🤖 多 LLM 支持(8 种提供商)
#### 🔥 推荐使用 - **DeepSeek** - 性价比之王 - 💰 价格:¥1/1M tokens - 🚀 速度快,中文友好 - ✅ 无需翻墙 - **硅基流动(小马算力)** - 💎 开源模型,极低成本 - 🌟 支持 Qwen、Llama 等 - ⚡ 高性能推理 #### 🌐 其他选择 - **智谱 AI (GLM-4)** - 国产大模型 - **月之暗面 (Moonshot)** - 长上下文 - **通义千问 (Qwen)** - 阿里云 - **百川智能 (Baichuan)** - 垂直领域 - **OpenAI (GPT-4)** - 最强大 - **Anthropic (Claude)** - 理解力强
### 🗄️ 多数据库支持 ```mermaid graph LR A[DataFlow] --> B[MySQL 8.0] A --> C[PostgreSQL 15] A --> D[SQLite 3] style A fill:#00f2fe,stroke:#764ba2,stroke-width:3px,color:#fff style B fill:#43e97b,stroke:#38f9d7,stroke-width:2px style C fill:#f093fb,stroke:#f5576c,stroke-width:2px style D fill:#667eea,stroke:#764ba2,stroke-width:2px ``` ### 💡 智能查询示例 ```sql -- 用户输入(自然语言) "销售额最高的前 5 个产品是什么?" -- AI 自动生成 SQL SELECT p.name, SUM(oi.quantity * oi.unit_price) as total_sales FROM products p JOIN order_items oi ON p.id = oi.product_id GROUP BY p.id, p.name ORDER BY total_sales DESC LIMIT 5; -- AI 解释结果(自然语言) "销售额最高的前 5 个产品是: 1. iPhone 15 Pro - ¥159,980 2. MacBook Pro - ¥129,990 3. iPad Air - ¥95,980 ..." ``` ### 🎨 设计特色
深色主题
深色主题
深蓝/紫色渐变背景
玻璃态射
玻璃态射
Glassmorphism 效果
动态背景
动态背景
神经网络脉冲动画
霓虹配色
霓虹配色
青色/品红色高光
--- ## 🚀 快速开始 ### 方式 1: Docker 一键部署(推荐) ```bash # 1. 克隆项目 git clone https://github.com/yourusername/dataflow.git cd dataflow # 2. 配置环境变量 cp .env.docker .env nano .env # 配置 LLM API Key # 3. 一键启动 docker-compose up -d # 4. 访问应用 # 前端: http://localhost # API: http://localhost/api/docs ``` ### 方式 2: 本地运行 ```bash # 1. 安装依赖 pip install -r requirements.txt # 2. 配置环境 cp .env.example .env nano .env # 配置 LLM API Key 和数据库 # 3. 创建演示数据库(可选) python examples/setup_demo_db.py # 4. 启动后端 python api_server.py # 5. 打开前端 # 浏览器访问: frontend/index.html ``` ### ⚡ 最小配置 ```env # .env 文件 LLM_PROVIDER=deepseek DEEPSEEK_API_KEY=sk-your-api-key-here DB_TYPE=sqlite DB_PATH=./demo.db ``` --- ## 🎯 使用场景
### 📊 业务分析 ``` "过去 30 天销售额最高的产品类别" "本月新增客户数量趋势" "各地区销售额对比分析" ``` ### 🔍 数据探索 ``` "有哪些表?" "customers 表有什么字段?" "显示订单表的示例数据" ``` ### 📈 报表生成 ``` "生成本月销售报表" "导出客户购买统计" "分析产品库存情况" ``` ### 🎧 客户服务 ``` "张三的订单状态" "查询最近的退款订单" "统计客户投诉类型" ```
--- ## 🏗️ 架构设计 ```mermaid graph TB subgraph "前端层" A[精美 Web 界面
未来主义设计] end subgraph "应用层" B[FastAPI 服务器
RESTful API] end subgraph "代理层" C[LangGraph Agent
智能推理] D[工具集
5 个自定义工具] end subgraph "LLM 层" E1[DeepSeek] E2[硅基流动] E3[智谱 AI] E4[其他 5 种] end subgraph "数据层" F1[MySQL] F2[PostgreSQL] F3[SQLite] end A --> B B --> C C --> D C --> E1 & E2 & E3 & E4 D --> F1 & F2 & F3 style A fill:#00f2fe,stroke:#764ba2,stroke-width:3px,color:#000 style C fill:#43e97b,stroke:#38f9d7,stroke-width:2px,color:#000 style E1 fill:#f5576c,stroke:#f093fb,stroke-width:2px,color:#fff ``` --- ## 📦 技术栈
### 后端技术 [![LangChain](https://img.shields.io/badge/LangChain-1.x-00f2fe?style=for-the-badge&logo=chainlink&logoColor=white)](https://python.langchain.com) [![LangGraph](https://img.shields.io/badge/LangGraph-0.2+-43e97b?style=for-the-badge)](https://langchain-ai.github.io/langgraph) [![FastAPI](https://img.shields.io/badge/FastAPI-0.100+-f5576c?style=for-the-badge&logo=fastapi&logoColor=white)](https://fastapi.tiangolo.com) [![SQLAlchemy](https://img.shields.io/badge/SQLAlchemy-2.0+-764ba2?style=for-the-badge)](https://www.sqlalchemy.org) ### 前端技术 [![HTML5](https://img.shields.io/badge/HTML5-Native-00f2fe?style=for-the-badge&logo=html5&logoColor=white)](https://developer.mozilla.org/en-US/docs/Web/HTML) [![CSS3](https://img.shields.io/badge/CSS3-Animations-43e97b?style=for-the-badge&logo=css3&logoColor=white)](https://developer.mozilla.org/en-US/docs/Web/CSS) [![JavaScript](https://img.shields.io/badge/JavaScript-ES6+-f5576c?style=for-the-badge&logo=javascript&logoColor=white)](https://developer.mozilla.org/en-US/docs/Web/JavaScript) ### 部署技术 [![Docker](https://img.shields.io/badge/Docker-20.10+-00f2fe?style=for-the-badge&logo=docker&logoColor=white)](https://www.docker.com) [![Nginx](https://img.shields.io/badge/Nginx-Alpine-43e97b?style=for-the-badge&logo=nginx&logoColor=white)](https://nginx.org) [![MySQL](https://img.shields.io/badge/MySQL-8.0-f5576c?style=for-the-badge&logo=mysql&logoColor=white)](https://www.mysql.com)
--- ## 🐳 Docker 部署 ### 服务架构 ```yaml services: dataflow-frontend: # Nginx (端口 80) dataflow-backend: # FastAPI (端口 8000) dataflow-mysql: # MySQL 8.0 (端口 3306) dataflow-postgres: # PostgreSQL 15 (可选) dataflow-redis: # Redis 7 (可选) ``` ### 一键启动 ```bash docker-compose up -d ``` ### 健康检查 ```bash # 检查所有服务状态 docker-compose ps # 查看日志 docker-compose logs -f # 健康检查 curl http://localhost/api/health ``` --- ## 📊 性能指标

⚡ 响应时间

简单查询: < 2秒
复杂查询: < 5秒
多表关联: < 8秒

🚀 并发能力

单实例: ~100 QPS
负载均衡: 可扩展
缓存加速: 支持 Redis

💰 成本估算

1K 查询: ~¥0.5
10K 查询: ~¥5
100K 查询: ~¥50
*基于 DeepSeek 模型估算* --- ## 🔐 安全特性 - ✅ **SQL 注入防护** - 参数化查询,安全验证 - ✅ **只读查询限制** - 默认禁止写操作 - ✅ **结果数量限制** - 防止大量数据泄露 - ✅ **查询超时控制** - 避免长时间占用资源 - ✅ **配置加密存储** - 敏感信息加密保存 - ✅ **访问日志记录** - 完整的审计追踪 --- ## 📖 文档 ### 快速入门 - 📘 [快速开始指南](QUICKSTART.md) - 5 分钟快速体验 - 🚀 [部署指南](DEPLOYMENT_GUIDE.md) - 完整部署说明 - 🐳 [Docker 部署](DOCKER_DEPLOYMENT.md) - 容器化部署 ### 使用指南 - 🎨 [前端使用指南](frontend/README.md) - 界面操作说明 - ⚙️ [配置管理](CONFIG_MANAGEMENT.md) - 配置持久化 - 📚 [入门指南](GETTING_STARTED.md) - 详细教程 ### 技术文档 - 🏗️ [架构设计](PROJECT_OVERVIEW.md) - 系统架构 - 📝 [API 文档](http://localhost:8000/docs) - 在线 API 文档 - 🔧 [扩展开发](PROJECT_OVERVIEW.md#扩展开发) - 自定义开发 --- ## 🎓 示例查询 ### 简单查询 ``` "有多少个客户?" "显示所有产品的价格" "列出最近 10 个订单" ``` ### 聚合查询 ``` "每个类别有多少个产品?" "订单的平均金额是多少?" "销售额最高的前 10 个客户" ``` ### 复杂查询 ``` "找出购买金额超过 10000 元的客户及其订单数" "显示每个产品的总销售数量,按销量降序排列" "列出过去 30 天内没有购买记录的客户" ``` ### 多表关联 ``` "显示每个客户的订单总额和订单数量" "哪些客户购买了 iPhone?" "列出包含特定产品的所有订单详情" ``` --- ## 🌟 项目亮点
### 💎 独特设计 - 🎨 未来主义 + 数据可视化风格 - ✨ 玻璃态射效果 - 🌊 动态背景动画 - 💫 流畅的交互体验 - 📱 完全响应式设计 ### 🚀 强大功能 - 🤖 支持 8 种 LLM 提供商 - 🗄️ 支持 3 种数据库 - 💬 上下文对话记忆 - ⚙️ 可视化配置管理 - 💾 配置持久化到数据库 ### 🏭 生产就绪 - ✅ 完整的安全特性 - ✅ 详细的日志记录 - ✅ 健康检查机制 - ✅ 性能优化 - ✅ 错误恢复 ### 🐳 易于部署 - 📦 Docker 一键部署 - 🔄 自动初始化数据库 - 🌐 Nginx 反向代理 - 📊 完整的监控 - 🔧 灵活的配置
--- ## 🗺️ 路线图 ### ✅ 已完成 - [x] 支持 8 种 LLM 提供商 - [x] 精美的前端界面 - [x] Docker 一键部署 - [x] 配置持久化到数据库 - [x] 完整的文档体系 ### 🚧 进行中 - [ ] 用户认证和权限管理 - [ ] 查询历史和收藏 - [ ] 数据可视化图表 - [ ] 移动端适配 ### 🔮 计划中 - [ ] 支持更多数据库(MongoDB、ClickHouse) - [ ] AI 数据分析报告生成 - [ ] 多语言支持 - [ ] 插件系统 --- ## 🤝 贡献 欢迎贡献!请查看 [贡献指南](CONTRIBUTING.md) ### 贡献者 --- ## 📄 许可证 本项目采用 [MIT 许可证](LICENSE) --- ## 🙏 致谢 ### 技术支持 - [LangChain](https://python.langchain.com) - LLM 应用框架 - [LangGraph](https://langchain-ai.github.io/langgraph) - 代理编排 - [FastAPI](https://fastapi.tiangolo.com) - Web 框架 - [SQLAlchemy](https://www.sqlalchemy.org) - ORM 框架 ### LLM 提供商 - [DeepSeek](https://www.deepseek.com) - 性价比之王 - [硅基流动](https://siliconflow.cn) - 开源模型加速 - [智谱 AI](https://open.bigmodel.cn) - 国产大模型 - [OpenAI](https://openai.com) - GPT 系列 - [Anthropic](https://www.anthropic.com) - Claude 系列 --- ## 📞 联系方式 - 📧 Email: your-email@example.com - 💬 微信: your-wechat - 🐦 Twitter: [@yourtwitter](https://twitter.com/yourtwitter) - 🌐 网站: https://your-website.com --- ## ⭐ Star History [![Star History Chart](https://api.star-history.com/svg?repos=yourusername/dataflow&type=Date)](https://star-history.com/#yourusername/dataflow&Date) ---
**如果这个项目对您有帮助,请给一个 ⭐ Star!** Made with ❤️ by [Your Name](https://github.com/yourusername) [🔝 回到顶部](#-dataflow---自然语言数据库查询平台)