Library-Management-OOP

Library Management System 2.0

CI Python 3.8+ License: MIT Code style: black

A comprehensive, production-ready library management system demonstrating advanced Object-Oriented Programming (OOP) principles in Python. This project showcases professional software development practices including modular architecture, comprehensive testing, type safety, and modern Python tooling.

Table of Contents

Features

Core Features

Advanced Features

Developer Features

Architecture

The system follows a layered architecture with clear separation of concerns:

library_system/
├── models/          # Domain models (Book, Member, Library)
├── services/        # Business logic and data persistence
├── exceptions/      # Custom exception classes
├── utils/          # Utility functions (validators)
├── config/         # Configuration management
└── cli/            # Command-line interface

Installation

Prerequisites

Standard Installation

# Clone the repository
git clone https://github.com/pyenthusiasts/Library-Management-OOP.git
cd Library-Management-OOP

# Install the package
pip install -e .

Development Installation

# Install with development dependencies
pip install -e ".[dev]"

# Install pre-commit hooks
pre-commit install

Quick Start

Using the CLI

# Run with demo data
library-cli --demo

# Run with custom configuration
library-cli --config config/library_config.json

Using the API

from library_system import Library, Book, Member, BookCategory

# Create a library
library = Library("My Library")

# Add a book
book = Book(
    title="1984",
    author="George Orwell",
    isbn="9780451524935",
    category=BookCategory.FICTION,
    publication_year=1949
)
library.add_book(book)

# Add a member
member = Member("John Doe", "john@example.com", "M001")
library.add_member(member)

# Borrow a book
member.borrow_book(book)
print(f"Due date: {book.due_date}")

# Return a book
member.return_book(book)

Usage

Command-Line Interface

The CLI provides an interactive menu for managing your library:

library-cli

Available Operations:

  1. Add Book
  2. Add Member
  3. Borrow Book
  4. Return Book
  5. List All Books
  6. List Available Books
  7. List Members
  8. Search Books
  9. Show Statistics
  10. Show Overdue Books

Examples

See the examples/ directory for complete examples:

Run examples:

python examples/basic_usage.py
python examples/advanced_usage.py

Advanced Usage with Persistence

from pathlib import Path
from library_system import Library
from library_system.services import StorageService
from library_system.config import Settings

# Load configuration
settings = Settings.load_or_default(Path("config/library_config.json"))

# Initialize storage
storage = StorageService(Path(settings.storage_path))

# Load existing library or create new one
library = storage.load_library() or Library(settings.library_name)

# Perform operations...

# Save changes
storage.save_library(library)

Project Structure

Library-Management-OOP/
├── library_system/              # Main package
│   ├── models/                  # Data models
│   ├── services/               # Business logic
│   ├── exceptions/             # Custom exceptions
│   ├── utils/                  # Utilities
│   ├── config/                 # Configuration
│   └── cli/                    # Command-line interface
├── tests/                      # Test suite
├── examples/                   # Usage examples
├── docs/                       # Documentation
├── config/                     # Configuration files
├── setup.py                    # Package setup
├── pyproject.toml             # Build configuration
└── README.md                  # This file

OOP Principles Demonstrated

1. Abstraction

2. Inheritance

3. Encapsulation

4. Polymorphism

5. Composition

6. SOLID Principles

Development

Setting Up Development Environment

# Install development dependencies
pip install -e ".[dev]"

# Install pre-commit hooks
pre-commit install

Code Quality Tools

# Format code
black library_system tests examples

# Sort imports
isort library_system tests examples

# Lint
flake8 library_system tests --max-line-length=100

# Type check
mypy library_system

# Run all checks
pre-commit run --all-files

Testing

# Run all tests
pytest

# Run with coverage
pytest --cov=library_system --cov-report=html

# Run specific tests
pytest tests/test_models/test_book.py

Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes with clear commit messages
  4. Add tests for new functionality
  5. Ensure all tests pass (pytest)
  6. Run code quality tools (pre-commit run --all-files)
  7. Commit your changes (git commit -m 'Add amazing feature')
  8. Push to the branch (git push origin feature/amazing-feature)
  9. Create a Pull Request

Development Guidelines

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Support

If you encounter any issues or have questions:


Version 2.0.0 - A complete rewrite with professional architecture and comprehensive features.