Module Project
March 2023
Last updated
March 2023
Last updated
This project aims to create a library system. Let’s imagine a library:
You can give books to this library.
You can register to this library and keep track of the books you read/liked.
You can find the books by their genre/author.
You can see the top books/authors.
With this project, you will be able to have all these functionalities in your Library Command-line application.
To illustrate, a person who wants to borrow the “Harry Potter” book from the library needs to first register at the library. Thus he will enter the command sign_up, only username is required to sign up. After signing up, he will enter the command borrow_book and will give the “Book ID” together with this command. After running the borrow_book command if this book is available in the library he will be able to borrow the book. Later he can run the command return_book to return this book. A user can also mark books as read by running mark_read command or add this book to his/her favorites by running fav_book command. Both commands will require “Username” and “Book ID”.
To illustrate, everyone can add books to the library by running the add_book command. It is possible to search books by their name or their genre which is described in more detail in the Command Details section. By executing these commands, you can also see detailed information about the books including their “Book ID”.
You will use the Typer library in the implementation of this project. Typer is a library for building CLI applications that users will love using and developers will love creating. You can follow this tutorial to get familiar with the library.
Example repository we created for you → https://github.com/iremugurlu/sample-library-cli-app
The commands are split into 2 categories: the commands do not require a sign-in (available to all users) and the commands require sign-in.
This command doesn’t take any arguments. It creates the database if not created. If it is created, it connects to it. Finally, it logs the following output.
2. sign_up
This command takes ‘NAME’ and ‘PASSWORD’ as an argument. It adds a user to the database with his username and password. If the username is already in use, logs an error message and asks for another username.
3. sign_in
This command takes ‘NAME’ and ‘PASSWORD’ as an argument. It logs in the user into the system if the username and password combination exists in the database (a user needs to sign up before signing in). Logs an error message when the username doesn’t exist or the password is incorrect. After a successful login, the commands require a sign-in will be available to this user.
Successful
Error
4. search_by_name
This command takes ‘NAME’ as an argument. It displays books with this name in the table view. Note: You can show ‘True/False’ or the number of available books in the ‘Availability’ column.
5. search_by_author
This command takes ‘AUTHOR’ as an argument. It displays books written by this author in the table view. Note: You can show ‘True/False’ or the number of available books in the ‘Availability’ column.
6. recently_added
This command takes ‘GENRE’ as an optional argument. If it is provided, it displays the 5 most recent books added in a given genre. If not, it displays the 5 most recent books added. Keep the “date_added” information when adding a book so you can identify the most recent ones. Also, keep the “username” who added this book for the “Added By” column. Note: You can show ‘True/False’ or the number of available books in the ‘Availability’ column.
Without genre
With genre
7. most_read_books
This command takes ‘GENRE’ as an optional argument. If it is provided, it displays the 10 most-read books in a given genre. If not, it displays the 10 most-read books.
Without genre
With genre
Note: You need to have an ‘Added By’ column as well. These screenshots for the ‘recently_added’ command are not up to date.
8. most_favorite_books
This command takes ‘GENRE’ as an optional argument. If it is provided, it displays the 10 most favorite books in a given genre. If not, it displays the 10 most favorite books.
Without genre
With genre
9. most_read_genres
This command doesn’t take any arguments. It displays the 5 most-read genres.
10. most_read_authors
This command doesn’t take any arguments. It displays the 3 most-read authors.
The following commands are not available for users who are not signed in. If the user tries to run these commands before signing in, log an error message saying that they need to log in.
11. add_book
This command doesn’t take any arguments. It asks for the details of the book: name, author, # pages, and genre. Then it adds the book to the database. The books are identical by the combination of their name and author. If another book with the same name and author exists, increment the quantity of the existing book instead of adding a new one.
12. borrow_book
This command takes ‘BOOK ID’ as an argument. If this book is available, saves the data as the signed-in user borrowed the book and reduces the available amount of the book. If not available, then logs an error message saying this book is not available.
Available book
Unavailable book
13. return_book
This command takes ‘BOOK ID’ as an argument. If the signed-in user borrowed the book previously, it saves the data as this user returned the book and increments the available amount of the book. If this user did not borrow the book, then logs an error message saying this book is not borrowed by him.
Borrowed book
Not borrowed book
14. mark_read
This command takes ‘BOOK ID’ as an argument. It marks this book as “read” for the signed-in user.
15. fav_book
This command takes ‘BOOK ID’ as an argument. It adds this book to signed-in user’s favorites
16. my_books
This command doesn’t take any arguments. It displays the books read and favorited by the signed-in user.
17. statistics
This command doesn’t take any arguments. It displays the following statistics for the signed-in user in a table: number of books you read, number of authors you read, number of genres you read, and number of total pages you read.
Full attendance at mentor meetings
ERD Diagram
Python CLI application
Project presentation
GitHub repository with a README
PostgreSQL will be used as a database management system.
GitHub will be used in the project.
Each team will have a GitHub repository and each team member will be added as a collaborator.
Trello board will be used in the project.
Team mentors will be added to the board and they will check if the team uses Trello actively.
Meetings
A minimum of 30 minutes of meetings will be held with teammates every day. The content of the daily meeting is generally as follows: what each teammate has done, the general direction of the project and task sharing until tomorrow.
Each team will have a mentor. A meeting will be held with the team mentor and team members on the specified dates (once in 2 - 3 days). Each team can determine the time of the meetings.
Presentation at the end of the project. To complete the project, all members have to show up in the presentation and present the program.
You have to stick to the schedule. You will have a progress meeting with your mentor once in 2-3 days. You have to complete related steps before the next meeting.
Project Kick-off Meeting
Reading instructions
Understanding and discussing the requirements of the project with your teammates
Step 2
Database & ERD Design
Design the database according to the requirements of the project.
You can use the pgAdmin ERD tool to draw your ERD diagram.
Note: Present your DB design and ERD diagram to your mentor so you can get feedback about it!
Extract the SQL query from your ERD design to create the necessary tables.
Use this SQL file in your python application to create tables in your database upon the application start.
Note: Step 4 and Step 5 can be done in parallel by different teammates!
Write SQL queries to get/add the required information from/to the database.
Tip: Having a separate database.py
file to connect to database and execute queries would ease your work!
Implement all commands described in the Command Details section.
Connect commands and database functions to have a running app.
Test Your Program
Test your program and try to find the bugs.
Execute all of the commands your program has and verify that they work correctly.
Try different scenarios to discover new bugs.
Improve the exception handling in your program. Show useful error messages to users when undesired behaviour occurs.