This project is a comprehensive desktop application designed to digitalize and streamline library processes. It facilitates seamless interactions between three distinct types of users: Administrators, Employees, and Customers.
The core purpose of the application is to handle book inventory, secure user authentication, process sales, and provide automated management reports. It features a robust MySQL database integration, a responsive JavaFX graphical interface, and a highly secure Role-Based Access Control (RBAC) system.
The application is built using modern software engineering practices to ensure scalability, maintainability, and security:
- Architecture: Layered Architecture (Presentation/View, Service, and Data Access/Repository layers) adhering to SOLID principles and Clean Code methodologies.
- Design Patterns: Extensive use of structural and creational patterns, including Builder (for complex objects), Factory (for component instantiation), Singleton (for database connections), and Decorator (for caching repository responses).
- Security: Secure authentication mechanism utilizing SHA-256 Hashing for passwords and granular Role-Based Access Control (RBAC) driven by relational database mapping.
- Data Transfer: Use of DTOs (Data Transfer Objects) to strictly separate database entity models from the UI presentation layer.
- Dependency Management: Manual Dependency Injection implemented via component factories, demonstrating a deep understanding of inversion of control without relying on heavy external frameworks.
- Java 21
- Gradle (Build Automation Tool)
- JDBC (Java Database Connectivity) for executing highly optimized native SQL queries.
- SHA-256 for secure password cryptography.
- iText PDF for automated generation of monthly sales and employee activity reports.
- JavaFX (for a responsive, component-based desktop user interface)
- MySQL (Relational Database Management System)
- Git (Version Control)
- JUnit 5 (Unit Testing)
Users are dynamically routed based on their database-assigned role (Customer, Employee, Administrator).

Real-time stock updates upon successful book purchases.

Administrators have access to a dedicated dashboard to promote customers to employees, delete users, and track activity.

Administrators can generate detailed monthly sales reports (powered by iText PDF) to track employee performance and total revenue.

This project was developed as a comprehensive practical implementation for the Software Engineering course, focusing on architectural patterns, database relational design, and secure application flow.
To run this application on your local machine, you will need to set up the Java environment and a local MySQL server.
Prerequisites:
- Java JDK 21
- MySQL Server running on the default port
3306. - Your preferred Java IDE (IntelliJ IDEA, Eclipse, etc.)
Setup Steps:
-
Clone the repository:
git clone https://github.com/vici1136/java-library-management-system.git cd java-library-management-system -
Configure the Database Credentials: Navigate to
src/main/java/database/JDBConnectionWrapper.javaand ensure the database credentials match your local MySQL setup:private static final String USER = "root"; private static final String PASSWORD = "your_mysql_password";
-
Initialize the Database: Run the
mainmethod inside thedatabase.Bootstrap.javaclass.⚠️ Note: This script will drop any existing library tables and recreate a fresh schema (including all foreign key constraints), automatically populating the necessary roles (Administrator,Employee,Customer) and rights. -
Start the Application: Run the
mainmethod inside thelauncher.Main.javaclass to launch the JavaFX GUI. -
Test Accounts: You can create a new account directly from the app's "Sign Up" screen. Alternatively, after running
Bootstrap, you can inject test users directly into your MySQL database or use the admin panel to promote newly created customers to Employees or Administrators.
The application includes a comprehensive suite of unit tests to ensure the reliability of the business logic and data access layers.
- Framework: JUnit 5
- Approach: Unit testing focuses primarily on the Service layer and Repository layer, ensuring that business rules (like stock validation during sales) operate correctly.
- Mocking: Custom mock implementations (e.g.,
BookRepositoryMock) are utilized to isolate services from the actual MySQL database. This ensures fast, deterministic test execution without causing side effects to the actual data.
To run the tests: You can run the tests directly from your IDE's testing interface, or by executing the following Gradle command in your terminal:
./gradlew test