This project upgrades the library system, enabling users to borrow books and pay in cash based on reading duration. It replaces outdated manual tracking with an online management system, improving efficiency, inventory visibility, and user experience.
- Python
- Django ORM
- Django
- DRF
- API with Books data
- Borrowing feature
- Filtering Borrowings list
To install the project locally on your computer, execute the following commands in a terminal:
git clone https://github.com/Illya-Maznitskiy/library-service.git
cd library-service
python -m venv venv
venv\Scripts\activate (on Windows)
source venv/bin/activate (on macOS)
pip install -r requirements.txt
You need to create a .env file and add the necessary environment variables, as shown in sample.env.
You can run the tests and check code style using flake8
with the following commands:
python manage.py test
flake8
- To create a superuser, use the following command:
python manage.py createsuperuser
After creating the superuser, you can log in using these credentials on the /users/token/ page to get your authentication token. This token can be used for authorized access to the Library API.
- To run server use the command:
python manage.py runserver
You can also use Docker to run service. Use the commands:
- To build the Docker image:
docker build -t library-service .
- To run the container and server:
docker run -p 8001:8001 library-service
- GET:
docs/
- Access Swagger UI documentation - GET:
download_docs/
- Download the API schema
- POST:
books/
- Add a new book - GET:
books/
- Get a list of books - GET:
books/<id>/
- Get book detail info - PUT/PATCH:
books/<id>/
- Update book (also manage inventory) - DELETE:
books/<id>/
- Delete book
- POST:
users/
- Register a new user - POST:
users/token/
- Get JWT tokens - POST:
users/token/refresh/
- Refresh JWT token - GET:
users/me/
- Get my profile info - PUT/PATCH:
users/me/
- Update profile info
- POST:
borrowings/
- Add new borrowing (inventory should be decremented by 1) - GET:
borrowings/?user_id=...&is_active=...
- Get borrowings by user ID and whether the borrowing is still active - GET:
borrowings/<id>/
- Get specific borrowing - POST:
borrowings/<id>/return/
- Set actual return date (inventory should be incremented by 1)