Skip to content

A Java-based, offline-first, console-driven Library Management System. Implements core data structures and file-based persistence.

Notifications You must be signed in to change notification settings

Programming-Sai/Library-Management-System

Repository files navigation

Logo




Deme

EbenLib Library Management System

A robust Java-based, offline-first library management CLI that enforces data integrity, borrow/return rules, and user roles without a database. Implements core data structures (dynamic arrays, hash maps, priority queues) and algorithms (binary search, merge sort) for efficient operations. Features an interactive menu-driven console UI with ANSI theming, spinners, and pagination. Packaged as a native Windows binary using GraalVM for fast startup.


πŸš€ Quick Start

Requirements

  • JavaΒ 17+Β (or your GraalVM distribution set asΒ JAVA_HOME)
  • GradleΒ 8+

How to run

For dev, use the utility psh script to run

  ./run.ps1 --interactive

  # For help.

  .\run.ps1 --help


Packaging

β­‘ Native Windows EXE (via GraalVM native-image)

  1. Install GraalVM 21 CE and set JAVA_HOME β†’

    $env:JAVA_HOME = 'C:\graalvm\jdk-21.0.2'
    $env:Path = "$env:JAVA_HOME\bin;$env:Path"
  2. Ensure you have Visual Studio Build Tools (for cl.exe).

  3. Build the β€œfat-jar” + native image:

    ./gradlew clean nativeImage
  4. You’ll end up with ebenlib.exe. To test:

    .\ebenlib.exe --interactive

Optional icon injection uses Resource Hacker if installed under C:\Program Files (x86)\Resource Hacker\ResourceHacker.exe.

β­‘ Fat-Jar Only

If you prefer a single JAR (no native-image):

./gradlew clean jar
java -jar app/build/libs/app.jar --interactive

πŸ“š Command Reference

ebenlib <category> <command>

Core Commands

Command Description
--interactive Launch the interactive, menu‑driven UI
auth signin Sign in to your account
auth signup Register a new Reader or Librarian
auth signout Sign out of the current session
user list List all users (Librarian only)
user delete Delete a user account
user promote Promote a user to Librarian
user demote Demote a Librarian to Reader
user deactivate Suspend a user’s account
user activate Reactivate a suspended user
book add Add a book to inventory (Librarian only)
book update Update book details
book delete Remove a book from inventory
book list List all books
book search Search books by title/author/ISBN
book stats Show stats for a given book (times borrowed, overdue count, etc.)
borrow request Request to borrow a book
borrow approve Approve a borrow request (Librarian only)
borrow reject Reject a borrow request (Librarian only)
borrow return Return a borrowed book
borrow list List all pending borrow requests
borrow history Show your personal borrowing history
profile view View your user profile
profile update Update your username
profile password Change your password
system seed Initialize or reset system data (Librarian only)
system import allows to get in data from external sources
system export allows for backing up data
system config allows for configuring some system functions
report views Report: summary stats
report books Report: book report stats
report borrows Report: borrow stats
report users Report: user stats
test Run the built‑in console UI tests
--help, -h Show this help message

Use ebenlib <category> <command> --help for detailed usage.


πŸ”§ Examples

# Sign up new Librarian
ebenlib auth signup

# Sign in
ebenlib auth signin

# Add a new book
ebenlib book add --title="1984" --author="Orwell" --copies=5

# Search books
ebenlib book search --title="Potter"

# Borrow a book
ebenlib borrow request --book-id=42

# Run the interactive menu
ebenlib --interactive

πŸ—‚ Project Structure

./Library-Management-System/*
        β”œβ”€ app/*
        |       β”œβ”€ src/*
        |       |       β”œβ”€ main/*
        |       |       |       β”œβ”€ java/*
        |       |       |       |       β”œβ”€ org/*
        |       |       |       |       |       └─ ebenlib/*
        |       |       |       |       |               β”œβ”€ book/*
        |       |       |       |       |               |       β”œβ”€ Book.java
        |       |       |       |       |               |       β”œβ”€ BookHandler.java
        |       |       |       |       |               |       β”œβ”€ BookService.java
        |       |       |       |       |               |       └─ BookStats.java
        |       |       |       |       |               β”œβ”€ borrow/*
        |       |       |       |       |               |       β”œβ”€ BorrowHandler.java
        |       |       |       |       |               |       β”œβ”€ BorrowRecord.java
        |       |       |       |       |               |       β”œβ”€ BorrowSettings.java
        |       |       |       |       |               |       β”œβ”€ BorrowStore.java
        |       |       |       |       |               |       └─ Status.java
        |       |       |       |       |               β”œβ”€ cli/*
        |       |       |       |       |               |       β”œβ”€ AuthHandler.java
        |       |       |       |       |               |       β”œβ”€ CommandRouter.java
        |       |       |       |       |               |       β”œβ”€ ConsoleThemeTest.java
        |       |       |       |       |               |       β”œβ”€ ConsoleUI.java
        |       |       |       |       |               |       β”œβ”€ InteractiveMenus.java
        |       |       |       |       |               |       β”œβ”€ InteractiveShell.java
        |       |       |       |       |               |       └─ TablePrinter.java
        |       |       |       |       |               β”œβ”€ ds/*
        |       |       |       |       |               |       β”œβ”€ EbenLibComparator.java
        |       |       |       |       |               |       β”œβ”€ EbenLibFunction.java
        |       |       |       |       |               |       β”œβ”€ EbenLibHashSet.java
        |       |       |       |       |               |       β”œβ”€ EbenLibList.java
        |       |       |       |       |               |       β”œβ”€ EbenLibMap.java
        |       |       |       |       |               |       β”œβ”€ EbenLibMapEntry.java
        |       |       |       |       |               |       β”œβ”€ EbenLibPriorityQueue.java
        |       |       |       |       |               |       β”œβ”€ EbenLibSet.java
        |       |       |       |       |               |       └─ EbenLibStack.java
        |       |       |       |       |               β”œβ”€ profile/*
        |       |       |       |       |               |       └─ ProfileHandler.java
        |       |       |       |       |               β”œβ”€ report/*
        |       |       |       |       |               |       └─ ReportHandler.java
        |       |       |       |       |               β”œβ”€ searchsort/*
        |       |       |       |       |               |       β”œβ”€ Searcher.java
        |       |       |       |       |               |       └─ Sorter.java
        |       |       |       |       |               β”œβ”€ system/*
        |       |       |       |       |               |       └─ SystemHandler.java
        |       |       |       |       |               β”œβ”€ user/*
        |       |       |       |       |               |       β”œβ”€ Role.java
        |       |       |       |       |               |       β”œβ”€ User.java
        |       |       |       |       |               |       β”œβ”€ UserHandler.java
        |       |       |       |       |               |       └─ UserStore.java
        |       |       |       |       |               β”œβ”€ utils/*
        |       |       |       |       |               |       └─ FileUtil.java
        |       |       |       |       |               └─ App.java
        |       |       |       |       └─ module-info.java
        |       |       |       └─ resources/*
        |       |       |               β”œβ”€ books.csv
        |       |       |               β”œβ”€ borrows.csv
        |       |       |               β”œβ”€ session.csv
        |       |       |               β”œβ”€ settings.txt
        |       |       |               └─ users.csv
        |       |       └─ test/*
        |       |               β”œβ”€ java/*
        |       |               |       └─ org/*
        |       |               |               └─ ebenlib/*
        |       |               |               └─ AppTest.java
        |       |               └─ resources/*
        |       β”œβ”€ build.gradle
        |       β”œβ”€ ebenlib.exe
        |       └─ ebenlib.ico
        β”œβ”€ src/*
        |       └─ main/*
        |               └─ resources/*
        |               β”œβ”€ books.csv
        |               └─ borrows.csv
        β”œβ”€ .fttignore
        β”œβ”€ .gitattributes
        β”œβ”€ .gitignore
        β”œβ”€ demo.png
        β”œβ”€ gradle.properties
        β”œβ”€ gradlew
        β”œβ”€ gradlew.bat
        β”œβ”€ README.md
        β”œβ”€ run.ps1
        └─ settings.gradle

πŸ”§ Data Structures & Algorithms

  • EbenLibList Dynamic array with O(1) random access, amortized O(1) append, O(n) remove.
  • EbenLibStack LIFO built on EbenLibList: push, pop, peek all O(1).
  • EbenLibMap<K,V> Chained-hash table: average O(1) get/put/remove; rehash at load > 0.75.
  • EbenLibPriorityQueue Binary-heap: O(log n) insert & remove-max/min.
  • EbenLibHashSet Wrapper over EbenLibMap<T,Boolean>, O(1) contains/add/remove.
  • Binary Search O(log n) on pre-sorted EbenLibList via Searcher.binarySearch.
  • Merge Sort O(n log n) stable sort implemented in Sorter.mergeSort.

🌱 Developer Notes

  • Adding new commands:

    1. Extend CommandRouter.route(...).
    2. Implement a new handler class (e.g. BookHandler).
    3. Wire it in CommandRouter and add stubs in InteractiveMenus.
  • Interactive UI: Uses ANSI colors, pagination, spinnersβ€”fully themable via ConsoleTheme.

  • Native packaging: For lightning‑fast startup, use GraalVM’s native-image to compile into a standalone ebenlib binary. See GraalVM docs.


🀝 Contributing

  1. Fork this repo
  2. Create your feature branch (git checkout -b feature/xyz)
  3. Commit your changes (git commit -m "feat: add XYZ")
  4. Push to your branch (git push origin feature/xyz)
  5. Open a Pull Request

About

A Java-based, offline-first, console-driven Library Management System. Implements core data structures and file-based persistence.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 6