How b20dcat186trandangthuc/learforwork-java-spring-mvc works
Main Components
• Bootstrapping & Configuration:
• LaptopshopApplication.java serves as the main entry point.
• The config package (with classes such as SecurityConfiguration.java, WebMvcConfig.java, and CustomSuccessHandler.java) encapsulates the application’s security, MVC, and any custom behaviors.
• Controller Layer:
• Separated into “admin” and “client” controllers.
• Under “src/main/java/org/example/laptopshop/controller”, you have packages for admin (DashboardController, OrderController, ProductController, UserController) and client (HomePageController, ItemController) which handle requests from the respective segments of the application.
• Service Layer:
• Contains business logic (OrderService, ProductService, UserService, UploadService, and a CustomUserDetailsService for authentication details).
• Validation services under the “validator” subpackage enforce domain-specific rules.
• Data (Repository/Domain) Layer:
• Domain models (such as Cart, Order, Product, User, etc.) interpret data.
• Repository interfaces handle persistence (like CartRepository, OrderRepository, ProductRepository, and UserRepository).
• Presentation Layer (View & Assets):
• JSP files under “src/main/webapp/WEB-INF/view” offer the UI for both admin and client interfaces.
• Static resources—CSS, JavaScript, images, and external libraries—are stored in subdirectories beneath “src/main/webapp/resources” and “src/main/webapp/resources/client”.
Relationships and Interactions
• Repository layer and Domain models below the service layer as the data persistence mechanism.
• Lastly, include the configuration/bootstrapping element (LaptopshopApplication and configuration classes) as the foundation that initializes all these components.
Architectural Patterns and Technologies
• Separation of Concerns: Emphasize how controllers delegate to services, which in turn interact with repositories.
• Web Security: Include the security configuration as a critical cross-cutting concern.