# thuxidau/cd_shopping_website architecture

> Architecture diagram of the GitHub repository thuxidau/cd_shopping_website, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thuxidau/cd_shopping_website
- Repository: https://github.com/thuxidau/cd_shopping_website

## Overview

##### Main Components
- Client/User Interface – represented by the web pages (JSPs, CSS, JS, images) inside the “web” directory.
- Presentation Layer – JSP pages and static resources (located in the “web” folder) that render the user interface.
- Controller Layer – Servlets found in “src/java/controller” handle user requests (e.g., LoginServlet, AddToCartServlet, etc.).
- Business Logic/Data Access Layer – The “src/java/dal” package contains the DAO classes that interact with the database. The “src/java/model” package holds business models (e.g., Product, Order, Users).
- Filter – A filter class (JSP_Filter in “src/java/filter”) processes incoming requests (likely managing sessions, authentication, etc.) before they hit the controllers.
- Database – The MySQL database is accessed via JDBC (using the connector provided as “lib/mysql-connector-j-8.4.0.jar”), with database scripts provided (script.sql).

##### Relationships and Interactions
- That the Servlets interact with the Business Logic/Data Access Layer (the DAO classes and model objects) to process the data.
- A Filter component that intercepts HTTP requests, positioned between the Client and Servlets.
- Optionally, display the build/configuration components (Ant build.xml and NetBeans project files) as supporting artifacts outside the main runtime flow.

##### Relevant Architectural Patterns and Technologies
- MVC Architecture – Though not strictly separated, the design follows a Model (dao, model), View (JSPs), and Controller (Servlets) pattern.
- Client-Server Model – Request handling from client browsers to the server-side application.
- Use of standardized Java web technologies – Java 17, JSP, Servlets, and JSTL.
- Utilization of session management, cookies, and filters for request processing.
- External libraries such as Bootstrap 3 for styling, JSTL for view logic, and MySQL Connector for the database connection.

- Controller to a “Business Logic Layer” that includes:
– Models (e.g., Product, Order, Users)
– DAOs (CategoryDAO, ProductDAO, OrderDAO, etc.)
- A side note for “Configuration & Build” that includes build.xml and project configurations, emphasizing that these support the actual deployment but are not part of the runtime flow.
- Optionally, mention that the system uses session management, and possibly denote that through an annotation near the filter or controller indicating session/cookie handling.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Nodes
    A["Client (Browser)"]:::client
    F["HTTP Filter (JSP_Filter.java)"]:::filter
    C["Servlets (src/java/controller)"]:::controller
    P["JSP Pages (web)"]:::presentation

    subgraph "Business Logic & Data Access Layer"
        BL1["DAO Classes (src/java/dal)"]:::business
        BL2["Business Models (src/java/model)"]:::business
    end

    DB["MySQL Database"]:::database
    Config["Configuration & Build<br/>(build.xml, project files, lib/mysql-connector-j-8.4.0.jar)"]:::config

    %% Connections
    A -->|"HTTPRequest"| F
    F -->|"FilterRequest"| C
    C -->|"RenderView"| P
    C -->|"DataRequest"| BL1
    C -->|"BusinessLogic"| BL2
    BL1 -->|"DBOps"| DB
    Config ---|"Supports"| C

    %% Click Events
    click P "https://github.com/thuxidau/cd_shopping_website/tree/main/web/"
    click C "https://github.com/thuxidau/cd_shopping_website/tree/main/src/java/controller/"
    click BL1 "https://github.com/thuxidau/cd_shopping_website/tree/main/src/java/dal/"
    click BL2 "https://github.com/thuxidau/cd_shopping_website/tree/main/src/java/model/"
    click F "https://github.com/thuxidau/cd_shopping_website/blob/main/src/java/filter/JSP_Filter.java"
    click DB "https://github.com/thuxidau/cd_shopping_website/blob/main/script.sql"

    %% Styles
    classDef client fill:#a2d9ce,stroke:#1abc9c,stroke-width:2px;
    classDef filter fill:#f9e79f,stroke:#f1c40f,stroke-width:2px;
    classDef controller fill:#fad7a0,stroke:#e67e22,stroke-width:2px;
    classDef presentation fill:#f5b7b1,stroke:#e74c3c,stroke-width:2px;
    classDef business fill:#d7bde2,stroke:#8e44ad,stroke-width:2px;
    classDef database fill:#aed6f1,stroke:#3498db,stroke-width:2px;
    classDef config fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
```
