# nguyentuanninh/library-management-system architecture

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

- Interactive diagram: https://gitdiagram.com/nguyentuanninh/library-management-system
- Repository: https://github.com/nguyentuanninh/library-management-system

## Overview

##### Main System Components
- Presentation Layer (Frontend):
- Represented by the web directory which contains all JSP pages, HTML, CSS, JavaScript, and assets (images, styles).
- Pages like Login.jsp, Register.jsp, HomePageAdmin.jsp, HomePageUser.jsp, and other feature-specific pages (e.g., ListBook.jsp, Feedback.jsp).
- Controller Layer (Back-End Controllers):
- Located in src/java/controller. This layer includes classes like Login, CreateUser, CreateBook, UpdateBook, etc.
- Controllers process client requests, coordinate between the view and the business logic.
- Business Logic & Data Access Layer:
- This layer is divided into:
- Data Access Objects (src/java/DAO) which includes classes such as BookDAO, UserDAO, BorrowerDAO, etc.
- Entity classes (src/java/entity) that define the core business objects (Book, Borrower, Category, Feedback, User).
- These components encapsulate and enforce the business rules and data manipulation logic.
- Database Connection and Configuration:
- The package src/java/dbConnect includes DBContext and TestConnection classes, responsible for establishing connections with the SQL Server.
- The database folder holds the DBScript.sql, which is used to set up the database.
- Configuration & Deployment Files:
- Configuration details like MANIFEST.MF in src/conf and web.xml in web/WEB-INF.
- Build and project configuration files (build.xml, nbproject) that support project building and deployment.

##### Relationships and Data Flow
- How user interactions via the web layer (JSP pages) invoke requests that are routed to the appropriate Controller.
- How controllers call DAO methods to interact with the database.
- Role of JDBC within DAOs for executing SQL queries on the SQL Server database.

##### Architectural Patterns and Design Principles
- Modular design: Each package (controller, DAO, entity, dbConnect) represents a modular component. This modularity aids in maintainability and extensibility.
- Integration of external libraries: Note the inclusion of libraries such as JSTL (for JSP) and SQL Server JDBC drivers (in the lib folder).

## Diagram (Mermaid)

```mermaid
graph TD
    A["Browser"]:::frontend

    subgraph "Application Server"
        subgraph "Presentation Layer"
            B["JSP Pages & Static Assets (View)"]:::frontend
        end

        subgraph "Controller Layer"
            C["Servlet Controllers"]:::controller
        end

        subgraph "Business Logic & Persistence Layer"
            D["Data Access Objects (DAO)"]:::dao
            E["Entity Models"]:::entity
            F["DB Connection Manager"]:::dao
        end

        subgraph "Configuration & Deployment"
            H1["Servlet Config"]:::config
            H2["Java Manifest"]:::config
            H3["Build Config"]:::config
            H4["nbproject"]:::config
        end
    end

    I["DB Script"]:::config
    G["SQL Server Database"]:::db

    %% Data Flow Connections
    A -->|"HTTP_Request"| B
    B -->|"Submits_Request"| C
    C -->|"Calls_DAO"| D
    C -->|"Uses_Model"| E
    D -->|"Uses_DB_Connection"| F
    D -->|"Executes_Query"| G
    F -->|"Establishes_Connection"| G
    G -->|"Returns_Result"| D
    D -->|"Maps_to"| E
    C -->|"Renders_View"| B

    %% Configuration Connections
    H1 -->|"Configures"| C
    H2 -->|"Defines_Config"| C
    H3 -->|"Builds"| C
    H4 -->|"Manages_Build"| C
    I -->|"Initializes"| G

    %% Click Events
    click B "https://github.com/nguyentuanninh/library-management-system/tree/main/web"
    click C "https://github.com/nguyentuanninh/library-management-system/tree/main/src/java/controller"
    click D "https://github.com/nguyentuanninh/library-management-system/tree/main/src/java/DAO"
    click E "https://github.com/nguyentuanninh/library-management-system/tree/main/src/java/entity"
    click F "https://github.com/nguyentuanninh/library-management-system/tree/main/src/java/dbConnect"
    click H1 "https://github.com/nguyentuanninh/library-management-system/blob/main/web/WEB-INF/web.xml"
    click H2 "https://github.com/nguyentuanninh/library-management-system/blob/main/src/conf/MANIFEST.MF"
    click H3 "https://github.com/nguyentuanninh/library-management-system/blob/main/build.xml"
    click H4 "https://github.com/nguyentuanninh/library-management-system/tree/main/nbproject"
    click I "https://github.com/nguyentuanninh/library-management-system/blob/main/database/DBscript.sql"

    %% Styles
    classDef frontend fill:#f9f,stroke:#333,stroke-width:2px;
    classDef controller fill:#ccf,stroke:#333,stroke-width:2px;
    classDef dao fill:#cfc,stroke:#333,stroke-width:2px;
    classDef entity fill:#fc9,stroke:#333,stroke-width:2px;
    classDef db fill:#ff9,stroke:#333,stroke-width:2px;
    classDef config fill:#9cf,stroke:#333,stroke-width:2px;
    class A,B frontend;
    class C controller;
    class D,F dao;
    class E entity;
    class G db;
    class H1,H2,H3,H4,I config;
```
