> ## Documentation Index
> Fetch the complete documentation index at: https://docs.readingsteps.uk/llms.txt
> Use this file to discover all available pages before exploring further.

# Library System

> Manage school libraries, books, copies, loans, and due dates with ReadingSteps.

# Library System

The ReadingSteps Library module lets schools run a simple physical library alongside the reading platform. Staff can create dedicated **librarian** accounts, build a catalog, generate copy codes for physical books, check books in and out, and surface due dates on the student dashboard.

## Who can use it

* **School administrators** create and manage librarian accounts from `/admin/library`.
* **Librarians** sign in through the shared staff login at `/login/staff` and are redirected to `/library/<school-domain>`.
* **Students** see their currently borrowed books and due dates on their dashboard.

## Core concepts

| Concept           | Description                                                                   |
| ----------------- | ----------------------------------------------------------------------------- |
| Librarian account | A Supabase auth user tied to a school via `library_accounts`.                 |
| Catalog book      | A title in `library_books` with metadata and aggregate copy counts.           |
| Copy              | A unique physical book instance in `library_book_copies` with a `copy_code`.  |
| Loan              | A checkout record in `library_loans` linking a copy to a student.             |
| Settings          | Per-school defaults for loan length, renewals, and public-catalog visibility. |

## Typical workflow

1. An admin invites a librarian on `/admin/library`. The account is created with a secure generated password.
2. The librarian signs in at `/login/staff` using the shared staff login.
3. The server identifies the account as a librarian, sets auth cookies, and redirects to `/library/<school-domain>`.
4. The librarian adds books to the catalog, either by ISBN or title. Books pull metadata from Open Library.
5. For each book, the librarian generates copy codes that can be printed and stuck to physical copies.
6. When a student borrows a copy, the librarian creates a loan by entering the copy code and the student ID.
7. Loans appear on the student dashboard with due dates. Librarians can renew loans or mark copies as returned.

## Public catalog

Each school library has a public catalog at `/library/<school-domain>`. If `allow_public_catalog` is enabled in settings, unauthenticated visitors can browse available books. When a librarian for that school is signed in, the same URL shows the full dashboard.

## Settings

Librarians can open `/library/<school-domain>/settings` to configure:

* **Default loan period** — how many days a copy is loaned for by default.
* **Renewal period** — how many extra days a renewal grants.
* **Maximum renewals** — how many times a single loan can be renewed.
* **Public catalog** — whether unauthenticated visitors can view the catalog.
