# CLAUDE.md

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

## Development Commands

### Build Commands
- `npm run build` - Build both client and server
- `npm run build:client` - Build client only
- `npm run build:server` - Build server only

### Development Commands
- `npm run dev` - Start development server (port 8080)
- `npm run dev:stock` - Development with backend debug logging
- `npm run dev:socket` - Development with socket debug logging
- `npm run start` - Start production server

## Architecture Overview

This is a full-stack TypeScript application using:
- **Frontend**: React 19 + Vite + Tailwind CSS
- **Backend**: Hono.js framework with Express-style routing
- **Database**: TypeORM with MySQL
- **Real-time**: Socket.IO for WebSocket communication
- **Authentication**: JWT-based auth with middleware

### Key Directories
- `src/client/` - Frontend React components and pages
- `src/server/` - Backend API routes, middleware, and services
- `src/server/api/` - Hono.js API route definitions
- `src/server/modules/` - Business logic modules (users, auth, etc.)
- `src/server/middleware/` - Authentication and custom middleware
- `src/share/` - Shared types and utilities

### Database & ORM
- Uses TypeORM with MySQL2 driver
- Entity files in `src/server/modules/*/*.entity.ts`
- Database configuration in `src/server/data-source.ts`

### Real-time Features
- Socket.IO integration for real-time communication
- Socket middleware for authentication
- Socket handlers in `src/server/socket/`

### Authentication System
- JWT-based authentication
- User roles: TEACHER, STUDENT, TRAINEE
- Trainee expiration system with automatic status updates
- Middleware in `src/server/middleware/`

## Project Standards & Rules
- @.roo/rules/01-general.md - 通用开发规范
- @.roo/rules/02-typescript.md - TypeScript规范
- @.roo/rules/03-modules.md - 模块化规范
- @.roo/rules/04-api.md - API开发规范
- @.roo/rules/05-database.md - 数据库规范
- @.roo/rules/06-service-di.md - 服务与依赖注入规范
- @.roo/rules/07-openapi.md - OpenAPI规范
- @.roo/rules/08-rpc.md - RPC调用规范
- @.roo/rules/09-logging.md - 日志规范
- @.roo/rules/10-entity.md - 实体定义规范
- @.roo/rules/11-admin-frontend.md - 管理前端规范
- @.roo/rules/11-custom-crud.md - 自定义CRUD规范
- @.roo/rules/11-entity-creation.md - 实体创建规范
- @.roo/rules/11-home-frontend.md - 首页前端规范
- @.roo/rules/11-standard-crud.md - 标准CRUD规范
- @.roo/rules/12-generic-crud.md - 通用CRUD规范
- @.roo/rules/14-crud-filtering.md - CRUD筛选规范
- @.roo/rules/15-user-tracking.md - 用户追踪规范

## Development Notes
- Uses pnpm as package manager
- Vite for both dev server and production builds
- SSR (Server-Side Rendering) setup with Hono.js
- Environment variables via `.env` file
- Port 8080 for development and production

## Claude Code
- Always response in Chinese