Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

BookVerse

AI-Powered Full-Stack Book E-Commerce Platform
Semantic search Β· Personalized recommendations Β· Admin MIS dashboard

React 19 Django 6.0 PostgreSQL Vite 8 Tailwind CSS 3 DRF 3.14 sentence-transformers License MIT


Demo

BookVerse Demo Video

Watch Demo on YouTube

Click the thumbnail or button above to watch the full walkthrough on YouTube.


Overview

BookVerse is a production-grade full-stack e-commerce platform for books, powered by AI/ML. It features hybrid semantic search using sentence-transformers embeddings, a personalized recommendation engine with multi-signal preference vectors, a complete Admin MIS dashboard with 16 real-time KPIs, and a full e-commerce workflow β€” cart, checkout, order tracking, reviews, wishlist/reading list, and role-based access control.


Key Features

AI & Personalization

Feature Description
πŸ” Hybrid Semantic Search 384-dim vector embeddings (all-MiniLM-L6-v2) fused with keyword search (65% vector + 35% keyword) with 10-min caching
🎯 Personalized Recommendations 5-signal blend: preference vectors (29-dim), recency-weighted activity, collaborative filtering, content similarity, trending fallback
πŸ“– For You Feed Trending scorer with exponential decay (half-life 3 days), personalized carousels with explanation text
🧠 Cold-Start Quiz Book Guide onboarding builds a 29-dim user preference vector across 15 genres, 4 moods, 3 levels, 3 lengths, 4 intents
πŸ”— Semantic Similarity Embedding-based "Similar Books" with human-readable genre/category explanations
⚑ In-Memory Vector Store Auto-rebuilding BookMatrixStore (NΓ—29 float32) on model signals; zero-cold-start on server restart

E-Commerce

Feature Description
πŸ“š 50+ Books, 14 Categories Seeded with real titles across Fiction, Science, Programming, AI/ML, Business, Self-Help, and more
πŸ›’ Full Cart & Checkout useReducer-based cart, atomic stock deduction via select_for_update, discount integration
πŸ“¦ Order Lifecycle 6 statuses (pending β†’ delivered/cancelled), estimated delivery dates, order tracking page
πŸ’³ Discount Engine Percentage/fixed-amount discounts with date-range validation, auto-status (Active/Scheduled/Expired)
⭐ Reviews & Ratings Per-user-per-book unique reviews, admin moderation, order-based review prompts
❀️ Wishlist / Reading List Bookmark with personal notes and reading completion tracking, optimistic UI updates

Admin & Operations

Feature Description
πŸ“Š MIS Dashboard 16 KPIs: total sales, orders, books, low-stock alerts, best-seller, category-sales distribution, orders-by-status chart, recent orders
βš™οΈ Full CRUD Panels Books, categories, authors, discounts β€” with role-guarded admin views
πŸ“‹ Order Management Status updates, customer details, expandable line items
πŸ’¬ Contact Management Threaded admin replies, read/unread tracking, user notification on reply
πŸ”” Notification System 8 notification types (welcome, order confirmed, order status, contact reply, discount, review approved); 15s client polling

Auth & Security

Feature Description
πŸ” Token Authentication DRF authtoken with localStorage persistence
πŸ‘₯ 3 Roles Guest (browsing), User (orders, wishlist, reviews), Admin (dashboard, CRUD, management)
πŸ”‘ Password Reset Token-based 1-hour expiry flow
πŸ›‘οΈ Rate Limiting In-memory per-IP rate limiter for search (20/60s) and autocomplete (30/60s)

Tech Stack

Frontend

Layer Technology Purpose
Framework React 19 + Vite 8 Modern concurrent rendering, instant HMR
Routing react-router-dom v7 Layout routes with auth-guarded outlet groups
Styling Tailwind CSS 3.4 + Radix UI Utility-first design system, 26 hand-built components
State Context API (4 contexts) Auth, Cart (useReducer), Wishlist (optimistic), Theme
Icons Lucide React Consistent 24px iconography
Build Vite 8 ~540ms builds, ~445KB JS, ~35KB CSS

Backend

Layer Technology Purpose
Framework Django 6.0 + DRF 3.14 Mature REST framework with token auth
Database PostgreSQL 16 (default) / SQLite (dev) Swappable via BOOKVERSE_DB env var
ML / NLP sentence-transformers 3.0 all-MiniLM-L6-v2 β€” 384-dim semantic embeddings
Math NumPy + scikit-learn Vector ops, cosine similarity, matrix management
CORS django-cors-headers Development CORS policy

AI/ML Stack

Component Technology Detail
Embedding Model all-MiniLM-L6-v2 384-dim, SentenceTransformer, lazy-loaded
Feature Space Custom 29-dim vector 15 genres + 4 moods + 3 levels + 3 lengths + 4 intents
Vector Store In-memory BookMatrixStore NΓ—29 float32, auto-rebuilds on post_migrate + signals
Trending Recency-weighted decay 7-day window, half-life 3 days, hourly refresh
Scoring Dot product + 5% popularity boost Preference vector Γ— feature matrix
Search Fusion Weighted hybrid 65% vector cosine similarity + 35% keyword BM25-style

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    FRONTEND (Vite 8)                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚  Pages   β”‚  β”‚Components β”‚  β”‚ Contexts β”‚  β”‚  API      β”‚ β”‚
β”‚  β”‚  (26)    β”‚  β”‚ (34)      β”‚  β”‚  (4)     β”‚  β”‚  Service  β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β”‚
β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚
β”‚                        β”‚  axios fetch (proxy /api)          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              DJANGO REST FRAMEWORK                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚                   API Layer (52 endpoints)          β”‚   β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚   β”‚
β”‚  β”‚  β”‚   api    β”‚ β”‚ semantic β”‚ β”‚ for_you   β”‚           β”‚   β”‚
β”‚  β”‚  β”‚ (CRUD)   β”‚ β”‚ (search) β”‚ β”‚ (feed)    β”‚           β”‚   β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜           β”‚   β”‚
β”‚  β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                  β”‚   β”‚
β”‚  β”‚              β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”                          β”‚   β”‚
β”‚  β”‚              β”‚recommend. β”‚                          β”‚   β”‚
β”‚  β”‚              β”‚(training) β”‚                          β”‚   β”‚
β”‚  β”‚              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                          β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                         β”‚                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚                 AI / ML Layer                        β”‚   β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                 β”‚   β”‚
β”‚  β”‚  β”‚  Embedder    β”‚  β”‚  Vectorizer β”‚  BookMatrix     β”‚   β”‚
β”‚  β”‚  β”‚(384-d model) β”‚  β”‚  (29-d)     β”‚  Store(NΓ—29)     β”‚   β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜                 β”‚   β”‚
β”‚  β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                         β”‚                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚                 PostgreSQL / SQLite                  β”‚   β”‚
β”‚  β”‚  15 models Β· 12 indexes Β· Atomic stock (FOR UPDATE)  β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Notable Technical Implementations

Hybrid Semantic Search

  • Embedding model: all-MiniLM-L6-v2 (384-dim, SentenceTransformers) β€” lazy-loaded on first request with graceful fallback
  • Query enrichment: Book text built from title | author | category | description | genres | mood | intent | level | length
  • Fusion algorithm: Raw keyword match (ILIKE on 5 fields) weighted at 35%, vector cosine similarity at 65%
  • Filters: category, author, price range, stock level; sort by relevance, newest, popularity, price, rating, title
  • Caching: 10-minute LocMemCache per unique param signature; autocomplete cached 30 minutes
  • Rate limiting: 20 req/60s search, 30 req/60s autocomplete (in-memory per-IP)

Personalized Recommendation Engine

  • 5-signal blend:
    1. Preference vector (29-dim from cold-start quiz)
    2. Activity vector (recency-weighted interactions; half-life 7 days; view=1, cart_add=2, purchase=4)
    3. Collaborative filtering (similar users via interaction overlap)
    4. Content similarity (embedding-based "similar to past purchases")
    5. Trending fallback (for cold-start / unauthenticated users)
  • Blending: 60% preference + 40% activity when both exist
  • Scoring: Dot product + 5% popularity boost β†’ top-N
  • Explanation engine: Human-readable "why this was recommended" (genre match, level match, intent match)

Admin MIS Dashboard

  • 16 computed KPIs via single optimized aggregation query
  • Metrics: total sales, total orders, total books, low-stock count, orders-by-status breakdown, discounts given, best-seller (title + units + revenue), top 5 books, category sales distribution, recent orders
  • Frontend renders: 3 KPI card groups (financial, inventory, delivery), best-seller spotlight, top-5 table, status distribution bar chart, category sales bar chart, low-stock alerts, recent orders table

Atomic Stock Deduction

  • Orders use select_for_update() row-level locking to prevent oversell under concurrency
  • F() expressions for atomic decrement: Book.objects.filter(id=book_id).update(stock=F('stock') - qty)
  • Rollback-safe: failures at any point release the lock

Wishlist with Optimistic UI

  • React Context with useReducer β€” immediately reflects UI changes before server confirmation
  • Rollback on error: stale snapshot restored if API call fails
  • Supports personal notes and reading completion (is_finished) per item

User Roles & Flows

πŸ‘€ Guest

Browse β†’ Search (semantic + keyword) β†’ View details β†’ See trending β†’ Register

πŸ‘₯ Authenticated User

Browse β†’ Search β†’ Purchase (cart β†’ checkout β†’ order) β†’ Track order β†’ Write review β†’ Manage wishlist/reading list β†’ Get personalized recommendations β†’ Manage profile β†’ Contact support

πŸ›‘οΈ Admin

Full CRUD (books, categories, authors, discounts) β†’ Manage orders (status updates) β†’ MIS Dashboard (16 KPIs with charts) β†’ Moderate reviews β†’ Reply to contacts β†’ View all notifications


Project Statistics

Metric Count
Frontend Pages 26 (13 public, 6 auth-guarded, 7 admin)
UI Components 34 (18 base + 9 feature + 7 layout/shared)
API Endpoints 52
Backend Apps 5 (api, semantic, for_you, recommendations, bookstore)
Database Models 15 (UserProfile, Book, Author, Category, Order, OrderItem, Discount, Review, WishlistItem, Notification, ContactMessage, PasswordResetToken, UserInteraction + User, Token)
Serializers 25
Views / ViewSets 40+
Seed Data 50+ books Β· 14 categories Β· unique authors
Embedding Dimension 384 (semantic) + 29 (feature)
Frontend Bundle ~445KB JS Β· ~35KB CSS Β· ~540ms build
Caching Layers 4 (search 10m, autocomplete 30m, trends 1h, general 15m)

Setup & Installation

Prerequisites

  • Python 3.10+
  • Node.js 18+
  • PostgreSQL 14+ (optional; SQLite works out-of-the-box for evaluation)

Quick Start

# 1. Backend
cd backend
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt
python manage.py migrate
python manage.py seed_data                     # 50+ books across 14 categories
python manage.py generate_embeddings --all     # Build 384-dim semantic vectors
python manage.py runserver

# 2. Frontend (separate terminal)
cd frontend
npm install
npm run dev
  • Frontend β†’ http://localhost:5173
  • Backend API β†’ http://localhost:8000/api/

Using PostgreSQL

export BOOKVERSE_DB=postgres
export DB_NAME=bookverse DB_USER=bookuser DB_PASSWORD=1234 DB_HOST=localhost DB_PORT=5432
python manage.py runserver

Or use the included run.sh (configures PostgreSQL automatically).

Management Commands

Command Purpose
seed_data Populates 50+ books, 14 categories, authors
generate_embeddings Generates 384-dim semantic embeddings (single/batch/all)
refresh_trending Rebuilds in-memory trending scores

License

MIT


Built with React, Django, and a lot of coffee Β· @AdnanZaman

About

AI-powered full-stack book e-commerce platform with hybrid ML recommendations, semantic search, and real-time personalized user experience. Includes admin analytics dashboard and complete e-commerce workflow.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages