docs: 添加项目文档体系 + 修复租户创建模态框
- 新增 .agents/summary/ 完整文档(架构、组件、接口、数据模型、流程、依赖) - 新增 AGENTS.md(AI 助手导航) - 更新 README.md - 修复 dashboard.html 租户模态框多余 </div> 导致保存按钮失效 - 更新 .gitignore 排除虚拟环境文件
This commit is contained in:
136
.agents/summary/data_models.md
Normal file
136
.agents/summary/data_models.md
Normal file
@@ -0,0 +1,136 @@
|
||||
# Data Models / 数据模型
|
||||
|
||||
## ORM 模型 (`src/core/models.py`)
|
||||
|
||||
所有模型继承 SQLAlchemy `Base`,核心表均包含 `tenant_id` 字段用于多租户隔离。
|
||||
|
||||
```mermaid
|
||||
erDiagram
|
||||
Tenant ||--o{ WorkOrder : "tenant_id"
|
||||
Tenant ||--o{ ChatSession : "tenant_id"
|
||||
Tenant ||--o{ KnowledgeEntry : "tenant_id"
|
||||
Tenant ||--o{ Alert : "tenant_id"
|
||||
Tenant ||--o{ Analytics : "tenant_id"
|
||||
|
||||
WorkOrder ||--o{ Conversation : "work_order_id"
|
||||
WorkOrder ||--o{ WorkOrderProcessHistory : "work_order_id"
|
||||
WorkOrder ||--o{ WorkOrderSuggestion : "work_order_id"
|
||||
|
||||
ChatSession ||--o{ Conversation : "session_id"
|
||||
|
||||
Tenant {
|
||||
int id PK
|
||||
string tenant_id UK
|
||||
string name
|
||||
text description
|
||||
bool is_active
|
||||
text config "JSON: feishu, system_prompt"
|
||||
}
|
||||
|
||||
WorkOrder {
|
||||
int id PK
|
||||
string tenant_id FK
|
||||
string order_id UK
|
||||
string title
|
||||
text description
|
||||
string category
|
||||
string priority
|
||||
string status
|
||||
string feishu_record_id "飞书记录ID"
|
||||
string assignee
|
||||
text ai_suggestion
|
||||
string assigned_module
|
||||
string module_owner
|
||||
string vin_sim "车架号"
|
||||
}
|
||||
|
||||
ChatSession {
|
||||
int id PK
|
||||
string tenant_id FK
|
||||
string session_id UK
|
||||
string source "websocket/api/feishu_bot"
|
||||
}
|
||||
|
||||
Conversation {
|
||||
int id PK
|
||||
string tenant_id FK
|
||||
int work_order_id FK
|
||||
string session_id FK
|
||||
string role "user/assistant/system"
|
||||
text content
|
||||
}
|
||||
|
||||
KnowledgeEntry {
|
||||
int id PK
|
||||
string tenant_id FK
|
||||
string question
|
||||
text answer
|
||||
string category
|
||||
bool is_verified
|
||||
float confidence_score
|
||||
}
|
||||
|
||||
Alert {
|
||||
int id PK
|
||||
string tenant_id FK
|
||||
string level
|
||||
string type
|
||||
text message
|
||||
bool is_resolved
|
||||
}
|
||||
|
||||
VehicleData {
|
||||
int id PK
|
||||
string vehicle_id
|
||||
string vin
|
||||
text data "JSON"
|
||||
}
|
||||
|
||||
Analytics {
|
||||
int id PK
|
||||
string tenant_id FK
|
||||
string metric_type
|
||||
float value
|
||||
text details "JSON"
|
||||
}
|
||||
|
||||
User {
|
||||
int id PK
|
||||
string username UK
|
||||
string password_hash
|
||||
string role "admin/user"
|
||||
}
|
||||
|
||||
WorkOrderProcessHistory {
|
||||
int id PK
|
||||
int work_order_id FK
|
||||
string action
|
||||
text details
|
||||
}
|
||||
|
||||
WorkOrderSuggestion {
|
||||
int id PK
|
||||
int work_order_id FK
|
||||
text suggestion
|
||||
float confidence
|
||||
}
|
||||
```
|
||||
|
||||
## 配置 Dataclasses (`src/config/unified_config.py`)
|
||||
|
||||
| Dataclass | 关键字段 |
|
||||
|-----------|---------|
|
||||
| `DatabaseConfig` | `url` |
|
||||
| `LLMConfig` | `api_key`, `base_url`, `model`, `temperature`, `max_tokens`, `timeout` |
|
||||
| `ServerConfig` | `host`, `port`, `websocket_port`, `debug`, `log_level` |
|
||||
| `FeishuConfig` | `app_id`, `app_secret`, `app_token`, `table_id` |
|
||||
| `AIAccuracyConfig` | `auto_approve_threshold`, `manual_review_threshold` |
|
||||
| `EmbeddingConfig` | `enabled`, `model`, `dimension`, `similarity_threshold` |
|
||||
| `RedisConfig` | `host`, `port`, `db`, `password`, `pool_size`, `default_ttl`, `enabled` |
|
||||
|
||||
## 业务枚举
|
||||
|
||||
- `WorkOrderStatus`: 工单状态流转
|
||||
- `WorkOrderPriority`: 工单优先级
|
||||
- `AlertLevel`: 预警级别
|
||||
- `AlertType`: 预警类型
|
||||
Reference in New Issue
Block a user