nomadro/.cursor/rules/modular-design.mdc
Eric 2b574f7957 Ship native /social/work: Planka-shaped boards + Etherpad pads on FastAPI.
Secondary-dev Next UI with DnD, labels, stopwatch, archive, activity; pads with revisions; README documents pnpm dev:work-api.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-04 01:06:26 +08:00

18 lines
1.7 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: 模块化设计 — 易扩展业务、解耦
alwaysApply: true
---
# 模块化与解耦
- **门户业务**:垂直前端进 `src/modules/<name>`,路由在 `src/app/<route>`;禁止把业务堆进 `src/components/` 壳层。
- **受众横切**:中文 / 国际进 `src/modules/audience/{cn,intl}`(支付·登录·关注·文案·VIP·埋点·社群等);见 `audience-cn-intl.mdc`。禁止页面散落 `if (isChina)`。
- **端形态**:小程序 / 管理 SPA / API 进 `apps/{miniprogram,admin,api}`;**.com(美国 VPS)进 `apps/com/*`,与 `.cn` 源码隔离**;共享进 `packages/*`。
- **远程工作**:门户壳 `src/modules/work`;Planka / Etherpad 上游与 overlay 在 `apps/work`(二次开发写 overlay,勿把整个 upstream 硬塞进主仓)。
- **稳定公共面**:`@nomadro/pay`、`@nomadro/pb`、`@nomadro/sdk` 经显式导出;模块之间禁止深路径互相 import。
- **依赖方向**:`packages` ← `apps` / `src/modules` ← 门户路由;下层不依赖上层;**`apps/com` 禁止依赖 `apps/admin` / 小程序源码**。
- **新增业务清单**:`src/modules/<name>` + 可选 `apps/api` 路由前缀 + 门户挂载路径(如 `/xxx`)+ 内容进 `src/modules/*-content`;不改无关模块。**.com Web 能力进 `apps/com`,勿塞进微信/抖音后台。**
- **接口优先**:模块对外用 HTTP/OpenAPI 或清晰 TS 类型;配置与密钥走 env。
- **可替换**:支付/存储/分析经 provider 接入(见 `@nomadro/pay.resolvePayProvider`)。
- **统一编排**:`.cn` 跨垂直入口在 `/admin` 与 `apps/admin`;`.com` 在 `apps/com/admin`(`admin.nomadro.com`);后台壳不承载垂直页面实现。