Skip to content

erfanbyt/digital-library-backend-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Digital Library App

This repo includes the code for creating the backend of a digital library. It has functionalities needed by the backend of a digital library app, like getting the book data from "google book API", adding new books to database, changing the status of the book, and rating it.

Note: the API key is removed from server.py and create_book_table.py.

Technologies Used

  • PostgreSQL for database
  • FastAPI for backend
  • Docker for containerization

data format

for each book, the following info is fetched from google book API and stored in the database.

  • ID (auto increment)
  • volume_id (unique key)
  • title
  • authors
  • thumbnail
  • state (0: completed, 1: in progress, 2: wishlist)
  • rating

installation

step 1:

make sure Docker is installed on your system

step 2:

run the following command to create postgres and adminer container. Adminer container provides UI for interacting with the DB.

docker compose up -d

Adminer is accessible at (http://localhost:8080/).

step 3:

install the requirements for the python env.

pip install -r requirements.txt

step 4:

In order to test the API, run server.py and type this address in browser http://localhost:8000/docs#/default. Then you can interactively use and test the API.

In the following, I will explain different components of the API calls.

GET /books

This endpoint will query all the data from the database and return the result in json format.

POST /books

This end point gets the data in the following format and adds it to the databse.

{
  "id": 0,
  "volume_id": "string",
  "title": "string",
  "authors": "string",
  "thumbnail": "string",
  "state": 0,
  "rating": 0
}

POST /books-ISBN

this endpoint gets the ISBN of the book as input and gets the books information from google book API and stores it in the database.

PUT /books/update_rating

this endpoint is used for updating the rating of the book. The input should be in the following format.

{
  "volume_id": "string",
  "new_rating": 0
}

PUT /books/update_book_state

This end point is used for updating the book state to finished, in progress, or wishlist. The input should be in the following format

{
  "volume_id": "string",
  "new_state": 0
}

Future goal for this project

I will create a user interface using react so that the user can use it as a digital library.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages