A comprehensive command-line library management system built in Python that allows librarians to manage books, DVDs, magazines, and users with full borrowing/returning functionality.
- Item Management: Add, remove, update, and view books, DVDs, and magazines
- User Management: Register and manage library users
- Borrowing System: Track item borrowing and returns
- Reservation System: Reserve items (books and DVDs)
- Data Persistence: Automatic JSON file storage
- Input Validation: Comprehensive error handling and data validation
- Interactive CLI: User-friendly menu-driven interface
- Python 3.7+
- No external dependencies (uses only Python standard library)
For a visual representation of the system architecture and data flow, view our System Flow Chart on Miro.
Library: Main controller class managing items and usersLibraryItem: Abstract base class for all library itemsBook: Represents books with genre informationDVD: Represents DVDs with duration informationMagazine: Represents magazines with genre informationUser: Represents library users with borrowing historyReservable: Interface for items that can be reserved
- Books:
B-Aa-YYYY-N(e.g.,B-JD-2020-1) - DVDs:
D-Aa-YYYY-N(e.g.,D-SS-2019-2) - Magazines:
M-Aa-YYYY-N(e.g.,M-NG-2021-3)
Where:
T: Item type (B/D/M)Aa: Author initials (first letter of first and last word)YYYY: Publication yearN: Sequential item number
- Users:
U-Ff-Ll-N(e.g.,U-Jo-Sm-1)
Where:
U: User identifierFf: First name initials (first two characters)Ll: Last name initials (first two characters)N: Sequential user number
# Navigate to the project directory
cd "Library Management System"
# Run the main application
python main.py- Start the application: The main menu will appear
- Navigate menus: Use number keys to select options
- Add items: Go to "Items" β "Add Item" to add books/DVDs/magazines
- Add users: Go to "Users" β "Add User" to register new users
- Borrow items: Go to "Borrow/Return" β "Borrow Item"
- Return items: Go to "Borrow/Return" β "Return Item"
- Save and exit: Choose "Exit" from main menu
Library Management System/
βββ data/ # Data storage
β βββ items.json # Library items data
β βββ users.json # User data
βββ modules/ # Source code
β βββ main.py # Main application and CLI
β βββ library.py # Core library management
β βββ library_item.py # Abstract base class
β βββ book.py # Book implementation
β βββ dvd.py # DVD implementation
β βββ magazine.py # Magazine implementation
β βββ user.py # User management
β βββ reservable.py # Reservation interface
β βββ exceptions.py # Custom exceptions
βββ methods_exceptions/ # Documentation
β βββ *.txt # Method documentation files
βββ README.md # This file
The main controller class that manages all library operations.
add_item(item): Add a new item to the libraryremove_item(item): Remove an item from the libraryupdate_item(item, new_item): Update item attributesadd_user(user): Register a new userremove_user(user): Remove a user from the systemborrow_item(user, item): Borrow an item for a userreturn_item(user, item): Return a borrowed itemload_data(): Load data from JSON filessave_data(): Save data to JSON files
book = Book(title, author, year, available, genre, custom_id=None)dvd = DVD(title, author, year, available, duration, custom_id=None)magazine = Magazine(title, author, year, available, genre, custom_id=None)user = User(first_name, last_name, custom_id=None)The system includes comprehensive error handling with custom exceptions:
InvalidDataTypeError: Wrong data type providedInvalidValueError: Invalid value (empty, too short, etc.)MissingFieldError: Required field missing from dataItemNotFoundError: Item doesn't exist in libraryUserNotFoundError: User doesn't exist in systemItemNotAvailableError: Item is not available for borrowingItemNotBorrowedError: User hasn't borrowed the itemItemAlreadyExistsError: Item already exists in libraryUserAlreadyExistsError: User already exists in system
{
"id": "B-JD-2020-1",
"type": "Book",
"title": "The Great Gatsby",
"author": "F. Scott Fitzgerald",
"year": 1925,
"available": true,
"genre": "Fiction"
}{
"id": "U-Jo-Sm-1",
"first_name": "John",
"last_name": "Smith",
"borrowed_items": ["B-JD-2020-1", "D-SS-2019-2"]
}- Create a new class inheriting from
LibraryItem - Implement required abstract methods
- Add validation logic
- Update the
Library.__create_item()method - Add to the main menu system
The system includes comprehensive input validation and error handling. Test edge cases by:
- Providing invalid data types
- Using empty or invalid strings
- Testing boundary conditions
- Verifying data persistence
This project is open source and available under the MIT License.
- Fork the repository
- Create a feature branch
- Make your changes
- Add appropriate documentation
- Submit a pull request
For issues or questions, please open an issue in the repository or contact the development team (only me).