Files
vibe_coding/.cursor/rules/019-modular.mdc
2026-03-05 21:27:11 +08:00

42 lines
1.2 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
description: >
模块化架构规范。当新建模块、讨论架构设计、模块划分、
依赖方向或 DDD 边界时激活。含模块通信和文件拆分最佳实践。
alwaysApply: false
---
# 🧩 Modular Architecture Standards (Core)
## 架构边界
- 模块按业务能力划分,避免按技术层随意切分
- 模块间通过公开接口通信,禁止引用他模块内部实现
- 依赖方向单向UI → Service → Repository → Model
## 拆分与聚合
- 单文件职责单一,超过复杂度阈值立即拆分
- 公共能力抽到 Case-Database-Frontend-shared/core业务逻辑保留在业务模块
- 新增目录优先复用既有模式,避免“再发明一套结构”
## 反模式禁止
- 循环依赖
- 横向跨层调用Controller 直连 DB
- 超大文件混合业务/状态/展示逻辑
## 评审基线
- 每次改动需回答:边界是否更清晰?耦合是否降低?
- 新增接口必须说明输入/输出和错误语义
## 验证清单
- [ ] 无循环依赖
- [ ] 模块边界清晰,可替换性提升
- [ ] 公共能力与业务能力分层明确
## Tier 3 深度参考
- `.cursor/rules/references/019-modular-deep.md` — 完整模块化规范与案例