# harismuneer/library-management-system-java architecture

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

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

## Overview

##### Project Type & Purpose
- This is a console-based Library Management System written in Java. Its purpose is to provide functionalities for managing library operations, including handling books, borrowers, clerks, librarians, and administrators. The system includes a database (Java DB/Derby) for persistence, and the design adheres to object-oriented principles with a clear separation of concerns.

##### Analyzing the File Structure
- The top-level directories/files indicate two major parts:
- The "Project" folder contains the NetBeans project setup, with “src/LMS” holding the primary Java source code (classes like Book, Borrower, Clerk, HoldRequest, HoldRequestOperations, etc.).
- The "Database" folder holds the Derby database files, logs, and schema files (e.g., the "Database Schema.txt") which define and initialize the underlying data.

##### Insights from the README
- The README confirms that the system is developed using object-oriented design in Java. It also explains that the interface is console-based, and provides screenshots to illustrate how the UI looks.
- The actors (Librarian, Checkout Clerk, Borrower, Administrator) and use cases are clearly defined, which indicates that the logic is built around distinct roles and responsibilities.

##### Key Components in the Architecture
a. Presentation/UI Layer:
- Console-based interface driven by the Main class.
- Input/Output handling for command-line interactions.
b. Business Logic/Domain Layer:
- Core classes in the LMS package such as Library, Book, Borrower, Clerk, Librarian, Staff, and HoldRequest.
- The newly added HoldRequestOperations class acts as a mediator to decouple the bidirectional dependency between Book and HoldRequest.
- Use cases and operations are organized around the actual user tasks like searching, checking out, and returning items.
c. Persistence/Database Layer:
- The Derby (Java DB) database contains all the library data. The “Database” folder, along with files like Database Schema.txt, shows the schema and the related control and data files.
- The project provides instructions for setting up the database connection (using specified credentials) in NetBeans.
d. Build & Configuration:
- The NetBeans project setup (with nbproject/ files) and Ant build script (build.xml) dictate how the system is built and deployed.
- There’s a separate manifest file indicating deployment parameters (derby properties, logging, etc.).

- Presentation Layer (UI): Represent the Main class and any input/output handling modules.
- Business Logic/Domain Layer: Capture all the core classes (Book, Borrower, Clerk, Librarian, HoldRequest, HoldRequestOperations, Library, Loan, Person, etc.). Use UML notation to show associations, dependencies, and especially the mediating role of HoldRequestOperations.
- Persistence Layer: Represent the Derby database. You might include elements like the schema, tables (inferred from the schema and file names), and the connection interface (Java DB/Derby JDBC connection).
- Also, include supporting components:
- Configuration & Deployment: Optionally, annotate the build process using NetBeans, highlighting that the project is built using Ant scripts (build.xml) and that configuration files (derby.properties, project settings) are involved.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Actors
    subgraph "Actors"
        Librarian["Librarian"]:::actor
        Clerk["Checkout Clerk"]:::actor
        Borrower["Borrower"]:::actor
        Administrator["Administrator"]:::actor
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["Console UI – Main.java"]:::presentation
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        subgraph "Core Library Classes"
            Book["Book"]:::business
            BorrowerClass["Borrower"]:::business
            ClerkClass["Clerk"]:::business
            LibrarianClass["Librarian"]:::business
            Library["Library"]:::business
            Loan["Loan"]:::business
            Person["Person"]:::business
            Staff["Staff"]:::business
            HoldRequest["HoldRequest"]:::business
            HoldRequestOps["HoldRequestOperations"]:::business
        end
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        DB["Derby Database"]:::database
        Schema["Database Schema.txt"]:::database
    end

    %% Build & Configuration Layer
    subgraph "Build & Configuration Layer"
        Build["Build Script (build.xml)"]:::build
        NBProj["NetBeans Project (nbproject)"]:::build
        Manifest["Manifest (manifest.mf)"]:::build
        ProjectDBConfig["Project Derby Config (derby.properties, derby.log)"]:::build
    end

    %% Relationships
    %% Actors interact with the UI
    Librarian -->|"initiates"| UI
    Clerk -->|"initiates"| UI
    Borrower -->|"initiates"| UI
    Administrator -->|"initiates"| UI

    %% UI interacts with business logic
    UI -->|"calls"| Library

    %% Mediator relationship inside Business Logic
    Book -.->|"mediatedBy"| HoldRequestOps
    HoldRequest -.->|"mediatedBy"| HoldRequestOps

    %% Business Logic updates Persistence
    Library -->|"persistsTo"| DB
    DB -->|"definedBy"| Schema

    %% Build & Configuration sets up the system
    Build -->|"configures"| UI
    Build -->|"configures"| Library
    Build -->|"configures"| DB

    %% Click Events
    click UI "https://github.com/harismuneer/library-management-system-java/blob/master/Project/src/LMS/Main.java"
    click Book "https://github.com/harismuneer/library-management-system-java/blob/master/Project/src/LMS/Book.java"
    click BorrowerClass "https://github.com/harismuneer/library-management-system-java/blob/master/Project/src/LMS/Borrower.java"
    click ClerkClass "https://github.com/harismuneer/library-management-system-java/blob/master/Project/src/LMS/Clerk.java"
    click LibrarianClass "https://github.com/harismuneer/library-management-system-java/blob/master/Project/src/LMS/Librarian.java"
    click Library "https://github.com/harismuneer/library-management-system-java/blob/master/Project/src/LMS/Library.java"
    click Loan "https://github.com/harismuneer/library-management-system-java/blob/master/Project/src/LMS/Loan.java"
    click Person "https://github.com/harismuneer/library-management-system-java/blob/master/Project/src/LMS/Person.java"
    click Staff "https://github.com/harismuneer/library-management-system-java/blob/master/Project/src/LMS/Staff.java"
    click HoldRequest "https://github.com/harismuneer/library-management-system-java/blob/master/Project/src/LMS/HoldRequest.java"
    click HoldRequestOps "https://github.com/harismuneer/library-management-system-java/blob/master/Project/src/LMS/HoldRequestOperations.java"
    click DB "https://github.com/harismuneer/library-management-system-java/tree/master/Database"
    click Schema "https://github.com/harismuneer/library-management-system-java/blob/master/Database Schema.txt"
    click Build "https://github.com/harismuneer/library-management-system-java/blob/master/Project/build.xml"
    click NBProj "https://github.com/harismuneer/library-management-system-java/tree/master/Project/nbproject"
    click Manifest "https://github.com/harismuneer/library-management-system-java/blob/master/Project/manifest.mf"
    click ProjectDBConfig "https://github.com/harismuneer/library-management-system-java/blob/master/Project/derby.properties and Project/derby.log"

    %% Styles
    classDef actor fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef presentation fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef business fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef database fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef build fill:#D2B4DE,stroke:#7D3C98,stroke-width:2px;
```
