An enterprise-grade, portfolio-quality Library Management System built from the ground up using Core Java 25, JDBC, MySQL 8.0, HikariCP, and Log4j2.
LibraCore exhibits clean software engineering patterns, custom thread-bound database transactions context management, salted BCrypt user authentication, fine-grained role authorization, automatic late-return penalty calculations, and an interactive Console User Interface.
- Interactive Command-Line Interface: Dynamic console menus tailored to active user roles with color-coded ANSI formatting and clean tabular alignment.
- Role-Based Access Control (RBAC): Fine-grained authorizations distinct for
ADMIN,LIBRARIAN, andSTUDENTprofiles. - Double-Booking & Reservation Control: Concurrency controls, waitlists, and reservation holds to prevent book allocation conflicts.
- Automatic Fine Invoicing: Automatic scan and calculation of late-return penalties ($0.50/day overdue).
- Enterprise Reporting: Built-in CSV report exporter mapping book catalog inventories.
- Audit Footprinting: Custom system-wide auditing triggers recording database updates and user security footprint logs.
LibraCore is designed with a defense-in-depth approach to application security:
- BCrypt Password Hashing: Utilizes the industry-standard
jBCryptlibrary to hash passwords with a secure salt, protecting credentials from disclosure. - Environment-Based Secrets: Connection parameters and secrets are loaded dynamically from a
.envconfiguration file at runtime, ensuring no raw passwords are committed to source control. - Secure JDBC PreparedStatements: All SQL execution is handled via parameterized queries, strictly eliminating SQL injection (SQLi) vulnerabilities.
- Transaction Management & Rollbacks: Uses a thread-local transaction helper that guarantees database mutations commit only on successful execution, auto-rolling back if exceptions are encountered.
- Input Validation: Centralized validation helper (
com.libracore.validation) checking for structural validity of parameters (such as Email format checks and ISBN-10/13 length matching) before processing data. - Thread-Safe Configurations: Implements thread-safe singleton connection pools via HikariCP and Initialization-on-demand holder configurations for system variables.
LibraCore implements a strict Clean Layered Architecture with unidirectional dependency flows:
graph TD
UI[Presentation Layer: Console CLI] --> AppService[Authentication & Session Cache Managers]
AppService --> BizService[Business Service Layer: Rules & Transaction Boundaries]
BizService --> DAO[Data Access Object Layer: PreparedStatements]
DAO --> DB[(MySQL 8 Database / HikariCP Pool)]
style UI fill:#f9f,stroke:#333,stroke-width:2px
style BizService fill:#bbf,stroke:#333,stroke-width:2px
style DAO fill:#dfd,stroke:#333,stroke-width:2px
style DB fill:#fdb,stroke:#333,stroke-width:2px
- Presentation Layer (
com.libracore.ui): Manages console inputs via Scanner helpers, renders ANSI-styled displays, prints tables, and forwards navigation based on active roles. - Security & Session Layer (
com.libracore.security): Intercepts unauthorized commands, hashes credentials, monitors active sessions, and handles session caching. - Business Service Layer (
com.libracore.service): Manages business rules (limits, status checks, waitlist queuing), sets transaction boundaries, and processes system actions. - DAO Persistence Layer (
com.libracore.dao): Decouples Java domain models from MySQL execution blocks by extending JDBC query execution templates. - Database Layer: Enforces referential integrity constraints, primary/foreign key mappings, performance indexes, and audit log triggers.
- DAO (Data Access Object) Pattern: Decouples domain services from raw database execution.
- Template Method: Standardizes SQL execution and query mapping inside
AbstractJdbcDAO.java. - Builder Pattern: Enforces validation on domain models (e.g.
Book.Builder,User.Builder). - Strategy Pattern: Decouples role-based permission checks into polymorphic strategy classes (
PermissionStrategy,AdminPermissionStrategy, etc.). - Singleton Pattern: Guarantees single thread-safe instances for connection pools and configurations.
- Command Pattern: Encapsulates menu navigation routes as executable command commands (
Command,CommandInvoker).
LibraCore/
├── .github/ # GitHub Actions CI workflow & pull request templates
│ └── workflows/
│ └── maven.yml # CI build testing (JDK 25 + MySQL service container)
├── docs/ # Architecture guides, database designs, and dev references
├── src/
│ ├── main/
│ │ ├── java/com/libracore/
│ │ │ ├── dao/ # Data Access Object contracts & execution templates
│ │ │ │ └── impl/ # Entity implementations (User, Book, Reservation, etc.)
│ │ │ ├── database/ # HikariCP pool configurations & transaction utilities
│ │ │ ├── exception/ # Domain exception hierarchy
│ │ │ ├── model/ # Builders and rich relational models
│ │ │ ├── security/ # BCrypt cryptography, session cache, RBAC strategies
│ │ │ ├── service/ # Service contracts & transaction management limits
│ │ │ │ └── impl/ # Business implementations & CSV report exporters
│ │ │ ├── ui/ # Interactive Console CLI navigation layers & MainApp
│ │ │ │ ├── command/ # UI routing encapsulating Command Pattern
│ │ │ │ └── menu/ # Action options for Admin, Student, and Librarian
│ │ │ └── validation/ # Central input validation checking
│ │ └── resources/ # database.properties, log4j2 configs & schemas
│ └── test/java/com/libracore/ # JUnit 5, Mockito, AssertJ integration/unit tests
├── pom.xml # Maven dependencies & build plugins
├── .env.example # Template file detailing configuration credentials
└── LICENSE # MIT License
erDiagram
CATEGORIES ||--o{ BOOKS : classifies
BOOKS ||--o{ BORROW_TRANSACTIONS : "borrowed in"
BOOKS ||--o{ RESERVATIONS : "reserved in"
BOOKS ||--o{ WAITLIST : "waitlisted in"
USERS ||--o{ BORROW_TRANSACTIONS : performs
USERS ||--o{ RESERVATIONS : holds
USERS ||--o{ WAITLIST : joins
USERS ||--o{ AUDIT_LOGS : triggers
BORROW_TRANSACTIONS ||--o{ FINE_PAYMENTS : accrues
The application leverages pinned versions of production-ready enterprise libraries:
- Connection Pool: HikariCP (5.1.0)
- JDBC Driver: MySQL Connector/J (9.0.0)
- Logging System: Log4j2 (2.24.1) bridged to SLF4J (2.0.16)
- Security & Encryption: jBCrypt (0.4)
- Report Exporter: Apache Commons CSV (1.11.0)
- JSON Parser: Jackson Databind (2.18.0)
- Utility Modules: Apache Commons Lang3 (3.17.0) and Commons IO (2.17.0)
- Test Architecture: JUnit 5 (5.11.2), Mockito (5.14.2), and AssertJ (3.27.0)
- Test Coverage Tool: JaCoCo (0.8.13)
- JDK 25 installed and configured in your path variables.
- Maven 3.8+ installed.
- MySQL Server 8.0+ running locally or remotely.
Connect to your local MySQL instance and load the database structure:
CREATE DATABASE IF NOT EXISTS libracore_db;
USE libracore_db;
-- Execute SQL script (creates tables, indexes, audit triggers, and default seeds)
SOURCE src/main/resources/schema.sql;To configure database connection credentials securely, copy the example template to a local environment file:
cp .env.example .envOpen your newly created .env file and set your MySQL username and password:
DB_USERNAME=your_mysql_username
DB_PASSWORD=your_mysql_secure_passwordThe application configures connection pooling properties in src/main/resources/database.properties by reading these environment values at startup, maintaining credential safety:
database.url=jdbc:mysql://localhost:3306/libracore_db?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
database.username=${DB_USERNAME:root}
database.password=${DB_PASSWORD:}
...Compile the source code using Maven:
mvn clean compileLaunch the Console CLI directly:
mvn exec:java -Dexec.mainClass="com.libracore.ui.MainApp"Run the full JUnit 5 test suite:
mvn clean testGenerates HTML JaCoCo code coverage reports:
mvn jacoco:reportThe test coverage reports will be located inside the project workspace directory at: target/site/jacoco/index.html.
LibraCore prioritizes high test coverage and structural correctness. The project maintains a complete integration and unit test suite targeting:
- Authentication, tokens, and authorization security strategies.
- Service transaction rollbacks and limits.
- Validation checks and data integrity.
Status: All 46 test cases execute and pass successfully with JaCoCo test coverage validation.
This project is licensed under the MIT License - see the LICENSE file for details.