How nhnamdev/phone_repair_jsp works
1. Overall shape
- This is a Java Maven web application packaged as a WAR and deployed on a servlet container.
- The app uses a classic MVC-style JSP/Servlet architecture with a MySQL-backed persistence layer.
2. Primary business domain
- The core product is a phone repair appointment booking website.
- Main user capabilities include browsing products/services, filtering/searching devices, booking consultations/appointments, checking repair status, paying, applying vouchers, and managing account/password recovery.
- Main admin capabilities include managing users, products, devices, manufacturers, orders, appointments, vouchers, repair issues, consultations, and payment history.
3. Presentation layer
- Runtime UI lives under src/main/webapp/WEB-INF/views as JSP pages.
- The UI is split into two major portals:
- User-facing pages under views/user
- Admin pages under views/admin
- Shared fragments such as header, footer, sidebar, and generic content blocks are in views/header_footer and views/components.
- Static assets are under src/main/webapp/resources for CSS, JS, and images.
4. Request handling layer
- Controllers are in dao/controller, despite the package name: they are the actual HTTP entry points.
- They are also split by role:
- controller/User for customer workflows
- controller/AdminContronller for admin workflows
- These controllers coordinate navigation, form submission, and page-to-page flow, usually forwarding to JSPs or redirecting after mutations.
5. Access control boundary
- There is an AdminFilter in dao/controller/filter.
- This likely protects administrative routes and acts as the main boundary between authenticated admin access and the public/user side.
6. Service layer
- The service package provides business logic above the DAOs.
- Services present in the repo include:
- UserService
- ProductService
- AppointmentService
- VoucherService
- DescriptionService
- ResetPasswordService
- This is where domain rules are likely centralized instead of being embedded directly in controllers.
7. Persistence layer
- Data access is organized into two DAO groups:
- dao/UserDao for user-side flows
- dao/AdminDao for admin-side management
- DAOs map closely to domain features: users, appointments, invoices, payment history, vouchers, search/filtering, device issues, and admin dashboards.
- The app uses JDBI for database access, backed by MySQL.
8. Domain model
- Domain entities live in dao/model.
- Important entities include:
- User, Product, Voucher
- Appointment, ConsulationAppointment
- Order, Invoice, InvoiceDetails, PaymentHistory
- Device, DeviceInfo, Issue, DeviceIssue
- Manufacturer, Store
- PasswordResetToken, HashMD5
- These models define the data exchanged between controllers, services, and DAOs.
9. Key user flows
- Discovery flow: home page → product detail → filtering/searching → issue-specific device pages.
- Booking flow: user selects a repair issue/service → fills appointment/contact details → books consultation/repair.
- Payment flow: checkout/payment pages create invoices and payment history records.
- Account flow: registration, login, profile/account management, password change, forgot/reset password.
10. Key admin flows
- Admin pages support CRUD-style management of:
- products and devices
- manufacturers
- users/customers
- vouchers
- repair issue definitions
- appointments and consultation requests
- orders, invoices, and payment history
- There are dedicated pages and controllers for “add/update” operations, suggesting the admin side is the operational control plane of the system.
11. External/infrastructure concerns
- Database connection settings are externalized in src/main/resources/db.properties, with connection helpers in dao/db.
- JDBIConnect is the central DB connector; DBProperties likely loads the MySQL credentials/configuration.
- The presence of jakarta.mail suggests email is used for password reset or similar account recovery flows.
12. Uploads and media
- FileUploadUtil indicates the admin side supports file uploads, most likely for product/device images.
- Image assets are stored in multiple categorized folders under resources/img, aligning with product groups and repair-issue categories.
13. Error handling and deployment
- Custom error pages are defined in WEB-INF/error-404.jsp and WEB-INF/error-502.jsp.
- web.xml is present, so servlet mappings, filters, and error-page configuration are likely declared there rather than using annotation-only configuration.
14. Important repo note for diagramming
- The GiuaKi/ directory contains mostly static HTML/CSS/JS prototypes or source assets that mirror the JSP application structure.
- For architecture diagrams, the runtime system should be drawn from src/main/..., with GiuaKi/ treated as supporting/static design material rather than the deployed application path.
Main entry points: WebDatLichSuaDienThoai Phone Repair App · UserDao User DAO · User User controllers · AdminContronller Admin controllers
Components 19
Presentation
JSP views and static assets for user/admin portals
- User portal · Customer-facing pages for browsing, booking, payment, and account flows
WebDatLichSuaDienThoai/src/main/webapp/WEB-INF/views/user - Admin portal · Back-office pages for managing catalog, orders, bookings, vouchers, and history
WebDatLichSuaDienThoai/src/main/webapp/WEB-INF/views/admin - Shared fragments · Header, footer, sidebar, and reusable content blocks
WebDatLichSuaDienThoai/src/main/webapp/WEB-INF/views/header_footer - Static assets · Stylesheets, scripts, and uploaded/display images for the web UI
WebDatLichSuaDienThoai/src/main/webapp/resources
Controllers
HTTP entry points and route handlers
- User controllers · Public/customer HTTP flows for search, booking, payment, and account management
WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/controller/User - Admin controllers · Administrative HTTP flows for CRUD and operational management
WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/controller/AdminContronller - Admin filter · Protects admin routes and gates administrative access
WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/controller/filter/AdminFilter.java
Services
Business logic and domain orchestration
- User service · User/account-related business logic
WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/service/UserService.java - Product service · Catalog and product-side business rules
WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/service/ProductService.java - Appointment service · Booking and consultation orchestration
WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/service/AppointmentService.java - Voucher service · Voucher validation and application logic
WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/service/VoucherService.java - Reset service · Password recovery and reset flow logic
WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/service/ResetPasswordService.java
Persistence
DAO layer and model objects
- User DAO · Persistence for customer accounts and user-facing flows
WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/UserDao - Admin DAO · Persistence for admin dashboards and management workflows
WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/AdminDao - Domain models · User, product, booking, invoice, device, voucher, and reset-token models
WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/model
Infrastructure
Database access, filters, deployment config
- DB connector · Central database connection and configuration loader
WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/db/JDBIConnect.java - DB properties · Externalized MySQL connection settings
WebDatLichSuaDienThoai/src/main/resources/db.properties - Web config · Servlet, filter, and error-page mapping configuration
WebDatLichSuaDienThoai/src/main/webapp/WEB-INF/web.xml
Other components
- Phone Repair App · Servlet-based JSP application for phone repair booking and admin operations
WebDatLichSuaDienThoai
Connections 27
- Phone Repair App → User portal: renders · Customer pages served from JSP views
- Phone Repair App → Admin portal: renders · Admin pages served from JSP views
- Phone Repair App → Shared fragments: includes · Shared JSP fragments used across portals
- Phone Repair App → Static assets: serves · Static CSS, JS, and images
- Phone Repair App → User controllers: routes to · Public request handlers
- Phone Repair App → Admin controllers: routes to · Administrative request handlers
- Phone Repair App → Web config: configured by · Servlet and error-page mappings
- Admin filter → Admin controllers: guards · Protects admin endpoints
- User controllers → User service: calls · Delegates business logic
- User controllers → Appointment service: calls · Booking and consultation actions
- User controllers → Voucher service: calls · Voucher application flow
- User controllers → Reset service: calls · Forgot/reset password flow
- Admin controllers → Product service: calls · Catalog management actions
- Admin controllers → Appointment service: calls · Booking management actions
- Admin controllers → User service: calls · User management actions
- User service → User DAO: uses · Reads and writes account data
- Product service → User DAO: uses · Reads product and search data
- Appointment service → User DAO: uses · Persists appointments and payments
- Voucher service → User DAO: uses · Reads voucher data
- Reset service → User DAO: uses · Stores reset tokens and updates passwords
- Admin controllers → Admin DAO: uses · Admin CRUD and reporting persistence
- User DAO → Domain models: maps · DAO objects exchanged as entities
- Admin DAO → Domain models: maps · Admin-side entities and records
- User DAO → DB connector: connects · Uses central JDBI connection
- Admin DAO → DB connector: connects · Uses central JDBI connection
- DB connector → DB properties: loads · Reads external MySQL settings
- Reset service → User controllers: email flow · Password recovery may trigger mail-based reset flow