How ntramanh1204/bookstore-web works
Main Components
• Client/Browser: Users interact via web browsers, viewing JSP pages (in the “web” directory) that include HTML, CSS, and JavaScript.
• Web Server/Servlet Container: The application is deployed on Apache Tomcat. The server processes HTTP requests and serves the JSP pages.
• Controller Layer: All the Servlet files under “src/java/controller” manage incoming HTTP requests and coordinate responses. There are also filters (in “src/java/filter”) for cross-cutting concerns like login and home redirection.
• Business Logic/Model Layer: The packages under “src/java/model” (and some classes under “abundant”) represent the data models such as Account, Cart, Order, etc.
• Data Access Layer (DAL): Classes in “src/java/dal” (e.g., AccountDAO, CartDAO, OrderDAO) are responsible for interacting with the Microsoft SQL Server database. The database schema and data are set up using the provided BookDatabase.sql script.
• External Components: There is also supporting functionality like Selenium-based data crawling (via the Jupyter notebook in “scripts/crawl-best-books-final.ipynb”) that was used to populate the database, and static resources (images, CSS, JS) are located under “web” for both user and admin interfaces.
• Build & Deployment: Build scripts (Ant’s build.xml and nbproject files) are used for compiling and deploying the application. The “dist” folder generates both a .jar and a .war, indicating multiple deployment options.
Relationships and Interactions
• Clients send HTTP requests to the Tomcat server.
• The server forwards these requests to the appropriate Servlet controllers.
• Controllers (e.g., HomeServlet, LoginServlet, CartServlet) process the requests, invoke corresponding methods in the Business/Model layer, and may interact with the DAL to perform CRUD operations on the SQL Server.
• After processing, the controllers dispatch the responses (via JSP views) that are rendered back on the client side.
• Filters intercept requests to enforce session management or route unrecognized URLs to a “NotFound” page.
• The build and deployment process (via Ant and the project’s nbproject configuration) packages the application for Tomcat deployment.
Architectural Patterns and Technologies
• MVC Pattern: The clear separation between JSP views, Servlets controllers, and model/DAO classes suggests an MVC pattern.
• Layered Architecture: Front-end (views), controller/servlets, business logic, and data access layers are well-defined.
• Technologies: Java, Servlets, JSP, Bootstrap 5, and SQL Server (using sqljdbc42.jar), with build and deployment managed via Apache Ant and NetBeans project configuration.
Final Elements
• Clear and descriptive labels for every component/block (e.g., “Client Browser”, “Apache Tomcat”, “Controllers (Servlets)”, “Business Model/DAO”, “SQL Server Database”).
• Optionally, include notes on external tools for data crawling (linking the Selenium/Jupyter Notebook component to initial database population).