ByteClass is a modular, feature-based Spring Boot application for managing e-learning courses, users, and interactive tasks. It showcases simple, but robust architecture, resilience, security, caching, and comprehensive testing.
-
User Module (
/api/user&/api/auth/login)- Register users (name, email, password)
- Update, delete, list users
- JWT-based authentication
-
Course Module (
/api/course)- Create, list, retrieve, update, delete courses
- Publish courses (requires at least one task of each type and continuous order)
-
Task Module (
/api/task)-
Create three task types for courses in BUILDING status:
- Open-text
- Single-choice (exactly one correct option)
- Multiple-choice (at least two correct options)
-
List tasks by course, retrieve task details
-
Automatic reordering when inserting a task at an existing position
-
-
Feature-Based Project is organized by feature (
user,course,task), each containing its own controllers, services, repositories, DTOs, and mappers. -
Clean Layers
- Controller: REST endpoints with validation, caching, security
- Application (Service / Strategy / Facade): business logic, transactions, resilience
- Repository: Spring Data JPA interfaces
- Port (DTOs / Mappers): MapStruct for entity ↔ DTO mapping
-
Module Decoupling Features interact via interfaces (
UserPort,CoursePort,TaskPort), exchanging only DTOs and primitive IDs—no direct entity coupling. -
Resilience Resilience4j integration (
@Resilient+ AOP) for rate limiting and circuit breaking. -
Security Spring Security OAuth2 Resource Server with JWT; role hierarchy ADMIN > INSTRUCTOR > STUDENT.
-
Caching Redis configured and used in controllers via
@Cacheable/@CacheEvict. -
Database Migrations Flyway scripts for MySQL schema (
V1__…throughV4__…_create_table_*.sql).
src/
├── main/
│ ├── java/…/byteclass/
│ │ ├── ByteClassApplication.java
│ │ ├── common/ # exceptions, handlers, utilities
│ │ ├── config/ # resilience, security, OpenAPI
│ │ └── feature/
│ │ ├── user/ # adapter/controller, service, domain, port
│ │ ├── course/ # adapter/controller, service, facade, domain, port
│ │ └── task/ # adapter/controller, service, strategies, domain, port
│ └── resources/
│ ├── db/migration/ # Flyway scripts
│ ├── application-*.properties
│ ├── app.key / app.pub
│ └── …
└── test/
├── java/…/byteclass/feature/
│ ├── user/… # UserControllerTest, UserServiceImplTest, etc.
│ ├── course/… # CourseControllerTest, CourseServiceImplTest, facade tests
│ └── task/… # TaskControllerTest, TaskServiceImplTest, strategy tests
└── resources/
└── application-test.properties (H2 in-memory)
- Language & Framework: Java 21, Spring Boot 3
- Persistence: Spring Data JPA (MySQL)
- Migrations: Flyway
- Security: Spring Security (OAuth2 Resource Server + JWT)
- Resilience: Resilience4j (rate limiter, circuit breaker)
- Mapping & Annotations: Lombok, MapStruct
- Caching: Spring Data Redis
- API Docs: Springdoc OpenAPI (Swagger UI)
- Build & Orchestration: Maven, Docker Compose(MySQL and Redis containers)
- Testing: JUnit 5, Mockito, AssertJ
-
Prerequisites
- Docker & Docker Compose
- Java 21+
- 3306 and 6369 ports free
-
Generate RSA Keys
./generate_keys.sh
-
Start Infrastructure
docker-compose up -d
-
Build & Run
./mvnw clean package ./mvnw spring-boot:run
Or simply run in your preferred IDE
-
Access
- API Base:
http://localhost:8080/api - Swagger UI:
http://localhost:8080/swagger-ui.html
- API Base:
- Unit Tests: JUnit 5 + Mockito + AssertJ
- Coverage: Services, Controllers, Strategies, Facades, Repositories
- Test Profile:
application-test.propertiesuses H2 in-memory database