@@ -13,6 +13,7 @@ QueryGPT v2 是自然语言数据库查询助手,采用前后端分离架构
1313./start.sh # 同时启动前后端
1414./start.sh stop # 停止服务
1515./start.sh restart # 重启
16+ ./start.sh status # 查看状态
1617```
1718
1819### 后端 (apps/api)
@@ -25,9 +26,14 @@ uvicorn app.main:app --reload --port 8000
2526alembic upgrade head
2627alembic revision --autogenerate -m " description"
2728
28- # 代码检查
29+ # 代码检查和格式化
2930ruff check .
31+ ruff check --fix . # 自动修复
3032ruff format .
33+
34+ # 测试
35+ pytest tests/ -v --tb=short
36+ pytest tests/test_auth.py -v # 单个测试文件
3137```
3238
3339### 前端 (apps/web)
@@ -37,6 +43,11 @@ npm run dev # 开发服务器 :3000
3743npm run build # 构建
3844npm run lint # ESLint
3945npm run type-check # TypeScript 检查
46+
47+ # 测试
48+ npm run test # 运行测试
49+ npm run test:watch # 监听模式
50+ npm run test:coverage # 覆盖率报告
4051```
4152
4253## Architecture
@@ -45,28 +56,37 @@ npm run type-check # TypeScript 检查
4556- ` api/v1/ ` - API 路由
4657 - ` auth.py ` - 注册/登录/刷新 token
4758 - ` chat.py ` - SSE 流式对话接口
48- - ` config.py ` - 模型/数据库连接 CRUD
59+ - ` connections.py ` - 数据库连接 CRUD
60+ - ` models.py ` - AI 模型配置 CRUD
61+ - ` schema.py ` - 表关系管理 + 布局 API
62+ - ` semantic.py ` - 语义层术语 CRUD
63+ - ` export_import.py ` - 配置导出/导入
4964 - ` history.py ` - 对话历史
65+ - ` user_config.py ` - 用户偏好设置
5066- ` core/ ` - 核心模块
5167 - ` config.py ` - Pydantic Settings 配置
5268 - ` security.py ` - JWT + Fernet 加密
5369 - ` demo_db.py ` - SQLite 示例数据库初始化
54- - ` db/tables.py ` - SQLAlchemy 2.0 模型 (User, Model, Connection, Conversation, Message)
70+ - ` db/ `
71+ - ` tables.py ` - SQLAlchemy 2.0 模型 (User, Model, Connection, Conversation, Message, TableRelationship, SemanticTerm)
72+ - ` metadata.py ` - SQLite 元数据库 (布局存储,独立于主数据库)
5573- ` services/ `
5674 - ` execution.py ` - 执行服务入口
5775 - ` gptme_engine.py ` - gptme AI 引擎封装,获取表结构后执行查询
5876
5977### 前端 Next.js (apps/web/src/)
6078- ` app/ ` - App Router 页面
6179 - ` page.tsx ` - 主页(登录/对话)
62- - ` settings/page.tsx ` - 设置页
80+ - ` settings/page.tsx ` - 设置页(模型、连接、表关系、语义层、偏好、关于)
6381- ` components/ `
6482 - ` chat/ ` - ChatArea, Sidebar, DataTable, ChartDisplay, SqlHighlight
65- - ` settings/ ` - ModelSettings, ConnectionSettings, PreferencesSettings
83+ - ` settings/ ` - ModelSettings, ConnectionSettings, SchemaSettings, SemanticSettings
84+ - ` schema/ ` - TableNode (React Flow 节点)
6685- ` lib/ `
6786 - ` api/client.ts ` - Axios 实例 + SSE 流处理
6887 - ` stores/auth.ts ` - Zustand 认证状态
6988 - ` stores/chat.ts ` - Zustand 对话状态
89+ - ` types/ ` - TypeScript 类型定义
7090
7191### 数据流
72921 . 用户输入 → ` ChatArea ` → ` POST /api/v1/chat/stream ` (SSE)
@@ -95,3 +115,28 @@ OPENAI_API_KEY=...
95115```
96116NEXT_PUBLIC_API_URL=http://localhost:8000
97117```
118+
119+ ## Git Commit 规范
120+
121+ ** 重要** : 提交时不要添加任何 AI 生成标记或署名!
122+
123+ ``` bash
124+ # 正确的 commit 格式
125+ git commit -m " feat: 添加新功能"
126+ git commit -m " fix: 修复某个问题"
127+ git commit -m " docs: 更新文档"
128+
129+ # 禁止添加以下内容:
130+ # - 🤖 Generated with [Claude Code]
131+ # - Co-Authored-By: Claude
132+ # - 任何 AI 相关的标记或署名
133+ ```
134+
135+ commit 类型:
136+ - ` feat ` : 新功能
137+ - ` fix ` : 修复 bug
138+ - ` docs ` : 文档更新
139+ - ` style ` : 代码格式
140+ - ` refactor ` : 重构
141+ - ` test ` : 测试
142+ - ` chore ` : 构建/工具
0 commit comments