Skip to content

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

CommandDescription
--interactiveLaunch the interactive, menu‑driven UI
auth signinSign in to your account
auth signupRegister a new Reader or Librarian
auth signoutSign out of the current session
user listList all users (Librarian only)
user deleteDelete a user account
user promotePromote a user to Librarian
user demoteDemote a Librarian to Reader
user deactivateSuspend a user’s account
user activateReactivate a suspended user
book addAdd a book to inventory (Librarian only)
book updateUpdate book details
book deleteRemove a book from inventory
book listList all books
book searchSearch books by title/author/ISBN
book statsShow stats for a given book (times borrowed, overdue count, etc.)
borrow requestRequest to borrow a book
borrow approveApprove a borrow request (Librarian only)
borrow rejectReject a borrow request (Librarian only)
borrow returnReturn a borrowed book
borrow listList all pending borrow requests
borrow historyShow your personal borrowing history
profile viewView your user profile
profile updateUpdate your username
profile passwordChange your password
system seedInitialize or reset system data (Librarian only)
system importallows to get in data from external sources
system exportallows for backing up data
system configallows for configuring some system functions
report viewsReport: summary stats
report booksReport: book report stats
report borrowsReport: borrow stats
report usersReport: user stats
testRun the built‑in console UI tests
--help, -hShow 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

  • EbenLibListDynamic 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

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages