# Library Catalog Template

Library management and book catalog system.

## Files

- **library_example.rs** - Complete Rust implementation of library system

## Features

### Book Information
- ISBN
- Title
- Author(s)
- Publisher
- Publication date
- Edition
- Language
- Total pages

### Inventory Management
- Number of copies
- Available copies
- Location (shelf, building)
- Condition status
- Last inventory date

### Patron Management
- Member ID
- Name
- Email
- Phone
- Address
- Membership tier
- Lending privileges

### Checkout System
- Book selection
- Checkout date
- Due date
- Renewal options
- Late fees
- Hold requests

### Lending Rules
- Loan period (varies by type)
- Renewal limits
- Maximum books per member
- Overdue penalties
- Reservation system

## Running the Example

### CLI Interactive
```bash
cargo run --example library_example
```text

### Programmatic
The Rust implementation provides:
- Full library API
- Persistence layer
- Validation logic
- Report generation

## Data Model

```json
{
  "book": {
    "isbn": "978-0-13-110362-7",
    "title": "The C Programming Language",
    "author": "Brian W. Kernighan",
    "total_copies": 5,
    "available_copies": 3
  },
  "member": {
    "id": "MEM-12345",
    "name": "Alice Johnson",
    "tier": "premium",
    "max_books": 10,
    "current_books": 3
  },
  "checkout": {
    "member_id": "MEM-12345",
    "book_isbn": "978-0-13-110362-7",
    "checkout_date": "2024-01-15",
    "due_date": "2024-02-15",
    "renewable": true
  }
}
```text

## Use Cases

### Patron Workflows
- New member registration
- Book search and discovery
- Checkout and renewal
- Hold requests
- Fine payment

### Librarian Tools
- Add/update book information
- Manage inventory
- Process checkouts
- Generate reports
- Manage late returns

### Administrative
- Member management
- Lending policy configuration
- Overdue report generation
- Collection analysis
- Usage statistics

## Customization

### Add Genres/Categories
```rust
pub struct Book {
    isbn: String,
    title: String,
    genre: String,  // Add this
    categories: Vec<String>,  // Add this
}
```text

### Implement Reservations
```rust
pub struct Reservation {
    member_id: String,
    book_isbn: String,
    queue_position: u32,
    created_date: DateTime,
}
```text

### Add Rating/Reviews
```rust
pub struct Review {
    member_id: String,
    book_isbn: String,
    rating: u8,  // 1-5
    comment: String,
}
```text

## Database Integration

Example: Store with SQLite/PostgreSQL

```sql
CREATE TABLE books (
  isbn VARCHAR(13) PRIMARY KEY,
  title VARCHAR(255),
  author VARCHAR(255),
  total_copies INT,
  available_copies INT
);

CREATE TABLE members (
  id VARCHAR(20) PRIMARY KEY,
  name VARCHAR(255),
  email VARCHAR(255),
  tier VARCHAR(50)
);

CREATE TABLE checkouts (
  id SERIAL PRIMARY KEY,
  member_id VARCHAR(20),
  book_isbn VARCHAR(13),
  checkout_date DATE,
  due_date DATE,
  return_date DATE
);
```text

## Features Demonstrated

- Complex data structures
- State management
- Business logic
- Validation rules
- Interactive menus
- Error handling
- Persistence patterns
