# dbpcod/cnpm_qlsach architecture

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

- Interactive diagram: https://gitdiagram.com/dbpcod/cnpm_qlsach
- Repository: https://github.com/dbpcod/cnpm_qlsach

## Overview

##### Project type and purpose
- This is a two-tier, full-stack desktop application written in Java.
- Purpose: Manage a bookstore’s inventory, orders, and warehouse in real time, supporting multiple simultaneous clients via socket communication.

##### File structure
- Top-level directories:
- Source/Client – Java Swing GUI, DTOs, custom components, client socket code.
- Source/Server – Socket server, BLL (business logic), DAO (data access), DTOs, DB connection.
- setupDB – SQL scripts to create and seed MySQL database.
- libs – External JARs (MySQL connector, SwingX, charting, JSON).
- Client modules follow feature areas: BH (sales), NK (warehouse), QL (admin), GUI, DTO, Customize.
- Server modules: ConnectDB, DAO for CRUD, BLL for business rules, server socket handlers.

##### README for additional insights
- Confirms usage of MySQL (via XAMPP), NetBeans, Java sockets.
- Describes workflow: start XAMPP → import DB → launch server main.java → configure client IP → start client Login.java.

##### Elements
- Blue for client side
- Green for network sockets
- Orange for server side
- Red for database
- Rectangles for modules

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Side"
        direction TB
        BH["Sales Module"]:::client
        NK["Warehouse Module"]:::client
        QL["Admin Module"]:::client
        GUI["GUI Components"]:::client
        DTO_C["Client DTOs"]:::client
        Customize["Custom UI Components"]:::client
    end

    %% Network Layer
    subgraph "Network Layer"
        direction TB
        ClientApp["Client.java"]:::network
        ClientListener["ClientListener.java"]:::network
        ConfigIP["configIP.java"]:::network
        ConfigTXT["config.txt"]:::network
    end

    %% Server Side
    subgraph "Server Side"
        direction TB
        subgraph "Listener Layer"
            ServerMain["main.java"]:::server
            ServerListener["server.java"]:::server
            ClientHandle["ClientHandle.java"]:::server
        end
        subgraph "Business Logic Layer"
            BLL["BLL Modules"]:::server
        end
        subgraph "Data Access Layer"
            DAO["DAO Modules"]:::server
        end
        DTO_S["Server DTOs"]:::server
        DBUtil["ConnectDB Utility"]:::server
    end

    %% Database
    Database[(MySQL Database)]:::db

    %% Connections
    BH -->|"uses"| DTO_C
    NK -->|"uses"| DTO_C
    QL -->|"uses"| DTO_C
    GUI -->|"renders DTOs"| DTO_C
    Customize -->|"enhances UI"| GUI

    DTO_C -->|"serialize"| ClientApp
    ClientApp -->|"open socket"| ClientListener
    ClientListener -->|"reads config"| ConfigIP
    ClientListener -->|"loads"| ConfigTXT
    ClientListener -->|"connects to"| ServerListener

    ServerListener -->|"dispatch"| BLL
    BLL -->|"invoke"| DAO
    DAO -->|"query"| DBUtil
    DBUtil -->|"execute SQL"| Database

    Database -->|"result DTO"| DAO
    DAO -->|"result DTO"| BLL
    BLL -->|"result DTO"| ServerListener
    ServerListener -->|"send"| ClientListener
    ClientListener -->|"deliver DTO"| ClientApp
    ClientApp -->|"update UI"| GUI

    %% Click Events
    click BH "https://github.com/dbpcod/cnpm_qlsach/tree/main/Source/Client/src/BH"
    click NK "https://github.com/dbpcod/cnpm_qlsach/tree/main/Source/Client/src/NK"
    click QL "https://github.com/dbpcod/cnpm_qlsach/tree/main/Source/Client/src/QL"
    click GUI "https://github.com/dbpcod/cnpm_qlsach/tree/main/Source/Client/src/GUI"
    click DTO_C "https://github.com/dbpcod/cnpm_qlsach/tree/main/Source/Client/src/DTO"
    click Customize "https://github.com/dbpcod/cnpm_qlsach/tree/main/Source/Client/src/Customize"
    click ClientApp "https://github.com/dbpcod/cnpm_qlsach/blob/main/Source/Client/src/client/Client.java"
    click ClientListener "https://github.com/dbpcod/cnpm_qlsach/blob/main/Source/Client/src/client/ClientListener.java"
    click ConfigIP "https://github.com/dbpcod/cnpm_qlsach/blob/main/Source/Client/src/client/configIP.java"
    click ConfigTXT "https://github.com/dbpcod/cnpm_qlsach/blob/main/Source/Client/src/client/config.txt"
    click ServerMain "https://github.com/dbpcod/cnpm_qlsach/blob/main/Source/Server/src/server/main.java"
    click ServerListener "https://github.com/dbpcod/cnpm_qlsach/blob/main/Source/Server/src/server/server.java"
    click ClientHandle "https://github.com/dbpcod/cnpm_qlsach/blob/main/Source/Server/src/server/ClientHandle.java"
    click BLL "https://github.com/dbpcod/cnpm_qlsach/tree/main/Source/Server/src/BLL"
    click DAO "https://github.com/dbpcod/cnpm_qlsach/tree/main/Source/Server/src/DAO"
    click DTO_S "https://github.com/dbpcod/cnpm_qlsach/tree/main/Source/Server/src/DTO"
    click DBUtil "https://github.com/dbpcod/cnpm_qlsach/blob/main/Source/Server/src/ConnectDB/ConnectDB.java"
    click Database "https://github.com/dbpcod/cnpm_qlsach/blob/main/setupDB/db.sql"
    %% Styles
    classDef client fill:#cce5ff,stroke:#004085,color:#004085
    classDef network fill:#d4edda,stroke:#155724,color:#155724
    classDef server fill:#ffe5b4,stroke:#e69500,color:#e69500
    classDef db fill:#f8d7da,stroke:#721c24,color:#721c24
```
