Online Education Platform Development with Java, Spring Boot, and Vue.js

Project Background

The evolution of digital technologies has transformed education through online platforms that overcome traditional limitations. These systems enable flexible learning, global collaboration, and personalized educational experiences while promoting resource sharing and accessibility.

Technology Stack

Spring Boot Backend

Spring Boot simplifies Java application development with embedded servers, auto-configuration, and extensive plugins. Its ecosystem includes Spring Data and Spring Security, enabling rapid development of scalable systems.

Vue.js Frontend

Vue.js employs reactive data binding and virtual DOM technology to create efficient user interfaces. Its component-based architecture facilitates maintainable and responsive web applications.

MySQL Database

MySQL provides a robust open-source relational database solution with cross-platform compatibility. Its transactional support and indexing capabilities ensure efficient data management for web applications.

System Testing Methodology

Comprehensive black-box testing validates system functionality through simulated user interactions. Test scenarios include boundary value analysis and validation checks to ensure system reliability and usability.

Authentication Testing

Login functionality requires verification of credentials, role-based access controls, and input validation. Negative tests confirm proper error handling for invalid credentials.

User Management Testing

User operasions undergo validation checks for create, update, and delete functionality. Tests verify uniqueness constraints, mandatory field enforcement, and confirmation workflows.

Token Authentication Implementation

@PostMapping("/authenticate")
public ResponseEntity<?> authenticateUser(@RequestParam String username, 
                                          @RequestParam String password) {
    UserEntity account = userRepository.findByUsername(username);
    if (account == null || !account.getPassword().equals(password)) {
        return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
               .body("Invalid credentials");
    }
    String accessToken = tokenProvider.createToken(account.getId(), account.getRole());
    return ResponseEntity.ok().body(Map.of("accessToken", accessToken));
}

@Service
public class TokenProvider {
    public String generateToken(Long userId, String role) {
        TokenRecord tokenRecord = tokenRepository.findByUserId(userId);
        String tokenValue = generateRandomString(32);
        Date expiry = calculateExpiry(1);
        
        if (tokenRecord != null) {
            tokenRecord.setTokenValue(tokenValue);
            tokenRecord.setExpiryDate(expiry);
        } else {
            tokenRecord = new TokenRecord(userId, role, tokenValue, expiry);
        }
        tokenRepository.save(tokenRecord);
        return tokenValue;
    }
}

Security Interceptor Implementation

@Component
public class AuthInterceptor implements HandlerInterceptor {
    @Autowired
    private TokenProvider tokenProvider;

    @Override
    public boolean preHandle(HttpServletRequest request, 
                             HttpServletResponse response, 
                             Object handler) {
        response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
        // Handle OPTIONS requests
        if (request.getMethod().equals("OPTIONS")) {
            response.setStatus(HttpStatus.OK.value());
            return false;
        }

        String authToken = request.getHeader("Authorization");
        if (StringUtils.isBlank(authToken)) {
            sendError(response, "Authentication required");
            return false;
        }

        TokenRecord token = tokenProvider.validateToken(authToken);
        if (token != null) {
            request.getSession().setAttribute("userId", token.getUserId());
            request.getSession().setAttribute("userRole", token.getRole());
            return true;
        }
        
        sendError(response, "Invalid session");
        return false;
    }

    private void sendError(HttpServletResponse response, String message) {
        response.setContentType("application/json");
        try (PrintWriter writer = response.getWriter()) {
            writer.write(new JSONObject().put("error", message).toString());
        } catch (IOException e) {
            // Handle exception
        }
    }
}

Database Schema

CREATE TABLE auth_token (
    id BIGINT AUTO_INCREMENT PRIMARY KEY,
    user_id BIGINT NOT NULL,
    user_role VARCHAR(50) NOT NULL,
    token_value VARCHAR(200) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    expires_at TIMESTAMP NOT NULL
);

INSERT INTO auth_token (user_id, user_role, token_value, expires_at) 
VALUES (1001, 'admin', 'a1b2c3d4e5f6', '2023-12-31 23:59:59');

Tags: Spring Boot Vue.js MySQL Online Education java

Posted on Wed, 29 Jul 2026 16:53:42 +0000 by wowiz