Library Management
- Author: AhmedHamdy146
- Repository: https://github.com/AhmedHamdy146/library_management
- GitHub stars: 0
- Forks: 0
- License: MIT
- Category: Developer Tools
- Maintenance: Actively Maintained
- Frappe versions: v16
Install Library Management
bench get-app https://github.com/AhmedHamdy146/library_management
Add the Frappe Gems badge to your README
Maintain Library Management? Paste this into your README:
[](https://frappegems.com/gems/apps/AhmedHamdy146/library_management)
About Library Management
Library Management
Library Management System
Installation
You can install this app using the bench CLI:
cd $PATH_TO_YOUR_BENCH
bench get-app $URL_OF_THIS_REPO --branch version-16
bench install-app library_management
Contributing
This app uses pre-commit for code formatting and linting. Please install pre-commit and enable it for this repository:
cd apps/library_management
pre-commit install
Pre-commit is configured to use the following tools for checking and formatting your code:
- ruff
- eslint
- prettier
- pyupgrade
License
mit
Library Management
A Frappe application for managing a library's books, members, memberships, and loan transactions. Built on Frappe Framework v16.
Features
- Manage books with full metadata (ISBN, genre, authors, cover image, copies tracking)
- Register and manage library members
- Issue and track memberships with date validation and payment status
- Issue and return books with full loan lifecycle management
- Automatic fine calculation for late returns
- Daily scheduled jobs to mark overdue loans
- Role-based access control for System Manager, Librarian, and Library Member roles
- Field-level permissions (price hidden from Library Members)
- Web view portal for members to browse available books
Doctypes
Author
Stores author information linked to books.
| Field | Type | Notes |
|---|---|---|
author_name |
Data | Required, unique, used as document name |
bio |
Text Editor | Optional biography |
country |
Link → Country | Used for User Permissions filtering |
date_of_birth |
Date | Validated: not future, not >150 years ago |
Book
Core book record combining metadata and inventory tracking.
| Field | Type | Notes |
|---|---|---|
title |
Data | Required |
authors |
Table → Book Author Link | At least one author required, no duplicates |
isbn |
Data | Required, validated to exactly 13 digits, hyphens stripped |
publication_year |
Int | Validated: between 1450 and 2100 |
price |
Currency | Permission level 1 — hidden from Library Members |
in_stock |
Check | Manual stock flag |
genre |
Select | Fiction, Non-fiction, Science, History, Poetry |
cover_image |
Attach Image | Optional |
description |
Text Editor | Optional |
total_copies |
Int | Required, minimum 1 |
available_copies |
Int | Auto-set to total_copies on creation |
Naming: BOOK-.YYYY.-.####
Book Author Link
Child table linking books to authors. Supports multiple authors per book.
| Field | Type | Notes |
|---|---|---|
author |
Link → Author | No duplicate authors per book |
Library Member
Represents a person who can borrow books.
| Field | Type | Notes |
|---|---|---|
first_name |
Data | Required |
last_name |
Data | Optional |
full_name |
Data | Read only, auto-computed from first + last name |
email_address |
Data | Validated format, must be unique across members |
phone |
Data | Validated: digits only, 7–15 characters |
Naming: LM.####.
Library Membership
Tracks a member's active subscription period. Submittable document.
| Field | Type | Notes |
|---|---|---|
library_member |
Link → Library Member | Required |
full_name |
Data | Fetched from member, read only |
from_date |
Date | Required |
to_date |
Date | Required, must be after from_date |
paid |
Check | Must be checked before submitting |
amended_from |
Link → Library Membership | Auto-filled on amendment |
Rules:
- Cannot submit if paid is unchecked
- Cannot have overlapping memberships for the same member
- Cannot cancel if member has active or overdue loans
Naming: LMS.#####
Book Loan
Tracks every book borrowing transaction.
| Field | Type | Notes |
|---|---|---|
book |
Link → Book | Required |
borrower |
Link → Library Member | Required |
loan_date |
Date | Required |
due_date |
Date | Required, must be after loan_date |
return_date |
Date | Filled when book is returned |
fine_amount |
Currency | Auto-calculated on late return |
status |
Select | Active, Returned, Overdue |
Rules:
- Borrower must have a valid submitted paid membership covering today's date
- Book must have at least 1 available copy
- Member cannot have two active loans for the same book
- return_date must be ≥ loan_date
- due_date must be > loan_date
- On issue: available_copies decremented by 1
- On return: available_copies incremented by 1, fine calculated if late
- Fine rate: 5 EGP per day overdue
Validation Summary
| Doctype | Key validations |
|---|---|
| Author | DOB not in future, not >150 years ago, name normalized |
| Book | ISBN 13 digits, year 1450–2100, copies logic, no duplicate authors |
| Library Member | Email format + unique, phone format, full name auto-set |
| Library Membership | Date range valid, no overlap, paid before submit, no cancel with active loans |
| Book Loan | Valid membership, copies available, no duplicate active loan, date logic, fine on late return |
Permissions
| Role | Book | Library Member | Library Membership | Book Loan |
|---|---|---|---|---|
| System Manager | Full access | Full access | Full access | Full access |
| Librarian | Read, Write, Create, Delete | — | Read, Write, Create, Delete | Read, Write, Create |
| Library Member | Read only (no price field) | — | — | — |
Scheduled Jobs
Registered in hooks.py and run daily:
mark_overdue_loans
Finds all Book Loan records with status = Active and due_date < today and marks them as Overdue.
expire_memberships
Finds all submitted Library Membership records with to_date < today and marks them as expired.
scheduler_events = {
"daily": [
"library_management.tasks.mark_overdue_loans",
"library_management.tasks.expire_memberships",
]
}
Installation
cd frappe-bench
bench get-app library_management
bench --site your-site-name install-app library_management
bench --site your-site-name migrate
bench restart
Demo Data Setup
Create records in this order to have a fully working demo:
1. Authors - Robert C. Martin (United States) - James Clear (United States) - Yuval Noah Harari (Israel) - Paulo Coelho (Brazil) - Cal Newport (United States)
2. Books - Clean Code — ISBN 9780132350884 — 3 copies - Atomic Habits — ISBN 9780735211292 — 2 copies - Sapiens — ISBN 9780062316097 — 4 copies - The Alchemist — ISBN 9780062315007 — 3 copies - Deep Work — ISBN 9781455586691 — 1 copy
3. Library Members - Ahmed Hassan — ahmed@library.test - Sara Mohamed — sara@library.test - Omar Khalid — omar@library.test - Layla Ahmed — layla@library.test
4. Library Memberships (submit each one) - Ahmed Hassan — 2026-01-01 to 2026-12-31 — Paid ✅ - Sara Mohamed — 2026-03-01 to 2026-12-31 — Paid ✅ - Omar Khalid — 2025-01-01 to 2025-12-31 — Paid ✅ (expired — for testing) - Layla Ahmed — 2026-05-01 to 2026-12-31 — Paid ❌ (unpaid — for testing)
5. Book Loans - Clean Code → Ahmed Hassan — loaned 2026-05-01, due 2026-05-15 (overdue) - Sapiens → Sara Mohamed — loaned 2026-05-10, due 2026-05-24 - Atomic Habits → Ahmed Hassan — loaned 2026-05-20, due 2026-06-03
Edge Cases to Test
| Scenario | Expected |
|---|---|
| Omar borrows any book | ❌ Expired membership |
| Layla borrows any book | ❌ Unpaid membership |
| Ahmed borrows Clean Code again | ❌ Duplicate active loan |
| Book with 0 available copies | ❌ No copies available |
| Return date before loan date | ❌ Validation error |
| Return Clean Code (overdue) | ✅ Fine calculated (5 EGP/day) |
| Cancel Sara's membership | ❌ Has active loan |
| Submit Layla's membership unpaid | ❌ Cannot submit unpaid |
Project Structure
library_management/
├── library_management/
│ ├── doctype/
│ │ ├── author/
│ │ │ ├── author.py
│ │ │ ├── author.json
│ │ │ └── test_author.py
│ │ ├── book/
│ │ │ ├── book.py
│ │ │ ├── book.json
│ │ │ ├── book.js
│ │ │ └── test_book.py
│ │ ├── book_author_link/
│ │ ├── book_loan/
│ │ │ ├── book_loan.py
│ │ │ └── book_loan.json
│ │ ├── library_member/
│ │ │ ├── library_member.py
│ │ │ └── library_member.json
│ │ └── library_membership/
│ │ ├── library_membership.py
│ │ └── library_membership.json
│ └── tasks.py
├── hooks.py
├── requirements.txt
└── README.md
License
MIT — see license.txt
Author
Ahmed Hamdy — 2026
Related Developer Tools apps for Frappe & ERPNext
- Frappe — Low code web framework for real world applications, in Python and Javascript
- Frappe Docker — Docker environment for developing, deploying, and running Frappe applications (ERPNext and custom apps) in production and development
- Builder — Craft beautiful websites effortlessly with an intuitive visual builder and publish them instantly
- Bench — CLI to manage Multi-tenant deployments for Frappe apps
- Frappe Ui — A set of components and utilities for rapid UI development
- Press — Full service cloud hosting for the Frappe stack - powers Frappe Cloud
- Gameplan — Open Source Discussions Platform for Remote Teams
- Doppio — A Frappe app (CLI) to magically setup single page applications and Vue/React powered desk pages on your custom Frappe apps.