Library System is a console-based Java application for managing books, users, and lending operations. The project is built around the Model-View-Controller (MVC) architecture and uses SQLite for persistent data storage, JUnit 5 for automated testing, Maven for dependency and build management, and Docker for containerized execution.
The project demonstrates practical use of object-oriented programming, MVC architecture, JDBC, relational database integration, automated testing, Java Stream API, Maven, and Docker.
- Features
- Technologies
- Architecture
- Data Persistence
- Testing
- Project Structure
- Getting Started
- Running with Maven
- Running with Docker
- Docker Architecture
- Screenshots
- Future Improvements
- License
- Add books to the library
- Remove books
- List all books
- Lend books to users
- Return borrowed books
- Display borrowed books
- Search books by author
- Search books by publication year
- Sort books by title
- Sort books by year
- Create and manage users
- Track borrowed books
- Associate lending operations with users
- Persistent storage using SQLite
- Database access implemented using JDBC
- Dedicated database controllers for persistence operations
- Automated tests using JUnit 5
- Model and controller testing
- Database-related testing
- Maven test lifecycle integration
- Dockerized application
- Multi-stage Docker build
- Maven build and tests executed during the Docker image build
- Lightweight Java 21 runtime image for the final container
| Technology | Purpose |
|---|---|
| Java 21 | Application development |
| Maven | Dependency management and build automation |
| SQLite | Persistent relational database |
| JDBC | Database connectivity |
| JUnit 5 | Automated testing |
| Java Stream API | Collection filtering, sorting and processing |
| Docker | Containerization and reproducible execution |
| Git / GitHub | Version control and source-code hosting |
The application follows the Model-View-Controller (MVC) architectural pattern.
The model layer contains the main domain objects:
BookUserLibrary
These classes represent the application's core entities and their state.
The controller layer contains both business and persistence logic.
Examples include:
LibraryControllerUserControllerBookDbControllerDbConnectionController
Interfaces are used for controller contracts, helping keep the application modular and easier to test.
The view layer provides the console-based user interface.
The main view is responsible for:
- displaying the library menu
- reading user input
- displaying results
- delegating operations to controllers
Business logic is kept outside the view layer.
The application uses SQLite as its relational database.
Database communication is handled through JDBC, with database-specific operations separated into dedicated controllers.
The database stores information required for:
- books
- users
- lending operations
- book availability/status
This separation keeps SQL/database operations independent from the main business logic.
SQLite was chosen because it provides a lightweight relational database that does not require a separate database server.
This makes the project easy to run locally while still providing experience with:
- relational data
- SQL
- JDBC
- database connections
- CRUD operations
- persistence
The project uses the Java Stream API for collection processing.
Examples include:
- filtering books
- searching by author
- searching by year
- sorting books by title
- sorting books by publication year
Streams help keep collection-processing operations concise and readable.
The project uses JUnit 5 for automated testing.
Tests cover important application functionality including:
- model behavior
- controller operations
- library operations
- database-related functionality
The Maven build is configured to execute the test suite automatically.
The current test suite contains 30 tests, all passing successfully.
Tests run: 30
Failures: 0
Errors: 0
Skipped: 0
Tests can be executed with:
mvn testLibrarySystemMVC/
│
├── src/
│ ├── main/
│ │ └── java/
│ │ ├── controller/
│ │ │ ├── BookDbController.java
│ │ │ ├── DbConnectionController.java
│ │ │ ├── LibraryController.java
│ │ │ ├── UserController.java
│ │ │ └── interfaces...
│ │ │
│ │ ├── model/
│ │ │ ├── Book.java
│ │ │ ├── User.java
│ │ │ └── Library.java
│ │ │
│ │ └── view/
│ │ ├── MainUI.java
│ │ └── MainView.java
│ │
│ └── test/
│ └── java/
│ ├── model/
│ └── controller/
│
├── pom.xml
├── Dockerfile
├── .dockerignore
└── README.md
For running the project directly on your machine:
- JDK 21
- Apache Maven
- Git
For containerized execution:
- Docker Desktop or Docker Engine
git clone https://github.com/MIhajloS07/LibrarySystem-Java.git
cd LibrarySystem-JavaBuild the project:
mvn packageRun the tests:
mvn testThe packaged application is generated in the target directory.
The application includes a multi-stage Dockerfile that separates the build environment from the runtime environment.
docker build -t library-system .docker run --rm -it library-systemThe container starts the application automatically and displays the library management menu.
The Dockerfile uses two stages.
The first stage uses Maven with Java 21:
maven:3.9-eclipse-temurin-21
It:
- Copies the Maven configuration and source code.
- Runs the JUnit test suite.
- Packages the application into a JAR file.
The final stage uses:
eclipse-temurin:21-jre
Only the packaged application JAR is copied into the runtime image.
This approach keeps the final runtime image separate from the Maven build environment.
|
|
|
|
||
Possible future improvements include:
- Docker volume for persistent SQLite storage
- Improved CLI user experience and input validation
- Additional integration tests
- Database migration toward PostgreSQL or MySQL
- REST API layer
- GUI client
- CI/CD pipeline
- Deployment to a cloud environment
This project is licensed under the MIT License.



