How kyuu-302/ea103g4 works
Project Type and Purpose
• This is a full-stack Java EE web application (“Bookshop Project”) built on Apache Tomcat, with JSP/Servlet front-end and back-end, MVC layering, Oracle and Redis as data stores, plus WebSocket chat and scheduled tasks. The purpose is to run an online bookshop with customer shopping, reviews, book clubs, forums, admin panels, promotions, recommendation engine, and real-time features.
File Structure Analysis
• WebContent/: all static assets and JSPs, split into front-end/ and back-end/ subfolders for user-facing and admin consoles.
• src/: Java source organized by package:
• com.*.controller – Servlets and WebSocket endpoints
• com.*.service – business logic
• com.*.model/dao – DAO interfaces and implementations (JDBC, JNDI)
• filters/, listeners/, timers/, tools/, util/ – cross-cutting code (auth filters, startup listeners, scheduled tasks, helpers).
• WEB-INF/lib/: third-party JARs (JDBC drivers, Redis/Jedis, JSON, commons-*, WebSocket API).
• Configuration: web.xml for servlet mapping; build/run on Tomcat; Git integration; tests in src/tests.
README Insights
• Technologies: Java, JSP, AJAX, jQuery, Bootstrap, WebSocket, CKEditor; Oracle + Redis; Tomcat on GCP.
• Features: product/catalog management, user/account, orders, reviews, book clubs (with real-time chat and notifications), forums, promotions, recommendations, scheduled statistics/promotions.
a. Main Components
• Presentation Layer
– Front-end JSP pages + CSS/JS assets
– Back-end admin JSP pages
• Controller Layer
– Servlets (com.*.controller)
– WebSocket endpoints for chat/notifications
• Service Layer
– Business logic classes (com.*.service)
• Data Access Layer
– DAO interfaces + JDBC/JNDI implementations
• Databases
– Oracle RDBMS (persistent storage)
– Redis cache (session data, pub/sub, temporary data)
• External Services
– SMTP/Gmail for email
– SMS gateway for password recovery
• Infrastructure
– Apache Tomcat on GCP
– Scheduled tasks (PromoTimerTask, StatisticsTimerTask)
b. Relationships & Data Flow
1. Browser → HTTP request → JSP/View (WebContent)
2. JSP invokes a Servlet → Controller processes request
3. Controller calls Service layer → business logic
4. Service calls DAO → interacts with Oracle or Redis
5. DAO returns data → Service → Controller → JSP response
6. WebSocket channels connect browser ↔ server endpoint for real-time chat/notifications
7. Timer tasks triggered by ServletContextListener on server to perform scheduled DB/cache operations
c. Architectural Patterns
• MVC: clear separation of View (JSP), Controller (Servlets), Model/Service
• DAO pattern for data access abstraction (supports JDBC and JNDI lookup)
• Singleton or Factory for JedisUtil (Redis connection pooling)
• Observer/pub-sub via WebSocket and Redis (for real-time notifications)
• Filter chain for authentication/authorization (SignInFilter, BackEndPermissionFilter)
d. Key Technologies & Frameworks
• Java Servlets/JSP, JDBC, JNDI
• Redis (Jedis) for caching, sessions, pub/sub
• WebSocket API for chat/notifications
• jQuery/AJAX, Bootstrap, CKEditor for rich UI
• Oracle database with PL/SQL triggers/stored procedures