# jasonma1127/library-manage-system architecture

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

- Interactive diagram: https://gitdiagram.com/jasonma1127/library-manage-system
- Repository: https://github.com/jasonma1127/library-manage-system

## Overview

##### Project type and purpose
- This is a standalone Java desktop application (“Library-Manage-System”) built using Java Swing for its GUI and MySQL as its persistent store.
- Its purpose is to let users register, log in, view/search/borrow/return book items, and for an admin to add new book items. Development follows Test-Driven Development (TDD).

##### File structure
- Top-level:
- Dump20210610.sql – database schema dump
- LibraryManageSystem/lib – third-party JAR (mysql-connector-java)
- LibraryManageSystem/bin – compiled classes, mirroring src packages
- LibraryManageSystem/src – Java source, split into packages:
– dataType: domain models (BookItem, UserInfo, Status)
– development: GUI.java (presentation), jdbcConnection.java (data access), ButtonColumn.java (helper)
– testing: unit tests exercising all user flows (login, register, search, borrow, return, etc.)
- Configuration: jdbcConnection.java contains JDBC URL/credentials.
- Build/deploy: running GUI.java launches the app; AllTests.java runs the TDD suite.

##### README insights
- Emphasizes TDD; all core behaviors are covered by unit tests in testing/.
- Workflow: GUI <-> JDBC <-> MySQL.
- User scenarios documented with screenshots.

##### Main components
a. Presentation Layer (Java Swing GUI)
- GUI.java, ButtonColumn.java
- Handles user interactions (register, login, view/search, borrow/return, add book)
b. Domain Model (Data Types)
- BookItem, UserInfo, Status
- Shared by presentation and data access layers
c. Data Access Layer (JDBC Connector)
- jdbcConnection.java
- Manages SQL connections/queries against MySQL
d. Database
- MySQL schema loaded from Dump20210610.sql
- Tables: users, book_items, borrow_records (implied)
e. Test Harness
- AllTests.java and individual test classes in testing/
- Invokes domain logic and data access methods to validate behavior
f. External Library
- mysql-connector-java-8.0.24.jar in lib/
- Shown as an external dependency

##### Relationships and interactions
- UI layer calls methods on Data Access Layer to read/write data.
- Data Access Layer maps result sets to Domain Model objects and vice versa.
- Domain Model flows between UI and DAL.
- Tests bypass the UI (where appropriate) to directly exercise DAL/domain methods.
- JDBC driver acts as the intermediary between the Java app and MySQL server.

##### Architectural patterns & design principles
- Layered architecture (Presentation → Business/Domain → Data Access → Database)
- Separation of concerns: UI, domain types, persistence, tests clearly separated into packages.
- TDD: each feature is backed by a unit test class.

##### Essential details to capture
- Source-folder separation (dataType vs. development vs. testing)
- The external MySQL connector JAR and the SQL dump as deployment artifacts
- The bidirectional flow between the Java app and the database
- The TDD feedback loop (unit tests driving development of domain & DAL)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        GUI["GUI (GUI.java)"]:::ui
        Button["ButtonColumn (ButtonColumn.java)"]:::ui
    end

    %% Domain Model
    subgraph "Domain Model"
        direction TB
        BookItem["BookItem"]:::domain
        UserInfo["UserInfo"]:::domain
        Status["Status"]:::domain
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        JDBC["JDBC Connector"]:::dataaccess
    end

    %% Database
    subgraph "Database"
        direction TB
        MySQLDB["MySQL Database"]:::database
    end

    %% External Dependency
    subgraph "External Dependency"
        direction TB
        MySQLJAR["MySQL JDBC Driver"]:::external
        SQLDump["Database Schema Dump"]:::external
    end

    %% Test Harness
    subgraph "Test Harness"
        direction TB
        AllTests["AllTests"]:::test
        testRegister["testUserRegister"]:::test
        testLogin["testUserLogin"]:::test
        testSearch["testSearchBookItem"]:::test
        testShow["testShowBookItems"]:::test
        testBorrow["testBorrowBooks"]:::test
        testReturn["testReturnBooks"]:::test
        testShowBorrowed["testShowBooksBorrowedByUser"]:::test
    end

    %% Data Flows
    GUI -->|"User Actions"| JDBC
    Button -->|"User Actions"| GUI
    JDBC -->|"SQL SELECT/INSERT/UPDATE"| MySQLDB
    MySQLDB -->|"Result Sets"| JDBC
    JDBC -->|"Maps to Domain Objects"| BookItem
    JDBC -->|"Maps to Domain Objects"| UserInfo
    JDBC -->|"Maps to Domain Objects"| Status
    BookItem -->|"Domain Objects"| GUI
    UserInfo -->|"Domain Objects"| GUI
    Status -->|"Domain Objects"| GUI

    %% Test Flows
    AllTests --> JDBC
    AllTests --> BookItem
    testRegister --> JDBC
    testRegister --> UserInfo
    testLogin --> JDBC
    testLogin --> UserInfo
    testSearch --> JDBC
    testSearch --> BookItem
    testShow --> JDBC
    testShow --> BookItem
    testBorrow --> JDBC
    testBorrow --> BookItem
    testBorrow --> UserInfo
    testReturn --> JDBC
    testReturn --> BookItem
    testReturn --> UserInfo
    testShowBorrowed --> JDBC
    testShowBorrowed --> BookItem
    testShowBorrowed --> UserInfo

    %% External Dependencies
    MySQLJAR --> JDBC
    SQLDump --> MySQLDB

    %% Click Events
    click GUI "https://github.com/jasonma1127/library-manage-system/blob/main/LibraryManageSystem/src/development/GUI.java"
    click Button "https://github.com/jasonma1127/library-manage-system/blob/main/LibraryManageSystem/src/development/ButtonColumn.java"
    click BookItem "https://github.com/jasonma1127/library-manage-system/blob/main/LibraryManageSystem/src/dataType/BookItem.java"
    click UserInfo "https://github.com/jasonma1127/library-manage-system/blob/main/LibraryManageSystem/src/dataType/UserInfo.java"
    click Status "https://github.com/jasonma1127/library-manage-system/blob/main/LibraryManageSystem/src/dataType/Status.java"
    click JDBC "https://github.com/jasonma1127/library-manage-system/blob/main/LibraryManageSystem/src/development/jdbcConnection.java"
    click SQLDump "https://github.com/jasonma1127/library-manage-system/blob/main/Dump20210610.sql"
    click MySQLJAR "https://github.com/jasonma1127/library-manage-system/blob/main/LibraryManageSystem/lib/mysql-connector-java-8.0.24.jar"
    click AllTests "https://github.com/jasonma1127/library-manage-system/blob/main/LibraryManageSystem/src/testing/AllTests.java"
    click testRegister "https://github.com/jasonma1127/library-manage-system/blob/main/LibraryManageSystem/src/testing/testUserRegister.java"
    click testLogin "https://github.com/jasonma1127/library-manage-system/blob/main/LibraryManageSystem/src/testing/testUserLogin.java"
    click testSearch "https://github.com/jasonma1127/library-manage-system/blob/main/LibraryManageSystem/src/testing/testSearchBookItem.java"
    click testShow "https://github.com/jasonma1127/library-manage-system/blob/main/LibraryManageSystem/src/testing/testShowBookItems.java"
    click testBorrow "https://github.com/jasonma1127/library-manage-system/blob/main/LibraryManageSystem/src/testing/testBorrowBooks.java"
    click testReturn "https://github.com/jasonma1127/library-manage-system/blob/main/LibraryManageSystem/src/testing/testReturnBooks.java"
    click testShowBorrowed "https://github.com/jasonma1127/library-manage-system/blob/main/LibraryManageSystem/src/testing/testShowBooksBorrowedByUser.java"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1F618D,color:#1B4F72;
    classDef domain fill:#A9DFBF,stroke:#27AE60,color:#196F3D;
    classDef dataaccess fill:#F9E79F,stroke:#B7950B,color:#7E5109;
    classDef database fill:#D5D8DC,stroke:#566573,color:#2C3E50;
    classDef external fill:#E8DAEF,stroke:#8E44AD,color:#4A235A;
    classDef test fill:#F5B7B1,stroke:#C0392B,color:#641E16;
```
