How kl3init/coursehub-backend works
Project Type and Purpose
• CourseHub Backend is a monolithic Spring Boot 3.4.5 application providing RESTful APIs and WebSocket endpoints for an online course management platform.
• It handles user authentication/authorization, course/lesson/module CRUD, payment processing, analytics, real-time comments/notifications, email OTP, and AWS S3 file storage.
Top-Level Components
• Reverse Proxy: Nginx (SSL termination, routing)
• Application Container: Spring Boot service
• Web MVC layer (Controllers)
• Service layer (business logic, schedulers, components)
• Persistence layer (Repositories → MySQL, Redis cache)
• Database: MySQL
• Cache: Redis
• External Integrations:
• AWS S3 for media uploads
• Gmail SMTP for OTP/email
• OAuth2 Google for login
• SePay/TPBank payment gateway (webhook)
• Certbot container for Let’s Encrypt certificates
Relationships & Data Flows
• Client (Frontend/browser/mobile) → HTTPS → Nginx → Spring Boot Controllers
• Controllers → Services → Repositories → MySQL (stateful data)
• Services → Redis (caching, OTP storage)
• Service components (e.g., DiscountScheduler) run on scheduler thread → update DB
• WebSocketConfig exposes ws:// endpoints → push notifications/comments in real time
• AuthenticationService → Gmail SMTP (via JavaMailSender) for OTP
• File upload endpoints → S3Service → AWS S3 (pre-signed URL)
• PaymentController → external SePay API + webhook callback → PaymentService
• Actuator endpoints → health/metrics
Architectural Patterns & Principles
• Layered Architecture (Controller → Service → Repository)
• DTO/Converter pattern for request/response mapping
• Centralized configuration via @Configuration classes (AppConfig, SecurityConfig, AwsConfig, RedisConfig, etc.)
• Scheduled tasks (DiscountScheduler) for time-based jobs
• Exception handling via @ControllerAdvice (GlobalExceptionHandler)
• WebSocket handshake customization (CustomHandshakeHandler)