How quyetdaika/bookstore works
1. This is a classic Java MVC-style bookstore web application built with Maven, JSP, and Servlets. The repository is split into three main layers: presentation in src/main/webapp, request handling in src/main/java/...Servlet, and persistence in src/main/java/bookstore/subsystem.
2. The presentation layer is JSP-heavy. Pages like index.jsp, login.jsp, register.jsp, cart.jsp, wishlist.jsp, checkout.jsp, product-detail.jsp, and search-results.jsp render the customer-facing site, while src/main/webapp/admin/* contains the admin UI. The all_component directory holds reusable JSP fragments such as headers, navbars, footers, sliders, and CSS includes.
3. Controller logic lives in servlet packages organized by feature:
- bookstore.user for authentication (LoginServlet, LogoutServlet)
- bookstore.user.customer for registration
- bookstore.user.admin for book management
- bookstore.cart for cart actions
- bookstore.wishlist for wishlist actions
These servlets are the HTTP entry points and likely forward to JSP views after performing business operations.
4. The domain model is minimal and centered on three entities in bookstore.entities: Book, CartItem, and User. These represent the key business objects passed between servlets, DAOs, and JSPs.
5. Persistence is abstracted through DAO interfaces in bookstore.subsystem.iface: IBookDAO, ICartDAO, IUserDAO, IWishlistDAO, plus IDBConnector. This creates a clear boundary between the web tier and storage implementation, making the data-access layer swappable.
6. The concrete database implementation is in bookstore.subsystem.mysqlsubsystem. MySQLConnector handles database connectivity, and the MySQL DAO classes (MySQLBookDAO, MySQLCartDAO, MySQLUserDAO, MySQLWishlistDAO) implement the interface contracts. The architecture is therefore database-backed, with MySQL as the operational datastore.
7. The main request/data flow is: browser request → servlet controller → DAO → MySQL database → servlet → JSP response. Cart and wishlist operations are broken into discrete actions such as add, remove, update, and bulk transfer between wishlist and cart, which suggests the application relies on session/user context plus database state.
8. Feature boundaries are clear:
- Authentication and account creation are handled separately from shopping actions.
- Cart and wishlist have their own servlet sets and DAO support.
- Admin book management is isolated under the admin package and admin JSPs.
This separation should be reflected as distinct subsystems in an architecture diagram.
9. The admin area has its own UI and flows. AddBookServlet and ViewBookServlet map to admin pages like add_book.jsp and all_books.jsp, indicating a management path for catalog maintenance separate from customer shopping paths.
10. src/main/resources/META-INF/persistence.xml and src/main/webapp/WEB-INF/web.xml are the key deployment/configuration files. web.xml defines servlet/webapp routing and startup behavior, while persistence.xml indicates the app also carries JPA-style persistence configuration, even though the visible implementation is DAO/MySQL-oriented.
11. The application is packaged as a standard Java web archive and runs on a servlet container rather than as a standalone server. mvnw, pom.xml, and the Maven wrapper indicate Maven manages build, dependencies, and test execution.
12. For diagramming, the important external boundary is the MySQL database. The other major boundary is the HTTP browser/client, which talks only to JSP-rendered pages and servlet endpoints; all business operations are server-side.
13. src/test/java/Test.java and src/main/java/TestServlet.java appear to be supporting/demo artifacts rather than core architecture. The core system is the bookstore flow around users, catalog, cart, and wishlist, with JSP/Servlet presentation and DAO-based persistence underneath.
Main entry points: webapp Storefront · iface DAO API · user Auth · admin Catalog Admin
Components 19
Presentation
Customer and admin JSP views
- Shared JSPs · Reusable headers, navbars, footers, and UI components
src/main/webapp/all_component - Storefront · Customer-facing pages for browsing, login, cart, wishlist, checkout, and search
src/main/webapp - Admin UI · Admin pages for catalog management
src/main/webapp/admin
Controllers
Servlet entry points
- Auth · Login and logout request handling
src/main/java/bookstore/user - Register · Customer account creation
src/main/java/bookstore/user/customer - Catalog Admin · Admin book add and listing flows
src/main/java/bookstore/user/admin - Cart · Add, remove, and update cart actions
src/main/java/bookstore/cart - Wishlist · Wishlist add/remove and transfer-to-cart actions
src/main/java/bookstore/wishlist
Domain
Core business entities
Persistence
DAO interfaces and MySQL implementations
- DAO API · Storage contracts for books, carts, users, wishlist, and DB connections
src/main/java/bookstore/subsystem/iface - MySQL Connector · Creates and manages database connectivity
src/main/java/bookstore/subsystem/mysqlsubsystem/MySQLConnector.java - MySQL DAOs · Concrete MySQL implementations for book, cart, user, and wishlist persistence
src/main/java/bookstore/subsystem/mysqlsubsystem
Config
Build and deployment configuration
- web.xml · Servlet routing and webapp configuration
src/main/webapp/WEB-INF/web.xml - persistence.xml · JPA-style persistence configuration
src/main/resources/META-INF/persistence.xml - Maven Build · Project build and dependency management
pom.xml
Other components
- Browser · HTTP client using rendered JSP pages
- MySQL DB · Operational datastore
Connections 27
- Browser → Storefront: browse · Users load storefront pages
- Browser → Admin UI: admin · Admins use management pages
- Storefront → Shared JSPs: includes · Storefront pages reuse common components
- Admin UI → Shared JSPs: includes · Admin pages reuse shared UI pieces
- Storefront → Auth: submit · Login and account actions post to servlets
- Storefront → Register: submit · Registration posts to servlet
- Storefront → Cart: actions · Cart operations originate from storefront views
- Storefront → Wishlist: actions · Wishlist operations originate from storefront views
- Admin UI → Catalog Admin: actions · Admin catalog actions post to servlet controllers
- Auth → DAO API: uses · Auth controllers read/write through DAO contracts
- Register → DAO API: uses · Registration relies on user persistence contract
- Catalog Admin → DAO API: uses · Admin catalog flows use book DAO contract
- Cart → DAO API: uses · Cart flows use cart DAO contract
- Wishlist → DAO API: uses · Wishlist flows use wishlist DAO contract
- DAO API → MySQL DAOs: implemented by · MySQL classes realize the DAO interfaces
- MySQL DAOs → MySQL Connector: connects via · DAO implementations acquire database connections
- MySQL Connector → MySQL DB: reads/writes · Connector talks to the MySQL datastore
- Auth → User: maps · Authentication uses user model
- Register → User: creates · Registration creates user records
- Catalog Admin → Book: manages · Catalog management centers on books
- Cart → CartItem: manages · Cart actions operate on cart items
- Wishlist → Book: tracks · Wishlist stores books for later purchase
- web.xml → Auth: routes · Deployment descriptor maps servlet endpoints
- web.xml → Catalog Admin: routes · Deployment descriptor maps admin endpoints
- persistence.xml → MySQL Connector: configures · Persistence settings accompany database access
- Maven Build → web.xml: packages · Build assembles the web archive
- Maven Build → persistence.xml: packages · Build includes persistence configuration