A modular Library Management System built using Java, Spring MVC, Spring JDBC, Spring AOP, JUnit5, Mockito, PostgreSQL, and Maven—featuring clean architecture, robust testing, and interactive console routing for both admin and user operations.
Get the project running in just a few steps:
# Clone the repo
git clone git@github.com:Junaid-Ashraf-56/Library_Management_System-Spring-.git
cd Library_Management_System-Spring-
# Build the project
mvn clean install
# Run the application
java -jar target/library-management-system-0.0.1-SNAPSHOT.jarFor a deeper understanding of the concepts used in this project, check out my Hashnode blogs:
- Features
- Tech Stack
- Architecture Overview
- Screenshots
- Installation
- Usage
- Testing
- Console Navigation
- Project Structure
- Contributing
- Acknowledgments
- Book Management: Add, update, delete, and list books.
- User Management: Manage library members and librarians.
- Search: Find books by title, author, ISBN, or category.
- Borrow/Return Workflow: Track checkouts and returns with due dates.
- Role-Based Access: Admins manage inventory/users; patrons borrow books.
- Audit Logging (AOP): Automatic logging of key operations.
- Data Validation: Ensures integrity (e.g., unique ISBNs, valid logins).
This project is structured following Clean Architecture principles, ensuring modularity, maintainability, and clear separation of concerns:
- Model Layer
Defines core domain entities such asBook,Person, andBorrow. - Service Layer
Encapsulates business logic, including borrowing workflows and user registration. - Repository Layer
Handles persistence with Spring JDBC, ensuring reliable communication with the PostgreSQL database. - Controller / UI Layer
Provides console-driven interfaces for both Admin and User operations.
Spring AOP handles cross-cutting concerns like logging, ensuring clean and maintainable code.
-
Install prerequisites: Java (11+), Maven, PostgreSQL.
-
Database setup:
- Create a PostgreSQL database (e.g.,
librarydb).
- Create a PostgreSQL database (e.g.,
-
Build the project:
mvn clean install
Run the application:
Or run the packaged JAR:
java -jar target/library-management-system-0.0.1-SNAPSHOT.jarRun all tests:
mvn testRun a single test:
mvn test -Dtest=BookServiceTestAdmin Menu
1. Add Person
2. Add Book
3. Manage Books
4. List Persons
5. List Books
6. Delete Person
7. Delete Book
8. Logout
User Menu
1. Borrow a Book
2. Return Book
3. View Borrowed Books
4. Search Books
5. Logout
LibraryManagementSystem/
├─ src/
│ ├─ main/java/
│ │ ├─ aspect/
│ │ ├─ config/
│ │ ├─ controller/
│ │ ├─ dao/
│ │ ├─ model/
│ │ ├─ service/
│ │ ├─ terminal_ui/
│ │ └─ Main.java
│ ├─ main/resources/
│ └─ test/java/
│ ├─ controller/
│ ├─ dao/
│ ├─ service/
├─ pom.xml
└─ README.md
Contributions are welcome!
- Fork the repo & create a branch
- Add tests for new features
- Follow coding standards
- Submit a PR with a clear description
- Spring Framework – for modular development
- JUnit & Mockito – for testing support
- Clean Architecture (Robert C. Martin) – design inspiration
- Baeldung – helpful Spring/JUnit
✨ Thank you for using and contributing to this Library Management System!


