A comprehensive Python-based library management system that allows users to manage books, members, and loan transactions.
- Add Book: Register new books to the library with ID, title, and author
- View Books: Display all books with their availability status
- Register Member: Register new library members with ID, name, and email
- View Members: Display all registered members
- Borrow Book: Process book borrowing with validation
- Return Book: Process book returns and close loan transactions
- View Loans: Display all loan transactions with status
- Error handling with custom exceptions
- Real-time availability tracking
- Unique loan ID generation
- Comprehensive user interface with menu-driven operations
Library-Management-System/
├── book.py # Book model class
├── member.py # Member model class
├── loan.py # Loan transaction model class
├── exceptions.py # Custom exception classes
├── library_service.py # Core service logic
├── main.py # Main program and menu interface
└── README.md # This file
┌─────────────────────┐
│ Book │
├─────────────────────┤
│ - book_id │
│ - title │
│ - author │
│ - available │
├─────────────────────┤
│ + borrow() │
│ + return_book() │
└─────────────────────┘
┌─────────────────────┐
│ Member │
├─────────────────────┤
│ - member_id │
│ - name │
│ - email │
└─────────────────────┘
┌─────────────────────┐
│ Loan │
├─────────────────────┤
│ - loan_id │
│ - book │
│ - member │
│ - borrow_date │
│ - is_active │
├─────────────────────┤
│ + close_loan() │
└─────────────────────┘
┌──────────────────────────────┐
│ LibraryService │
├──────────────────────────────┤
│ - _books │
│ - _members │
│ - _loans │
│ - _loan_counter │
├──────────────────────────────┤
│ + add_book() │
│ + view_books() │
│ + register_member() │
│ + view_members() │
│ + borrow_book() │
│ + return_book() │
│ + view_loans() │
│ + get_active_loans() │
└──────────────────────────────┘
python main.py- Add Book - Add a new book to the library
- Register Member - Register a new library member
- Borrow Book - Borrow a book (must exist and be available)
- Return Book - Return a borrowed book
- View Books - Display all books and their status
- View Members - Display all registered members
- View Loans - Display all active and closed loans
- Exit - Close the program
1. Add a book:
- Book ID: B001
- Title: Python Programming
- Author: John Doe
2. Register a member:
- Member ID: M001
- Name: Alice Smith
- Email: alice@example.com
3. Borrow a book:
- Book ID: B001
- Member ID: M001
- System generates Loan ID: L001
- Book becomes unavailable
4. Return the book:
- Loan ID: L001
- Book becomes available again
- Loan is marked as closed
The system includes comprehensive error handling:
- BookNotFoundError: Raised when a book ID doesn't exist
- MemberNotFoundError: Raised when a member ID doesn't exist
- BookUnavailableError: Raised when attempting to borrow an already borrowed book
- LoanNotFoundError: Raised when a loan ID doesn't exist or is already closed
- User provides book details
- Book object is created with
available = True - Book is stored in
_booksdictionary with book_id as key
- System validates book and member exist
- System checks if book is available
- Book's
availableflag is set toFalse - Loan object is created with unique loan_id
- Loan is appended to
_loanslist
- System validates loan ID
- Book's
availableflag is set toTrue - Loan's
is_activeflag is set toFalse
- Persistent data storage (database or file-based)
- Due date tracking and late fee calculations
- Member borrowing history
- Book search and filtering capabilities
- Data export functionality
- Graphical user interface (GUI)
- Python 3.6+
- No external dependencies required
Library Management System - Mini Project
MIT License