Skip to main content

📚 Personal Library Manager

A dependency-free, command-line manager for your personal book collection. Add, remove, search, browse and track your reading — with automatic, crash-safe persistence to JSON and a human-readable TXT export.

Python 3.9+ No dependencies CLI MIT License

PyPI version PyPI Python versions CI

Package names

  • PyPI distribution: personal-library-manager-cli-aui
  • Python import: personal_library_manager
  • CLI command: personal_library_manager

The distribution name differs because the plain personal-library-manager name is already registered on PyPI by another project. The import package and command are exactly as expected.

PyPI badges populate after the first release. This project has not been published to PyPI yet.


📑 Table of Contents


✨ Overview

Personal Library Manager stores each book with its title, author, publication year, genre and read status, then lets you search, filter, and measure your reading progress from a simple numbered menu.

The project uses only the Python Standard Library, so installation is fast and there is nothing to compile. User data is written outside the installed package to a per-user data directory, which means your library survives upgrades and works on Windows, macOS and Linux.


🚀 Features

Feature Description
➕ Add books Store title, author, year, genre and read status
🗑️ Remove books Delete by title using case-insensitive matching
🔎 Search Case-insensitive substring search by title or author
📖 Browse Numbered, formatted list of every book
📊 Statistics Total books, books read, unread and completion percentage
💾 Dual persistence Writes library.json (data) and library.txt (readable export)
🛡️ Crash-safe saves Atomic writes via temporary file + rename
🔁 Corrupt-file recovery Broken JSON is backed up, never silently deleted
📦 Legacy migration Imports an existing library.json from the working directory
✅ Validation Rejects empty fields, non-numeric or non-positive years
🧪 Tested 98 automated tests covering models, storage, CLI and packaging
🪶 Zero runtime dependencies Standard library only

📦 Installation

Requires Python 3.9 or newer.

From PyPI (after publication)

pip install personal-library-manager-cli-aui

Isolated install with pipx

pipx install personal-library-manager-cli-aui

From source

git clone https://github.com/afaqulislam/personal_library_manager.git
cd personal_library_manager
python -m pip install .

For development (editable install with test tooling):

python -m pip install -e ".[dev]"

▶️ Quick Start

personal_library_manager

You can also run the module directly:

python -m personal_library_manager

Choose a custom data directory (useful for testing):

personal_library_manager --data-dir ./my-library

Check the installed version:

personal_library_manager --version

🖥️ CLI Usage

📚 Welcome to your Personal Library Manager!
1. Add a book
2. Remove a book
3. Search for a book
4. Display all books
5. Display statistics
6. Exit
Enter your choice: 1
Enter the book title: Atomic Habits
Enter the author: James Clear
Enter the publication year: 2018
Enter the genre: Self-Help
Have you read this book? (yes/no): yes
✅ 'Atomic Habits' added successfully!

Enter your choice: 4

📚 Your Library:
1. Atomic Habits by James Clear (2018) - Self-Help - ✅ Read

Enter your choice: 5

📊 Library Statistics:
📚 Total books: 1
✅ Books read: 1
📖 Percentage read: 100.00%

Enter your choice: 6
💾 Library saved to:
   • C:\Users\<you>\AppData\Roaming\personal-library-manager\library.json
   • C:\Users\<you>\AppData\Roaming\personal-library-manager\library.txt
📌 Exiting... Goodbye!

Menu reference

Option Action Notes
1 Add a book All fields required; year must be digits; yes/y/true/1 = read
2 Remove a book First case-insensitive title match
3 Search Substring match by title or author
4 Display all books Numbered list with read status
5 Statistics Totals and percentage read
6 Exit Saves before exiting

Saving behavior

  • The library is saved when you choose 6 (Exit).
  • It is also saved if you press Ctrl+C or close standard input, so work is not lost.
  • Saves are atomic: data is written to a temporary file and then renamed.

Command-line options

Option Description
--data-dir PATH Store library.json/library.txt in PATH
--version Print the version and exit
--help Show help and exit

🗂️ Where Your Data Lives

User data is stored in a per-user directory, not inside the installed package:

Platform Default location
Windows %APPDATA%\personal-library-manager\
macOS ~/Library/Application Support/personal-library-manager/
Linux $XDG_DATA_HOME/personal-library-manager/ (defaults to ~/.local/share/personal-library-manager/)

Override the location with:

# environment variable
PERSONAL_LIBRARY_MANAGER_HOME=/path/to/data personal_library_manager

# or the command-line flag
personal_library_manager --data-dir /path/to/data

Legacy data: if no library exists yet and a valid library.json is present in the current working directory, it is imported automatically on first run.


🗃️ Data Format

library.json

[
    {
        "title": "Atomic Habits",
        "author": "James Clear",
        "year": 2018,
        "genre": "Self-Help",
        "read": true
    }
]
Key Type Description
title string Book title
author string Author name
year integer Positive publication year
genre string Genre / category
read boolean true = read, false = unread

Invalid entries are skipped with a warning, and a corrupted file is renamed to library.json.corrupt-<timestamp> before the app starts with an empty library.

library.txt

Regenerated on every save:

Title: Atomic Habits | Author: James Clear | Year: 2018 | Genre: Self-Help | Read: Yes

🐍 Python API

The package can be used as a library:

from personal_library_manager import Book, Library

library = Library()  # default user data directory
# library = Library(data_dir="./my-library")  # or a custom directory

library.add_book("Atomic Habits", "James Clear", 2018, "Self-Help", read=True)
library.add(Book("Deep Work", "Cal Newport", 2016, "Productivity", False))

print(len(library))                       # 2
print(library.statistics())
# {'total': 2, 'read': 1, 'unread': 1, 'percentage': 50.0}

for book in library.search("clear", field="author"):
    print(book.describe())

removed = library.remove_book("deep work")  # case-insensitive
json_path, text_path = library.save()
print(json_path, text_path)

Public classes and methods

API Description
Book(title, author, year, genre, read=False) Validated book model; to_dict(), from_dict(), describe()
Library(data_dir=None) Loads existing data by default
Library.add_book(...) Add and return a Book
Library.add(book) Add a Book instance
Library.remove_book(title) Remove first match; returns Book or None
Library.search(keyword, field="title") field is "title" or "author"
Library.statistics() Totals and percentage
Library.save() Write JSON + TXT atomically; returns paths
Library.load() Reload from disk; returns count
Library.export_text() TXT representation as a string
len(library) / library.books / iteration Collection access

Invalid input raises ValueError with a descriptive message.


📁 Project Structure

personal_library_manager/
├── src/
│   └── personal_library_manager/
│       ├── __init__.py      # Public API and version
│       ├── __main__.py      # python -m personal_library_manager
│       ├── cli.py           # Menu loop, prompts, argparse entry point
│       ├── library.py       # Collection logic + persistence
│       ├── models.py        # Book model and validation
│       └── paths.py         # Cross-platform data directory
├── tests/
│   ├── conftest.py
│   ├── test_cli.py
│   ├── test_library.py
│   ├── test_models.py
│   ├── test_package.py
│   └── test_storage.py
├── .github/workflows/       # CI and publishing workflows
├── CHANGELOG.md
├── LICENSE
├── MANIFEST.in
├── pyproject.toml
└── README.md

🛠️ Development Setup

git clone https://github.com/afaqulislam/personal_library_manager.git
cd personal_library_manager

python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS / Linux
source .venv/bin/activate

python -m pip install --upgrade pip
python -m pip install -e ".[dev]"

🧪 Testing

The suite uses pytest and covers the data model, collection operations, JSON/TXT persistence, disaster recovery, the interactive CLI, module execution and installed metadata.

python -m pytest

Useful variants:

python -m pytest -q                 # quiet
python -m pytest tests/test_cli.py  # one module
python -m pytest -k storage         # keyword match

📦 Building Distributions

python -m pip install build twine
python -m build
python -m twine check dist/*

This produces:

  • dist/personal_library_manager_cli_aui-0.1.0-py3-none-any.whl
  • dist/personal_library_manager_cli_aui-0.1.0.tar.gz

Verify an artifact in a clean environment:

python -m venv /tmp/verify
/tmp/verify/bin/pip install dist/personal_library_manager_cli_aui-0.1.0-py3-none-any.whl
/tmp/verify/bin/personal_library_manager --version

🚢 Publishing (Maintainers)

Status: not published. Publishing requires explicit approval.

Workflows are included:

  • .github/workflows/publish-testpypi.yml — manual TestPyPI publish
  • .github/workflows/publish-pypi.yml — publish on a GitHub Release

One-time setup on PyPI / TestPyPI → Your projects → Publishing → Add a pending publisher:

Field TestPyPI PyPI
PyPI project name personal-library-manager-cli-aui personal-library-manager-cli-aui
Owner afaqulislam afaqulislam
Repository personal_library_manager personal_library_manager
Workflow name publish-testpypi.yml publish-pypi.yml
Environment testpypi pypi

No API tokens are stored in the repository; the workflows use OIDC.

After that:

  1. Go to Actions → Publish to TestPyPI → Run workflow to validate.
  2. Create a GitHub Release (tag e.g. v0.1.0) to publish to PyPI.

Option B — Manual upload

TestPyPI:

python -m build
python -m twine upload --repository testpypi dist/*

Official PyPI:

python -m twine upload dist/*

When prompted, use __token__ as the username and your API token as the password. Never commit tokens.


🧩 Compatibility

  • Python: 3.9, 3.10, 3.11, 3.12, 3.13
  • Operating systems: Windows, macOS, Linux
  • Runtime dependencies: none
  • Development dependencies: pytest, build, twine

🤝 Contributing

  1. Fork the repository.
  2. Create a branch: git checkout -b feature/short-description.
  3. Make your change and add or update tests.
  4. Run python -m pytest and confirm everything passes.
  5. Commit with a clear message.
  6. Push the branch and open a Pull Request.

Please keep the package free of runtime dependencies unless there is a strong justification.


📜 License

Released under the MIT License. See LICENSE.


👨‍💻 Author

Afaq Ul Islam


⭐ If this project helps you, consider starring the repository.

Metadata

Release files for personal-library-manager-cli-aui 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for personal-library-manager-cli-aui 0.1.0
File Size Uploaded Provenance Actions
personal_library_manager_cli_aui-0.1.0.tar.gz 25.6 kB With provenance Details for personal_library_manager_cli_aui-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for personal-library-manager-cli-aui 0.1.0
File Interpreter ABI Platform Actions
personal_library_manager_cli_aui-0.1.0-py3-none-any.whl Python 3 none any Details for personal_library_manager_cli_aui-0.1.0-py3-none-any.whl

Total release size: 42.1 kB

Release files / personal_library_manager_cli_aui-0.1.0.tar.gz

Download URL personal_library_manager_cli_aui-0.1.0.tar.gz
Size 25.6 kB
Tags Source
SHA-256 checksum
How to use checksums
83e35d18ae8e3ff15771f8d7e6f531a7b652feb86a539b10fca526cd963e8d7f
BLAKE2b-256 checksum
How to use checksums
4823297d3b2e928acd8ce623835ced4bab4a2fbe6159b83992e9e0ca64a48e76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / personal_library_manager_cli_aui-0.1.0-py3-none-any.whl

Download URL personal_library_manager_cli_aui-0.1.0-py3-none-any.whl
Size 16.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c41b94c3572e28c0a2f1b77c4eee3a855555947203f232a2ef040abff61eb37b
BLAKE2b-256 checksum
How to use checksums
7721f883b9ff43aef4b3d4e6766f44d6f41016d109be5aa639a027916683f730
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Security for personal-library-manager-cli-aui 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for personal_library_manager_cli_aui-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page