Files
peipei-backend/CLAUDE.md
irving cd0449d6af WIP
2025-08-29 09:59:08 -04:00

3.8 KiB

CLAUDE.md

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

Project Overview

This is a Spring Boot multi-module Java backend application called "peipei-backend" that appears to be a social platform/gaming system with WeChat Mini Program integration. The system supports clerk management, customer interactions, orders, gifts, and various social features.

Project Structure

The project is organized as a Maven multi-module application:

  • play-admin: Main backend API module containing REST controllers and business logic
  • play-common: Shared utilities, configurations, and common components
  • play-generator: Code generation tool for creating CRUD operations from database tables

Technology Stack

  • Java 11 with Spring Boot 2.5.4
  • MyBatis Plus 3.5.3 with join support for database operations
  • MySQL 8 with Flyway migrations
  • Redis for caching and session management
  • JWT for authentication
  • WeChat Mini Program SDK for WeChat integration
  • Aliyun OSS for file storage
  • Lombok for reducing boilerplate code
  • Knife4j/Swagger for API documentation

Development Commands

Building and Running

# Build the entire project
mvn clean compile

# Package the application
mvn clean package

# Run the main application (play-admin module)
cd play-admin
mvn spring-boot:run

# Or run the packaged jar
java -jar play-admin/target/play-admin-1.0.jar

Database Migrations

# Run Flyway migrations
mvn flyway:migrate

# Check migration status
mvn flyway:info

Code Generation

# Generate CRUD code from database tables
cd play-generator
mvn clean compile exec:java
# Or run directly: ./run.sh (Linux/Mac) or run.bat (Windows)

Configuration

The application uses Spring profiles with separate configuration files:

  • application.yml: Main configuration
  • application-dev.yml: Development environment
  • application-test.yml: Test environment
  • application-prod.yml: Production environment

Default active profile is test. Change via spring.profiles.active property.

Architecture

Module Structure

  • Controllers: Located in modules/{domain}/controller/ - Handle HTTP requests and responses
  • Services: Located in modules/{domain}/service/ - Business logic layer
  • Mappers: Located in modules/{domain}/mapper/ - Database access layer using MyBatis Plus
  • Entities: Domain objects representing database tables

Key Domains

  • clerk: Clerk/staff management and operations
  • custom: Customer management and interactions
  • order: Order processing and management
  • shop: Product catalog and commerce features
  • system: System administration and user management
  • weichat: WeChat Mini Program integration

Authentication & Security

  • JWT-based authentication with Spring Security
  • Multi-tenant architecture support
  • Role-based access control
  • XSS protection and input validation

Database

  • Uses MyBatis Plus for ORM with automatic CRUD generation
  • Flyway for database migration management
  • Logical deletion support (soft delete)
  • Multi-tenant data isolation

Code Generation Tool

The project includes a powerful code generator (play-generator) that can:

  • Read MySQL table structures
  • Generate Entity, Mapper, Service, Controller classes
  • Create MyBatis XML mapping files
  • Support batch generation for multiple tables

Configure database connection in play-generator/src/main/resources/config.properties and specify table names to generate complete CRUD operations.

Deployment

The project includes a deployment script (deploy.sh) that:

  • Builds and packages the application
  • Deploys to remote server via SCP
  • Restarts the application service

Server runs on port 7002 with context path /api.