Skip to content

Latest commit

 

History

History
54 lines (44 loc) · 3.58 KB

memory.md

File metadata and controls

54 lines (44 loc) · 3.58 KB

Advanced Library Management System - Memory

Project Overview

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).

Business Purpose

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.

Tech Stack

  • 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 (currentUser in Main.java), BCrypt-like hashing via custom PasswordUtil.

Repository Structure

  • 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).

System Architecture

A standard 3-Tier Layered Architecture: View (ConsoleView & Main) <-> Service (LibraryService, AuthService) <-> DAO (BookDAO, etc.) <-> SQLite DB

Authentication Flow

  • Handled by AuthService.
  • Registration: Checks for duplicate username via UserDAO. Hashes the password via PasswordUtil. Stores the User object.
  • Login: Retrieves user by username. Verifies password hash. If successful, sets the static currentUser in Main.java to manage the active session.

Environment & Configuration

  • Database Config: SQLite path is hardcoded/defaulted in DBConnection.java to library.db.
  • Dependencies: Requires SQLite JDBC jar in the classpath at runtime.

Important Features & Data Flow

  1. Adding a Book: Main reads input -> LibraryService.addNewBook() -> BookDAO.addBook() -> DB.
  2. 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.
  3. Returning a Book: Main -> LibraryService.returnBook(). Rules: Check issue ID exists, check not already returned. -> IssueDAO.returnBook() -> BookDAO.updateAvailableCopies() (increase).

Technical Debt & Performance

  • Global State: Uses a global static currentUser in Main.java, which prevents multi-user concurrency if this were a server application.
  • Console Blocking: Uses Scanner which blocks the main thread.
  • Hardcoded DB Paths: The SQLite connection string might be hardcoded in DBConnection, limiting environment configurations.

Future Recommendations

  • Migrate to a Web Framework (Spring Boot) and REST APIs.
  • Replace custom PasswordUtil with standard BCrypt or Argon2.
  • Remove static state and adopt dependency injection.