- Project Overview
- Features
- Technology Stack
- Project Structure
- Database Models
- Installation Guide
- Configuration
- Blueprints & Routes
- User Guide
- Admin Guide
- Troubleshooting
Online Bookstore is a full-featured e-commerce web application for selling books online. It provides a complete shopping experience with user authentication, cart management, order processing, customer reviews, and a comprehensive admin panel for managing inventory and orders.
- 🛍️ Complete shopping cart functionality
- 👤 User authentication & authorization
- 📦 Order management system
- ⭐ Customer review & rating system
- 🎨 Modern, responsive UI with Tailwind CSS
- 🔐 Secure payment processing (Cash on Delivery)
- 📊 Admin dashboard with analytics
- 🔍 Search functionality
- Browse Books: View all available books with images, prices, and stock status
- Search: Search books by title or author
- Book Details: View detailed information including description, binding type, and customer reviews
- Shopping Cart: Add/remove books, adjust quantities
- Checkout: Complete order with shipping details
- Order Tracking: View order history and status
- Reviews: Rate and review purchased books (1-5 stars)
- User Authentication: Secure login/signup system
- Dashboard: Overview of sales, revenue, and inventory
- Book Management: Add, edit, delete books with image upload
- Order Management: View all orders, update order status
- Inventory Tracking: Monitor stock levels and low stock alerts
- Analytics: Top selling books, recent orders, revenue tracking
- User Management: View registered users
- Framework: Flask (Python 3.x)
- Database: SQLAlchemy ORM with MYSQL
- Authentication: Flask-Login
- Migrations: Flask-Migrate
- Security: Werkzeug password hashing
- CSS Framework: Tailwind CSS 3.x
- Icons: Font Awesome 6.4
- JavaScript: Vanilla JS (ES6+)
- Animations: AOS (Animate On Scroll)
- Responsive: Mobile-first design
- Image Storage: Local filesystem
- Allowed Formats: PNG, JPG, JPEG
- Max Size: 5MB
online-bookstore/
│
├── app/
│ ├── __init__.py # App factory
│ ├── models.py # Database models
│ ├── extension.py # Flask extensions
│ │
│ ├── auth/ # Authentication blueprint
│ │ ├── __init__.py
│ │ ├── routes.py
│ │ └── decorators.py
│ │
│ ├── books/ # Books blueprint
│ │ ├── __init__.py
│ │ └── routes.py
│ │
│ ├── cart/ # Cart blueprint
│ │ ├── __init__.py
│ │ └── routes.py
│ │
│ ├── orders/ # Orders blueprint
│ │ ├── __init__.py
│ │ └── routes.py
│ │
│ ├── reviews/ # Reviews blueprint
│ │ ├── __init__.py
│ │ └── routes.py
│ │
│ ├── admin/ # Admin blueprint
│ │ ├── __init__.py
│ │ ├── routes.py
│ │ ├── book_routes.py
│ │ └── decorators.py
│ │
│ ├── static/ # Static files
│ │ ├── uploads/
│ │ │ └── books/ # Book cover images
│ │ └── css/
│ │
│ └── templates/ # HTML templates
│ ├── home.html
│ ├── book_detail.html
│ ├── cart.html
│ ├── checkout.html
│ ├── my_orders.html
│ ├── order_details.html
│ ├── login.html
│ ├── register.html
│ └── admin/
│ ├── dashboard.html
│ ├── add_book.html
│ ├── manage_books.html
│ ├── admin_order.html
│ └── admin_order_details.html
│
├── migrations/ # Database migrations
├── config.py # Configuration
├── run.py # Application entry point
└── requirements.txt # Dependencies
class User(db.Model):
id = Integer (Primary Key)
full_name = String(100)
email = String(120) - Unique
password = String(200) - Hashed
is_admin = Boolean - Default: False
created_at = DateTimeclass Books(db.Model):
id = Integer (Primary Key)
title = String(200)
author = String(100)
price = Float
stock = Integer
binding = String(50) - (Paperback/Hardcover/eBook/Audiobook)
description = Text
image = String(200) - Image path
created_at = DateTimeclass Order(db.Model):
id = Integer (Primary Key)
user_id = Foreign Key -> User
first_name = String(100)
last_name = String(100)
country = String(100)
street_address = String(200)
appartment = String(100)
city = String(100)
state = String(100)
phone = String(20)
email = String(120)
sub_total = Float
shipping_fee = Float
total_amount = Float
status = String(50) - (Pending/Processing/Shipped/Delivered/Cancelled)
payment_method = String(50)
payment_status = String(50)
created_at = DateTimeclass Order_Item(db.Model):
id = Integer (Primary Key)
order_id = Foreign Key -> Order
book_id = Foreign Key -> Books
quantity = Integer
price = Float
created_at = DateTimeclass Reviews(db.Model):
id = Integer (Primary Key)
user_id = Foreign Key -> User
book_id = Foreign Key -> Books
rating = Integer (1-5)
review_text = Text
created_at = DateTime
updated_at = DateTimeclass Config:
SECRET_KEY = os.environ.get('SECRET_KEY') or 'dev-secret-key'
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or 'sqlite:///bookstore.db'
SQLALCHEMY_TRACK_MODIFICATIONS = False
UPLOAD_FOLDER = 'app/static/uploads/books'
MAX_CONTENT_LENGTH = 5 * 1024 * 1024 # 5MB max file size- Fixed Shipping Fee: Rs 250.00 (defined in
cart/routes.py)
GET /- List all books and top selling booksGET /search- Search books by title/authorGET /book/<int:book_id>- Book detail page
GET|POST /auth/register- User registrationGET|POST /auth/login- User loginGET /auth/logout- User logout
GET /add-to-cart/<int:book_id>- Add book to cartGET /cart- View shopping cartGET /remove-from-cart/<int:book_id>- Remove from cartGET /checkout- Checkout page (requires login)POST /place-order- Process order
GET /my-orders- User's order history (requires login)GET /order/<int:order_id>- Order details (requires login)
POST /reviews/add/<int:book_id>- Add review (requires login)POST /reviews/edit/<int:review_id>- Edit review (requires login)GET /reviews/delete/<int:review_id>- Delete review (requires login)
GET /admin/dashboard- Admin dashboard (requires admin)GET|POST /admin/add-book- Add new bookGET /admin/manage-book- Manage all booksGET /admin/delete-book/<int:book_id>- Delete bookGET /admin/orders- View all ordersGET /admin/order/<int:order_id>- Order detailsGET /admin/order/<int:order_id>/status/<string:new_status>- Update order status
- Visit the homepage to see featured and all available books
- Use the search bar to find specific books by title or author
- Click on any book card to view detailed information
- On the book detail page, select quantity
- Click "Add to Cart" button
- Cart icon shows the number of items
- Click the cart icon to review your items
- Adjust quantities using +/- buttons
- Click "Proceed to Checkout" (requires login)
- Fill in shipping information
- Review order summary
- Click "Place Order (COD)"
- Order confirmation displayed
- Navigate to "My Orders" from the navbar
- View all past and current orders
- Click "View Full Details" to see order specifics
- Track order status (Pending → Processing → Shipped → Delivered)
- Go to a book detail page
- Click on "Customer Reviews" tab
- Select star rating (1-5)
- Write optional review text
- Click "Submit Review"
- Edit or delete your reviews anytime
- Login with admin credentials
- You'll be redirected to the admin dashboard automatically
The dashboard displays:
- Total Books: Number of books in inventory
- Total Users: Registered customers
- Total Orders: All orders placed
- Total Revenue: Sum of approved/paid orders
- Recent Orders: Last 10 orders
- Top Selling Books: Top 5 bestsellers
- Low Stock Alerts: Books with stock ≤ 5
- Click "Add Book" in sidebar
- Fill in required information:
- Title *
- Author *
- Price (Rs) *
- Stock Quantity *
- Binding Type (Paperback/Hardcover/eBook/Audiobook)
- Description (optional)
- Book Cover Image * (PNG/JPG/JPEG, max 5MB)
- Click "Add Book"
- Click "Manage Books" in sidebar
- View all books with images, prices, and stock
- Use delete button (trash icon) to remove books
- Confirm deletion (also deletes the image file)
- Click "All Orders" in sidebar
- Filter by status: All, Pending, Processing, Shipped, Delivered, Cancelled
- View customer details, order items, and totals
- Click "View Details" on any order OR use "Update Status" dropdown
- Select new status:
- Pending: Order received, awaiting processing
- Processing: Order being prepared
- Shipped: Order dispatched
- Delivered: Order completed (auto-updates payment to "Approved")
- Cancelled: Order cancelled (auto-updates payment to "Cancelled")
- Status updates are immediate
- Full customer information
- Shipping address
- All order items with quantities and prices
- Payment information
- Print invoice functionality
session['cart'] = {
'book_id': quantity,
'1': 2, # Book ID 1, Quantity 2
'5': 1, # Book ID 5, Quantity 1
}success- Green background (successful actions)danger- Red background (errors)warning- Yellow background (warnings)info- Blue background (informational)
Pending → Processing → Shipped → Delivered
↓
Cancelled (can be set from any status)
- Status changed to Delivered → Payment Status = "Approved"
- Status changed to Cancelled → Payment Status = "Cancelled"
# Remove migrations folder
rm -rf migrations/
# Re-initialize
flask db init
flask db migrate -m "Initial migration"
flask db upgrade- Check
UPLOAD_FOLDERpath exists:app/static/uploads/books - Verify file permissions
- Ensure file size < 5MB
- Check allowed extensions: PNG, JPG, JPEG
- Clear browser cookies/cache
- Check if user exists in database
- Verify password hashing is working
# Set is_admin = True for user
flask shell
>>> from app.models import User
>>> from app.extension import db
>>> user = User.query.filter_by(email='user@example.com').first()
>>> user.is_admin = True
>>> db.session.commit()- Verify
Reviewsmodel is imported (notReview) - Check database has reviews table
- Ensure
reviews,avg_rating,user_reviewpassed to template
- Sessions require
SECRET_KEYto be set - Check browser allows cookies
- Session data stored server-side
The application uses a consistent color scheme:
Main Background: #FCF8F8
Card Background: #FBEFEF
Highlight Background: #F9DFDF
Accent (Primary): #F5AFAF
Primary Text: #3A2E2E
Secondary Text: #4A3A3A
Muted Text: #7A6A6A-
Password Security
- Passwords hashed using Werkzeug's
generate_password_hash - Never store plain text passwords
- Passwords hashed using Werkzeug's
-
Session Security
- Use strong
SECRET_KEYin production - Sessions are server-side only
- Use strong
-
File Upload Security
- Only allowed file types: PNG, JPG, JPEG
- File size limit: 5MB
- Filenames sanitized using
secure_filename()
-
Access Control
@login_requireddecorator for authenticated routes@admin_requireddecorator for admin-only routes- Authorization checks on sensitive operations
Potential features to add:
- Payment gateway integration (Stripe, PayPal)
- Email notifications for orders
- Wishlist functionality
- Advanced search filters (genre, price range, publication date)
- Book recommendations based on purchase history
- Coupon/discount system
- Multi-image support for books
- Pagination for book listings
- Export orders to CSV/PDF
- SMS notifications for order updates
- Social media login (OAuth)
- Book categories/genres
- Featured/bestseller tags
- Related books suggestions
Developed by: Asad Nadeem Date: 3/10/2026 Framework: Flask Design: Tailwind CSS