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.
- Features
- Architecture
- Installation
- Quick Start
- Usage
- Project Structure
- OOP Principles
- Development
- Testing
- Contributing
- License
- Book Management: Add, remove, search, and categorize books
- Member Management: Register members with customizable borrowing limits
- Borrowing System: Track book loans with due dates
- Overdue Tracking: Automatic overdue detection with late fee calculation
- Search Functionality: Search by title, author, or category
- Data Persistence: Save and load library state using JSON storage
- Statistics: Comprehensive library statistics and reports
- Type Safety: Full type hints throughout the codebase
- Custom Exceptions: Specific exception handling for different error scenarios
- Data Validation: Email and ISBN validation
- Configurable Settings: JSON-based configuration system
- CLI Interface: Interactive command-line interface
- Extensible Architecture: Modular design for easy extension
- Comprehensive Testing: Full test coverage with pytest
- CI/CD Pipeline: GitHub Actions for automated testing
- Code Quality Tools: Black, isort, flake8, mypy, pylint
- Pre-commit Hooks: Automated code quality checks
- API Documentation: Detailed API reference in
docs/API.md
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
- Python 3.8 or higher
# 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.jsonfrom 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-cliAvailable Operations:
- Add Book
- Add Member
- Borrow Book
- Return Book
- List All Books
- List Available Books
- List Members
- Search Books
- Show Statistics
- Show Overdue Books
See the examples/ directory for complete examples:
basic_usage.py: Basic library operationsadvanced_usage.py: Advanced features including persistence and search
Run examples:
python examples/basic_usage.py
python examples/advanced_usage.pyfrom 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
- Abstract Base Class:
Persondefines the interface for all person types - Abstract Methods:
get_details()must be implemented by subclasses
Memberinherits fromPerson- Extends functionality while maintaining the base interface
- Private attributes with property accessors
- Controlled access to internal state
- Multiple classes implement
get_details()differently - Common interface for different object types
Librarymanages collections ofBookandMemberobjects- Clear "has-a" relationships
- Single Responsibility: Each class has one clear purpose
- Open/Closed: Extensible through inheritance and composition
- Liskov Substitution: Subclasses can replace parent classes
- Interface Segregation: Focused interfaces
- Dependency Inversion: Depends on abstractions
# 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.pyContributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes with clear commit messages
- Add tests for new functionality
- Ensure all tests pass (
pytest) - Run code quality tools (
pre-commit run --all-files) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Create a Pull Request
- Follow PEP 8 style guide
- Add type hints to all functions
- Write docstrings for all public methods
- Maintain test coverage above 90%
- Update documentation for new features
This project is licensed under the MIT License - see the LICENSE file for details.
- Designed for educational purposes to demonstrate OOP principles
- Inspired by real-world library management systems
- Built with modern Python best practices
If you encounter any issues or have questions:
- Issues: GitHub Issues
- Documentation: See
docs/API.md - Examples: Check the
examples/directory
Version 2.0.0 - A complete rewrite with professional architecture and comprehensive features.