A Flask-based REST API for managing personal book collections with user authentication, admin controls, and comprehensive book management features.
- User Registration & Authentication - JWT-based authentication system
- Role-based Access Control - User and Admin roles with different permissions
- Account Security - Password hashing, token blacklisting, and ban/unban functionality
- Rate Limiting - Built-in rate limiting to prevent abuse
- CRUD Operations - Create, Read, Update, Delete books in your collection
- Search & Filter - Search by title, author, genre with sorting options
- Soft Delete - Books are marked as deleted but can be recovered
- Favorites System - Mark books as favorites for quick access
- Pagination - Efficient pagination for large collections
- User Management - Ban/unban users, promote users to admin
- Book Oversight - View all books across all users
- Token Management - Clean up expired JWT tokens
- Admin Controls - Full administrative access to the system
- Backend: Flask, Flask-RESTful
- Database: SQLAlchemy with SQLite
- Authentication: Flask-JWT-Extended
- Validation: Marshmallow
- Security: Werkzeug password hashing
- Rate Limiting: Flask-Limiter
-
Clone the repository
git clone https://github.com/yourusername/book-manager-api.git cd book-manager-api
-
Create a virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables Create a
.env
file in the root directory:FLASK_SECRET_KEY=your-secret-key-here JWT_SECRET_KEY=your-jwt-secret-key-here
-
Run the application
python run.py
POST /auth/v1/register
- Register a new userPOST /auth/v1/login
- Login and get JWT tokensPOST /auth/v1/refresh
- Refresh access tokenDELETE /auth/v1/logout
- Logout and blacklist token
GET /api/v1/books
- Get all books (with pagination, search, filters)POST /api/v1/books
- Create a new bookGET /api/v1/books/{id}
- Get a specific bookPUT /api/v1/books/{id}
- Update a bookDELETE /api/v1/books/{id}
- Delete a book (soft delete)GET /api/v1/recovery
- Get deleted booksGET /api/v1/favourites
- Get favorite booksPUT /api/v1/favourites
- Add book to favoritesDELETE /api/v1/favourites
- Remove book from favorites
GET /a/v1/manage
- Get all adminsPOST /a/v1/manage
- Create new adminPUT /a/v1/manage
- Promote user to adminDELETE /a/v1/manage
- Demote admin to userGET /a/v1/books
- View all books (admin only)PUT /a/v1/user/ban
- Unban userDELETE /a/v1/user/ban
- Ban userPOST /a/v1/user/ban
- Reset user passwordDELETE /a/v1/jwt/clear
- Clear expired JWT tokens
- Password Hashing: Uses Werkzeug's secure password hashing
- JWT Token Management: Access and refresh tokens with blacklisting
- Rate Limiting: Prevents API abuse with configurable limits
- Input Validation: Marshmallow schemas validate all inputs
- Role-based Access: Admin-only endpoints protected
- SQL Injection Prevention: SQLAlchemy ORM protects against SQL injection
Default rate limits:
- General: 200 requests per day, 50 per hour
- Registration: 3 attempts per day
- Login: 3 attempts per day
- Book operations: 50 per day
This project is licensed under the MIT License .
For support, email zayed.ah06@gmail.com or create an issue in the GitHub repository.
- Initial release
- User authentication and authorization
- Book CRUD operations
- Admin panel
- Rate limiting
- JWT token management