# huuthanh2k4/sales-website architecture

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

- Interactive diagram: https://gitdiagram.com/huuthanh2k4/sales-website
- Repository: https://github.com/huuthanh2k4/sales-website

## Overview

##### Main Components
- Client/User Interface – Represented by the web pages (JSP views found in /src/main/webapp/WEB-INF/views) and static resources (CSS, JS, SQL scripts, images). These are the elements that the end user interacts with.
- Web Server/Application Server – This Java web application is deployed in a servlet container (such as Tomcat). The web.xml is the deployment descriptor; additionally, Spring configuration files (spring-config.xml and spring-security-config.xml) indicate the use of the Spring Framework.
- Controllers – Located in the package “Porject/DieuKhien”, these classes (e.g., DangNhap.java, TrangAdmin.java, TrangNguoiDung.java) act as entry points for handling HTTP requests and directing flow.
- Business/Service Layer – The “GoiHamChucNang” package (with sub-packages like CaiDat) contains business function calls, likely abstracting core functionality and integrating calls between different parts of the logic.
- Data/Entity Layer – The “Porject/entities” package holds domain models such as NguoiDung, QuanLyThongTin, and various classes under ThongTinSP. This layer represents the data structure corresponding to your database.
- Database – Although not directly included as a separate module, SQL files and scripts (in /src/main/webapp/resources/SQL) indicate a backend database (likely accessed via an ORM or JDBC gateway) that persists business data.

##### Relationships and Interactions
- The client (browser) accesses the frontend (JSPs and static resources), which then makes HTTP requests routed to the web server.
- The Web Server/Servlet Container uses Spring’s DispatcherServlet (configured in web.xml and spring-config.xml) to route requests to the appropriate controller (i.e., classes inside Porject/DieuKhien).
- Controllers process these requests and call into business methods (in “GoiHamChucNang”) to perform logic such as user authentication (i.e., DangNhap) or admin functions.
- Business methods in turn interact with the entity classes defined in “Porject/entities”. These entities map to database records. The database is managed or updated via SQL scripts and configurations.
- Spring Security configuration (spring-security-config.xml) governs authentication and authorization rules, affecting how controllers and services expose certain functions.

##### Architectural Patterns and Design Principles
- MVC Pattern – Separation between the view (JSPs & static resources), controller (DieuKhien package), and model (entities).
- Layered Architecture – There is a clear separation of concerns between the presentation layer, business/service layer, and data access layer.
- Dependency Injection – Likely provided by Spring’s core container as inferred from the Spring configuration files.
- Maven Build/Dependency Management – The pom.xml ensures that the project uses a managed library and dependency ecosystem.

##### Relevant Technologies, Frameworks, and Modules
- Java & JSP for the application logic and views.
- Spring (and Spring Security) for dependency injection, MVC, and security handling.
- Maven for project management and building.
- The existence of SQL scripts suggests use of a relational database (MySQL, PostgreSQL, etc.) though the exact DBMS might be defined elsewhere in configuration files.

##### Additional Details
- Maven project structure by indicating where dependencies are defined (pom.xml) because it sets up the whole architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        A1["JSP Views"]:::frontend
        A2["Static Resources"]:::frontend
    end

    subgraph "Web Server & Configuration"
        B1["Servlet Container\n(web.xml)"]:::server
        B2["Spring Configurations\n(spring-config.xml, spring-security-config.xml)"]:::config
    end

    subgraph "Application Layer"
        C1["Controllers\n(Porject/DieuKhien)"]:::controller
        D1["Business/Service Layer\n(Porject/GoiHamChucNang)"]:::service
    end

    subgraph "Data Layer"
        E1["Data/Entity Layer\n(Porject/entities)"]:::entity
        F1["Database\n(SQL Scripts)"]:::database
    end

    %% Data Flow
    A1 -->|"HTTPRequest"| B1
    A2 -->|"HTTPRequest"| B1
    B1 -->|"InitDispatcher"| B2
    B2 -->|"RouteRequest"| C1
    C1 -->|"InvokeLogic"| D1
    D1 -->|"DataOps"| E1
    E1 -->|"PersistQuery"| F1
    F1 -->|"DataResponse"| E1
    E1 -->|"EntityMapping"| D1
    D1 -->|"ResponseData"| C1
    C1 -->|"RenderResponse"| B1
    B1 -->|"HTTPResponse"| A1
    B1 -->|"HTTPResponse"| A2

    %% Click Events
    click A1 "https://github.com/huuthanh2k4/sales-website/tree/master//src/main/webapp/WEB-INF/views"
    click A2 "https://github.com/huuthanh2k4/sales-website/tree/master//src/main/webapp/resources"
    click B1 "https://github.com/huuthanh2k4/sales-website/blob/master//src/main/webapp/WEB-INF/web.xml"
    click B2 "https://github.com/huuthanh2k4/sales-website/blob/master//src/main/webapp/WEB-INF/config/spring-config.xml"
    click C1 "https://github.com/huuthanh2k4/sales-website/tree/master//src/main/java/Porject/DieuKhien"
    click D1 "https://github.com/huuthanh2k4/sales-website/tree/master//src/main/java/Porject/GoiHamChucNang"
    click E1 "https://github.com/huuthanh2k4/sales-website/tree/master//src/main/java/Porject/entities"
    click F1 "https://github.com/huuthanh2k4/sales-website/tree/master//src/main/webapp/resources/SQL"

    %% Styles
    classDef frontend fill:#f9f,stroke:#333,stroke-width:2px;
    classDef server fill:#ccf,stroke:#333,stroke-width:2px;
    classDef config fill:#cfc,stroke:#333,stroke-width:2px;
    classDef controller fill:#fcc,stroke:#333,stroke-width:2px;
    classDef service fill:#fc9,stroke:#333,stroke-width:2px;
    classDef entity fill:#9cf,stroke:#333,stroke-width:2px;
    classDef database fill:#ff9,stroke:#333,stroke-width:2px;
```
