# AGENTS.md — 杭州第一技师学院智慧校园管理系统
## Monorepo Structure
Multi-project workspace. No monorepo tool — each sub-project is independent.
| Directory | Stack | Framework | Port | Notes |
|-----------|-------|-----------|------|-------|
| `crm/backend/` | Java 17, Maven | RuoYi-Vue-Plus 5.4.0, Spring Boot 3.4.6 | 8080 | Main backend; Sa-Token auth, MyBatis-Plus ORM |
| `crm/web/` | Node 18.18+, npm | Vue 3.5 + TypeScript 5.8 + Vite 6.3 + Element Plus 2.9 | 80 | Main admin frontend; auto-imports Vue APIs |
| `crm/py-backend/` | Python | FastAPI / scripts | — | 主工程侧 Python 服务(若使用) |
| `crm/mobile/` | Node, pnpm | uni-app Vue 2.6 + uview-ui 2.0 + vue-cli-service | 8081 (H5) | 主工程移动端(纳入仓库时使用该路径) |
| `bx/bx-backend/` | Python 3.11+ | FastAPI + SQLAlchemy 2 + Uvicorn | 8011 | 报销(expense) sub-system backend |
| `bx/bx-web/` | Node, npm | Vue 3.5 + TypeScript + Vite 6.3 + Element Plus | — | 报销 sub-system admin frontend |
| `bx/bx-mobile/` | Node, npm | Vue 3.4 + TypeScript + Vite 5 + Vant 4 | — | 报销 sub-system mobile frontend |
| `crm/` | — | — | — | 主工程(智慧校园 / RuoYi)根:`crm/backend`、`crm/web`、`crm/sql`、文档与原型等 |
| `bx/docs/` | — | — | — | 报销子系统规范与计划(含 UI 规范、superpowers 计划) |
Non-app under `crm/`: `crm/sql/`、`crm/yuanxing/`、`crm/graphify-out/`、`crm/docs/`、`crm/*.md` 等;报销文档在 `bx/docs/`;另有 `ui-ux-pro-max-skill-main/` 等工具目录。
## Developer Commands
### Backend (Java)
```bash
cd crm/backend
# Build (skips tests by default — true in pom.xml)
mvn clean package -DskipTests
# Start all services in order (monitor → job → main app)
bash start-all.sh
# Or start individually (MUST follow this order):
bash start-monitor.sh # Monitor center → port 9090
bash start-job.sh # SnailJob scheduler → port 8800
bash hot-start.sh # Main app → port 8080 (interactive, supports hot-reload)
# Maven profiles: local, dev (default), prod, prod-local
# (prod-9900 is a Spring profile only, not a Maven profile)
mvn clean package -P dev
```
**`hot-start.sh`** compiles `ruoyi-modules/` with `mvn clean install` first, then `ruoyi-admin/`. Supports flags: `-p `, `-P `, `-c` (clean), `-d` (debug on port 5005), `--no-hot`.
### Web Frontend (Vue 3)
```bash
cd crm/web
npm install --registry=https://registry.npmmirror.com
npm run dev # Dev server on port 80, proxies /prod-api → localhost:8080
npm run build:prod # Production build (increases heap to 8GB)
npm run lint:eslint # Lint
npm run lint:eslint:fix # Lint fix
npm run prettier # Format
```
Vitest is installed as devDependency but no `test` script is defined in `package.json`.
### Mobile (uni-app)
```bash
cd crm/mobile
pnpm install # Has .npmrc with shamefully-hoist=true; pnpm-lock.yaml present
pnpm run dev:h5 # H5 development (vue-cli-service uni-serve)
pnpm run dev:mp-weixin # WeChat miniprogram development
pnpm run build:h5 # H5 production build
```
### CRM Python backend (optional)
```bash
cd crm/py-backend
bash start.sh # Uses .venv + uvicorn per project script
```
### BX Backend (Python/FastAPI)
```bash
cd bx/bx-backend
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
bash start.sh # Reads .env, runs uvicorn on port 8011 (default)
# With debug reload: set DEBUG=true in .env
# Tests: pytest (httpx + pytest in dev deps)
```
### BX Web & Mobile
```bash
cd bx/bx-web && npm install && npm run dev # Proxies /api → localhost:8011
cd bx/bx-mobile && npm install && npm run dev
```
## Architecture Notes
### Backend Module Layout
```
crm/backend/
├── ruoyi-admin/ # App entry point (SpringApplication.run)
├── ruoyi-common/ # Shared library modules (20+)
│ ├── ruoyi-common-core/
│ ├── ruoyi-common-mybatis/
│ ├── ruoyi-common-redis/
│ ├── ruoyi-common-satoken/
│ ├── ruoyi-common-web/
│ ├── ruoyi-common-excel/
│ └── ...
├── ruoyi-modules/ # Business modules
│ ├── ruoyi-system/ # System management (users, roles, menus)
│ ├── ruoyi-xg/ # 学工管理 (student affairs) ⭐ main custom module
│ ├── ruoyi-crm/ # CRM module
│ ├── ruoyi-workflow/ # Workflow (warm-flow engine)
│ ├── ruoyi-job/ # Scheduled tasks
│ ├── ruoyi-generator/ # Code generator
│ └── ruoyi-demo/ # Demo/examples
└── ruoyi-extend/
├── ruoyi-monitor-admin/ # Spring Boot Admin → port 9090
└── ruoyi-snailjob-server/ # SnailJob scheduler → port 8800
```
### BX Backend Layout
```
bx/bx-backend/app/
├── main.py # FastAPI entry (app.main:app)
├── config.py # Settings via pydantic-settings
├── database.py # SQLAlchemy engine/session
├── models/ # SQLAlchemy ORM models
├── schemas/ # Pydantic request/response schemas
├── routers/ # API route handlers
├── services/ # Business logic
└── utils/ # Helpers
```
### Key Backend Conventions
- **Package**: `org.dromara.{module}` — e.g. `org.dromara.xg`, `org.dromara.system`
- **Auth**: Sa-Token with JWT, permission format `{module}:{entity}:{action}` (e.g. `xg:student:list`)
- **ORM**: MyBatis-Plus with `BaseMapperPlus` — provides `selectVoPage`, `selectVoList` etc.
- **Object mapping**: MapStruct-Plus 1.5.0 (`@AutoMapper` annotation on BO/VO classes)
- **Multi-tenant**: Entities extend `TenantEntity`, tenant filtering is automatic
- **ID strategy**: Snowflake (`ASSIGN_ID`) — NOT auto-increment
- **Logical delete**: `del_flag` field with `@TableLogic`
- **API docs**: SpringDoc auto-generated at `/swagger-ui/index.html` (uses javadoc comments, no annotations needed)
- **Excel**: FastExcel with `@ExcelProperty` on VO fields for export
- **Validation groups**: `AddGroup` / `EditGroup` for create vs update validation
- **Key deps**: Hutool 5.8, Redisson 3.45, Warm-Flow 1.7.3, SnailJob 1.5.0
### Backend Layer Pattern (ruoyi-xg as reference)
```
controller/ → REST endpoints, @SaCheckPermission, @Log, @RepeatSubmit
service/ → Interface (IXgXxxService)
service/impl → Implementation with LambdaQueryWrapper + MapstructUtils.convert
mapper/ → BaseMapperPlus (XML only for custom SQL)
domain/ → Entity (@TableName, extends TenantEntity)
domain/bo/ → Business Object (@AutoMapper(target=Entity), validation groups)
domain/vo/ → View Object (@AutoMapper(target=Entity), @ExcelProperty)
```
### Frontend Conventions (crm/web/)
- **Style**: `