码巢引擎2026年开发文档
00-开发规范
后端规范
README
后端开发手册
前端规范
README
TypeScript最佳实践
前端布局规范
前端页面模板
前端颜色与组件规范
核心规范
组件配置手册
问题排查指南
页面模板
最佳实践
README
bp-20260223-m7ps
图片上传优化总结
BUG自动记录系统使用指南
README
TYPE_SAFETY_GUIDE
常见BUG知识库
常见BUG知识库
开发前检查清单
开发安全规范
开发规范-完整版-含FutureBirdAadminAi部署
数据模型字典
文档分类规范
文档标准化规范
文档模板-基础版
文档模板-技术版
类型安全快速参考卡
类型安全规范体系
规范更新指南
过期文档清理机制
错误处理规范
错误预防指南
常见BUG知识库
常见BUG知识库
01-快速开始
Gitee快速开始
README
协作快速开始
快速开始
质量保证快速开始
02-部署指南
Docker更新指南
Docker部署
FutureBirdAadminAi部署指南
FutureBirdAadminAi部署问题分析
README
发布指南
宝塔Docker部署教程
宝塔PM2部署教程
宝塔图形化部署教程
快速发布指南
数据库和依赖变更处理指南
构建和发布
构建标准
构建检查清单
生产部署快速开始
生产部署方案
生产部署标准
生产部署检查清单
程序备份性能
自动修复和发布指南
自动化发布命令使用指南
部署快速开始
部署指南
项目更新部署指南
03-开发指南
Git凭据配置
Git推送规则
Git自动配置
README
全局样式
协作设置
定时任务
开发指南
开发流程
开发环境标准
技术改进
贡献指南
项目目录树
项目目录结构
04-API文档
API接口文档
README
hr-api
企业API
05-数据库
DATABASE_SCHEMA
README
分区指南
数据库字典
数据持久化
数据模型统一
数据迁移
06-架构设计
RBAC-PERMISSIONS
README
SaaS客户引导流程设计
companyId统一规范
employee-permission-system-design
enterprise-data-linkage
仓库实现总结
仓库模式
企业管理端员工权限系统分析
前端架构
前端重构总结
员工权限系统评估报告
员工管理菜单重构方案
权限系统混乱问题分析
架构优化计划
架构使用指南
架构结构
架构结构
状态管理
用户身份管理体系
系统架构
面试管理模块重构规划
项目技术栈
07-测试质量
README
测试修复标准
测试报告
质量保证系统
08-版本管理
CHANGELOG
README
VERSION_RULES
09-配置指南
README
SMTP配置指南
主题切换指南
渠道配置指南
环境变量指南
环境隔离
12-项目记忆
README
知识库导入指南
记忆系统指南
13-迁移指南
README
备份迁移指南
管理员迁移指南
迁移快速开始
17-其他
README
压缩摘要
18-开放平台
01-架构设计
02-API接口设计
03-安全机制
04-前端设计
05-数据库设计
开放平台API指南
开放平台API说明
19-智能进化
AI执行规则
AI进化机制
README
自动化实现总览
黄金规则
40-操作教程
README
微信公众号域名配置指南
微信本地开发调试指南
44-技能文件
alipay-payment-integration
references
checklist
SKILL
audio
python
README
typescript
README
SKILL
database
python
README
typescript
README
SKILL
design-style-thinking
SKILL
doctor
references
sql-patterns
SKILL
document-generation
python
README
SKILL
email
SKILL
embedding
python
README
typescript
README
SKILL
expo-advanced
references
audio-record-play
file-upload
masonry-layout
save-to-gallery
top-tab-navigation
SKILL
feishu-base
SKILL
feishu-message
SKILL
fetch-url
python
README
typescript
README
SKILL
frontend-design
LICENSE
SKILL
FutureBird-coding-web-performance-best-practice
SKILL
general-dev-preview
references
web-preview
SKILL
image-generation
python
README
typescript
README
SKILL
knowledge
references
python
README
typescript
README
cli
SKILL
llm
python
README
typescript
README
SKILL
miniapp-upload-asr
SKILL
pptx-generation
python
README
SKILL
project-memory-loader
scripts
project_memory_loader
SKILL
repair
scripts
merge-commit-map
SKILL
shadcn-web-base-theme
assets
colors
amber
artistic-green
bento-blue
blue
cyan
emerald
fuchsia
gray
green
indigo
lime
low-pink
neutral
orange
purple
red
retro-brown
rose
sky
supbase-green
teal
tech-purple
vintage-grey
violet
yellow
fonts
business
classic
playful
radius
2xl
2xs
lg
md
none
sm
xl
xs
shadow
artistic
bento
cool
retro
superbase
tech
tool
vintage
default
references
colors
fonts
quick
radius
shadows
scripts
theme
SKILL
package
skill-creator-coze
scripts
init_skill
quick_validate
SKILL
storage
python
README
typescript
README
SKILL
supabase
assets
supabase-client
supabase-client
references
_future
asset-supabase-browser
asset-supabase-config-inject
asset-supabase-config-route
python-auth
python-realtime
python-storage
typescript-auth
typescript-realtime
typescript-storage
typescript-supabase-browser
typescript-supabase-config-inject
typescript-supabase-config-route
python
README
database
edge-functions
orm-model-guide
supabase_client
typescript
README
database
drizzle-schema-guide
edge-functions
supabase-client
cli
rls
SKILL
supabase-auth
references
typescript
supabase-browser
supabase-config-inject
supabase-config-route
auth-config
verify-session
SKILL
ui-design-ref
reference
3D黏土风
克莱因蓝高定风
暗黑科技风
杂志风
极光柔和
柔和卡片
玻璃拟态
纯白极简风
自然有机
SKILL
ui-ux-pro-max
scripts
core
design_system
search
SKILL
vercel-composition-patterns
rules
architecture-avoid-boolean-props
architecture-compound-components
patterns-children-over-render-props
patterns-explicit-variants
react19-no-forwardref
state-context-interface
state-decouple-implementation
state-lift-state
AGENTS
SKILL
vercel-react-best-practices
rules
advanced-event-handler-refs
advanced-init-once
advanced-use-latest
async-api-routes
async-defer-await
async-dependencies
async-parallel
async-suspense-boundaries
bundle-barrel-imports
bundle-conditional
bundle-defer-third-party
bundle-dynamic-imports
bundle-preload
client-event-listeners
client-localstorage-schema
client-passive-event-listeners
client-swr-dedup
js-batch-dom-css
js-cache-function-results
js-cache-property-access
js-cache-storage
js-combine-iterations
js-early-exit
js-hoist-regexp
js-index-maps
js-length-check-first
js-min-max-loop
js-set-map-lookups
js-tosorted-immutable
rendering-activity
rendering-animate-svg-wrapper
rendering-conditional-render
rendering-content-visibility
rendering-hoist-jsx
rendering-hydration-no-flicker
rendering-hydration-suppress-warning
rendering-svg-precision
rendering-usetransition-loading
rerender-defer-reads
rerender-dependencies
rerender-derived-state-no-effect
rerender-derived-state
rerender-functional-setstate
rerender-lazy-state-init
rerender-memo-with-default-value
rerender-memo
rerender-move-effect-to-event
rerender-simple-expression-in-memo
rerender-transitions
rerender-use-ref-transient-values
server-auth-actions
server-cache-lru
server-cache-react
server-dedup-props
server-parallel-fetching
server-serialization
AGENTS
SKILL
video-edit
python
README
typescript
README
SKILL
video-generation
python
README
typescript
README
SKILL
volcano-ark
SKILL
web-design-guidelines
SKILL
web-search
python
README
typescript
README
SKILL
webrtc-best-practice
SKILL
websocket-guide
references
nextjs
nodejs
SKILL
wechat-bot
SKILL
wechat-official-account
SKILL
README
README
未来鸟:企业数字化转型奔腾的力量!
-
+
首页
项目目录结构
> **文档版本**: v1.0.0 > **创建日期**: 2026-02-12 > **最后更新**: 2026-02-12 > **维护人**: 未来鸟FutureBird码巢企业服务引擎开发组 > **状态**: [最新] --- # 项目目录结构(DDD架构) ## 目录说明 本项目采用领域驱动设计(DDD)架构,将代码划分为清晰的层次。 ``` src/ ├── app/ # Next.js页面(App Router) │ ├── (routes)/ # 页面路由 │ ├── api/ # API路由(接口层) │ └── layout.tsx # 根布局 │ ├── domains/ # 领域层(核心业务逻辑) │ ├── shared/ # 共享领域 │ │ └── auth/ # 认证和授权 │ │ ├── types.ts # 角色和权限类型 │ │ ├── permission.ts # 权限验证 │ │ └── token.ts # Token解析 │ │ │ ├── platform/ # 平台管理领域 │ │ ├── entities/ # 领域实体 │ │ ├── value-objects/ # 值对象 │ │ ├── repositories/ # 仓储接口 │ │ └── domain-services/ # 领域服务 │ │ │ ├── tenant/ # 企业管理领域 │ │ ├── entities/ │ │ ├── value-objects/ │ │ ├── repositories/ │ │ └── domain-services/ │ │ │ ├── salary/ # 工资管理领域 │ │ ├── entities/ │ │ ├── value-objects/ │ │ ├── repositories/ │ │ └── domain-services/ │ │ │ └── crm/ # CRM领域 │ ├── entities/ │ ├── value-objects/ │ ├── repositories/ │ └── domain-services/ │ ├── infrastructure/ # 基础设施层 │ ├── database/ # 数据库 │ │ ├── shared/ # 共享Schema │ │ │ ├── schema.ts # 主Schema │ │ │ ├── schema-legacy.ts # 旧Schema迁移 │ │ │ └── relations.ts # 表关系 │ │ ├── migrations/ # 数据库迁移 │ │ └── seeders/ # 数据填充 │ │ │ ├── email/ # 邮件服务 │ │ ├── index.ts │ │ └── templates/ # 邮件模板 │ │ │ ├── sms/ # 短信服务 │ │ ├── index.ts │ │ └── providers/ # 短信提供商 │ │ │ ├── storage/ # 对象存储 │ │ ├── s3.ts # S3存储实现 │ │ └── types.ts # 存储类型定义 │ │ │ └── cache/ # 缓存服务 │ └── cache.ts # 缓存实现 │ ├── application/ # 应用层(用例编排) │ ├── services/ # 应用服务 │ │ ├── salarySlipManager.ts # 工资条服务 │ │ ├── employeeManager.ts # 员工服务 │ │ ├── saasCompanyManager.ts # 企业服务 │ │ ├── saasUserManager.ts # 用户服务 │ │ ├── saasOrderManager.ts # 订单服务 │ │ └── ... │ │ │ ├── commands/ # 命令(写操作) │ │ └── ... │ │ │ └── queries/ # 查询(读操作) │ └── ... │ ├── interfaces/ # 接口层 │ ├── middleware/ # 中间件 │ │ └── api-middleware.ts # API中间件 │ │ │ └── api/ # API相关 │ ├── dto/ # 数据传输对象 │ └── validators/ # 请求验证器 │ ├── shared/ # 共享层 │ ├── constants/ # 常量 │ │ ├── app.ts │ │ └── database.ts │ │ │ ├── types/ # 类型定义 │ │ ├── api-response.ts # API响应类型 │ │ └── common.ts # 通用类型 │ │ │ ├── utils/ # 工具函数 │ │ ├── utils.ts # 通用工具 │ │ ├── error-handler.ts # 错误处理 │ │ ├── logger.ts # 日志 │ │ ├── seo.ts # SEO │ │ ├── wechat.ts # 微信 │ │ └── export/ # 数据导出 │ │ └── DataExporter.ts # 数据导出器 │ │ │ └── validation/ # 验证 │ ├── validation.ts # 验证器 │ └── validators.ts # 验证规则 │ ├── components/ # UI组件 │ ├── ui/ # 基础UI组件(shadcn/ui) │ ├── layouts/ # 布局组件 │ ├── brand/ # 品牌组件 │ ├── charts/ # 图表组件 │ └── employee/ # 员工组件 │ ├── config/ # 配置 │ └── ... │ ├── contexts/ # React上下文 │ └── ... │ ├── hooks/ # React Hooks │ └── ... │ ├── docs/ # 文档 │ └── ... │ └── services/ # 其他服务 └── ... ``` ## 层次说明 ### 1. 领域层(domains/) **核心业务逻辑**,最纯粹的业务规则。 - **职责**:封装业务逻辑,领域模型,业务规则 - **特点**:不依赖外部框架,可独立测试 - **包含**: - 实体(Entities):具有唯一标识的对象 - 值对象(Value Objects):不可变的对象 - 聚合(Aggregates):一组相关对象的集合 - 领域服务(Domain Services):业务服务 - 仓储接口(Repository Interfaces):数据访问接口 ### 2. 基础设施层(infrastructure/) **技术实现**,提供技术支持。 - **职责**:提供技术能力,实现领域层的接口 - **特点**:可替换,不包含业务逻辑 - **包含**: - 数据库实现(Drizzle ORM) - 邮件服务 - 短信服务 - 对象存储 - 缓存 - 外部API集成 ### 3. 应用层(application/) **用例编排**,协调领域对象完成业务用例。 - **职责**:协调领域对象,编排业务流程 - **特点**:薄应用层,胖领域层 - **包含**: - 应用服务(Application Services) - 命令(Commands):写操作 - 查询(Queries):读操作 ### 4. 接口层(interfaces/) **对外接口**,处理外部请求。 - **职责**:处理HTTP请求,参数验证,响应格式化 - **特点**:薄接口层,只负责协议转换 - **包含**: - API路由 - 中间件 - DTO(数据传输对象) - 验证器 ### 5. 共享层(shared/) **通用工具**,被各层共享。 - **职责**:提供通用工具和类型 - **特点**:无状态,可复用 - **包含**: - 工具函数 - 类型定义 - 常量 - 验证器 ### 6. 展示层(app/, components/) **用户界面**,Next.js页面和组件。 - **职责**:展示数据,处理用户交互 - **特点**:依赖应用层服务 - **包含**: - 页面路由 - UI组件 - 布局组件 ## 依赖规则 **单向依赖原则**: - 展示层 → 应用层 → 领域层 - 应用层 → 领域层 - 基础设施层 ← 领域层(实现领域接口) **禁止依赖**: - ❌ 领域层依赖应用层 - ❌ 领域层依赖基础设施层 - ❌ 应用层依赖展示层 ## 导入路径规范 ```typescript // 领域层 import { User } from '@/domains/platform/entities/User'; import { UserRepository } from '@/domains/platform/repositories/UserRepository'; // 基础设施层 import { getDb } from '@/infrastructure/database'; // 应用层 import { UserService } from '@/application/services/UserService'; // 接口层 import { withAuthAndPermission } from '@/interfaces/middleware/api-middleware'; // 共享层 import { ApiResponse } from '@/shared/types/api-response'; import { formatDate } from '@/shared/utils/utils'; import { UserRole } from '@/domains/shared/auth/types'; ``` ## 迁移进度 ### ✅ 已完成 - 创建DDD目录结构 - 迁移shared/通用代码 - 迁移infrastructure/基础设施 - 迁移application/应用服务 - 迁移interfaces/中间件 ### 🔄 进行中 - 更新导入路径 - 验证构建 ### 📋 待完成 - 创建领域实体和值对象 - 实现仓储模式 - 优化服务分层 - 添加单元测试 ## 最佳实践 1. **领域优先**:核心业务逻辑放在领域层 2. **依赖倒置**:依赖抽象而非具体实现 3. **单一职责**:每层只负责自己的职责 4. **接口隔离**:使用接口隔离外部依赖 5. **可测试性**:每层都可以独立测试
未来鸟
2026年7月27日 10:26
转发
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
分享
链接
类型
密码
更新密码
有效期
Markdown文件
Word文件
PDF文档(打印)
AI