Skip to content

Command-line Library Management System for managing items and users, with interactive menus and data persistence.

Notifications You must be signed in to change notification settings

Amer-Abuyaqob/Library-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Library Management System

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.

πŸš€ Features

  • 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

πŸ“‹ Requirements

  • Python 3.7+
  • No external dependencies (uses only Python standard library)

πŸ—οΈ Architecture

System Flow Chart

For a visual representation of the system architecture and data flow, view our System Flow Chart on Miro.

Core Classes

  • Library: Main controller class managing items and users
  • LibraryItem: Abstract base class for all library items
  • Book: Represents books with genre information
  • DVD: Represents DVDs with duration information
  • Magazine: Represents magazines with genre information
  • User: Represents library users with borrowing history
  • Reservable: Interface for items that can be reserved

Data Structure

Item ID Format

  • 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 year
  • N: Sequential item number

User ID Format

  • Users: U-Ff-Ll-N (e.g., U-Jo-Sm-1)

Where:

  • U: User identifier
  • Ff: First name initials (first two characters)
  • Ll: Last name initials (first two characters)
  • N: Sequential user number

πŸš€ Quick Start

Running the Application

# Navigate to the project directory
cd "Library Management System"

# Run the main application
python main.py

Basic Usage

  1. Start the application: The main menu will appear
  2. Navigate menus: Use number keys to select options
  3. Add items: Go to "Items" β†’ "Add Item" to add books/DVDs/magazines
  4. Add users: Go to "Users" β†’ "Add User" to register new users
  5. Borrow items: Go to "Borrow/Return" β†’ "Borrow Item"
  6. Return items: Go to "Borrow/Return" β†’ "Return Item"
  7. Save and exit: Choose "Exit" from main menu

πŸ“ Project Structure

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

πŸ”§ API Documentation

Library Class

The main controller class that manages all library operations.

Key Methods

  • add_item(item): Add a new item to the library
  • remove_item(item): Remove an item from the library
  • update_item(item, new_item): Update item attributes
  • add_user(user): Register a new user
  • remove_user(user): Remove a user from the system
  • borrow_item(user, item): Borrow an item for a user
  • return_item(user, item): Return a borrowed item
  • load_data(): Load data from JSON files
  • save_data(): Save data to JSON files

Item Classes

Book

book = Book(title, author, year, available, genre, custom_id=None)

DVD

dvd = DVD(title, author, year, available, duration, custom_id=None)

Magazine

magazine = Magazine(title, author, year, available, genre, custom_id=None)

User Class

user = User(first_name, last_name, custom_id=None)

πŸ›‘οΈ Error Handling

The system includes comprehensive error handling with custom exceptions:

  • InvalidDataTypeError: Wrong data type provided
  • InvalidValueError: Invalid value (empty, too short, etc.)
  • MissingFieldError: Required field missing from data
  • ItemNotFoundError: Item doesn't exist in library
  • UserNotFoundError: User doesn't exist in system
  • ItemNotAvailableError: Item is not available for borrowing
  • ItemNotBorrowedError: User hasn't borrowed the item
  • ItemAlreadyExistsError: Item already exists in library
  • UserAlreadyExistsError: User already exists in system

πŸ’Ύ Data Storage

Items JSON Structure

{
  "id": "B-JD-2020-1",
  "type": "Book",
  "title": "The Great Gatsby",
  "author": "F. Scott Fitzgerald",
  "year": 1925,
  "available": true,
  "genre": "Fiction"
}

Users JSON Structure

{
  "id": "U-Jo-Sm-1",
  "first_name": "John",
  "last_name": "Smith",
  "borrowed_items": ["B-JD-2020-1", "D-SS-2019-2"]
}

πŸ§ͺ Development

Adding New Item Types

  1. Create a new class inheriting from LibraryItem
  2. Implement required abstract methods
  3. Add validation logic
  4. Update the Library.__create_item() method
  5. Add to the main menu system

Testing

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

πŸ“ License

This project is open source and available under the MIT License.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add appropriate documentation
  5. Submit a pull request

πŸ“ž Support

For issues or questions, please open an issue in the repository or contact the development team (only me).

About

Command-line Library Management System for managing items and users, with interactive menus and data persistence.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages