How thinh77/student-management works
Project Type & Purpose
• This is a full-stack web application focused on managing students, courses, classes, trainers, and related user accounts.
• The backend is implemented using Spring Boot (with controllers, services, repositories, DTOs, and validations), and there is a frontend layer with static assets (HTML, CSS, JavaScript) provided in both the “fe” folder and under “src/main/resources/templates” and “static.”
• Security, exception handling, and custom validations are also integrated, suggesting a robust, modular design following typical multi-layered (MVC) architecture patterns.
Breaking Down the File Structure into Main Components
A. Frontend Components:
– “fe/” folder: Contains standalone static pages (e.g., 404.html, new_trainer.html) and associated assets like script.js and CSS files.
– “src/main/resources/static”: Hosts additional CSS, JavaScript, and images for the UI.
– “src/main/resources/templates”: Holds Thymeleaf (or similar templating engine) HTML pages for different roles and parts of the system (admin, auth, class, course, student, trainer).
B. Backend Components:
i. Controllers (Presentation Layer):
• Located under src/main/java/org/example/springbootpractice/controller.
• AdminController, AuthController, ClassController, CourseController, StudentController, and UserController.
ii. Services (Business Logic Layer):
• Interfaces in the “service” package and concrete implementations in “service/impl”.
• Examples include AccountServiceImpl, ClassServiceImpl, CourseServiceImpl, and StudentServiceImpl.
iii. Repositories (Data Access Layer):
• Found under the “repository” package to handle database interactions (e.g., AccountRepository, ClassRepository, CourseRepository, etc.).
iv. Domain/Entities & DTOs:
• Domain models under “entity” and data transfer objects under “dto” that map the business objects.
• Request DTOs are in a subpackage “dto/requestDto”, which represent the incoming data for creating or updating resources.
v. Configuration & Cross-Cutting Concerns:
• “config” folder: Contains various configuration classes such as SecurityConfig, GlobalExceptionHandler, custom authentication handlers, NoCacheFilter, and ModelMapperConfig.
• “validation”: Contains custom validation annotations and corresponding validators for unique emails, past dates, etc.
C. Build & Deployment Artifacts:
– Gradle configuration files (build.gradle, settings.gradle) and Gradle wrapper files.
– GitHub workflow files (.github/workflows/gradle.yml) are used for CI/CD processes.
Relationships & Interactions
• The user's browser interacts with the Frontend, which loads static pages (from either “fe” or templates) and makes HTTP requests (as forms submissions or AJAX calls) to the backend.
• HTTP requests are initially received by Controllers. For example:
– Login and registration requests are handled by AuthController.
– Course, student, and class management actions are routed to their respective controllers.
• Controllers invoke the corresponding Service layer (AccountService, StudentService, etc.) to perform business logic.
• The Service layer uses Repository interfaces to access and modify data in the database (while not explicitly visible, there’s an assumed external database per the application.properties file).
• Custom validations, exception handling, and security (via classes in “config” and “validation”) are applied throughout the request-processing pipeline.
Important Architectural Patterns & Technologies to Highlight
• MVC Pattern: Clear separation into controllers (presentation), services (business logic), and repositories (persistence).
• Dependency Injection: Managed by Spring Boot (e.g., wiring of controllers, services, repositories).
• Security: Handled via the custom security configuration and authentication handlers.
• Validation & Exception Management: Custom validators and a global exception handler ensure data integrity and consistent error messaging.
• Frontend Separation: Both static assets (in “fe” and “src/main/resources/static”) and dynamic server-rendered views (in “src/main/resources/templates”) are managed accurately.