This project was created specifically for a library management system. It facilitates the operation of library services, including book borrowings, user management, and payment handling via this API.
- Copy and rename the .env.sample file to .env
- Open the .env file and edit the environment variables
- Save the .env file securely
- Add the .env file to .gitignore
On Windows:
python -m venv venv
venv\Scripts\activateOn UNIX or macOS:
python3 -m venv venv
source venv/bin/activatedocker-compose up --builddocker-compose run library sh -c "python manage.py loaddata fixtures.json"If you want to perform all available features, create a superuser account in a new terminal:
docker exec -it library-service-project-db-1 /bin/sh
python manage.py createsuperuser😄 Go to site http://localhost:8000/
- JWT Authentication
- Swagger documentation (Coming soon)
- Docker
- Telegram Bot
- Redis as cache handler
- Stripe Payment Integration
Manage books in the library.
Manage user authentication and registration.
Manage borrowings of books by users. Includes validation to prevent new borrowings if there are pending payments.
Handle payments for book borrowings and overdue fines.
Send notifications about borrowings, payments, and overdue fines. Users receive messages if they have pending payments or overdue fines.
Calculate and manage fines for overdue book returns. Automatically create a fine payment if a book is returned late, and send a daily reminder to users about overdue fines.
The Telegram bot is set up to interact with users and administrators, providing timely notifications and allowing users to manage their borrowings.
- User Registration: The bot registers users by linking their Telegram chat IDs to their user profiles.
- Notifications: Users receive notifications for:
- New borrowings created.
- Borrowing due dates.
- Overdue borrowings.
- Successful payments.
- Notifications for new borrowings and overdue books.
- Commands:
/start: Initiates the registration process./all_borrow: Admin command to list all borrowings./upcoming_borrow: Lists upcoming borrowings for the user.
- Create a Telegram Bot: Use BotFather to create a new bot and get the API token.
- Configure Environment Variables: Add the API token to your
.envfile. - Run the Bot: Ensure the bot is running and integrated with your Django project.
Payments for book borrowings are processed through Stripe. The integration ensures secure and efficient handling of transactions.
- Payment Creation: Automatically create a Stripe payment session when a new borrowing is created.
- Payment Status: Track and update payment statuses (Pending, Paid).
- Fines: Calculate and process fines for overdue borrowings.
- Create a Stripe Account: Set up a Stripe account and get the API keys.
- Configure Environment Variables: Add the Stripe API keys to your
.envfile. - Payment Workflow: Implement the workflow to create, handle, and track payments using Stripe's API.
- Creating Payment Session: A payment session is created when a user borrows a book. This session calculates the total price based on the borrowing duration and the book's daily fee.
- Successful Payment: Upon successful payment, the status is updated, and a notification is sent to the user.
- Cancellation and Expiration: Handle payment session cancellations and check for expired sessions regularly.
To schedule periodic tasks like checking for overdue borrowings, we use Django-Q. Here's how to set it up through the admin console:
- Access the Admin Console: Log in to the Django admin console with your superuser account.
- Navigate to Django-Q: Find the Django-Q section and select "Schedules."
- Add a New Schedule:
- Name: Check overdue borrowings
- Func:
borrowing.signals.check_overdue_borrowings - Schedule Type: Choose the appropriate schedule type (e.g., hourly, daily).
- Next Run: Set the next run time.
- Repeat: Set the repeat interval if needed.
- Save: Save the schedule, and Django-Q will handle running the task at the specified intervals.
If you want to contribute to the project, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make the necessary changes and commit them.
- Submit a pull request.