BookHive is a powerful API designed to simplify the management of your book collection. With this API, you can seamlessly:
- Create, Update, and Retrieve book records π
- Filter books based on various attributes π
- Manage user authentication and authorization securely π
- User Permissions: Users can only modify or delete books that they own. Admins have full access to manage all books, ensuring that each user can only interact with their own records. π
- Advanced Filtering: Easily search and filter books based on title, author, publication date, and more, providing a tailored experience for managing your collection. π
- JWT Authentication: Secure access with JSON Web Tokens (JWT) for user authentication. Refresh tokens and secure login mechanisms keep your data safe. π Built with Django, Django Ninja, and Pydantic, BookHive leverages PostgreSQL for robust data management and is deployed on Render for seamless scalability. π
- Django: πΈοΈ Web framework for building the API.
- Django Ninja: β‘ Fast API framework for Django.
- Pydantic: π Data validation and settings management.
- PostgreSQL: ποΈ Relational database for storing data.
- Render: π Deployment platform for hosting the API.
- Python 3.6+
- PostgreSQL
pip
(Python package installer)
-
Clone the Repository
git clone https://github.com/Mannuel25/bookhive.git cd bookhive
-
Create a virtual environment
python -m venv .\venv
-
Activate the virtual environment
venv\scripts\activate
Note: Upon activating the virtual environment if this error shows up:
venv\scripts\activate : File ..\venv\scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
Run this command:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
Then run the command to activate the virtual environment :
venv\scripts\activate
-
Install Dependencies
pip install -r requirements.txt
-
Configure the Database
Update
DATABASES
settings inbookhiveConfig/settings.py
to match your PostgreSQL configuration. -
Make Migrations
python manage.py makemigrations
-
Apply Migrations
python manage.py migrate
-
Create a Superuser (Optional)
python manage.py createsuperuser
-
Run the Development Server
python manage.py runserver
Explore the API using the interactive documentation:
- Generate Token: POST
/api/token/
withemail
andpassword
π - Refresh Token: POST
/api/token/refresh/
withrefresh_token
π
curl -X POST "https://bookhiveapi.onrender.com/api/user_mgt/login" -H "Content-Type: application/json" -d '{"email": "user@example.com", "password": "yourpassword"}'
curl -X POST "https://bookhiveapi.onrender.com/api/token/refresh" -H "Content-Type: application/json" -d '{"refresh_token": "your_refresh_token"}'
- List Books: GET
/api/books/
- List all books. - Create Book: POST
/api/books/
- Create a new book. - Retrieve Book: GET
/api/books/{id}/
- Retrieve a specific book. - Update Book: PUT
/api/books/{id}/
- Update a specific book. - Delete Book: DELETE
/api/books/{id}/
- Delete a specific book.
- User Signup: POST
/api/users/signup/
- Create a new user. - User Login: POST
/api/users/login/
- Login a user. - Update User: PATCH
/api/users/{id}/
- Update user information. - Retrieve User: GET
/api/users/{id}/
- Retrieve a specific user's details.
Run tests using the following command:
python manage.py test
Errors are returned in the following format:
{
"message": "Error message"
}
This project is licensed under an MIT License.