You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RuoYi-Vue/openspec/changes/archive/2026-06-28-refactor-archite.../design.md

8.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

Design: 架构梳理方法与技术决策

Architecture Overview

现有系统架构分析

┌─────────────────────────────────────────────────────────────┐
│                        RuoYi-Vue 系统架构                      │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  前端 (ruoyi-ui)                    后端 (Spring Boot)       │
│  ┌──────────────────┐              ┌──────────────────┐    │
│  │  Vue2 + Vue CLI  │  HTTP/JSON  │  ruoyi-admin     │    │
│  │  Element UI      │◄──────────►│  (启动配置)        │    │
│  │  Vuex            │             └────────┬─────────┘    │
│  │  Vue Router      │                      │              │
│  └────────┬─────────┘             ┌────────▼─────────┐    │
│           │                       │  ruoyi-framework │    │
│  ┌────────┴─────────┐             │  (安全、配置)     │    │
│  │  components/     │             └────────┬─────────┘    │
│  │  views/          │                      │              │
│  │  api/            │             ┌────────▼─────────┐    │
│  │  store/          │             │  ruoyi-system    │    │
│  │  router/         │             │  (系统管理)       │    │
│  └──────────────────┘             └────────┬─────────┘    │
│                                            │              │
│                              ┌─────────────┼──────────┐   │
│                              ▼             ▼          ▼   │
│                         ruoyi-common  book-system  quartz │
│                         (工具类)     (业务模块)   (定时)  │
│                                                            │
│                              ┌──────────────────┐         │
│                              │     MySQL DB     │         │
│                              │  + Redis Cache   │         │
│                              └──────────────────┘         │
└─────────────────────────────────────────────────────────────┘

前端架构分析

ruoyi-ui/
├── src/
│   ├── api/              # API 接口定义
│   │   ├── booksystem/   # 业务模块 API
│   │   ├── system/       # 系统管理 API
│   │   └── monitor/      # 监控模块 API
│   ├── assets/           # 静态资源
│   ├── components/       # 通用组件
│   │   ├── Breadcrumb/   # 面包屑
│   │   ├── Pagination/   # 分页
│   │   ├── DictTag/      # 字典标签
│   │   └── ...           # 30+ 组件
│   ├── router/           # 路由配置
│   ├── store/            # Vuex 状态管理
│   ├── views/            # 页面视图
│   │   ├── dashboard/    # 首页
│   │   ├── system/       # 系统管理页面
│   │   └── booksystem/   # 业务页面
│   └── utils/            # 工具函数

后端架构分析

RuoYi-Vue/
├── ruoyi-admin/          # 启动模块
│   ├── controller/       # 控制器层
│   └── config/           # 配置类
├── ruoyi-framework/      # 框架核心
│   ├── security/         # 安全配置
│   ├── datasource/       # 数据源
│   └── aspectj/          # AOP 切面
├── ruoyi-system/         # 系统管理
│   ├── domain/           # 实体类
│   ├── mapper/           # MyBatis Mapper
│   └── service/          # 服务层
├── book-system/          # 业务模块
│   ├── controller/       # 业务控制器
│   ├── domain/           # 业务实体
│   ├── mapper/           # 业务 Mapper
│   └── service/          # 业务服务
├── ruoyi-common/         # 通用工具
│   ├── annotation/       # 自定义注解
│   ├── core/             # 核心类
│   ├── utils/            # 工具类
│   └── exception/        # 异常处理
└── ruoyi-generator/      # 代码生成器

前后端交互流程

┌─────────┐      ┌──────────┐      ┌──────────┐      ┌────────┐
│  User   │─────►│  Vue UI  │─────►│  API     │─────►│ Spring │
│  Action │      │  (View)  │      │  (Axios) │      │ Boot   │
└─────────┘      └──────────┘      └──────────┘      └───┬────┘
     ▲                                                    │
     │                                                    ▼
     │                                              ┌──────────┐
     │                                              │ Service  │
     │                                              └────┬─────┘
     │                                                   │
     │                                                   ▼
     │                                              ┌──────────┐
     │                                              │ Mapper   │
     │                                              └────┬─────┘
     │                                                   │
     │         ┌─────────────────────────────────────────┘
     │         ▼
     │    ┌────────┐
     └───│ Response│
         └────────┘

分析方法论

1. 静态代码分析

  • 使用工具扫描代码结构
  • 分析模块依赖关系
  • 识别循环依赖和耦合点

2. 动态行为分析

  • 分析请求链路
  • 分析数据流转
  • 分析错误处理路径

3. 架构模式识别

  • 识别使用的架构模式MVC、分层架构等
  • 评估模式应用的合理性
  • 识别反模式

技术决策

交互规范设计原则

  1. RESTful 风格:统一使用 RESTful API 设计
  2. 统一响应格式
    {
      "code": 200,
      "msg": "操作成功",
      "data": {}
    }
    
  3. 统一错误处理
    • 业务错误code != 200msg 说明原因
    • 系统错误HTTP 500统一异常处理
  4. 分页标准
    {
      "code": 200,
      "msg": "查询成功",
      "total": 100,
      "rows": []
    }
    

输出文档结构

  1. architecture.md - 整体架构文档
  2. frontend-architecture.md - 前端架构详细分析
  3. backend-architecture.md - 后端架构详细分析
  4. api-specification.md - 前后端交互规范
  5. optimization-suggestions.md - 优化建议清单

风险评估

风险 影响 缓解措施
分析不完整 后续重构遗漏 建立检查清单,交叉验证
文档过时 失去参考价值 文档与代码同步更新机制
规范难以执行 团队不遵守 制定可执行的检查工具