How norumai01/honkaibackendv2 works
Main Components
• Spring Boot Application: Represented by the main class (HonkaiWebsiteBackendApplication.java) that initializes the application.
• Configuration Layer: Include subcomponents such as:
• SecurityConfig (configures Spring Security with JWT and HTTPS settings)
• CorsConfig (manages CORS for secure communications with the frontend)
• LettuceRedisConfig and RedisCodecConfig (handle Redis connectivity and data encoding)
• Controller Layer: Illustrate controllers like AuthController (for authentication endpoints) and HelloController.
• DTOs: Mark the LoginRequest and RegisterRequest, facilitating data exchange.
• Repository Layer: Include the UserRepository that handles database interactions.
• Utilities: List utility components like JwtFilter (for request filtering) and Jackson2JsonRedisCodec (for custom object serialization with Redis).
Data and Control Flow
• Flow of requests through the JwtFilter for JWT validation on protected routes.
• How the controller communicates with corresponding services (for business logic), which in turn interact with the repository for MySQL operations.
• Chart out the role of Redis: services (JWTService and BlacklistTokenService) use Redis for token blacklisting.
• Interaction with external configuration via environment variables for MySQL, Redis, and SSL properties.
Architectural Patterns and Design Principles
• Security Integration: Emphasize JWT-based stateless authentication, HTTPS configuration, role-based access control, and CORS.
• Dependency Injection and ORM: Note the use of Spring Security, Spring Data JPA/Hibernate, and configuration classes to decouple application concerns.
Incorporate Specific Technologies and Tools
• Spring Boot as the core framework.
• MySQL as the relational database.
• Redis (configured via Lettuce) for handling token blacklisting.
• Spring Security, JWT, and BCrypt for authentication/authorization.
• Use clear, descriptive labels for each layer/component (e.g., “Spring Boot Application”, “Security Configuration”, “JWT Authentication Flow”, “MySQL Database”, “Redis Token Store”).
• Flow from JwtFilter intercepting requests and validating tokens.
• Web layer (controllers, filters)
• Business/service layer (services)
• Data layer (repositories, MySQL, Redis)
• Configuration components (configs for security, Redis, CORS)
• Optionally, add annotations for environmental dependencies (SSL/TLS, environment variables) that affect the system configuration.