# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

RuoYi v3.9.0 — a Java backend + Vue 2 frontend admin management framework with Spring Boot, Spring Security, JWT authentication, and a built-in code generator. This is a multi-module Maven project with a separate `ruoyi-ui` frontend.

## Commands

### Backend
```bash
# Windows — start/stop/restart/status of ruoyi-admin.jar
ry.bat

# Maven build (from project root)
mvn clean package

# Run locally (from project root)
mvn spring-boot:run -pl ruoyi-admin
```

### Frontend
```bash
cd ruoyi-ui

# Install dependencies
npm install

# Development (hot reload, proxy to backend)
npm run dev

# Production build
npm run build:prod

# Staging build
npm run build:stage

# Preview built output
npm run preview
```

### Other
```bash
# Swagger API docs (after backend starts)
http://localhost:80/swagger-ui.html

# Code generator UI (after backend starts)
http://localhost:80/tool/build
```

## Architecture

### Backend Modules
| Module | Purpose |
|--------|---------|
| `ruoyi-admin` | Boot entry point, web controllers, serves `ruoyi-ui/` as static resources via `RuoYiServletInitializer` |
| `ruoyi-framework` | Security (JWT filter chain), cross-cutting config (Redis, datasource, WebMvc), AOP/logging |
| `ruoyi-system` | Business domain: controller / service / mapper / domain layers for users, depts, roles, menus, posts, dicts, notices |
| `ruoyi-common` | Shared: annotations (`@Log`), constants, enums, utils, XSS filter, exception base classes |
| `ruoyi-quartz` | Scheduled task scheduling |
| `ruoyi-generator` | Database table → CRUD code generation (Velocity templates) |

Package layout within each domain module follows: `com.ruoyi.<module>.controller`, `.service`, `.service.impl`, `.mapper`, `.domain`.

### Frontend Structure
- `src/api/` — Axios API modules per domain (login.js, system/, monitor/, tool/)
- `src/utils/` — Auth utilities: `auth.js` (token storage), `request.js` (axios instance with JWT interceptor), `permission.js` (前端路由守卫和RBAC指令 `v-permission`)
- `src/store/modules/` — Vuex: `user.js` (user info + token), `permission.js` (routes + perms), `dict.js`, `tagsView.js`, `app.js`, `settings.js`
- `src/views/` — Page components organized by domain (system/, monitor/, tool/, dashboard/)
- `src/layout/` — Outer shell layout (sidebar, navbar, tags view)

### Authentication Flow
1. Vue SPA calls `POST /login` with username + password (password RSA-encrypted via `jsencrypt.js`)
2. Backend `JwtAuthenticationFilter` validates credentials, `JwtTokenUtil` generates a signed JWT
3. Frontend stores JWT in `localStorage` via `auth.js` / `user.js` Vuex module
4. `request.js` axios interceptor attaches `Authorization: Bearer <token>` to every request
5. Backend `JwtAuthenticationFilter` on every request validates the token and populates `SecurityContext`

### Code Generator
- Add/edit database tables, then use the web UI at `/tool/build` to generate CRUD files
- Templates live in `ruoyi-generator/src/main/resources/vm/` (Velocity `.vm` files)
- Generated output includes controller, service, mapper XML, domain entity, and Vue view HTML

### Database
- Schema + seed data in `sql/ry_20250522.sql`
- Quartz tables in `sql/quartz.sql`
- Uses Druid connection pool (configured externally, not in `pom.xml`)

## Tech Stack
- Backend: Java 8, Spring Boot 2.5.15, Spring Security 5, MyBatis + PageHelper, Redis, JWT (jjwt 0.9.1), Swagger 3, Apache POI, Velocity
- Frontend: Vue 2.6, Element UI 2.15, Vuex 3, vue-router 3, axios 0.28, ECharts 5, webpack via `@vue/cli-service` 4.4
