Skip to content

Latest commit

 

History

History
297 lines (245 loc) · 9.48 KB

File metadata and controls

297 lines (245 loc) · 9.48 KB

IntelliTask AI 技术架构图

1. DDD分层架构图

flowchart TD
    subgraph "用户界面层 (UI Layer)"
        UI[前端应用] -->|HTTP请求| API
    end

    subgraph "应用服务层 (Application Service Layer)"
        API[REST API] --> UserService
        API --> HomeworkService
        API --> LearningPlanService
    end

    subgraph "领域服务层 (Domain Service Layer)"
        UserService -->|使用| UserProfile
        HomeworkService -->|使用| HomeworkTask
        HomeworkService -->|调用| AIService
        LearningPlanService -->|使用| LearningPlan
        LearningPlanService -->|调用| AIService
    end

    subgraph "领域模型层 (Domain Model Layer)"
        UserProfile[用户资料]
        HomeworkTask[作业任务]
        LearningPlan[学习计划]
        AppSettings[应用设置]
    end

    subgraph "基础设施层 (Infrastructure Layer)"
        AIService -->|调用| AIModels
        UserProfile -->|持久化| UserRepository
        HomeworkTask -->|持久化| HomeworkRepository
        LearningPlan -->|持久化| LearningPlanRepository
        AppSettings -->|持久化| AppSettingsRepository
        
        UserRepository -->|使用| JPA
        HomeworkRepository -->|使用| JPA
        LearningPlanRepository -->|使用| JPA
        AppSettingsRepository -->|使用| JPA
        
        JPA -->|连接| PostgreSQL
        AIModels -->|连接| OpenAI
        AIModels -->|连接| Ollama
        AIModels -->|连接| HuggingFace
    end

    classDef domain fill:#f9f,stroke:#333,stroke-width:2px;
    classDef service fill:#bbf,stroke:#333,stroke-width:2px;
    classDef infra fill:#bfb,stroke:#333,stroke-width:2px;
    classDef ui fill:#ffb,stroke:#333,stroke-width:2px;

    class UserProfile,HomeworkTask,LearningPlan,AppSettings domain;
    class UserService,HomeworkService,LearningPlanService,AIService service;
    class UserRepository,HomeworkRepository,LearningPlanRepository,AppSettingsRepository,JPA,PostgreSQL,AIModels,OpenAI,Ollama,HuggingFace infra;
    class UI,API ui;
Loading

2. 核心组件关系图

flowchart LR
    subgraph "应用组件"
        UserController
        HomeworkController
        LearningPlanController
        AIController
    end

    subgraph "应用服务"
        UserServiceImpl
        HomeworkServiceImpl
        LearningPlanServiceImpl
    end

    subgraph "领域服务"
        AIServiceImpl
    end

    subgraph "领域模型"
        UserProfile
        HomeworkTask
        LearningPlan
        AppSettings
    end

    subgraph "数据访问"
        UserProfileRepository
        HomeworkTaskRepository
        LearningPlanRepository
        AppSettingsRepository
    end

    subgraph "外部服务"
        ChatModel[Spring AI Chat Model]
        PostgreSQL
        Nacos[服务发现]
        Seata[分布式事务]
    end

    UserController --> UserServiceImpl
    HomeworkController --> HomeworkServiceImpl
    LearningPlanController --> LearningPlanServiceImpl
    AIController --> AIServiceImpl

    UserServiceImpl --> UserProfileRepository
    UserServiceImpl --> AppSettingsRepository
    
    HomeworkServiceImpl --> HomeworkTaskRepository
    HomeworkServiceImpl --> UserProfileRepository
    HomeworkServiceImpl --> AIServiceImpl
    
    LearningPlanServiceImpl --> LearningPlanRepository
    LearningPlanServiceImpl --> HomeworkTaskRepository
    LearningPlanServiceImpl --> AIServiceImpl
    
    AIServiceImpl --> ChatModel
    
    UserProfileRepository --> UserProfile
    HomeworkTaskRepository --> HomeworkTask
    LearningPlanRepository --> LearningPlan
    AppSettingsRepository --> AppSettings
    
    UserProfileRepository --> PostgreSQL
    HomeworkTaskRepository --> PostgreSQL
    LearningPlanRepository --> PostgreSQL
    AppSettingsRepository --> PostgreSQL
    
    UserServiceImpl --> Nacos
    HomeworkServiceImpl --> Nacos
    LearningPlanServiceImpl --> Nacos
    
    UserServiceImpl --> Seata
    HomeworkServiceImpl --> Seata
    LearningPlanServiceImpl --> Seata

    classDef controller fill:#e6f7ff,stroke:#1890ff,stroke-width:2px;
    classDef service fill:#f6ffed,stroke:#52c41a,stroke-width:2px;
    classDef domain fill:#fff2e8,stroke:#fa8c16,stroke-width:2px;
    classDef repo fill:#f9f0ff,stroke:#722ed1,stroke-width:2px;
    classDef external fill:#fff1f0,stroke:#f5222d,stroke-width:2px;

    class UserController,HomeworkController,LearningPlanController,AIController controller;
    class UserServiceImpl,HomeworkServiceImpl,LearningPlanServiceImpl,AIServiceImpl service;
    class UserProfile,HomeworkTask,LearningPlan,AppSettings domain;
    class UserProfileRepository,HomeworkTaskRepository,LearningPlanRepository,AppSettingsRepository repo;
    class ChatModel,PostgreSQL,Nacos,Seata external;
Loading

3. 数据流转图

sequenceDiagram
    participant UI as 前端应用
    participant API as REST API
    participant AS as 应用服务
    participant DS as 领域服务
    participant DM as 领域模型
    participant DB as 数据库
    participant AI as AI服务

    %% 作业采集流程
    UI->>API: 提交作业消息
    API->>AS: HomeworkService.extractAndCreateHomework()
    AS->>DS: AIService.extractHomeworkFromMessage()
    DS->>AI: 调用大模型提取作业
    AI-->>DS: 返回提取结果
    DS-->>AS: 提取的作业信息
    AS->>DM: 创建HomeworkTask
    DM->>DB: 保存作业
    DB-->>DM: 保存成功
    DM-->>AS: 返回作业任务
    AS-->>API: 返回作业信息
    API-->>UI: 201 Created

    %% 作业批改流程
    UI->>API: 提交作业批改请求
    API->>AS: HomeworkService.gradeHomework()
    AS->>DS: AIService.gradeSubmission()
    DS->>AI: 调用大模型批改
    AI-->>DS: 返回批改结果
    DS-->>AS: 批改结果JSON
    AS->>DM: 更新HomeworkTask状态
    DM->>DB: 保存批改结果
    DB-->>DM: 保存成功
    DM-->>AS: 返回更新后的作业
    AS-->>API: 返回批改结果
    API-->>UI: 200 OK

    %% 生成学习计划流程
    UI->>API: 请求生成学习计划
    API->>AS: LearningPlanService.generateLearningPlanByTaskId()
    AS->>DM: 获取HomeworkTask
    DM->>DB: 查询作业
    DB-->>DM: 返回作业信息
    DM-->>AS: 作业详情
    AS->>DS: AIService.analyzeHomeworkAndGeneratePlan()
    DS->>AI: 调用大模型生成学习计划
    AI-->>DS: 返回学习计划
    DS-->>AS: 生成的学习计划
    AS->>DM: 创建LearningPlan
    DM->>DB: 保存学习计划
    DB-->>DM: 保存成功
    DM-->>AS: 返回学习计划
    AS-->>API: 返回学习计划
    API-->>UI: 201 Created
Loading

4. 分层架构说明

4.1 用户界面层

  • 职责:处理用户交互,发送HTTP请求到后端API
  • 技术:前端框架(如React、Vue等)
  • 接口:RESTful API

4.2 应用服务层

  • 职责:协调领域对象完成业务功能,实现用例
  • 组件:UserService、HomeworkService、LearningPlanService
  • 技术:Spring Boot、Spring Cloud Alibaba
  • 特性:事务管理、服务编排、权限控制

4.3 领域服务层

  • 职责:实现核心业务逻辑,领域规则
  • 组件:AIService
  • 技术:Spring AI
  • 特性:AI能力封装、业务规则实现

4.4 领域模型层

  • 职责:核心业务概念和规则,实体、值对象、聚合根
  • 组件:UserProfile、HomeworkTask、LearningPlan、AppSettings
  • 技术:Java、Lombok、JPA
  • 特性:封装业务状态和行为,DDD核心

4.5 基础设施层

  • 职责:提供技术支持,实现与外部系统的交互
  • 组件
    • 仓储:UserProfileRepository、HomeworkTaskRepository、LearningPlanRepository、AppSettingsRepository
    • 数据访问:JPA、PostgreSQL
    • AI服务:Spring AI Chat Model
    • 微服务组件:Nacos服务发现、Seata分布式事务
  • 技术:Spring Data JPA、PostgreSQL、Spring AI、Spring Cloud Alibaba
  • 特性:数据持久化、外部服务集成、技术基础设施支持

5. 技术栈说明

技术类别 技术栈 版本 用途
应用框架 Spring Boot 3.2.0 应用容器
AI框架 Spring AI 0.8.0 AI能力集成
微服务 Spring Cloud Alibaba 2023.0.0.0 服务发现、分布式事务
数据库 PostgreSQL 13+ 数据存储
ORM Spring Data JPA - 数据访问
编程语言 Java 17 开发语言
代码简化 Lombok - 简化Java代码
AI模型 OpenAI - 大语言模型
AI模型 Ollama - 本地大语言模型
AI模型 HuggingFace - AI模型库

6. 核心业务流程

6.1 作业采集流程

  1. 前端提交作业消息
  2. 后端API接收请求
  3. 调用AI服务提取作业信息
  4. 创建作业任务并保存到数据库
  5. 返回作业信息给前端

6.2 作业批改流程

  1. 前端提交作业批改请求
  2. 后端API接收请求
  3. 调用AI服务批改作业
  4. 更新作业状态和批改结果
  5. 返回批改结果给前端

6.3 学习计划生成流程

  1. 前端请求生成学习计划
  2. 后端API接收请求
  3. 获取作业详情
  4. 调用AI服务生成学习计划
  5. 创建学习计划并保存到数据库
  6. 返回学习计划给前端

7. 系统特性

  • DDD架构:基于领域驱动设计,清晰的分层结构
  • AI集成:支持多AI模型提供商,灵活切换
  • 微服务支持:基于Spring Cloud Alibaba,支持服务发现和分布式事务
  • RESTful API:规范的API设计,易于集成
  • 可扩展性:模块化设计,易于扩展新功能
  • 数据持久化:PostgreSQL数据库,支持JSONB存储复杂数据