How codeurjc-daw-2024-25/webapp05 works
Project Components and Purpose
• Recognize that AlphaGym is a full-stack web application targeting a gym environment. Its primary purpose is to manage user profiles, offer personalized training and nutrition plans, enable comments on these plans, generate PDFs, and handle security (authentication/authorization with JWT and Spring Security).
• The README outlines both the web-based interfaces (templates, controllers for web navigation) and the REST APIs that expose business functionality as JSON endpoints. In addition, there is a clear separation of roles (anonymous, registered, admin) that affects how data is handled and which endpoints each user can access.
Main Components
a. Presentation Layer:
• Web controllers (@Controller) and template files (HTML pages, static resources like CSS, JS, images).
• REST API endpoints provided by @RestController classes (for Nutrition, Training, Comments, and User management).
b. Business/Service Layer:
• The service classes that implement business logic for entities (NutritionService, TrainingService, UserService, etc.).
c. Data Access Layer (Persistence):
• Spring Data repositories (UserRepository, NutritionRepository, TrainingRepository, etc.) managing CRUD operations with a MySQL database.
d. Domain Model:
• Entity classes such as User, Nutrition, Training, TrainingComment, NutritionComment, along with DTOs coming via mappers.
e. Security and Authentication:
• Security configuration setup (WebSecurityConfig, JWT filters, LoginController, and related security classes).
f. Integration Components:
• PDF generation for nutrition and training plans.
• External dependencies such as Docker containers (Dockerfile, docker-compose) for deployment and environment configuration.
g. API Documentation:
Relationships and Interactions
• Directional flows:
• From the client (browser or API consumer) to the Presentation Layer (web pages and REST endpoints).
• From Controllers to their respective Service classes where business logic is applied.
• From the Service layer to the Repository layer for CRUD operations with MySQL.
• From the Service layer back up to Controllers where responses (data, PDFs, error messages) are built.
• Additional flows such as the integration of security mechanisms where authentication requests pass through JWT filters and the Security configuration.
• API documentation consumption and Docker deployment where the application container interacts with external configuration (ports, environment variables).
Architectural Patterns and Design Principles
• Reinforce the Model-View-Controller (MVC) pattern present in the web controllers and view templates.
• The RESTful API design that exposes similar functionality nearly parallel to the MVC controllers.
• Separation of concerns is clearly seen in dividing responsibilities among controllers, services, repositories, and security classes.
• Use of DTOs and Mappers to decouple the entity model from external representations.
Technologies and Frameworks
• Java (version 21.0.5), Spring Boot (3.4.3) for the backend application.
• MySQL (8.0.33) for database management.
• Maven for build and dependency management.
• Docker for containerization and deployment.
• PDF generation libraries as part of the business logic.
• Frontend technologies include HTML/CSS/JavaScript.