How lmmax0/hongdou works
Project Type and Purpose
• The project is a full-stack application focused on providing video playback along with the ability for remote friends to synchronously watch videos (“红豆” – HongDou).
• The README confirms its purpose as a platform that involves video playback and synchronized viewing, while the file tree supports both a front-end (built with Vue.js and managed with webpack and Node tools) and a Java-based back-end (using Spring Boot, Spring Security, and more).
Analyzing the File Structure
• Frontend (myweb Folder):
• Contains configuration files such as babel.config.json, package.json, webpack.config.js.
• The “src” directory includes Vue components (e.g., App.vue) and JavaScript libraries (flv.js, hls.js) for media handling.
• index.html and server.js indicate that this layer might serve static assets or run a lightweight Node-based server.
• Backend (src/main Directory):
• Organized as a standard Maven/Spring Boot project with pom.xml at the root of the backend.
• Java packages include controllers, services, security, ffmpeg operations, exception handling, data access objects (mappers), and configurations.
• Key components include HongDouApplication (the Spring Boot main class), various WebSocket, Spring Security, and JWT-related classes, plus custom components for media handling (FFmpegUtils, TranscodeConfig).
• Resources contain configurations in application.yml, log4j2.xml, and MyBatis mapper XML files.
Key Architectural Components
a. Frontend Component:
• A Vue.js single-page application (SPA) that likely handles routing, UI, and direct video playback using libraries like flv.js and hls.js.
• Communicates with the backend via APIs and possibly WebSocket connections for synchronized viewing.
b. Backend Component:
• A Spring Boot application acting as the core REST API server.
• Several modules in the backend:
• Controllers: Expose REST endpoints for user management, video processing, and real-time synchronization (e.g., HelloController, UserController, UploadController).
• Security Module: Managed via SpringSecurityConfig, custom authentication providers, JWT filters, LDAP authenticators, and login filters to control access and authentication.
• Database Access: Uses MyBatis (evident from UserMapper.xml, RoleMapper.xml and DAO packages) for persistent storage of user data, roles, etc.
• WebSocket Services: Classes like WebSocketConfig and WebSocketService to support real-time communication for synchronized video sessions.
• FFmpeg Module: Provides video transcoding and media processing functionalities (FFmpegUtils, TranscodeConfig, MediaInfo).
• Exception Handling & Logging: GlobalExceptionHandler, WebLogAspect for managing errors and logging behaviors.
c. Integration & External Components:
• Potential integration with external services for LDAP authentication (shown by the LDAP-related providers) and possibly cloud storage for uploads.
• The use of JWT and WebSocket hint at real-time and secure communications across the system.
Architectural Patterns and Technologies
• MVC Pattern: The separation within the Spring Boot application (Controllers, Services, DAOs) and the Vue frontend follows an MVC approach.
• Security and Real-time Communication: Emphasize the integration of Spring Security, JWT, and WebSocket configurations.
• Media Processing: Highlight the use of FFmpeg-based utilities for video transcoding.
• Technologies & Frameworks:
• Frontend: Vue.js, Webpack, Babel, and associated media libraries.
• Backend: Spring Boot, Spring Security, MyBatis, JWT, WebSocket, and FFmpeg integrations.
• Build and Packaging: Maven (pom.xml) and Node Package Manager (package.json).