Skip to content

Latest commit

Β 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š AI-Powered Book Intelligence Platform

πŸš€ Overview

This project is a full-stack AI-powered document intelligence system that:

  • Scrapes book data from the web
  • Stores it in a structured database
  • Enables intelligent question answering using a RAG (Retrieval-Augmented Generation) pipeline

πŸ’» Live Demo (How it works)

  1. Scrape books using Selenium
  2. Store books in backend database
  3. Generate AI summaries
  4. User asks a question
  5. System retrieves relevant books (ChromaDB)
  6. LLM generates contextual answer

Example Query:


What is Sapiens about?

Output:


Provides a historical narrative of human evolution...


πŸ‘€ Users Can

  • Browse books
  • View detailed book information
  • Ask natural language questions
  • Get AI-generated answers with sources
  • Receive book recommendations

🧠 Design Decisions

  • Used LM Studio instead of OpenAI to avoid API costs and enable offline usage
  • Implemented RAG instead of keyword search for better contextual answers
  • Used ChromaDB for fast semantic similarity search
  • Added caching to reduce repeated LLM calls

🧠 Key Features

  • πŸ“– Automated book scraping using Selenium
  • πŸ—„οΈ Book storage using Django + SQLite/MySQL
  • πŸ”Ž Semantic search using Sentence Transformers
  • 🧠 RAG pipeline using ChromaDB
  • πŸ€– AI-powered answers using local LLM (LM Studio)
  • πŸ“Œ Book recommendations via similarity search
  • ⚑ Response caching for faster queries
  • 🎨 Responsive frontend using Next.js + Tailwind CSS

πŸ—οΈ Tech Stack

πŸ”§ Backend

  • Django
  • Django REST Framework
  • Python
  • SQLite / MySQL
  • Requests

🧠 AI / RAG

  • SentenceTransformers (all-MiniLM-L6-v2)
  • ChromaDB
  • LM Studio (Mistral / Phi-3)
  • Retrieval-Augmented Generation (RAG)

πŸ•·οΈ Automation

  • Selenium
  • ChromeDriver

🎨 Frontend

  • Next.js (React)
  • TypeScript
  • Tailwind CSS
  • Axios

🧩 System Architecture


Scraper (Selenium)
↓
Django Backend (API Layer)
↓
Database (Books Metadata)
↓
Embeddings (Sentence Transformers)
↓
Vector DB (ChromaDB)
↓
RAG Retrieval System
↓
LM Studio LLM (Answer Generation)
↓
Frontend (Next.js UI)


πŸ“‘ API Endpoints

πŸ“˜ Books

(use postman for post requests)

Method Endpoint Description
GET /books/ Get all books
POST /books/ Add a new book
GET /books// Get book details
PUT /books// Update a book

πŸ€– AI / RAG

Method Endpoint Description
POST /ask-question/ Ask AI question
GET /books//recommend/ Get similar books
GET /load-rag/ Load embeddings into vector DB
POST /upload-book/ Upload & process book

πŸ§ͺ Sample Questions

  • What is this book about?
  • Recommend books similar to mystery genre
  • Summarize the book description
  • Which books are best for fiction lovers?

βš™οΈ Setup Instructions

1️⃣ Clone Repository

git clone https://github.com/your-username/AI-Powered-Book-Insight.git
cd AI-Powered-Book-Insight

2️⃣ Start LM Studio (IMPORTANT FIRST)

  • Open LM Studio

  • Load model:

    • phi-3-mini-4k-instruct (recommended)
  • Start server at:

http://localhost:1234

3️⃣ Backend Setup

cd ai_book_project
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt

Run migrations:

python manage.py migrate

Start server:

python manage.py runserver

4️⃣ Load RAG Data

GET http://127.0.0.1:8000/load-rag/

πŸ‘‰ This generates embeddings and stores them in ChromaDB


5️⃣ Run Scraper (if DB is empty)

python scraper.py

6️⃣ Frontend Setup

cd frontend
npm install
npm run dev

Frontend runs at:

http://localhost:3000

βœ… 7️⃣ Verify Everything Works

  • Open frontend
  • Ask:
What is Sapiens about?

πŸ‘‰ If AI answers β†’ βœ… SUCCESS

Testing APIs with Postman

You can test the backend endpoints using Postman.

1. Get All Books

Method: GET

http://127.0.0.1:8000/books/


2. Get Book Details

Method: GET

http://127.0.0.1:8000/books/1/

(Replace 1 with a valid book ID)


3. Get Recommended Books

Method: GET

http://127.0.0.1:8000/books/1/recommend/


4. Ask a Question (RAG Query)

Method: POST

http://127.0.0.1:8000/ask-question/

Body β†’ raw β†’ JSON

{ "question": "What books are related to mystery?" }


5. Upload a Book

Method: POST

http://127.0.0.1:8000/upload-book/

Body β†’ raw β†’ JSON

{ "title": "Test Book", "price": "$20", "rating": "Four", "link": "http://example.com/book", "description": "A mystery novel about a detective.", "summary": "A detective investigates a strange crime.", "genre": "Mystery" }


πŸ“Š Example Flow

User asks:

Recommend me books like mystery novels

System:

  • Converts query β†’ embedding
  • Searches ChromaDB
  • Retrieves relevant chunks
  • Sends context to LLM

Output:

  • AI-generated answer
  • Source books displayed

πŸ’‘ Key Improvements Implemented

  • Overlapping chunking for better retrieval
  • Embedding-based semantic search
  • Cached responses for faster queries
  • Structured prompt engineering
  • Clean REST API design
  • Responsive frontend UI

πŸ“· Screenshots

Dashboard

Dashboard

Book Detail Page

Book Detail

Q&A Interface

Q&A


⚠️ Challenges Faced

  1. Slow AI response time β†’ Solved using caching + limited batch processing

  2. ChromeDriver compatibility issues β†’ Fixed by matching browser version

  3. Large context handling in RAG β†’ Solved using chunking with overlap

  4. API failures during scraping β†’ Added error handling and retries


πŸš€ Future Improvements

  • Async processing using Celery
  • Docker deployment
  • User authentication system
  • Hybrid search (BM25 + embeddings)

⚠️ Notes

  • Ensure LM Studio is running before asking questions
  • First RAG load may take time (/load-rag/)
  • ChromeDriver must match Chrome version

πŸ‘¨β€πŸ’» Author

Built as part of a Frontend/Backend AI Internship Assignment


⭐ Support

If you like this project, give it a ⭐ on GitHub!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages