Skip to content

lessurgobris/Library-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Library Management System

A comprehensive Python-based library management system that allows users to manage books, members, and loan transactions.

Features

📚 Book Management

  • Add Book: Register new books to the library with ID, title, and author
  • View Books: Display all books with their availability status

👥 Member Management

  • Register Member: Register new library members with ID, name, and email
  • View Members: Display all registered members

📋 Loan Management

  • Borrow Book: Process book borrowing with validation
  • Return Book: Process book returns and close loan transactions
  • View Loans: Display all loan transactions with status

✨ System Features

  • Error handling with custom exceptions
  • Real-time availability tracking
  • Unique loan ID generation
  • Comprehensive user interface with menu-driven operations

Project Structure

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

Class Diagram

┌─────────────────────┐
│      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()         │
└──────────────────────────────┘

Usage

Running the Program

python main.py

Menu Options

  1. Add Book - Add a new book to the library
  2. Register Member - Register a new library member
  3. Borrow Book - Borrow a book (must exist and be available)
  4. Return Book - Return a borrowed book
  5. View Books - Display all books and their status
  6. View Members - Display all registered members
  7. View Loans - Display all active and closed loans
  8. Exit - Close the program

Example Workflow

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

Error Handling

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

Data Flow

Adding a Book

  1. User provides book details
  2. Book object is created with available = True
  3. Book is stored in _books dictionary with book_id as key

Borrowing a Book

  1. System validates book and member exist
  2. System checks if book is available
  3. Book's available flag is set to False
  4. Loan object is created with unique loan_id
  5. Loan is appended to _loans list

Returning a Book

  1. System validates loan ID
  2. Book's available flag is set to True
  3. Loan's is_active flag is set to False

Future Enhancements

  • 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)

Requirements

  • Python 3.6+
  • No external dependencies required

Author

Library Management System - Mini Project

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages