Skip to content

joel-003/Library-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š Library Management System – CLI Application Documentation

Badges

Java PostgreSQL

Maven

Status License

IDE OS

Overview

This project is a full-featured Library Management System (LMS) built as a Command-Line Interface (CLI) application using Java, JDBC, and PostgreSQL.

The LMS supports multiple user roles, including:

Admin

Librarian

Staff

Borrower

The system manages books, loans, requests, fines, holds, and user accounts with a clean DAO β†’ Service β†’ UI architecture.

πŸ“Œ Features

πŸ‘¨β€πŸ’Ό Admin

  • Manage staff & librarians
  • View system reports
  • Full control over library operations

πŸ“š Book Management

  • Add / Update / Delete books
  • Search by title, author, subject, ISBN
  • Track availability

πŸ§‘β€πŸ€β€πŸ§‘ Borrower Management

  • Register borrower
  • Update borrower info
  • View borrower history

πŸ“– Loan Management

  • Issue books
  • Return books
  • Auto-calculate late fees
  • Track overdue items

πŸ“ Request & Hold Management

  • Borrower can request books
  • Staff processes holds
  • Automated hold queue

πŸ’° Fine System

  • Daily fine calculation
  • Track fine history
  • Fine payment handling

πŸ“Š Reports

  • Issued books
  • Loan summaries

Technologies Used

  • Java 17+
  • PostgreSQL
  • JDBC
  • Maven / Gradle / IDE Build Tools

PostgreSQL JDBC Dependency

β–Ά For Maven users:

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>42.7.2</version>
</dependency>

β–Ά For Gradle users:

dependencies {
    implementation 'org.postgresql:postgresql:42.7.2'
}

β–Ά For IntelliJ / Manual Setup:

Download the JDBC driver manually:

πŸ”— https://jdbc.postgresql.org/download/

Add the .jar file to your project:

File β†’ Project Structure β†’ Modules β†’ Dependencies β†’ + Add JAR

Architecture Diagram (Mermaid)

  • Java 17+
  • PostgreSQL
  • JDBC
  • Maven / IDE Build Tools

Architecture Diagram (Mermaid)

graph TD;
    A[User CLI] --> B[Controller Layer]
    B --> C[Service Layer]
    C --> D[DAO Layer]
    D --> E[(PostgreSQL DB)]
    C --> F[Utility Classes]
Loading

Project Structure

src/
β”‚
β”œβ”€β”€ entity/
β”‚   β”œβ”€β”€ Book.java
β”‚   β”œβ”€β”€ Loan.java
β”‚   β”œβ”€β”€ Borrower.java
β”‚   β”œβ”€β”€ Staff.java
β”‚   β”œβ”€β”€ Person.java
β”‚   └── HoldRequest.java
β”‚
β”œβ”€β”€ dao/
β”‚   β”œβ”€β”€ BookDAO.java
β”‚   β”œβ”€β”€ LoanDAO.java
β”‚   β”œβ”€β”€ UserDAO.java
β”‚   β”œβ”€β”€ StaffDAO.java
β”‚   └── AdminDAO.java
β”‚
β”œβ”€β”€ service/
β”‚   β”œβ”€β”€ BookService.java
β”‚   β”œβ”€β”€ LoanService.java
β”‚   β”œβ”€β”€ UserService.java
β”‚   └── StaffService.java
β”‚
β”œβ”€β”€ controller/
β”‚   β”œβ”€β”€ AdminInterface.java
β”‚   β”œβ”€β”€ LibrarianInterface.java
β”‚   β”œβ”€β”€ StaffInterface.java
β”‚   └── UserInterface.java
β”‚
└── util/
|    β”œβ”€β”€ DBConnection.java
|    β”œβ”€β”€ InputValidation.java
|    └── ConsoleHelper.java
└── Main.java

Database Schema

Full SQL seed data provided here:

πŸ‘‰ Download SQL Seed File

πŸ—„οΈ Database Tables

Table Name Description
admin Stores admin accounts and privileges
staff Holds staff records (common parent for clerks and librarians)
clerk Clerk-specific details (desk assignments, linked to staff)
librarian Librarian-specific details (office assignments, linked to staff)
borrowers Contains borrower information, login credentials, and contact details
books Stores book details (title, author, subject, ISBN)
book_copies Tracks individual copies of books, their condition, and issue status
loans Tracks issued books, due dates, returns, and borrower associations
hold_requests Manages book requests and the hold queue

▢️ Running the Project

1️⃣ Clone the repository

git clone https://github.com/joel-003/Library-Management-System.git
cd Library-Management-System

2️⃣ Setup PostgreSQL

Run the SQL seed file

psql -U postgres -d Library-Management-System -f LMS-SQL-seed.txt

3️⃣ Update JDBC credentials

private static final String URL = "jdbc:postgresql://localhost:5432/Library-Management-System";
private static final String USER = "postgres";
private static final String PASSWORD = "root";

Update DB credentials in DBConnection.java.

4️⃣ Run the project

Compile and run Main.java.

Login Flow

  • User selects role (Admin/Librarian/Staff/Borrower)
  • Enter credentials
  • Application validates
  • UI layer loads appropriate dashboard

Fine & Due Date Logic

  • Each loan records issue date & due date

  • Fine auto-calculated using service layer formula

  • Staff/librarian can collect fine

Hold Request Flow

  • Borrower requests book

  • Request added to hold-queue

  • Staff processes requests

  • Book assigned when available

Utility Classes

DBConnection

Provides a single shared database connection.

ConsoleHelper

Clears screen and formats CLI output.

InputValidator

Reusable validation functions for email, phone, numbers, etc.

Future Improvements

  • Add notifications (email/SMS)

  • Add librarian shift scheduling

  • Add analytics dashboard

  • Add PDF report generation

  • Add automated overdue reminders

License

This project is licensed under the MIT License.

See the LICENSE file for full details.

🎬 Run Demo

Below is a short demo of the CLI in action:

πŸ“Έ CLI Screenshots

Click below to view all screenshots:

πŸ‘‰ Open Screenshots Folder

UML Class Diagram

Below is the complete class diagram representing the system architecture.

UML Diagram

Database ER Diagram

erDiagram
    admin {
        serial id PK
        text name
        text user_id
        text password
    }

    staff {
        serial id PK
        varchar name
        varchar password
        varchar email
        varchar phno
        numeric salary
        varchar role
    }

    clerk {
        int id PK, FK
        varchar deskid
    }

    librarian {
        int id PK, FK
        varchar officeid
    }

    borrowers {
        serial borrower_id PK
        varchar name
        varchar email
        varchar password
        varchar phone_number
    }

    books {
        serial book_id PK
        varchar title
        varchar author
        varchar subject
        varchar isbn
    }

    book_copies {
        serial copy_id PK
        int book_id FK
        boolean is_issued
        varchar condition
    }

    hold_requests {
        serial hold_id PK
        int book_id FK
        int borrower_id FK
        date request_date
    }

    loans {
        serial loan_id PK
        int book_id FK
        int copy_id FK
        int borrower_id FK
        date issue_date
        date due_date
        date return_date
    }

    %% Relationships based on your diagram
    staff ||--|| clerk : "is a"
    staff ||--|| librarian : "is a"

    borrowers ||--o{ hold_requests : "places"
    books ||--o{ hold_requests : "requested for"

    books ||--o{ book_copies : "has"

    borrowers ||--o{ loans : "borrows"
    books ||--o{ loans : "loaned"
    book_copies ||--o{ loans : "copy used"

Loading

Releases

No releases published

Packages

 
 
 

Contributors

Languages