How nhatnhudinh/golden-finger works
Project Type and Purpose
• Project Type: This is a full-stack e-commerce web application built with Jakarta EE.
• Purpose: It provides two distinct experiences—a customer-facing shop interface and an administrative dashboard for managing products, orders, users, categories, suppliers, and sales analytics. Additionally, it integrates external services like VNPay for payment processing and uses SQL Server for data persistence.
File Structure to Identify Main Components
• src/java – Contains the application’s backend logic:
• Controller packages: Separate controllers for admin, shop, and user interfaces (e.g., AdminHomeServlet, LoginServlet). They serve as the entry points for HTTP requests.
• DAL (Data Access Layer): DAO classes (e.g., CategoryDAO, OrderDAO, ProductDAO) handle database interactions.
• Model: Entity classes representing domain objects (e.g., Product, Order, User).
• Filter: Request filters (AdminFilter, HomeFilter) enforce authentication and authorization.
• Utils: Utility classes (DBConnect, PasswordUtils, ServletUtils) for common functionality.
• Config and common classes: For payment configuration and VNPay integration.
• web – Contains all web assets:
• JSP pages for both storefront (shop.jsp, product.jsp, checkout.jsp, etc.) and admin dashboard (dashboard folder).
• Assets (CSS, JS, images) that reflect both customer (Tailwind, jQuery) and admin (custom JS/CSS) interfaces.
• WEB-INF configuration: Including web.xml and context.xml, which set up servlet mappings and deploy configurations.
• lib – External libraries (e.g., Jakarta EE libraries, SQL Server JDBC driver, Gson, JAXB, etc.) that support various functionalities.
• build.xml and nbproject – Build configurations (Ant scripts and NetBeans project files) that indicate the Java and Jakarta EE technologies in use.
• script.sql – Contains the SQL scripts for initializing the SQL Server database.
System’s Main Components and Their Interactions
• Client Applications (Presentation Layer):
• Web Browser: Users access the e-commerce website through JSP pages.
• Separate interfaces for customers (shopping, cart, checkout, profile) and admins (dashboard, order management, product management).
• Web Server / Application Server:
• Jakarta EE Container (e.g., Apache Tomcat or similar) that hosts the application.
• Servlet Controllers handle incoming HTTP requests and determine whether they go to the customer-facing or admin sections.
• Business Logic and Middleware:
• Controller Layer: Segregates functionality for shop, user, and admin operations.
• Filters: Enforce security (authentication, session management) before reaching the controllers.
• Utility Modules: DBConnect for establishing database connections and PasswordUtils for secure password processing.
• Data Access Layer:
• DAO Classes: Abstract interactions with the SQL Server database, handling CRUD operations on models.
• Database:
• SQL Server Database: Stores all data including user accounts, orders, products, categories, suppliers, etc.
• script.sql for setting up initial schema and data.
• External Services:
• VNPay Integration: Configured within the application (via Config.java) for handling payment transactions.
• Email (javax.mail): For notifications, password recovery, etc.
Architectural Patterns and Design Principles
• MVC Pattern: The separation of concerns is visible with JSP views, servlet controllers, and DAO/model backends.
• Layered Architecture: Clear demarcation between presentation, business logic, data access, and integration layers.
• Role-Based Access Control: Implemented via filters and distinct servlet controllers ensuring security.
• Modular Design: Separate packages for controllers, models, DAL, and utilities promote a clean, maintainable codebase.