πWelcome to the Library Service API! This system allows you to manage books, users, and borrowings effectively. It's designed to track books, handle borrow requests, and process payments.
- β¨ Book Management: Add, update, and delete books in the library.
- π€ User Registration: Users can register, log in, and manage their profiles.
- π Borrowing System: Users can borrow books with an automated return and fee calculation.
- π³ Payment Tracking: Keeps track of payments for borrowings.
- π Django for backend API
- π PostgreSQL for database
- π§ Django Rest Framework (DRF) for API development
- β³ Django Celery for background tasks
- π³ Stripe for payment processing
- π± Telegram API for notifications
- π Docker for containerization
- Python 3.12.8+
- Poetry
- Docker & Docker Compose
Follow these steps to set up the project locally. π»
Clone the repository to your local machine using Git:
git clone https://github.com/dmytrik/LibraryServiceAPI.git
cd LibraryServiceAPICreate a .env file based on the .env.sample file. You can do this by copying the .env.sample to .env:
cp .env.sample .envUse Poetry to install the necessary dependencies:
poetry installRun the migrations to set up the database schema:
python manage.py migrateRedis is required for Celery task management. Follow the instructions for your operating system:
brew install redis Start Redis:
redis-serversudo apt update
sudo apt install redis-server
sudo systemctl enable redis
sudo systemctl start redis - Download the Redis installer from here
- Install Redis and start the server by running:
redis-serverStart Celery worker and beat scheduler to handle background tasks:
celery -A core worker --loglevel=info --pool=solo celery -A core beat --loglevel=infoRun the Django development server:
python manage.py runserverπ Your server will be available at: http://localhost:8000/
If you'd like to run the project using Docker, follow the steps below. π³
Use Docker Compose to build and run the application and database containers:
docker-compose up --buildOnce the services are up, the API will be available at: http://localhost:8000/
The PostgreSQL database will be available on port 5432.
Manages the quantity of books in the library.
- POST
/api/books/- Add a new book - GET
/api/books/- Get a list of all books - GET
/api/books/<id>/- Get detailed information about a specific book - PUT/PATCH
/api/books/<id>/- Update a book (also manages inventory) - DELETE
/api/books/<id>/- Delete a book
Manages authentication and user registration.
- POST
/api/users/register/- Register a new user - POST
/api/users/token/- Get JWT tokens - POST
/api/users/token/refresh/- Refresh JWT token - GET
/api/users/me/- Get current user profile information - PUT/PATCH
/api/users/me/- Update user profile information
Manages users' borrowing actions and keeps track of borrowed books.
- POST
/api/borrowings/- Add a new borrowing (decrease inventory by 1 when borrowing a book) - GET
/api/borrowings/?user_id=<user_id>&is_active=<active_status>- Get borrowings by user id and active status - GET
/api/borrowings/<id>/- Get specific borrowing details - POST
/api/borrowings/<id>/return/- Set the actual return date (increase inventory by 1 when book is returned)
Notifies about new borrowings and overdue borrowings.
- Uses Django Celery to manage background tasks.
- Interacts with other services to send notifications to library administrators.
- Leverages Telegram API, Chats, and Bots for communication.
Handles payments for book borrowings via Stripe.
- GET
/api/payments/- - GET
/api/payments/{id}/- - GET
/api/payments/success/- Check for successful Stripe payment - GET
/api/payments/cancel/- Return a message if the payment was paused or canceled
- Delegated to the Front-end Team (Not implemented in this repository).
- Provides the user interface for interacting with the library system.
API documentation is available via Redoc at:
π http://localhost:8000/api/schema/redoc/
and via Swagger at:
π http://localhost:8000/api/schema/swagger-ui/
- Fork the repository
- Create a new branch (
git checkout -b feature-name) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature-name) - Open a pull request
π Happy Coding and enjoy building with Library Service API! π