# ai-nestjs **Repository Path**: zcf250/ai-nestjs ## Basic Information - **Project Name**: ai-nestjs - **Description**: 基础工程的集合,,, - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-09 - **Last Updated**: 2026-11-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # AI NestJS — Monorepo pnpm workspace monorepo managed by Turborepo: NestJS backend + Vue 3 micro-frontend shell (wujie) with a shared, contract-driven UI component library. **系统架构详解(含高清架构图)见 [系统架构](#系统架构) 章节。** ## 目录 - [系统架构](#系统架构) — 架构图 · 分层总览 · Shell / 子应用 / 通信协议 / 认证路由 / UI 契约 / 共享包清单 - [Package Structure](#package-structure) — apps 与 packages 完整列表 - [Frontend Architecture](#frontend-architecture) — 布局滚动、CRUD 与弹窗契约、Shell 通信、通知中心 - [Harness and Project Conventions](#harness-and-project-conventions) — 技术栈档案与门禁 - [Quick Start](#quick-start) / [Commands](#commands) / [Storage](#storage) / [Quality Gates](#quality-gates) ## 系统架构 > 本节介绍 **NestJS server 之外** 的完整架构(server 仅在「外部依赖」中一带而过)。 > 高清架构图:[`docs/architecture.svg`](docs/architecture.svg)(矢量,可无损缩放,推荐); > 位图版:[`docs/architecture.png`](docs/architecture.png)(4800×4800)。 ### 架构图 ![ai-nestjs 系统架构总览](docs/architecture.svg) *(若你的 Markdown 查看器不渲染 SVG,请直接打开 [architecture.png](docs/architecture.png)。)* ### 分层总览 | 层 | 组成 | 职责 | | --- | --- | --- | | 接入端 | 浏览器 · Shell 主应用 `:5174`;独立运行子应用 `:5173 / :5176 / :5177 / :5178 / :5175`;微信小程序 | 同一套子应用代码,支持「Shell 嵌入」与「独立部署」两种形态 | | Shell 主应用 | `apps/shell`(wujie 宿主) | 顶栏 / 侧栏 / 页签工作区 / 子应用注册表 / 全局通知聚合 | | 微前端通信 | `@project/shell-sdk` + wujie props & event bus | 认证下发、路由同步、主题广播、401 上报、通知聚合与回执 | | wujie 子应用 | `web` · `web-business` · `docs` · `flow-center`(`resume` 暂未挂载) | 业务功能;每个应用均可脱离 Shell 独立启动 | | 共享包层 | `packages/` 下 14 个 workspace 包 | 应用引导、状态内核、通信协议、UI 契约与实现、业务公共能力 | | 工程体系 | pnpm workspace + Turborepo + Vite 8/Rolldown + Harness | 依赖管理、任务编排、按需分包、静态门禁与事件留痕 | ### Shell 主应用(apps/shell · wujie 宿主) - **定位**:唯一主壳(harness 中注册为 `host`,不参与 CRUD 模块扫描)。登录、菜单装配、应用切换、 主题/密度/布局控制、跨应用 404 接管、全局通知聚合都发生在这一层。 - **布局**:`UeAppHeader`(应用切换器 + 通知铃铛 + 外观/布局入口)→ `UeAppSidebarContainer` (按当前应用过滤菜单,全部/最近两态)→ `UeTabsView`(唯一内容工作区,`content-padding="none"`、 `persist-key="shell-tabs"`)。 - **子应用挂载**:`SubAppContainer` 以 `wujie-vue` 挂载子应用,提供 100% 宽高、`overflow:hidden` 的有界父容器;`realUrl = url + activeRule 之后的子路径`(query/hash 保留),响应式驱动子应用内部路由。 启动前 `fetch(no-cors)` 探活,失败展示可重载的错误页;`alive=false`(缺省)时切走或关闭标签即 `destroyApp`。 - **路由**:静态路由(`/login`、`/dashboard`、`/notifications`、404)+ `syncSubAppRoutes` 按子应用 `activeRule` 动态注册 `/s-web/**`、`/s-business/**`、`/s-docs/**`、`/s-flow/**` → `SubAppContainer`; 守卫内先 `getInfo` + `subApps.load()` + 注册动态路由,再重走一次导航。 - **数据源**:`/auth/getInfo` 一次带回 `apps`(子应用注册信息:url / activeRule / alive / menus); 接口不可用时回退 `src/subApps/index.ts` 的 `builtinSubApps`(`VITE_MENU_SOURCE=api|local` 可强制)。 - **wujie 插件**:`htmlLoader` 屏蔽子应用 DevTools 注入、`windowPropertyOverride` 捕获运行时错误并经 bus 上报、同步事件构造函数修复 `instanceof` 校验;另有 `preload` 预载。 ### wujie 子应用 所有子应用共用同一条装配链路(差异由选项注入,见 `@project/app-bootstrap`): ``` main.ts ──► bootstrapApp({ App, router, useAuthStore, onAuthApplied/onAuthCleared, setupApp }) ├─ inWujie() → documentElement.is-wujie-subapp + HOST_CONTEXT_KEY(showChrome=false) ├─ registerAuthExpiredHandler(嵌入态只上报,独立态清态跳 /login) ├─ initAppearance()(主题 gov/red/cyan/dark · 密度 compact/standard/comfort) ├─ pinia + persistedstate → useWujieShellSync(props.auth → applyShellAuth → 重建动态路由) └─ router + ElementPlus → setupApp(指令/权限注入) → mount ``` | 应用 | 端口 | 职责与内部结构 | | --- | --- | --- | | `apps/web` | 5173 | RBAC 管理后台。`views/system/*` 直接复用 `@project/module-system`(用户/角色/菜单/部门/岗位/字典/参数/文件/应用);另有监控、代码生成、个人中心。页面经 `import.meta.glob('@/views/**/*.vue')` 懒加载,路由按 `authStore.routes` 动态注册(`syncDynamicRoutesFromAuth`)。 | | `apps/web-business` | 5178 | 业务管理后台。`views/business/*`:工单、服务类型、质保卡、维保、工人审核、订阅账单;`composables` 三层(`useIndex` 编排 → `features/useXxxCrud` → `shared/` 表单/详情/转换)。与 web 同构,仅 `appKey` 与业务视图不同。 | | `apps/docs` | 5176 | 组件文档站。`DocLayout` + `DemoBlock`/`ApiTable` 渲染 Ue* 契约文档与 shadcn 示例;免认证的独立子应用(自建 pinia/ElementPlus,不走 bootstrapApp)。 | | `apps/flow-center` | 5177 | 流程中心。BPMN 设计器/查看器/审批追踪(`@project/bpmn`)+ `GatewayPanel`/`UserTaskPanel`;构建启用 `flow-editor` 分包。 | | `apps/resume` | 5175 | 独立简历站(零 UI 库依赖),当前未注册进 Shell。 | | `apps/miniapp` | — | 原生微信小程序(非 wujie、非 workspace 包),客户/工人双身份,`utils/request.js` 直连 `:3000/api`。详见 `apps/miniapp/README.md`。 | ### 微前端通信协议(@project/shell-sdk) **启动 props**(Shell → 子应用,随 `PROPS_UPDATED` 实时更新): `appId` · `routerBase` · `theme` · `density` · `layout` · `auth: ShellAuthData{ user, roles, permissions, routes, token }` · `onAuthExpired(payload)` 回调。 **事件总线**:`useShellBus(bus, appId?)` —— 定向事件走 `${event}:${appId}` 命名空间,同时向统一通道 `wujie-channel` 广播信封 `{ type, data, appId }`;监听方不传 `appId` 即接收全部应用与全局事件。 | 事件 | 方向 | 用途 | | --- | --- | --- | | `AUTH_EXPIRED` | 子→主 | 认证最终过期,Shell 接手 SSO 跳转与回跳 | | `PROPS_UPDATED` | 主→子 | props 实时变更(账号切换/权限变更/token 续期) | | `ROUTE_CHANGE` | 子→主 | 子应用内路由变化(菜单高亮/面包屑同步) | | `THEME_CHANGE` | 主→子 | 主题/密度/布局广播 | | `TITLE_CHANGE` | 子→主 | 页面标题变化 | | `RUNTIME_ERROR` | 子→主 | 沙箱内 error / unhandledrejection 上报 | | `NOT_FOUND` | 子→主 | 子应用内 404,Shell 统一接管跳 `/404` | | `NOTIFICATION_PUSH` | 子→主 | 消息上报(items + 服务端权威 unreadCount) | | `NOTIFICATION_READ` | 子→主 | 已读回执 | | `NOTIFICATION_COMMAND` | 主→子 | `mark-read` / `mark-all-read`(空 appId 广播) | **关键链路**: 1. **认证**:Shell 登录 → `GET /auth/getInfo` → `apps` + `menus` + `routes` → wujie `props.auth` → `applyShellAuth` 落库 → `onAuthApplied` 重建动态路由。 2. **401**:任意子应用 401 → `withAuth`(bearer) 刷新重试 → 仍失败 → `notifyShellAuthExpired` (props 回调 + bus 双通道,3s 去重)→ Shell 清态跳 `/login`(`redirect` 回跳)。 3. **通知**:子应用 `notification-push` → Shell 求和出角标(纯聚合,不落库、不调 `/notifications`)→ 点击/已读经 `notification-command` 回子应用执行。 4. **主题/密度/布局**:Shell `useAppearance` 单向广播,子应用 `initAppearance` 写到 `documentElement`(shadow html),样式用 `:root, html` 双选择器命中。 ### 认证与路由体系(共享包) - **`@project/auth-core`**:`createAuthStore(options)` 是各应用唯一的认证状态内核。应用差异只有三处, 经 options 注入:`appKey`(getInfo 入参)、`filterRoutes`(后端菜单按应用归属过滤,如 web 的 `filterWebRoutes`)、`localRoutes + routeMode`(static 模式的本地菜单源)。其余(登录态、权限判断、 wujie 短路、持久化、登出清理)只有一份实现。嵌入态 token 持久化短路(storage no-op)。 - **`@project/route-mode`**:解析构建期路由模式(`VITE_ROUTE_MODE`,默认 `dynamic`);`dynamic` 菜单来自 后端 `getInfo`,`static` 用本地 `routes.ts` 全量展示(按钮级权限仍由后端 permissions 控制)。 - **`@project/http-auth`**:认证外挂(bearer/cookie/apikey),只做凭证注入 + 401 刷新重试,以拼接方式 挂到已有 axios 实例;`withApiPrefix`/`apiWith` 统一 `/api` 前缀。 - **动态路由闭环**:守卫检测 `isLoggedIn` → `getInfo` → `addRoute('layout', …)`;账号切换/权限变更时 `resetDynamicRoutes` + `syncDynamicRoutesFromAuth` 重建,失效路由回退 `/dashboard`。 ### UI 契约与组件库 - **`@project/ui-contract`**:UI 无关契约层(CRUD/表单/树/弹窗/滚动/通知类型 + InjectionKey + `buildCrudPageConfig`)。原则:**共享契约,不共享实现**。 - **`@project/ui-elementplus`**:`Ue*` 实现(`UeCrudTable/UeCrudCard/UeBaseModal/UeSchemaForm/ UeSearchForm/UeDropdownSelect/UeTreePanel/UeEditableTable/UeTabsView/UeAppHeader/…`),四套主题 `gov/red/cyan/dark`,内置 wujie 弹层修正;应用经 `@/components` 消费。 - **`@project/ui-antdvue`**:`Ua*` 平行实现(同一份契约;表格仍为有界测高,尚未对齐 fluid)。 - **`@project/ui-shadcn`**:Radix Vue + Tailwind(Button / ButtonGroup)。 - **`@project/module-system`**:RBAC 系统模块包(用户/角色/菜单/部门/岗位/字典/参数/文件/应用)+ 菜单 + API 一体实现,多子应用共享同一套代码。 - **`@project/crud-core`**:`useDict` 字典、`useSchemaDetail` 配置式详情、状态标签词表与字典 API。 - **`@project/bpmn`**:bpmn.js 封装的设计器/查看器/审批追踪组件。 ### 共享包清单(packages/) | 分组 | 包 | 一句话职责 | | --- | --- | --- | | 引导/状态 | `app-bootstrap` | 子应用统一引导(wujie 接入、认证过期、Shell 同步、装配与卸载) | | 引导/状态 | `auth-core` | 认证 Store 内核 + `applyShellAuth` 落库 | | 引导/状态 | `route-mode` | static/dynamic 路由模式与菜单树↔路由记录转换 | | 布局 | `app-layout` | 顶栏/侧栏/页签/水印共享布局(`APP_LAYOUT_KEY` 注入) | | 基础设施 | `app-utils` | 共享 axios(pending 去重/业务码解包)、notify、storage、字典、外观 | | 基础设施 | `http-auth` | 凭证外挂 + 401 刷新重试 + API 前缀助手 | | 通信 | `shell-sdk` | env 检测、类型化 bus、认证同步、通知桥、token 等待 | | 契约/UI | `ui-contract` | UI 无关契约 + InjectionKey + CRUD 配置组装器 | | 契约/UI | `ui-elementplus` | Ue* 组件实现 + 四套主题 + wujie 修正 | | 契约/UI | `ui-antdvue` | Ua* 平行实现 | | 契约/UI | `ui-shadcn` | shadcn-vue(Radix Vue + Tailwind) | | 流程 | `bpmn` | BPMN 设计器/查看器/审批追踪 | | 业务公共 | `crud-core` | 字典/配置式详情/状态标签词表 | | 业务公共 | `module-system` | RBAC 系统模块(视图+菜单+API 一体包) | > 包 exports 指向 `dist`:改 `src` 后需重建(watch 或 `pnpm build`),否则应用读到的仍是旧产物。 ### 构建与质量门禁(摘要) - **Monorepo**:pnpm workspace(`apps/*`、`packages/*`)+ Turborepo 任务图(`build`/`dev`/ `type-check`/`lint`,`dependsOn: ^build`)。 - **分包**:`scripts/vite-chunking.mts` 统一 Rolldown `codeSplitting`(`vue-core` / `element-plus` / `micro-frontend` / `flow-editor` / `animation`,按应用真实依赖开启);Vue/Router/Pinia 单实例由根 `pnpm.overrides`(TS ~6.0.3)与组件库 peer external 共同保证。 - **门禁**:`harness/harness.json` 为机器可读事实源;`verify` 只扫 `role=app` 模块,`shell`(host) 与 `packages/*` 需额外跑 `pnpm type-check` / `pnpm build`。 ## Package Structure ``` apps/ ├── server/ @project/server NestJS 11 backend (port 3000) ├── shell/ @project/shell Micro-frontend shell: wujie host, app switcher, tabs (port 5174) ├── web/ @project/web RBAC admin sub-app (port 5173) ├── web-business/ @project/web-business Business admin sub-app (port 5178) ├── docs/ @project/docs Component documentation sub-app (port 5176) ├── flow-center/ @project/flow-center BPMN workflow sub-app (port 5177) ├── miniapp/ Native WeChat mini-program (worker/customer; no Vite build, not a workspace package) └── resume/ @project/resume Resume sub-app (port 5175, currently unregistered in shell) packages/ ├── app-bootstrap/ Sub-app bootstrap: wujie wiring, auth expiry, Shell sync, pinia/router/ElementPlus assembly ├── auth-core/ Auth store kernel (createAuthStore) + applyShellAuth sink mapping ├── route-mode/ static/dynamic route mode resolution and menu-tree ↔ router-record conversion ├── app-layout/ Shared app layout: header, sidebar, tabbed workspace, watermark (APP_LAYOUT_KEY) ├── app-utils/ Shared axios instance (pending dedupe, envelope unwrap), notify, storage, dict, appearance ├── http-auth/ Pluggable credentials, 401 refresh/retry and API-prefix helpers ├── shell-sdk/ Typed wujie bus protocol, env detection, auth sync and token-refresh coordination ├── ui-contract/ UI-agnostic CRUD/form/tree contracts, injection keys and shared utilities ├── ui-elementplus/ Element Plus Ue* components, layout primitives and wujie popup fixes ├── ui-antdvue/ Ant Design Vue Ua* implementation of the shared contracts ├── ui-shadcn/ shadcn-vue based components ├── bpmn/ BPMN designer / viewer / approval-tracker widgets ├── crud-core/ useDict, schema-driven detail, status-tag rules and dict API └── module-system/ RBAC system modules (user/role/menu/dept/post/dict/config/file/app) as one shared package ``` ## Frontend Architecture ### Layout and scrolling - **`UeTabsView` is the only content-workspace owner** in Shell, Web, docs and flow-center. Layouts place it directly as a flex child without a `
` or MainCard wrapper. It owns the outer gap, canvas background, border, radius, shadow, content padding, tab bar and the single `UeTabsView.__content` scroll container. Business pages must not add their own page frame, outer padding or scrolling overrides. - **Standalone/host and embedded modes are automatic.** Standalone apps and Shell show tabs and use the framed workspace. Under wujie, `UeTabsView` hides its own tab bar, disables tab routing, keep-alive and persistence, and removes duplicate frame decoration and content padding so Shell's workspace owns those concerns. `contentPadding="none"` is available for full-height flow pages; embedded workspaces always use zero inner padding. - **Shell remains a bounded host, not a scroll bridge.** `SubAppContainer` gives each wujie sub-app a 100% width/height, `overflow: hidden` parent. Shell does not propagate scroll locks or sub-app heights through the bus. - **`APP_SCROLL_CONTAINER_KEY`** (`@project/ui-contract`) is provided by `UeTabsView` itself. `UeBaseModal` locks that content element while open, in addition to Element Plus' native body lock. The built-in `UeBackTop` uses the same element. Route changes reset scroll via the active tab, or directly via the route when tab behavior is disabled. ### CRUD and overlay contracts - **`UeCrudTable` (Element Plus) is fluid by default**: natural document-flow height, no ResizeObserver and no component-owned page scrolling. Set `tableConfig.fluid = false` for bounded measured height. Virtual scrolling (`virtual.enabled`) requires bounded mode and forces it automatically; set `fluid: false` explicitly to avoid the warning. - **`mode` controls rendering shape only**: `'table'` (default) | `'card'` | `'tree'`. Height belongs to `fluid`; do not use the legacy `'full'` / `'none'` modes. Tree data in a normal table is still `mode: 'table'`; `mode: 'tree'` means the left-tree/right-table layout. The Ant Design Vue `UaCrudTable` implementation is still bounded and does not yet implement the Element Plus fluid behavior. - **`UeBaseModal` is configuration-first**. It defaults to a 720px `ElDialog` with native `align-center`, built-in title/footer and an `@ok` event; no custom body height/overflow is imposed. Dialog forms explicitly use `label-position="top"` on `UeSchemaForm`/`ElForm` (Element Plus then left-aligns the labels), with consistent field spacing/control heights and a single-column small-screen layout. Large trees must use their component props to avoid viewport overflow—for example, role permissions default to collapsed, accordion nodes. Use `modalType="ElDrawer"` for detail/complex panels: it is resizable and **always maskless** (`modal` is forced to `false`), with a pointer-transparent overlay host so surrounding page controls remain clickable. It tracks the injected content area's top, height and right edge (the drawer's right edge lines up with the content card's right edge, and its right corners follow the card radius so the card's rounded corners stay visible), falling back to the viewport without an injection. Normally use `:show-footer="false"`. `modalType="ElDrawerFull"` keeps the same content-area bounds (its top edge stays below the tab bar, so the tab bar is never covered) but takes the full content-area width, so its left edge lines up with the content area; the bottom corners follow the card radius and `resizable` defaults to `false` (dragging would break the left-edge alignment). Both drawer modes anchor a `UeBackTop` at the drawer's bottom-right: once `.el-drawer__body` scrolls past 200px a back-to-top button appears and smooth-scrolls the drawer body to the top. The page-level `UeBackTop` is bound to the injected content-area scroller, so it cannot see drawer-internal scrolling; the drawer owns its own button and business code mounts nothing. Other Element Plus props pass through via attrs. The old `blend` API is gone; header/footer slots are escape hatches, not the default composition pattern. - **wujie popup fixes live in the component library**, not in business pages. `UeDropdownSelect`, CRUD dropdowns and table overflow tooltips apply the required Popper fixes. Keep popups teleported to `body`; `teleported=false` reintroduces clipping and offset bugs. ### Shell communication and authentication - `@project/shell-sdk` defines ten typed bus events for authentication, props/routes, theme, title, runtime errors, 404s and notification push/read receipts. App-specific events use an `appId` channel and envelope namespace; only intentionally global events omit it. Scroll/height state is deliberately not part of this protocol. - `@project/http-auth` handles credential injection and 401 refresh/retry. The intended embedded-app boundary is to notify Shell on final auth expiry rather than navigate to a local login page; standalone apps clear in-memory auth state before pushing `/login`. - Embedded auth stores must not persist into the host origin's `localStorage`. Web and flow-center disable auth persistence under wujie; `UeTabsView` also disables its own tab persistence while embedded and versions standalone/host snapshots so incompatible saved tabs are discarded. ### Header notifications - `UeNotificationBell` lives inside `UeAppHeader` (right of `#actions`, left of the user menu). It is enabled with the header prop `show-notifications` **and** requires a `NotificationCenter` provided through `NOTIFICATION_CENTER_KEY`; icon controls sit close to the user block on purpose. - One component, two scopes: standalone apps provide `scope: 'app'` + `appId` (flat panel, only that app's messages); Shell provides `scope: 'global'` (grouped by app, badge is the total unread across apps). - **Shell is a pure aggregator**: it calls no `/notifications` API and opens no SSE of its own. Items arrive only from sub-apps over the wujie bus (`notification-push`), each push carrying the app's authoritative `unreadCount`; the Shell badge is the sum of those per-app counts. - Read operations in Shell are forwarded, not executed: item click / `mark-read` / `mark-all-read` are dispatched back over the bus as `notification-command` and the owning sub-app performs them against its own data source. Shell keeps the server out of the loop. - Embedded sub-apps never render their own bell (`hostContext.showChrome = false`). `useShellNotificationBridge({ center })` (called from the app layout) then takes over: it starts the app's center even though no bell is mounted, pushes snapshots (`notifyShellPush`) on change, and answers Shell commands. Standalone runs skip the bridge entirely, leaving `start()` / `stop()` to the bell's mount / unmount. - `apps/server/src/modules/notification` stays the per-app source of truth (`sys_notification`, keyed by `appId`); realtime reuses `SseService`, and `@Sse` responses bypass `TransformInterceptor` so event payloads are not wrapped in `ApiResult`. - `UeNotificationList` backs the `/notifications` "view all" page in shell / web / flow-center. ## Harness and Project Conventions `harness/harness.json` is the machine-readable source of truth: `web` is the CRUD module app, `shell` is registered as a `host` (excluded from CRUD module scans), and applications consume components through `@/components`. The `vue3-ue` preset supplies the UI kit `@project/ui-elementplus` and the stack-family gates; the manifest also registers the post/user/dept/dict modules as implementation blueprints. | File | Purpose | | --------------------------- | --------------------------------------------------------------------------------- | | `harness/stack.md` | Current stack, build chunking, layout, authentication and wujie rules | | `harness/mode-table.md` | CRUD module skeleton, import boundaries, `mode`/`fluid` and display variants | | `harness/modal-patterns.md` | Generated modal wiring and current `UeBaseModal` usage | | `harness/rules.json` | Project-specific gates: notification entry, status-tag palette, sidebar surface | | `traces/` | Module event history used by the Harness completion workflow | ```bash H="E:/0work/0beijing/dev-harness/bin/harness.mjs" node "$H" context # Read the effective project configuration node "$H" verify --changed # Check changed CRUD modules pnpm check # Full static verification (type-check disabled) pnpm type-check # Type-check all apps/packages via Turborepo node "$H" done --app web --module system/post --msg "summary" ``` For whole-workspace validation, use `pnpm build`; it builds package dependencies in Turborepo order. Shell is a host rather than a CRUD module target, so validate shell and shared-package changes with `pnpm type-check` / `pnpm build` in addition to Harness checks. The **source-reconciliation notes** at the end of `harness/stack.md` record remaining migration gaps (the legacy CRUD builder signature, web's embedded 401 handler and the unused route-change event); those gaps are not new conventions to copy. ## Quick Start Prerequisites: Node.js `^20.19.0 || >=22.12.0` and pnpm `10.18.3`. ```bash # 1. Install all dependencies pnpm install # 2. Configure environment (copy and edit) cp apps/server/.env.example apps/server/.env # 3. Create database # CREATE DATABASE ruoyi_nest DEFAULT CHARSET utf8mb4; # 4. Start backend (auto-creates tables in dev mode) pnpm run dev:server # = pnpm --filter @project/server run start:dev # 5. Initialize database (another terminal; idempotent SQL, safe to re-run) set -a && . apps/server/.env && set +a # export DB_* for the mysql client (bash) mysql -h"$DB_HOST" -P"$DB_PORT" -u"$DB_USERNAME" -p"$DB_PASSWORD" "$DB_DATABASE" < sql/01-system-schema.sql pnpm run seed # base data: same as mysql ... < sql/02-system-data.sql node apps/server/scripts/db-doctor.mjs seed # business data: sql/04-business-data.sql # 6. Start frontend sub-apps pnpm run dev:web # RBAC admin, http://localhost:5173 pnpm --filter @project/web-business run dev # business admin, http://localhost:5178 pnpm run dev:docs # component docs, http://localhost:5176 pnpm run dev:flow # workflow center, http://localhost:5177 # 7. Start the shell (loads the sub-apps above via wujie) pnpm run dev:shell # http://localhost:5174 ``` Demo accounts (back office): | Account | Password | Role | | ------------------- | ------------ | --------------------------------------- | | `admin` | `admin123` | Super administrator | | `manager` | `admin123` | Work-order administrator | | `worker_waterproof` | `worker123` | Worker (waterproofing, lifetime plan) | | `worker_cleaning` | `worker123` | Worker (cleaning, annual plan) | The mini-program uses phone number + SMS code; the development mock code is always `123456` (`13900000001` waterproof worker, `13900000002` cleaning worker). Customers are created automatically on first login with any phone number. API documentation (Knife4j): http://localhost:3000/api/doc.html ## Commands | Command | Description | | -------------------- | ------------------------------------------------- | | `pnpm dev:server` | Start NestJS dev server (hot reload, port 3000) | | `pnpm --filter @project/server run start:dev` | Same as `dev:server`, invoked through the package | | `pnpm dev:web` | Start web sub-app Vite dev server (port 5173) | | `pnpm --filter @project/web-business run dev` | Start business admin sub-app (port 5178) | | `pnpm dev:shell` | Start micro-frontend shell (port 5174) | | `pnpm dev:resume` | Start standalone resume app (port 5175) | | `pnpm dev:docs` | Start docs sub-app (port 5176) | | `pnpm dev:flow` | Start flow-center sub-app (port 5177) | | `pnpm dev:ui` | Watch-build the Element Plus component library | | `pnpm dev:ui-shadcn` | Watch-build the shadcn-vue component library | | `pnpm dev` | Run all dev/watch tasks via Turborepo | | `pnpm build` | Build all apps and packages in dependency order | | `pnpm build:web` | Build the web app | | `pnpm build:shell` | Build the shell | | `pnpm build:ui` | Build and pack the Element Plus component library | | `pnpm lint` | ESLint all packages | | `pnpm format` | Prettier all packages | | `pnpm test` | Run server unit tests | | `pnpm seed` | Seed base data (sql/02-system-data.sql) | | `node apps/server/scripts/db-doctor.mjs doctor` | Diagnose/fix the database: NOT NULL columns, placeholder, menu column, permission data | | `node apps/server/scripts/db-doctor.mjs seed` | Run the business seed SQL (default sql/04-business-data.sql) | | `node apps/server/scripts/db-seed.mjs [file]` | Standalone business seed runner (same default SQL file) | | `node apps/server/scripts/init-minio.mjs` | Create local MinIO buckets and the biz-public read policy | | `node apps/server/scripts/smoke.mjs [baseUrl]` | End-to-end smoke test (login -> dispatch -> finish -> warranty verify) | | `pnpm check` | Run the full Harness static checks | | `pnpm type-check` | TypeScript check all packages | ## Storage `apps/server/src/common/infra/storage` exposes a single `StorageProvider` interface with `minio / local / aliyun / tencent / qiniu` adapters; `STORAGE_PROVIDER` switches the active adapter without touching business code. - Local development uses MinIO at `127.0.0.1:9002` (`minioadmin` / `minioadmin123`). - Buckets: `biz-private` (business photos, backend-issued presigned URLs), `biz-public` (warranty cards / worker cards, anonymous read), `ruoyi` (default bucket for file management). - Run `node apps/server/scripts/init-minio.mjs` once to create the buckets and apply the public-read policy on `biz-public`. - Without MinIO, set `STORAGE_PROVIDER=local` to store objects under `apps/server/.storage`. ## API Documentation Knife4j is served by the backend itself: http://localhost:3000/api/doc.html. The OpenAPI JSON is generated by `@nestjs/swagger` and exposed at `/api/v3/api-docs/default`; the static webjar assets are self-hosted in `apps/server/public/knife4j`, so the docs work offline. ## Quality Gates ```bash H="E:/0work/0beijing/dev-harness/bin/harness.mjs" node "$H" verify --changed # Check changed CRUD modules pnpm check # Full Harness static verification (type-check disabled) pnpm type-check # Type-check all apps/packages via Turborepo ``` ## Developing Shared Packages Workspace package exports point to `dist`, not directly to `src`. After changing `ui-contract`, `ui-elementplus`, `shell-sdk` or `http-auth`, run their watch builds (or `pnpm dev` for the whole workspace) so consuming apps see the changes. Use `pnpm build` for a clean, dependency-ordered production build. Keep Vue, Element Plus, Ant Design Vue, router and axios as peer dependencies where the package metadata already declares them; do not bundle a second framework instance into a library. Application code should use the existing bridges: components/types from `@/components`, shared utilities/composables/emitter/notifications from `@project/app-utils` (or `@/composables` for CRUD helpers), and APIs from `@/api/`.