nomadro/.cursor/rules/modular-design.mdc
eric 3e5b7c2098 Monorepo super-optimize: src layout, workspace scripts, docs.
Collapse portal under src/, unify pnpm workspace/scripts, thin VIP topic re-exports, drop orphan vip scaffolds and one-shot scripts, ignore xhs/release, document root commands.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-01 00:34:04 +08:00

16 lines
1.1 KiB
Plaintext
Raw 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: 模块化设计 — 易扩展业务、解耦
alwaysApply: true
---
# 模块化与解耦
- **门户业务**:垂直前端进 `src/modules/<name>`,路由在 `src/app/<route>`;禁止把业务堆进 `src/components/` 壳层。
- **端形态**:小程序 / 管理 SPA / API 进 `apps/{miniprogram,admin,api}`;共享进 `packages/*`。
- **稳定公共面**:`@nomadro/pay`、`@nomadro/pb`、`@nomadro/sdk` 经显式导出;模块之间禁止深路径互相 import。
- **依赖方向**:`packages` ← `apps` / `src/modules` ← 门户路由;下层不依赖上层。
- **新增业务清单**:`src/modules/<name>` + 可选 `apps/api` 路由前缀 + 门户挂载路径(如 `/xxx`)+ 内容进 `src/modules/*-content`;不改无关模块。
- **接口优先**:模块对外用 HTTP/OpenAPI 或清晰 TS 类型;配置与密钥走 env。
- **可替换**:支付/存储/分析经 provider 接入(见 `@nomadro/pay.resolvePayProvider`)。
- **统一编排**:跨垂直入口集中在 `/admin` 与 `apps/admin`;后台壳不承载垂直页面实现。