Skip to content

TapChap/LibraryCatalog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š LibraryTrackerBackEnd API Documentation

Base URL

http://<192.168.181.247:80>/

πŸ“– Book Management (from Book_api.py)

Book Json

πŸ“˜ Book JSON Schema Reference

This document describes the structure of a Book object as returned by the backend API in different levels of detail, based on flags such as full and holders.


🧩 Base Fields (Always Included)

{
  "id": "integer",
  "isTaken": "boolean",
  "quantity": "integer",
  "book_name": "string",
  "category": "string"
}
  • id: Unique identifier for the book
  • isTaken: Whether the book is currently taken (i.e., unavailable)
  • quantity: Number of available copies
  • book_name: The title of the book
  • category: The book's main category

πŸ‘₯ Holders (Included if holders)

{
  "holders": [ { ...user object... } ]
}
  • holders: A list of users currently holding the book. Each holder is serialized using their toJson() method.

🧾 Full Details (Included if full)

{
  "series": "string | null",
  "series_index": "integer | null",
  "author": "string | null",
  "sub_category": "string | null",
  "sub_category_index": "integer | null",
  "description": "string | null",
  "notes": "string | null",
  "librarian_notes": "string | null"
}

1. Add a New Book

  • Endpoint: POST /book/add

  • Query Parameters (optional):

    • series, series_index, author, sub_cat, sub_cat_index, quantity, description, notes, librarian_notes
  • Request Body:

    {
      "book_name": "string",
      "category": "string"
    }
  • Response:

    {
      "message": "updated bookDB",
      "Book": { ...book details... } full - βœ…, holders - ❌
    }

2. Get Books by Name

  • Endpoint: GET /book/<book_name>

  • Response:

    {
      "books": [ { ...all books with book_name... } ] full - ❌, holders - ❌
    }

3. Get Book by ID

  • Endpoint: GET /book/id/<id>

  • Response:

    {
      "book": { ...full book details... } full - βœ…, holders - βœ…
    }

4. Get All Books

  • Endpoint: GET /book/all

  • Response:

    [ { ...first db book... }, { ...seconds db book... }, ... ] full - βœ…, holders - βœ…

πŸ‘€ Client Management (from Client_api.py)

User Json

πŸ“˜ User JSON Schema Reference


🧩 Base Fields (Always Included)

{
  "id": "integer",
  "username": "string",
  "display_name": "string",
  "permission": "string",
  "held_books": [{ ...book details... }]
}

1. User Signup

  • Endpoint: POST /user/signup

  • Request Body:

    {
      "username": "string",
      "display_name": "string",
      "password": "string"
    }
  • Response:

    {
      "message": "User created",
      "user": { ...user json... }
    }

2. Admin Signup

  • Endpoint: POST /user/signup-admin
  • Request Body: same as /client/signup
  • Permission Level: Admin

3. Login

  • Endpoint: POST /user/login

  • Request Body:

    {
      "username": "string",
      "password": "string"
    }
  • Response:

    {
      "message": "Logged in",
      "user": { ...user json... }
    }

4. Get User by Username

  • Endpoint: GET /user/<username>

  • Response:

    { ...user json... }

5. Get User by ID

  • Endpoint: GET /user/id/<id>

  • Response:

    { ...user json... }

6. Get User's Held Books

  • Endpoint: GET /user/id/<client_id>/holding

  • Response:

    {
      "client": { ...client json... },
      "books": [ { ...held books json... } ]
    }

7. Get All Users

  • Endpoint: GET /user/all

  • Response:

    [ { ...all users json... }, ... ]

πŸ” Library Management (from Library.py)

1. Borrow Book

  • Endpoint: POST /library/user/id/<client_id>/obtain

  • Request Body:

    {
      "book_id": <book_id>
    }
  • Response:

    {
      "message": "book obtained by user",
      "book": { ...book json... },
      "user": { ...client json... }
    }

2. Return Book

  • Endpoint: POST /library/user/id/<client_id>/return

  • Request Body:

    {
      "book_id": <book_id>
    }
  • Response:

    {
      "message": "book returned from user",
      "book": { ...book json... },
      "user": { ...client json... }
    }

⚠️ Error Handling

  • 400 Bad Request: Missing or invalid fields
  • 404 Not Found: Book or user does not exist
  • 409 Conflict: Resource already exists
  • 200 OK / 201 Created: Successful operation

About

Back End Repository for a Library management system for Yeshivat Machanaim's Beit Midrash

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •