A comprehensive console-based Python application that provides complete book and user management with borrowing, returns, popularity tracking, and graph‑based recommendations.
This Library Management System showcases solid Python design with clear separation between domain models, services, and UI helpers. It supports CRUD operations, a borrow queue when copies are unavailable, top‑K popular books, and a recommendation engine that leverages a simple user–book graph and user interests.
- CRUD Operations: Create, read, update, and delete books and users
- Search: Filter books by title, author, or genre
- Structured Models:
Book,User, and baseLibraryItemwith validation
- Borrow/Return: Safe borrowing with availability checks and returns
- Request Queue: FIFO queue when copies are unavailable (auto-processed on return)
- Popularity Tracking:
borrow_countincrements to support rankings
- Top‑K Books: List the most borrowed books
- Recommendations: Graph traversal + interests + popularity scoring
- Consistent Output: Title, subtitles, tables, and status messages
- Simple Menu Flow: Numbered options and validated inputs
- JSON Storage: Automatically loads state on startup and saves on exit
- Location:
data/library.json(ignored by Git)
- Separation of Concerns: Domain, services, UI, and utilities
- Data Structures: Custom
LinkedListQueueandGraphto illustrate CS basics
src/book.py
├── LibraryItem (base)
└── Book (domain model)
src/user.py
└── User (domain model)
src/data_structures.py
├── LinkedListQueue[T]
└── Graph (undirected)
src/library.py
└── Library (service: CRUD, borrow/return, queries)
src/recommendation.py
└── RecommendationEngine
src/ui.py
└── Console helpers (title, table, messages)
src/app.py
└── CLI entry point and menu loop
- Python 3.9 or later
- Create and activate a virtual environment
python -m venv .venv # Windows .venv\Scripts\activate # macOS/Linux source .venv/bin/activate
- Install dependencies
pip install -r requirements.txt
The app seeds a few demo books and users at startup so you can explore features immediately.
- Windows:
python .\src\app.py - macOS/Linux:
python src/app.py
- Add Book – Create a new book
- Remove Book – Delete a book by ID
- Update Book – Modify title/author/genre
- Add User – Create a user with interests
- Borrow Book – Borrow if available, else enqueue
- Return Book – Return and auto-process queue
- Show Available Books – List books with copies left
- Show Top‑K Books – Most borrowed rankings
- Recommend Books – Personalized suggestions
- Exit – Quit the application
When you exit, the current state (books, users, borrow queue, popularity) is saved to data/library.json. Next launch will restore this state automatically.
- In‑Memory Storage: Data is kept in memory during runtime
- No Secrets: Application does not require authentication
- Persistence Layer: Add database or file storage
- Input Hardening: Expand validation and error handling
- Note: Basic JSON persistence is included; switch to a database for multi‑user or concurrent scenarios
LinkedListQueue[T]: O(1) enqueue/dequeue; used for borrow requestsGraph: Undirected adjacency list; used for recommendations (BFS)
- (Optional) Tests:
pytest - (Optional) Lint:
ruff check . - (Optional) Format:
black . - (Optional) Type Check:
mypy .
Library-Management-System/
├── src/
│ ├── app.py
│ ├── book.py
│ ├── data_structures.py
│ ├── library.py
│ ├── recommendation.py
│ ├── ui.py
│ └── user.py
├── data/ # runtime state (JSON), ignored by Git
├── requirements.txt
├── .gitignore
├── LICENSE
└── README.md
- JSON persistence is basic (single-user, no concurrency guarantees)
- Minimal validation in CLI prompts
- Simple recommendation heuristic (educational)
Contributions are welcome via pull requests.
MIT © 2025 elseh — see LICENSE.
If you have questions or issues:
- Review this README and docstrings in
src/ - Open an issue or PR if something can be improved