A feature-rich Library Management System built in Java using the console. This project is designed to manage library operations such as book borrowing, returning, fine tracking, and transaction logging β all with persistent storage using serialization.
- π Book Management
- Add, Delete, Search, List books
- π€ User Registration & Login
- Each user has their own borrowing history
- π Borrow & Return Books
- Books can only be borrowed if they are available
- β° Due Date Tracking
- Books must be returned within 7 days
- π° Fine System
- βΉ10/day fine after due date
- Borrowing is blocked if outstanding fine > βΉ50
- Users can pay partial or full fine via "Pay Fine" menu
- π Data Persistence
- All user and book data is stored using
.ser
files
- All user and book data is stored using
- π§Ύ Transaction Logging
- All borrow and return operations are logged to a text file
- π Admin Dashboard
- View total fines collected across all users
- π Export to CSV
- Export current book list to
books.csv
- Export current book list to
- π Admin Mode
- Protected with password (
admin123
by default)
- Protected with password (
The repository includes a sample books.csv
file under data/
so you can test the system immediately after cloning. Other files like .ser
and logs are generated after first run and are excluded from GitHub using .gitignore
.
- Language: Java (Object-Oriented Programming, Collections)
- Persistence: Java Serialization (
.ser
files) - Logging: Text-based logging via
transaction_log.txt
- I/O: Reading/writing CSV, file-based storage
LibraryManagementSystem/
β
βββ data/ # Stores persistent and runtime data
β βββ books.csv # Sample book data (versioned)
β βββ users_data.ser # Saved user objects (ignored in Git)
β βββ library_data.ser # Saved book objects (ignored in Git)
β βββ transaction_log.txt # Log of all transactions (ignored in Git)
β
βββ src/ # Java source code
β βββ Main.java # Entry point
β βββ models/
β β βββ Book.java
β β βββ User.java
β βββ services/
β β βββ LibraryService.java
β β βββ FileHandler.java
β βββ utils/
β βββ TransactionLogger.java
β
βββ README.md # This file
βββ .gitignore # Git ignore rules
-
Clone the repository
git clone https://github.com/dinesh38555/Library-Management-System.git cd Library-Management-System
-
Compile the Java code
javac -d bin src/**/*.java
-
Run the application
java -cp bin Main
-
Use the Console Menu
Choose between User or Admin access. Register/Login β Borrow books β Return books β Pay fines.
Default Password: admin123
(Can be changed in LibraryService.java
's adminPassword
field)
Admin options include:
- View all transaction logs
- View total fines collected
- Export books list to CSV
- Every borrowed book has a 7-day deadline.
- After 7 days, a fine of βΉ10/day is applied.
- Borrowing is blocked until the total outstanding fine is βΉ50 or less.
- Users can pay partial or full fines using the menu.
- Admin can track total fines collected across all users.
To effectively test the fine system without waiting:
- Simulate a late return:
- Borrow a book as a user.
- Temporarily modify the
borrowedDate
in your code (e.g., inLibraryService.java
, you can setbook.setBorrowedDate(LocalDate.now().minusDays(10));
). Remember to remove this line after testing. - Return the book to observe the fine calculation.
- Pay the fine: Use the "Pay the pending fines" option from the user menu.
- Verify as Admin: Switch to admin mode to view transaction logs and total collected fines.
- Runtime data (
*.ser
,transaction_log.txt
) is not pushed to GitHub. - Only
books.csv
is tracked for demo/testing. - The entire application runs in the console β no GUI required. You can easily extend this to a JavaFX/Swing GUI.
Want to improve this system? Feel free to fork the repository and raise a pull request! Ideas for features include:
- GUI (JavaFX or Swing)
- Role-based access
- Search filters
- REST API backend
- SQLite or MySQL integration
This project is licensed under the MIT License.