This is a simple command-line application for managing a book library. It allows users to perform basic operations such as adding, viewing, updating, and deleting book records. The application uses a MySQL database to store book information.
- Backend development using Java and Object-Oriented Programming (OOP) principles
- Designing and managing MySQL databases
- Building data access components for efficient database interaction (CRUD operations)
- Writing and executing unit tests
The project follows a standard Maven project structure:
Project-Java-Library_app/
├── .gitignore
├── pom.xml
├── README.md
├── .env.example
└── src/
├── main/
│ └── java/
│ └── org/example/
│ ├── App.java
│ ├── Main.java
│ ├── config/
│ │ └── DBManager.java
│ ├── controller/
│ │ └── BookController.java
│ ├── model/
│ │ └── Book.java
│ ├── repository/
│ │ └── BookRepository.java
│ └── view/
│ └── BookView.java
└── test/
└── java/
└── org/example/
└── repository/
└── BookRepositoryTest.java
The application provides the following features:
- Show book list: Displays all the books currently stored in the library.
- Show one book by ID: Displays detailed information about a specific book, identified by its ID.
- Add one book: Allows users to add a new book to the library by providing its title, author, summary, genre, and ISBN.
- Delete one book: Removes a book from the library based on its ID.
- Modify one book: Allows users to update the information of an existing book.
-
Prerequisites:
- Java (JDK): Version 21 or higher.
- Maven
- MySQL Server
-
Clone the Repository:
git clone <repository-url> cd Project-Java-Library_app
-
Database Setup:
- Ensure your MySQL server is running.
- Create a database for the application (e.g.,
project-java-library). - Create a table named
bookswithin your database. You can use the following SQL schema:CREATE TABLE books ( id_book INT AUTO_INCREMENT PRIMARY KEY, UNIQUE title VARCHAR(100) NOT NULL, author VARCHAR(100) NULL, summary VARCHAR(200) NULL, genre VARCHAR(50) NULL, isbn VARCHAR(13) NULL, );
-
Configure Environment Variables:
- Create a
.envfile in the root directory of the project. - Add the following environment variables to the
.envfile, replacing the placeholder values with your actual database credentials:DB_URL=jdbc:mysql://localhost:3306/your_database_name DB_USERNAME=your_mysql_username DB_PASSWORD=your_mysql_password
- An example file
.env.exampleis provided. You can rename it to.envand update the values.
- Create a
After successfully building the project, you can run the application from your IDE:
- Import the project into your Java IDE.
- Locate the
Main.javafile insrc/main/java/org/example/. - Run the
mainmethod in this class.
Once the application starts, it will run in your terminal and display a welcome message along with a menu. You can interact with the book library by typing options directly into the terminal.
Once the application is running, you will be presented with a menu:
Welcome to the library
Options:
1. Show book list
2. Show one book by Id
3. Add one book
4. Delete one book
5. Modify one book
6. Exit options menu
Select one number (eg 1):
You can interact with the application by entering the number corresponding to the desired option.
Example: Showing the book list
- Enter
1to select "Show book list". - The application will display a table with all the books:
Id | Title | Author | Genre | Isbn | 1 | Superintelligence: Paths, Dangers, Strategies | Nick Bostrom | Futurology | 9780198739838 |
- Java (Version 21)
- IntelliJ IDEA
- Git & Gitflow
- MySQL
- Dotenv-java
- JUnit 5 (Jupiter)
- Mockito
- Figma
- Trello
- Slack / WhatsApp
- Google Meet / Zoom
- Google Docs
The project includes tests, primarily focusing on the BookController and its interaction with the BookRepository.
This project was developed as a team exercise to practice team collaboration, software engineering best practices, and the use of modern development tools and workflows.
We applied the Model-View-Controller (MVC) architectural pattern to organize the application and improve code maintainability and separation of responsibilities.