# 源码树和文件组织 ## 版本信息 | 版本 | 日期 | 描述 | 作者 | |------|------|------|------| | 2.5 | 2025-10-21 | 更新为实际项目结构 | Winston | ## 实际项目结构 ```text 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 ├── 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/ # 服务器端代码 │ │ │ ├── api/ # API路由 │ │ │ │ ├── auth/ # 认证相关 │ │ │ │ │ ├── index.ts # 认证路由入口 │ │ │ │ │ ├── login/post.ts # 登录接口 │ │ │ │ │ ├── logout.ts # 登出接口 │ │ │ │ │ ├── me/get.ts # 获取用户信息 │ │ │ │ │ ├── me/put.ts # 更新用户信息 │ │ │ │ │ ├── mini-login/post.ts # 小程序登录 │ │ │ │ │ ├── register/create.ts # 注册接口 │ │ │ │ │ └── sso-verify.ts # SSO验证 │ │ │ │ ├── files/ # 文件管理 │ │ │ │ │ ├── [id]/delete.ts # 删除文件 │ │ │ │ │ ├── [id]/download.ts # 下载文件 │ │ │ │ │ ├── [id]/get-url.ts # 获取文件URL │ │ │ │ │ ├── index.ts # 文件列表 │ │ │ │ │ ├── multipart-complete/post.ts # 完成分片上传 │ │ │ │ │ ├── multipart-policy/post.ts # 分片上传策略 │ │ │ │ │ └── upload-policy/post.ts # 上传策略 │ │ │ │ ├── roles/index.ts # 角色管理 │ │ │ │ ├── users/index.ts # 用户管理 │ │ │ │ ├── users/custom.ts # 自定义用户接口 │ │ │ │ └── api.ts # API路由入口 │ │ │ ├── data-source.ts # 数据库连接 │ │ │ └── index.tsx # 服务器入口 │ │ └── share/ # 共享代码 │ ├── tests/ │ │ ├── e2e/ # E2E测试 (Playwright) │ │ ├── integration/ # 集成测试 │ │ └── unit/ # 单元测试 │ └── package.json ├── docs/ # 项目文档 │ └── architecture/ # 架构文档 ├── scripts/ # 脚本文件 ├── .bmad-core/ # BMAD核心配置 ├── .claude/ # Claude配置 ├── .git/ # Git仓库 ├── package.json # 根项目配置 └── pnpm-lock.yaml # 依赖锁定文件 ``` ## 集成指南 - **文件命名**: 保持现有kebab-case命名约定 - **项目结构**: 采用monorepo模式,包含小程序(mini)和Web应用(web)两个独立项目 - **小程序架构**: 基于Taro框架,支持多平台(微信小程序、H5等) - **Web应用架构**: 基于Hono + React SSR,使用shadcn/ui组件库 - **API设计**: 使用Hono框架,RESTful API设计,支持文件分片上传 - **数据库**: 使用PostgreSQL + TypeORM - **存储**: 使用MinIO进行文件存储 - **测试结构**: - 单元测试位于`tests/unit/` - 集成测试位于`tests/integration/` - E2E测试位于`tests/e2e/` (Playwright) - **开发环境**: 多八多云端开发容器,包含Node.js 20.19.2、PostgreSQL 17、Redis 7、MinIO - **构建工具**: 使用Vite + pnpm,支持SSR构建