How wujunjie521/ruoyi works
Main Components
• Frontend/UI Layer: Although it is mainly a backend system, static resources, templates (HTML, CSS, JavaScript) and client-side assets are stored under src/main/resources/static and src/main/resources/templates. This layer delivers the user interface to browsers.
• Web/Application Layer: The Java code under src/main/java/com/ruoyi handles incoming HTTP requests. This includes:
• Controllers (e.g., controllers under com.ruoyi.framework/web/controller, com.ruoyi/project/*/controller) that manage HTTP endpoints.
• Service layer implementations (in various “service” packages) that encapsulate business logic.
• Utility and common packages (com.ruoyi/common) that provide shared functions and error handling.
• Security & Middleware: The project uses Apache Shiro for security (repositories under com.ruoyi.framework/shiro) with filters for login, captcha verification, online session tracking, and more. There’s also integration with Druid for database connection pooling and configuration via the configuration classes.
• Persistence/Data Access Layer: MyBatis mappers (files under src/main/resources/mybatis/…) and mapper interfaces in various packages (e.g., system, monitor) interact with the database. Database configuration is defined in resource files (application.yml, application-druid.yml).
• Job Scheduling & Logging: Components for task scheduling (Quartz integration) and logging, as seen from the job packages (com.ruoyi/project/monitor/job) and log configuration.
• Code Generation/Tooling Module: Modules under com.ruoyi/project/tool provide functionalities like code generation and online builder utilities.
Relationships and Interactions
• The client (web browser) interacts with the Frontend UI, which in turn communicates with the backend controllers managed by Spring MVC.
• Controllers call Service layer methods to process business logic.
• Service methods, in turn, delegate operations to the data access layer using MyBatis mappers.
• The security filters (using Apache Shiro) guard access to controllers and services, ensuring authenticated and authorized access.
• Job scheduling components interact with the database to persist job logs and configurations.
• Static resources and templates are served as part of the presentation layer.
Architectural Patterns and Design Principles
• Layered Architecture: Clear separation into presentation (views), application (controllers and services), and persistence (mappers and database) layers.
• MVC Pattern: Controllers, views (HTML templates), and models/dtos (domain objects) are well separated.
• Modular Design: Sub-packages within com.ruoyi (framework, project, common, tool) indicate separation of concerns and encapsulation.
• Use of Cross-Cutting Concerns: Aspects (e.g., LogAspect in framework/aspectj) allow centralized logging, auditing, and exception handling.
• Security Integration: Apache Shiro is used to control authentication and authorization across layers.
Technologies, Frameworks, and Libraries
• Spring Boot / Spring MVC (implied by the overall project structure and configuration files)
• Apache Shiro for security management
• MyBatis for ORM and database interaction
• Druid for database connection pooling
• Quartz for scheduling tasks
• Frontend libraries: hplus, inspinia themes along with jQuery, Bootstrap, and various JS libraries (for dynamic behavior and validation)
• Code generation tools that produce Java, HTML, JS, XML, and SQL artifacts
Instructing the Principal Software Engineer
• Use clear, descriptive labels for each component: e.g., “UI/Static Resources”, “Controller Layer”, “Business Service Layer”, “Data Mapper Layer”, “Security (Shiro)”, “Scheduling/Job Module”, and “Database”.
• From Client Browser > UI/Static Files > Controllers.
• Controllers > Services > Data Mappers > Database.
• Scheduled tasks sending logs and alerts to the monitoring/logging module.
• Rectangles for modules (e.g., Presentation, Business, Persistence).
• Diamonds or parallelograms for decision points (e.g., authentication filtering).
• Annotations to highlight architectural principles such as “Separation of Concerns”, “Layered Design”, and “Modular Integration”.