An online bookstore API built with Flask, featuring user authentication, book management, shopping cart functionality, and an admin dashboard.
-
Authentication & Authorization
- JWT-based authentication
- Role-based access control (Admin/User)
- Password reset functionality
- Email verification
-
Book Management
- Comprehensive book catalog
- Search and filtering capabilities
- Category-based organization
- Stock management
-
Shopping Experience
- Shopping cart functionality
- Secure checkout with Stripe
- Order history
- Real-time stock updates
-
Review System
- Book ratings and reviews
- User-specific review management
- Review moderation
-
Admin Dashboard
- Book inventory management
- Order processing
- User management
- Sales analytics and reporting
-
Performance & Security
- Redis caching
- Rate limiting
- API documentation with Swagger
- Secure payment processing
- Backend: Python/Flask
- Database: PostgreSQL
- Caching: Redis
- Payment: Stripe
- Documentation: Swagger/OpenAPI
- Testing: Pytest
- CI/CD: GitHub Actions
- Containerization: Docker
- Python 3.12+
- PostgreSQL 15+
- Redis 7+
- Docker (optional)
- Clone the repository:
git clone https://github.com/codefromlani/BookNook.git
cd booknook- Create a
.envfile:
DATABASE_URL=postgresql://postgres:postgres@db:5432/booknook
SECRET_KEY=your-secret-key
JWT_SECRET_KEY=your-jwt-secret
MAIL_USERNAME=your-email
MAIL_PASSWORD=your-email-password
MAIL_DEFAULT_SENDER=your-email
STRIPE_PUBLIC_KEY=your-stripe-public-key
STRIPE_SECRET_KEY=your-stripe-secret-key
REDIS_URL=redis://redis:6379/0- Run with Docker Compose:
docker-compose up --build- 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 the database:
flask db upgrade- Run the application:
flask runRun the test suite:
pytestRun with coverage:
pytest --cov=app --cov-report=term-missingAccess the Swagger documentation at /api/docs when running the application.
-
Authentication
- POST
/auth/register- Register new user - POST
/auth/login- User login - POST
/auth/refresh- Refresh JWT token
- POST
-
Books
- GET
/books/list- List all books - GET
/books/search- Search books - GET
/books/{id}- Get book details - GET
/books/categories- List categories
- GET
-
Cart & Orders
- GET
/api/cart- View cart - POST
/api/cart/add- Add to cart - POST
/api/checkout/complete- Complete checkout
- GET
-
Reviews
- GET
/api/books/{book_id}/reviews- Get book reviews - POST
/api/books/{book_id}/reviews- Create review
- GET
-
Admin
- POST
/admin/books- Add new book - GET
/admin/orders- View orders - GET
/admin/reports/sales- View sales reports
- POST
- JWT-based authentication
- Rate limiting on sensitive endpoints
- Password hashing
- Input validation
- CORS protection
- Secure payment processing
The project includes a GitHub Actions workflow that:
- Runs tests
- Performs code quality checks
- Runs security scanning
- Builds and pushes Docker image
- Reports test coverage