How yzcheng90/x-springboot works
Project type and purpose
• X-SpringBoot is a monolithic, full-stack RESTful API platform (backend in Spring Boot 3.x, frontend in Vue2.x).
• It provides a rapid-development scaffold for mid-size Java services with built-in authentication, code‐generation, RBAC, file storage, logging, and common utilities.
File structure
• Top-level directories:
· authentication – Spring Security customization (filters, providers, handlers)
· common – utilities, annotations, AOP for logging, XSS filters
· config – global Spring configuration (MyBatisPlus, Swagger, Kaptcha, XSS)
· interceptor – JWT token and validation filters
· modules – business domains (sys for user/role/menu, oss for file storage, gen for code generation, apk versioning)
· resources – YAML profiles, SQL mappers, code‐gen templates
• Standard layered MVC: Controller → Service → Mapper (MyBatis-Plus) → Database
• Deployment artifacts: pom.xml (Maven), application‐*.yml, nginx.conf in doc.
Key components
a. Clients & Edge
• Web client (Vue2 SPA)
• Nginx (reverse proxy, load balancing)
b. Backend Application
• Spring Boot Application
· Authentication Layer (SecurityConfigurer, JWT filters, CustomUserDetailsService)
· Common Layer (AOP SysLogAspect, XSS filters, global exception handler)
· Config Layer (Swagger UI, MyBatisPlus, Kaptcha)
· Interceptor Layer (AuthenticationTokenFilter, ValidateCodeFilter)
· Business Modules:
• sys (user, role, menu management)
• oss (file upload/download, cloud adapters for Qiniu/MinIO)
• gen (dynamic code generation via templates)
• apk (version management)
c. Data Stores & External Services
• MySQL (persistent storage)
• Redis (cache, session or token store)
• MinIO or Qiniu Cloud (object storage)
d. Supporting Infrastructure
• Swagger API docs
• Logging (SLF4J/Log4j via SysLogAspect)
Relationships and data flows
• Client → (HTTPS) → Nginx → Spring Boot REST endpoints
• Security filter chain intercepts requests → JWT validation → Controller
• Controllers delegate to Service layer → MyBatisPlus Mappers → MySQL
• File APIs call OSS service → Qiniu/MinIO SDK → object storage
• Events (e.g. LoginLogEvent) published → listeners write to DB
• Redis used for caching lookup tables or session data
Important architectural patterns & design principles
• Layered MVC (Controller → Service → DAO)
• AOP for cross-cutting concerns (logging, exception handling, XSS)
• Custom JWT filter chain (stateless token auth)
• Template-based code generation (Velocity templates under resources/template)
• Modular package structure to isolate domains
Detail
• Sequence of filters in the security chain (ValidateCodeFilter → AuthenticationTokenFilter)
• AOP aspects intercepting controller methods for logging
• Code-generation flow: SysGenController → Velocity templates → Generated code in target project
• RBAC flow: SysUserService → permission checks (AuthIgnore annotation, SysLogAspect)