2
0

source-tree.md 31 KB

源码树和文件组织

版本信息

版本 日期 描述 作者
4.0 2025-11-17 添加多租户包架构,包含10个多租户模块包和10个多租户管理界面包 Claude
3.5 2025-11-12 添加订单管理模块包 (@d8d/orders-module) James
3.4 2025-11-12 添加商品管理模块包 (@d8d/goods-module) James
3.3 2025-11-12 补充新添加的业务模块包(广告、商户、供应商) Winston
3.2 2025-11-11 更新包结构,添加基础设施和业务模块包 Winston
3.1 2025-11-09 更新测试结构,清理重复测试文件 James
3.0 2025-10-22 更新为 monorepo 结构,添加 packages/server Winston

实际项目结构

d8d-mini-starter/
├── mini/                       # 小程序项目 (Taro + React)
│   ├── src/
│   │   ├── app.tsx            # 小程序入口
│   │   ├── app.config.ts      # 小程序配置
│   │   ├── api.ts             # API客户端
│   │   ├── components/
│   │   │   └── ui/            # UI组件库
│   │   │       ├── avatar-upload.tsx    # 头像上传组件
│   │   │       ├── button.tsx           # 按钮组件
│   │   │       ├── card.tsx             # 卡片组件
│   │   │       ├── form.tsx             # 表单组件
│   │   │       ├── image.tsx            # 图片组件
│   │   │       ├── input.tsx            # 输入框组件
│   │   │       ├── label.tsx            # 标签组件
│   │   │       ├── navbar.tsx           # 导航栏组件
│   │   │       └── tab-bar.tsx          # 标签栏组件
│   │   ├── layouts/
│   │   │   └── tab-bar-layout.tsx       # 标签栏布局
│   │   ├── pages/
│   │   │   ├── explore/                 # 探索页面
│   │   │   │   ├── index.tsx
│   │   │   │   └── index.config.ts
│   │   │   ├── index/                   # 首页
│   │   │   │   ├── index.tsx
│   │   │   │   └── index.config.ts
│   │   │   ├── login/                   # 登录页面
│   │   │   │   ├── index.tsx
│   │   │   │   ├── index.config.ts
│   │   │   │   └── wechat-login.tsx     # 微信登录
│   │   │   ├── profile/                 # 个人资料
│   │   │   │   ├── index.tsx
│   │   │   │   └── index.config.ts
│   │   │   └── register/                # 注册页面
│   │   │       ├── index.tsx
│   │   │       └── index.config.ts
│   │   ├── schemas/            # 验证模式
│   │   └── utils/              # 工具函数
│   ├── config/
│   │   ├── dev.ts              # 开发环境配置
│   │   ├── index.ts            # 配置入口
│   │   └── prod.ts             # 生产环境配置
│   └── package.json
├── packages/                   # 共享包
│   ├── server/                 # API服务器包 (@d8d/server) - 重构后
│   │   ├── src/
│   │   │   ├── api.ts                          # API路由导出
│   │   │   └── index.ts                        # 服务器入口
│   │   ├── tests/
│   │   └── package.json
│   ├── shared-types/           # 共享类型定义 (@d8d/shared-types)
│   │   ├── src/
│   │   │   └── index.ts                        # 类型定义导出
│   │   └── package.json
│   ├── shared-utils/           # 共享工具函数 (@d8d/shared-utils)
│   │   ├── src/
│   │   │   ├── utils/
│   │   │   │   ├── jwt.util.ts                 # JWT工具
│   │   │   │   ├── errorHandler.ts             # 错误处理
│   │   │   │   ├── parseWithAwait.ts           # 异步解析
│   │   │   │   ├── logger.ts                   # 日志工具
│   │   │   │   └── redis.util.ts               # Redis会话管理
│   │   │   └── data-source.ts                  # 数据库连接
│   │   ├── tests/
│   │   └── package.json
│   ├── shared-crud/            # 通用CRUD基础设施 (@d8d/shared-crud)
│   │   ├── src/
│   │   │   ├── services/
│   │   │   │   ├── generic-crud.service.ts     # 通用CRUD服务
│   │   │   │   └── concrete-crud.service.ts    # 具体CRUD服务
│   │   │   └── routes/
│   │   │       └── generic-crud.routes.ts      # 通用CRUD路由
│   │   ├── tests/
│   │   └── package.json
│   ├── shared-test-util/       # 测试基础设施 (@d8d/shared-test-util)
│   │   ├── src/
│   │   │   ├── integration-test-db.ts          # 集成测试数据库工具
│   │   │   ├── integration-test-utils.ts       # 集成测试断言工具
│   │   ├── tests/
│   │   └── package.json
│   ├── user-module/            # 用户管理模块 (@d8d/user-module)
│   │   ├── src/
│   │   │   ├── entities/
│   │   │   │   ├── user.entity.ts              # 用户实体
│   │   │   │   └── role.entity.ts              # 角色实体
│   │   │   ├── services/
│   │   │   │   ├── user.service.ts             # 用户服务
│   │   │   │   └── role.service.ts             # 角色服务
│   │   │   ├── schemas/
│   │   │   │   ├── user.schema.ts              # 用户Schema
│   │   │   │   └── role.schema.ts              # 角色Schema
│   │   │   └── routes/
│   │   │       ├── user.routes.ts              # 用户路由
│   │   │       ├── role.routes.ts              # 角色路由
│   │   │       └── custom.routes.ts            # 自定义路由
│   │   ├── tests/
│   │   └── package.json
│   ├── auth-module/            # 认证管理模块 (@d8d/auth-module)
│   │   ├── src/
│   │   │   ├── services/
│   │   │   │   ├── auth.service.ts             # 认证服务
│   │   │   │   └── mini-auth.service.ts        # 小程序认证服务
│   │   │   ├── schemas/
│   │   │   │   └── auth.schema.ts              # 认证Schema
│   │   │   ├── routes/
│   │   │   │   ├── login.route.ts              # 登录路由
│   │   │   │   ├── register.route.ts           # 注册路由
│   │   │   │   ├── mini-login.route.ts         # 小程序登录路由
│   │   │   │   ├── phone-decrypt.route.ts      # 手机号解密路由
│   │   │   │   ├── me.route.ts                 # 获取用户信息路由
│   │   │   │   ├── update-me.route.ts          # 更新用户信息路由
│   │   │   │   ├── logout.route.ts             # 登出路由
│   │   │   │   └── sso-verify.route.ts         # SSO验证路由
│   │   │   └── middleware/
│   │   │       ├── auth.middleware.ts          # 认证中间件
│   │   │       └── index.ts                    # 中间件导出
│   │   ├── tests/
│   │   └── package.json
│   ├── file-module/            # 文件管理模块 (@d8d/file-module)
│   │   ├── src/
│   │   │   ├── entities/
│   │   │   │   └── file.entity.ts              # 文件实体
│   │   │   ├── services/
│   │   │   │   ├── file.service.ts             # 文件服务
│   │   │   │   └── minio.service.ts            # MinIO服务
│   │   │   ├── schemas/
│   │   │   │   └── file.schema.ts              # 文件Schema
│   │   │   └── routes/
│   │   │       ├── upload-policy/post.ts       # 上传策略路由
│   │   │       ├── multipart-policy/post.ts    # 多部分上传策略路由
│   │   │       ├── multipart-complete/post.ts  # 完成多部分上传路由
│   │   │       └── [id]/
│   │   │           ├── get.ts                  # 获取文件详情路由
│   │   │           ├── get-url.ts              # 获取文件URL路由
│   │   │           ├── download.ts             # 文件下载路由
│   │   │           └── delete.ts               # 删除文件路由
│   │   ├── tests/
│   │   └── package.json
│   ├── mini-payment/           # 微信小程序支付模块 (@d8d/mini-payment)
│   │   ├── src/
│   │   │   ├── entities/
│   │   │   │   ├── payment.entity.ts           # 支付实体
│   │   │   │   └── payment.types.ts            # 支付类型定义
│   │   │   ├── services/
│   │   │   │   └── payment.service.ts          # 支付服务
│   │   │   ├── schemas/
│   │   │   │   └── payment.schema.ts           # 支付Schema
│   │   │   └── routes/
│   │   │       └── payment/
│   │   │           ├── create.ts               # 支付创建路由
│   │   │           ├── callback.ts             # 支付回调路由
│   │   │           └── status.ts               # 支付状态查询路由
│   │   ├── tests/
│   │   │   └── integration/
│   │   │       ├── payment.integration.test.ts         # 支付集成测试
│   │   │       └── payment-callback.integration.test.ts # 支付回调集成测试
│   │   └── package.json
│   ├── delivery-address-module/ # 配送地址管理模块 (@d8d/delivery-address-module)
│   │   ├── src/
│   │   │   ├── entities/
│   │   │   │   └── delivery-address.entity.ts  # 配送地址实体
│   │   │   ├── services/
│   │   │   │   └── delivery-address.service.ts # 配送地址服务
│   │   │   ├── schemas/
│   │   │   │   ├── user-delivery-address.schema.ts    # 用户专用Schema
│   │   │   │   └── admin-delivery-address.schema.ts   # 管理员专用Schema
│   │   │   └── routes/
│   │   │       ├── index.ts                    # 路由导出
│   │   │       ├── user-routes.ts              # 用户路由(数据权限控制)
│   │   │       ├── admin-routes.ts             # 管理员路由(完整权限)
│   │   │       └── admin-custom.routes.ts      # 管理员自定义路由(地区验证)
│   │   ├── tests/
│   │   │   └── integration/
│   │   │       ├── user-routes.integration.test.ts    # 用户路由集成测试
│   │   │       └── admin-routes.integration.test.ts   # 管理员路由集成测试
│   │   └── package.json
│   ├── advertisements-module/  # 广告管理模块 (@d8d/advertisements-module)
│   │   ├── src/
│   │   │   ├── entities/
│   │   │   │   ├── advertisement.entity.ts            # 广告实体
│   │   │   │   └── advertisement-type.entity.ts       # 广告类型实体
│   │   │   ├── services/
│   │   │   │   ├── advertisement.service.ts           # 广告服务
│   │   │   │   └── advertisement-type.service.ts      # 广告类型服务
│   │   │   ├── schemas/
│   │   │   │   ├── advertisement.schema.ts            # 广告Schema
│   │   │   │   └── advertisement-type.schema.ts       # 广告类型Schema
│   │   │   └── routes/
│   │   │       ├── advertisements.ts                  # 广告路由
│   │   │       └── advertisement-types.ts             # 广告类型路由
│   │   ├── tests/
│   │   │   └── integration/
│   │   │       ├── advertisements.integration.test.ts # 广告集成测试
│   │   │       └── advertisement-types.integration.test.ts # 广告类型集成测试
│   │   └── package.json
│   ├── merchant-module/        # 商户管理模块 (@d8d/merchant-module)
│   │   ├── src/
│   │   │   ├── entities/
│   │   │   │   └── merchant.entity.ts                 # 商户实体
│   │   │   ├── services/
│   │   │   │   └── merchant.service.ts                # 商户服务
│   │   │   ├── schemas/
│   │   │   │   ├── merchant.schema.ts                 # 商户Schema
│   │   │   │   ├── user-merchant.schema.ts            # 用户专用Schema
│   │   │   │   └── admin-merchant.schema.ts           # 管理员专用Schema
│   │   │   ├── types/
│   │   │   │   └── merchant.types.ts                  # 商户类型定义
│   │   │   └── routes/
│   │   │       ├── index.ts                           # 路由导出
│   │   │       ├── user-routes.ts                     # 用户路由
│   │   │       └── admin-routes.ts                    # 管理员路由
│   │   ├── tests/
│   │   │   └── integration/
│   │   │       ├── user-routes.integration.test.ts    # 用户路由集成测试
│   │   │       └── admin-routes.integration.test.ts   # 管理员路由集成测试
│   │   └── package.json
│   ├── supplier-module/        # 供应商管理模块 (@d8d/supplier-module)
│   │   ├── src/
│   │   │   ├── entities/
│   │   │   │   └── supplier.entity.ts                 # 供应商实体
│   │   │   ├── services/
│   │   │   │   └── supplier.service.ts                # 供应商服务
│   │   │   ├── schemas/
│   │   │   │   ├── supplier.schema.ts                 # 供应商Schema
│   │   │   │   ├── user-supplier.schema.ts            # 用户专用Schema
│   │   │   │   └── admin-supplier.schema.ts           # 管理员专用Schema
│   │   │   ├── types/
│   │   │   │   └── supplier.types.ts                  # 供应商类型定义
│   │   │   └── routes/
│   │   │       ├── index.ts                           # 路由导出
│   │   │       ├── user-routes.ts                     # 用户路由
│   │   │       └── admin-routes.ts                    # 管理员路由
│   │   ├── tests/
│   │   │   └── integration/
│   │   │       ├── user-routes.integration.test.ts    # 用户路由集成测试
│   │   │       └── admin-routes.integration.test.ts   # 管理员路由集成测试
│   │   └── package.json
│   ├── goods-module/           # 商品管理模块 (@d8d/goods-module)
│   │   ├── src/
│   │   │   ├── entities/
│   │   │   │   ├── goods.entity.ts                  # 商品实体
│   │   │   │   └── goods-category.entity.ts          # 商品分类实体
│   │   │   ├── services/
│   │   │   │   ├── goods.service.ts                  # 商品服务
│   │   │   │   └── goods-category.service.ts         # 商品分类服务
│   │   │   ├── schemas/
│   │   │   │   ├── goods.schema.ts                   # 商品Schema
│   │   │   │   ├── goods-category.schema.ts          # 商品分类Schema
│   │   │   │   ├── random.schema.ts                  # 随机商品Schema
│   │   │   │   ├── user-goods.schema.ts              # 用户专用Schema
│   │   │   │   ├── admin-goods.schema.ts             # 管理员专用Schema
│   │   │   │   └── public-goods.schema.ts            # 公开商品Schema
│   │   │   ├── types/
│   │   │   │   └── goods.types.ts                    # 商品类型定义
│   │   │   └── routes/
│   │   │       ├── admin-goods-categories.ts         # 商品分类管理路由
│   │   │       ├── public-goods-random.ts            # 公开随机商品路由
│   │   │       ├── user-goods-routes.ts              # 用户路由
│   │   │       ├── admin-goods-routes.ts             # 管理员路由
│   │   │       ├── public-goods-routes.ts            # 公开商品路由
│   │   │       └── index.ts                          # 路由导出
│   │   ├── tests/
│   │   │   └── integration/
│   │   │       ├── admin-goods-categories.integration.test.ts    # 商品分类集成测试
│   │   │       ├── public-goods-random.integration.test.ts       # 随机商品集成测试
│   │   │       ├── user-goods-routes.integration.test.ts         # 用户路由集成测试
│   │   │       ├── admin-goods-routes.integration.test.ts        # 管理员路由集成测试
│   │   │       └── public-goods-routes.integration.test.ts       # 公开商品路由集成测试
│   │   └── package.json
│   └── geo-areas/              # 地区模块 (@d8d/geo-areas)
│       ├── src/
│       │   ├── modules/areas/
│       │   │   ├── area.entity.ts              # 地区实体
│       │   │   ├── area.service.ts             # 地区服务
│       │   │   └── area.schema.ts              # 地区Schema
│       │   ├── api/
│       │   │   ├── areas/index.ts              # 公共地区API
│       │   │   └── admin/areas/index.ts        # 管理地区API
│       │   └── index.ts                        # 包入口
│       ├── tests/
│       └── package.json
│   └── orders-module/          # 订单管理模块 (@d8d/orders-module)
│       ├── src/
│       │   ├── entities/
│       │   │   ├── order.entity.ts             # 订单实体
│       │   │   ├── order-goods.entity.ts       # 订单商品实体
│       │   │   ├── order-refund.entity.ts      # 订单退款实体
│       │   │   └── index.ts                    # 实体导出
│       │   ├── services/
│       │   │   ├── order.service.ts            # 订单服务
│       │   │   ├── order-goods.service.ts      # 订单商品服务
│       │   │   ├── order-refund.service.ts     # 订单退款服务
│       │   │   ├── user-order-goods.service.ts # 用户订单商品服务
│       │   │   ├── user-refunds.service.ts     # 用户退款服务
│       │   │   └── index.ts                    # 服务导出
│       │   ├── schemas/
│       │   │   ├── create-order.schema.ts      # 创建订单Schema
│       │   │   ├── order.schema.ts             # 订单Schema
│       │   │   ├── user-order.schema.ts        # 用户订单Schema
│       │   │   ├── order-goods.schema.ts       # 订单商品Schema
│       │   │   ├── order-refund.schema.ts      # 订单退款Schema
│       │   │   └── index.ts                    # Schema导出
│       │   ├── types/
│       │   │   ├── order.types.ts              # 订单类型定义
│       │   │   └── index.ts                    # 类型导出
│       │   ├── routes/
│       │   │   ├── create-order.ts             # 创建订单路由
│       │   │   ├── user/
│       │   │   │   ├── orders.ts               # 用户订单路由
│       │   │   │   ├── order-items.ts          # 用户订单商品路由
│       │   │   │   └── refunds.ts              # 用户退款路由
│       │   │   ├── admin/
│       │   │   │   ├── orders.ts               # 管理员订单路由
│       │   │   │   ├── order-items.ts          # 管理员订单商品路由
│       │   │   │   └── refunds.ts              # 管理员退款路由
│       │   │   └── index.ts                    # 路由导出
│       │   └── index.ts                        # 包入口
│       ├── tests/
│       │   └── integration/
│       │       ├── entity-configuration.integration.test.ts    # 实体配置集成测试
│       │       ├── create-order.integration.test.ts            # 创建订单集成测试
│       │       ├── user-orders.integration.test.ts             # 用户订单集成测试
│       │       ├── user-order-items.integration.test.ts        # 用户订单商品集成测试
│       │       ├── user-refunds.integration.test.ts            # 用户退款集成测试
│       │       ├── admin-orders.integration.test.ts            # 管理员订单集成测试
│       │       ├── admin-order-items.integration.test.ts       # 管理员订单商品集成测试
│       │       ├── admin-refunds.integration.test.ts           # 管理员退款集成测试
│       │       └── utils/
│       │           └── test-data-factory.ts                    # 测试数据工厂
│       └── package.json
│   └── shared-ui-components/    # 共享UI组件包 (@d8d/shared-ui-components)
│       ├── src/
│       │   ├── components/      # UI组件库
│       │   │   ├── ui/          # shadcn/ui组件
│       │   │   │   ├── accordion.tsx            # 手风琴组件
│       │   │   │   ├── alert-dialog.tsx         # 警告对话框
│       │   │   │   ├── alert.tsx                # 警告组件
│       │   │   │   └── ...                      # 其他46+组件
│       │   │   └── index.ts     # 组件导出
│       │   └── index.ts         # 包入口
│       ├── tests/
│       └── package.json
│   └── 多租户包架构 (Epic-007 多租户包复制方案)
│       ├── 多租户模块包 (10个)
│       │   ├── tenant-module-mt/                # 租户基础包 (@d8d/tenant-module-mt)
│       │   ├── user-module-mt/                  # 多租户用户管理模块 (@d8d/user-module-mt)
│       │   ├── auth-module-mt/                  # 多租户认证管理模块 (@d8d/auth-module-mt)
│       │   ├── file-module-mt/                  # 多租户文件管理模块 (@d8d/file-module-mt)
│       │   ├── geo-areas-mt/                    # 多租户地区模块 (@d8d/geo-areas-mt)
│       │   ├── delivery-address-module-mt/      # 多租户地址管理模块 (@d8d/delivery-address-module-mt)
│       │   ├── merchant-module-mt/              # 多租户商户管理模块 (@d8d/merchant-module-mt)
│       │   ├── supplier-module-mt/              # 多租户供应商管理模块 (@d8d/supplier-module-mt)
│       │   ├── goods-module-mt/                 # 多租户商品管理模块 (@d8d/goods-module-mt)
│       │   ├── orders-module-mt/                # 多租户订单管理模块 (@d8d/orders-module-mt)
│       │   └── advertisements-module-mt/        # 多租户广告管理模块 (@d8d/advertisements-module-mt)
│       └── 多租户管理界面包 (10个)
│           ├── auth-management-ui-mt/           # 多租户认证管理界面 (@d8d/auth-management-ui-mt)
│           ├── user-management-ui-mt/           # 多租户用户管理界面 (@d8d/user-management-ui-mt)
│           ├── advertisement-management-ui-mt/  # 多租户广告管理界面 (@d8d/advertisement-management-ui-mt)
│           ├── advertisement-type-management-ui-mt/ # 多租户广告分类管理界面 (@d8d/advertisement-type-management-ui-mt)
│           ├── order-management-ui-mt/          # 多租户订单管理界面 (@d8d/order-management-ui-mt)
│           ├── goods-management-ui-mt/          # 多租户商品管理界面 (@d8d/goods-management-ui-mt)
│           ├── goods-category-management-ui-mt/ # 多租户商品分类管理界面 (@d8d/goods-category-management-ui-mt)
│           ├── supplier-management-ui-mt/       # 多租户供应商管理界面 (@d8d/supplier-management-ui-mt)
│           ├── merchant-management-ui-mt/       # 多租户商户管理界面 (@d8d/merchant-management-ui-mt)
│           ├── file-management-ui-mt/           # 多租户文件管理界面 (@d8d/file-management-ui-mt)
│           ├── delivery-address-management-ui-mt/ # 多租户地址管理界面 (@d8d/delivery-address-management-ui-mt)
│           └── area-management-ui-mt/           # 多租户区域管理界面 (@d8d/area-management-ui-mt)
├── web/                        # Web应用 (Hono + React SSR)
│   ├── src/
│   │   ├── client/             # 客户端代码
│   │   │   ├── admin/          # 管理后台
│   │   │   │   ├── components/ # 管理后台组件
│   │   │   │   │   ├── AvatarSelector.tsx       # 头像选择器
│   │   │   │   │   ├── DataTablePagination.tsx  # 表格分页
│   │   │   │   │   ├── ErrorPage.tsx            # 错误页面
│   │   │   │   │   ├── FileSelector.tsx         # 文件选择器
│   │   │   │   │   ├── MinioUploader.tsx        # MinIO上传器
│   │   │   │   │   ├── NotFoundPage.tsx         # 404页面
│   │   │   │   │   └── ProtectedRoute.tsx       # 路由保护
│   │   │   │   ├── hooks/
│   │   │   │   │   └── AuthProvider.tsx         # 认证状态管理
│   │   │   │   ├── layouts/
│   │   │   │   │   └── MainLayout.tsx           # 主布局
│   │   │   │   ├── pages/
│   │   │   │   │   ├── Dashboard.tsx            # 仪表板
│   │   │   │   │   ├── Files.tsx                # 文件管理
│   │   │   │   │   ├── Login.tsx                # 登录页面
│   │   │   │   │   └── Users.tsx                # 用户管理
│   │   │   │   ├── menu.tsx                     # 菜单配置
│   │   │   │   ├── routes.tsx                   # 路由配置
│   │   │   │   └── index.tsx                    # 管理后台入口
│   │   │   ├── components/
│   │   │   │   └── ui/                          # shadcn/ui组件库
│   │   │   │       ├── accordion.tsx            # 手风琴组件
│   │   │   │       ├── alert-dialog.tsx         # 警告对话框
│   │   │   │       ├── alert.tsx                # 警告组件
│   │   │   │       └── ...                      # 其他50+组件
│   │   │   ├── api.ts                           # API客户端
│   │   │   └── index.tsx                        # 前端入口
│   │   ├── server/             # 服务器端代码 (SSR)
│   │   │   ├── index.tsx                        # 服务器入口
│   │   │   └── renderer.tsx                     # React渲染器
│   │   └── share/              # 共享代码
│   ├── tests/
│   │   ├── e2e/                # E2E测试 (Playwright)
│   │   ├── integration/        # Web集成测试
│   │   │   └── client/         # 客户端集成测试
│   │   └── unit/               # 单元测试
│   │       └── client/         # 客户端单元测试
│   │           ├── pages/      # 页面组件测试
│   │           │   └── Users.test.tsx           # 用户页面测试
│   │           └── debug.test.tsx               # 调试测试
│   └── package.json
├── docs/                       # 项目文档
│   └── architecture/           # 架构文档
├── scripts/                    # 脚本文件
├── .bmad-core/                 # BMAD核心配置
├── .claude/                    # Claude配置
├── .git/                       # Git仓库
├── package.json                # 根项目配置
├── pnpm-workspace.yaml         # pnpm workspace 配置
└── pnpm-lock.yaml              # 依赖锁定文件

集成指南

  • 文件命名: 保持现有kebab-case命名约定
  • 项目结构: 采用monorepo模式,包含小程序(mini)、Web应用(web)和模块化包架构
  • 包管理: 使用pnpm workspace管理多包依赖关系
  • 小程序架构: 基于Taro框架,支持多平台(微信小程序、H5等)
  • Web应用架构: 基于Hono + React SSR,使用shadcn/ui组件库
  • 模块化架构: 采用分层包结构,支持按需安装和独立开发
  • API服务器: 重构后的@d8d/server包,基于模块化架构,提供RESTful API
  • API设计: 使用Hono框架,RESTful API设计,支持文件分片上传
  • 数据库: 使用PostgreSQL + TypeORM
  • 存储: 使用MinIO进行文件存储
  • 包架构层次:
    • 基础设施层: shared-types → shared-utils → shared-crud
    • 测试基础设施: shared-test-util
    • 业务模块层: user-module → auth-module → file-module → delivery-address-module → advertisements-module → merchant-module → supplier-module → goods-module → geo-areas → orders-module
    • 多租户模块层: 10个多租户模块包(-mt后缀),支持租户数据隔离
    • 前端界面层: 共享UI组件包 + 单租户管理界面包 + 多租户管理界面包
    • 应用层: server (重构后)
  • 多租户架构:
    • 包复制策略: 基于Epic-007方案,通过复制单租户包创建多租户版本
    • 租户隔离: 通过租户ID实现数据隔离,支持多租户部署
    • 前端包: 10个多租户管理界面包,支持租户上下文管理
    • 后端包: 10个多租户模块包,支持租户数据隔离
    • 共享组件: @d8d/shared-ui-components 提供46+基础UI组件
  • 测试结构:
    • 基础设施包: 每个包独立的单元测试和集成测试
    • 业务模块包: 每个模块包含完整的测试套件
    • 多租户包: 独立的测试套件,验证租户数据隔离
    • server包: 集成测试验证模块间协作
    • web应用: 组件测试、集成测试和E2E测试
  • 开发环境: 多八多云端开发容器,包含Node.js 20.19.2、PostgreSQL 17、Redis 7、MinIO
  • 构建工具: 使用Vite + pnpm,支持SSR构建
  • 架构优势:
    • 清晰的模块边界和职责分离
    • 支持按需安装,减少包体积
    • 基础设施和业务逻辑分离
    • 多租户支持,支持租户数据隔离
    • 统一的测试模式和工具
    • 更好的代码复用和维护性
    • 独立的包版本管理
    • 支持单租户和多租户部署模式