How tqchuong/thuctapweb works
Main Components
• User Interface / Web Presentation Layer: Represented by the JSP files (e.g., home.jsp, login.jsp, products.jsp, etc.), HTML files, CSS, JavaScript (in the “src/main/webapp” directory). This layer provides the client-side experience.
• Controller Layer: Mainly the Java classes in the “controller” package. This includes numerous servlet controllers (e.g., LoginController, CheckoutServlet, ProductController) that handle incoming HTTP requests and route them appropriately. Also include the admin sub-package and the cart controllers.
• Business Logic / Service Layer: Although there is only one service class (ProductService.java) explicitly visible, it represents where business logic resides. This layer could be expanded as the project evolves.
• Data Access Layer (DAO): All the DAO classes (e.g., CouponDAO, ProductDAO, OrderDao, etc.) and the DB connection class (DBConnect.java) form the persistence component that interacts with the underlying database.
• Domain/Model Layer: The POJOs in the “model” package (e.g., Products, Order, Users, etc.) are used by both service and DAO layers to represent business entities.
• Utility and Configuration Components: Filters (AuthenticationFilter.java, AdminFilter.java, etc.), configuration files (db.properties), and utility classes (PasswordUtils, SessionManager, TokenGenerator) help with authentication, session management, and general configuration.
• External Services and Resources: Although not explicitly described in the README, the project implies integration with payment services (e.g., VNPay endpoints) and external assets like fonts and images.
Relationships and Interactions
• From each Controller, illustrate calls to the Service Layer, which handles the business logic.
• The Service Layer then interacts with the DAO classes (Data Access Layer) to perform CRUD operations in the database.
• The DAO layer communicates with the Database using configuration details from the db.properties file (managed by DBConnect.java).
• Additionally, illustrate filters (e.g., AuthenticationFilter, AdminFilter) intercepting requests before they hit the controllers, ensuring security and proper session management.
• Components for static resources (JS, CSS, images, fonts) which are served to the client along with dynamic content from JSP pages.
Architectural Patterns and Technologies
• Model-View-Controller (MVC): The separation into JSP (views), Servlets (controllers), and Java model/logic (models, services, DAO) is a clear indication of the MVC pattern.
• Maven is used for build and dependency management (as seen with the pom.xml and Maven wrapper files).
• Java Servlet API is used extensively across controllers and filters.
• The project’s organization into packages (controller, dao, model, service, utils) demonstrates modular design and separation of concerns.