# nhnamdev/phone_repair_jsp architecture

> Architecture diagram of the GitHub repository nhnamdev/phone_repair_jsp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nhnamdev/phone_repair_jsp
- Repository: https://github.com/nhnamdev/phone_repair_jsp

## Overview

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`](https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai) (Phone Repair App), [`WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/UserDao`](https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/UserDao) (User DAO), [`WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/controller/User`](https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/controller/User) (User controllers), [`WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/controller/AdminContronller`](https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/controller/AdminContronller) (Admin controllers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_user_views["User portal<br/>JSP UI"]
  node_admin_views["Admin portal<br/>JSP UI"]
  node_shared_views["Shared fragments<br/>JSP partials"]
  node_assets["Static assets<br/>css/js/img"]
end

subgraph group_controllers["Controllers"]
  node_user_ctrl["User controllers<br/>servlet handlers"]
  node_admin_ctrl["Admin controllers<br/>servlet handlers"]
  node_admin_filter{{"Admin filter<br/>access filter<br/>[AdminFilter.java]"}}
end

subgraph group_logic["Services"]
  node_user_service["User service<br/>domain service<br/>[UserService.java]"]
  node_product_service["Product service<br/>domain service"]
  node_appointment_service["Appointment service<br/>domain service"]
  node_voucher_service["Voucher service<br/>domain service"]
  node_reset_service["Reset service<br/>domain service"]
end

subgraph group_persistence["Persistence"]
  node_user_dao[("User DAO<br/>JDBI DAO")]
  node_admin_dao[("Admin DAO<br/>JDBI DAO")]
  node_models["Domain models<br/>entities"]
end

subgraph group_infra["Infrastructure"]
  node_db_connect{{"DB connector<br/>JDBI connect<br/>[JDBIConnect.java]"}}
  node_db_props["DB properties<br/>mysql config<br/>[db.properties]"]
  node_web_xml["Web config<br/>servlet config<br/>[web.xml]"]
end

node_app["Phone Repair App<br/>WAR webapp"]

node_app -->|"renders"| node_user_views
node_app -->|"renders"| node_admin_views
node_app -->|"includes"| node_shared_views
node_app -->|"serves"| node_assets
node_app -->|"routes to"| node_user_ctrl
node_app -->|"routes to"| node_admin_ctrl
node_app -.->|"configured by"| node_web_xml
node_admin_filter -->|"guards"| node_admin_ctrl
node_user_ctrl -->|"calls"| node_user_service
node_user_ctrl -->|"calls"| node_appointment_service
node_user_ctrl -->|"calls"| node_voucher_service
node_user_ctrl -->|"calls"| node_reset_service
node_admin_ctrl -->|"calls"| node_product_service
node_admin_ctrl -->|"calls"| node_appointment_service
node_admin_ctrl -->|"calls"| node_user_service
node_user_service -->|"uses"| node_user_dao
node_product_service -->|"uses"| node_user_dao
node_appointment_service -->|"uses"| node_user_dao
node_voucher_service -->|"uses"| node_user_dao
node_reset_service -->|"uses"| node_user_dao
node_admin_ctrl -->|"uses"| node_admin_dao
node_user_dao -->|"maps"| node_models
node_admin_dao -->|"maps"| node_models
node_user_dao -->|"connects"| node_db_connect
node_admin_dao -->|"connects"| node_db_connect
node_db_connect -->|"loads"| node_db_props
node_reset_service -.->|"email flow"| node_user_ctrl

click node_app "https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai"
click node_user_views "https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/webapp/WEB-INF/views/user"
click node_admin_views "https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/webapp/WEB-INF/views/admin"
click node_shared_views "https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/webapp/WEB-INF/views/header_footer"
click node_assets "https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/webapp/resources"
click node_user_ctrl "https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/controller/User"
click node_admin_ctrl "https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/controller/AdminContronller"
click node_admin_filter "https://github.com/nhnamdev/phone_repair_jsp/blob/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/controller/filter/AdminFilter.java"
click node_user_service "https://github.com/nhnamdev/phone_repair_jsp/blob/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/service/UserService.java"
click node_product_service "https://github.com/nhnamdev/phone_repair_jsp/blob/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/service/ProductService.java"
click node_appointment_service "https://github.com/nhnamdev/phone_repair_jsp/blob/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/service/AppointmentService.java"
click node_voucher_service "https://github.com/nhnamdev/phone_repair_jsp/blob/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/service/VoucherService.java"
click node_reset_service "https://github.com/nhnamdev/phone_repair_jsp/blob/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/service/ResetPasswordService.java"
click node_user_dao "https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/UserDao"
click node_admin_dao "https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/AdminDao"
click node_models "https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/model"
click node_db_connect "https://github.com/nhnamdev/phone_repair_jsp/blob/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/db/JDBIConnect.java"
click node_db_props "https://github.com/nhnamdev/phone_repair_jsp/blob/master/WebDatLichSuaDienThoai/src/main/resources/db.properties"
click node_web_xml "https://github.com/nhnamdev/phone_repair_jsp/blob/master/WebDatLichSuaDienThoai/src/main/webapp/WEB-INF/web.xml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_user_views,node_admin_views,node_shared_views,node_assets toneBlue
class node_user_ctrl,node_admin_ctrl,node_admin_filter toneAmber
class node_user_service,node_product_service,node_appointment_service,node_voucher_service,node_reset_service toneMint
class node_user_dao,node_admin_dao,node_models toneRose
class node_db_connect,node_db_props,node_web_xml toneIndigo
class node_app toneNeutral
```

## Components

### Presentation

JSP views and static assets for user/admin portals

- [User portal](https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/webapp/WEB-INF/views/user): JSP UI · Customer-facing pages for browsing, booking, payment, and account flows · `WebDatLichSuaDienThoai/src/main/webapp/WEB-INF/views/user`
- [Admin portal](https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/webapp/WEB-INF/views/admin): JSP UI · Back-office pages for managing catalog, orders, bookings, vouchers, and history · `WebDatLichSuaDienThoai/src/main/webapp/WEB-INF/views/admin`
- [Shared fragments](https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/webapp/WEB-INF/views/header_footer): JSP partials · Header, footer, sidebar, and reusable content blocks · `WebDatLichSuaDienThoai/src/main/webapp/WEB-INF/views/header_footer`
- [Static assets](https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/webapp/resources): css/js/img · Stylesheets, scripts, and uploaded/display images for the web UI · `WebDatLichSuaDienThoai/src/main/webapp/resources`

### Controllers

HTTP entry points and route handlers

- [User controllers](https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/controller/User): servlet handlers · 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](https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/controller/AdminContronller): servlet handlers · Administrative HTTP flows for CRUD and operational management · `WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/controller/AdminContronller`
- [Admin filter](https://github.com/nhnamdev/phone_repair_jsp/blob/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/controller/filter/AdminFilter.java): access 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](https://github.com/nhnamdev/phone_repair_jsp/blob/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/service/UserService.java): domain service · User/account-related business logic · `WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/service/UserService.java`
- [Product service](https://github.com/nhnamdev/phone_repair_jsp/blob/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/service/ProductService.java): domain service · Catalog and product-side business rules · `WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/service/ProductService.java`
- [Appointment service](https://github.com/nhnamdev/phone_repair_jsp/blob/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/service/AppointmentService.java): domain service · Booking and consultation orchestration · `WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/service/AppointmentService.java`
- [Voucher service](https://github.com/nhnamdev/phone_repair_jsp/blob/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/service/VoucherService.java): domain service · Voucher validation and application logic · `WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/service/VoucherService.java`
- [Reset service](https://github.com/nhnamdev/phone_repair_jsp/blob/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/service/ResetPasswordService.java): domain 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](https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/UserDao): JDBI DAO · Persistence for customer accounts and user-facing flows · `WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/UserDao`
- [Admin DAO](https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/AdminDao): JDBI DAO · Persistence for admin dashboards and management workflows · `WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/AdminDao`
- [Domain models](https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/model): entities · 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](https://github.com/nhnamdev/phone_repair_jsp/blob/master/WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/db/JDBIConnect.java): JDBI connect · Central database connection and configuration loader · `WebDatLichSuaDienThoai/src/main/java/edu/hcmuaf/nlu/fit/webdatlichsuadienthoai/dao/db/JDBIConnect.java`
- [DB properties](https://github.com/nhnamdev/phone_repair_jsp/blob/master/WebDatLichSuaDienThoai/src/main/resources/db.properties): mysql config · Externalized MySQL connection settings · `WebDatLichSuaDienThoai/src/main/resources/db.properties`
- [Web config](https://github.com/nhnamdev/phone_repair_jsp/blob/master/WebDatLichSuaDienThoai/src/main/webapp/WEB-INF/web.xml): servlet config · Servlet, filter, and error-page mapping configuration · `WebDatLichSuaDienThoai/src/main/webapp/WEB-INF/web.xml`

### Other components

- [Phone Repair App](https://github.com/nhnamdev/phone_repair_jsp/tree/master/WebDatLichSuaDienThoai): WAR webapp · Servlet-based JSP application for phone repair booking and admin operations · `WebDatLichSuaDienThoai`

## Connections

- 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
