The Advanced Library Management System is a console-based Java application designed to manage the borrowing and returning of books within a library. It acts as a comprehensive demonstration of core Java capabilities, database integration using SQLite, and layered architectural patterns (Model-DAO-Service).
Problem Solved: Manually tracking books, users, and issue records is error-prone. This system digitizes the library catalog and user actions, enforcing business rules (like borrowing limits and inventory checks) automatically. Users:
- ADMIN: Staff who manage the library inventory (adding new books).
- STUDENT: Users who browse the catalog, issue books, and return them. Workflow: Users log in or register. Admins populate the library. Students view books, issue them (up to 3 at a time), and return them when finished.
- Language: Core Java (JDK)
- Database: SQLite (JDBC Driver
sqlite-jdbc-3.42.0.0.jar) - Frontend Framework: None (Console UI)
- Backend Framework: None (Custom MVC-like Layered Architecture)
- Authentication: Custom session state (
currentUserinMain.java), BCrypt-like hashing via customPasswordUtil.
src/model/: Plain Java Objects (POJOs) mapping to DB tables (User,Book,IssueRecord).src/dao/: Data Access Objects mapping to SQL statements (UserDAO,BookDAO,IssueDAO).src/service/: Business logic and rule enforcement (AuthService,LibraryService).src/util/: Helper utilities (DBConnection,InputUtil,PasswordUtil).src/view/: Console UI rendering logic (ConsoleView).sql/: Database schema definitions (schema.sql).
A standard 3-Tier Layered Architecture:
View (ConsoleView & Main) <-> Service (LibraryService, AuthService) <-> DAO (BookDAO, etc.) <-> SQLite DB
- Handled by
AuthService. - Registration: Checks for duplicate username via
UserDAO. Hashes the password viaPasswordUtil. Stores theUserobject. - Login: Retrieves user by username. Verifies password hash. If successful, sets the static
currentUserinMain.javato manage the active session.
- Database Config: SQLite path is hardcoded/defaulted in
DBConnection.javatolibrary.db. - Dependencies: Requires SQLite JDBC jar in the classpath at runtime.
- Adding a Book:
Mainreads input ->LibraryService.addNewBook()->BookDAO.addBook()-> DB. - Issuing a Book:
Main->LibraryService.issueBook(). Rules: Check book exists, check available copies > 0, check user has < 3 active issues. ->BookDAO.updateAvailableCopies()(reduce) ->IssueDAO.issueBook()-> DB. - Returning a Book:
Main->LibraryService.returnBook(). Rules: Check issue ID exists, check not already returned. ->IssueDAO.returnBook()->BookDAO.updateAvailableCopies()(increase).
- Global State: Uses a global static
currentUserinMain.java, which prevents multi-user concurrency if this were a server application. - Console Blocking: Uses
Scannerwhich blocks the main thread. - Hardcoded DB Paths: The SQLite connection string might be hardcoded in
DBConnection, limiting environment configurations.
- Migrate to a Web Framework (Spring Boot) and REST APIs.
- Replace custom
PasswordUtilwith standard BCrypt or Argon2. - Remove static state and adopt dependency injection.