Skip to content
Hussein Hany edited this page Oct 2, 2023 · 2 revisions

Local Library Documentation

Table of Contents

  1. Introduction
  2. Database Schema
  3. Routes
  4. API Endpoints
  5. Environment Variables

Introduction

This documentation provides an overview of the Local Library web application's architecture, important routes, and API endpoints.

Database Schema

The Local Library application uses MongoDB as its database. Below is an overview of the database schema:

  • Book: Represents a book with properties such as title, author, summary, genre, and availability status.

  • Author: Stores information about the authors of the books.

  • Genre: Contains information about book genres.

  • BookInstance: Represents individual physical copies of books, including their status (available, maintenance, etc.) and due date.

Routes

The application has various routes for different functionalities:

  • /: The home page displays a list of available books.

  • /catalog: Lists all books in the library's collection.

  • /catalog/book/:id: Displays detailed information about a specific book.

  • /catalog/authors: Lists all authors.

  • /catalog/author/:id: Displays detailed information about an author.

  • /catalog/genres: Lists all genres.

  • /catalog/genre/:id: Displays detailed information about a genre.

API Endpoints

The application provides the following API endpoints for accessing data programmatically:

  1. List All Books

    • Endpoint: /books
    • HTTP Method: GET
    • Description: Retrieves a list of all books in the library.
  2. Get Book by ID

    • Endpoint: /books/:id
    • HTTP Method: GET
    • Description: Retrieves detailed information about a specific book based on its ID.
  3. List All Authors

    • Endpoint: /authors
    • HTTP Method: GET
    • Description: Retrieves a list of all authors in the library.
  4. Get Author by ID

    • Endpoint: /authors/:id
    • HTTP Method: GET
    • Description: Retrieves detailed information about a specific author based on their ID.
  5. List All Genres

    • Endpoint: /genres
    • HTTP Method: GET
    • Description: Retrieves a list of all genres in the library.

Environment Variables

To run this application, you need to set the following environment variable in a .env file in the project root directory:

  • MONGODB_PASSWORD: Your MongoDB password.

For more detailed information about the code structure and implementation, please refer to the source code in the GitHub repository.