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.
docs/API.mdThe 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
# Clone the repository
git clone https://github.com/pyenthusiasts/Library-Management-OOP.git
cd Library-Management-OOP
# Install the package
pip install -e .
# Install with development dependencies
pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
# Run with demo data
library-cli --demo
# Run with custom configuration
library-cli --config config/library_config.json
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)
The CLI provides an interactive menu for managing your library:
library-cli
Available Operations:
See the examples/ directory for complete examples:
basic_usage.py: Basic library operationsadvanced_usage.py: Advanced features including persistence and searchRun examples:
python examples/basic_usage.py
python examples/advanced_usage.py
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)
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
Person defines the interface for all person typesget_details() must be implemented by subclassesMember inherits from Personget_details() differentlyLibrary manages collections of Book and Member objects# Install development dependencies
pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
# 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
# Run all tests
pytest
# Run with coverage
pytest --cov=library_system --cov-report=html
# Run specific tests
pytest tests/test_models/test_book.py
Contributions are welcome! Please follow these guidelines:
git checkout -b feature/amazing-feature)pytest)pre-commit run --all-files)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
docs/API.mdexamples/ directoryVersion 2.0.0 - A complete rewrite with professional architecture and comprehensive features.