ChatBook is a full-stack web application that blends real-time chatting with AI-powered book insights. Upload a book, ask anything, and get instant answers with vector search and LLMs.
- 🔌 Real-time chat using Socket.IO
- 🧠 AI-powered book Q&A with GPT-4 or Gemini
- 📘 Upload PDF or TXT files for instant analysis
- 🔎 Semantic search with vector embeddings
- 🔐 Auth0-based secure user authentication
- 🖥️ Modern, responsive UI with chat bubbles, loaders, and modals
| Frontend | Backend | Database | Auth | AI/ML |
|---|---|---|---|---|
| HTML5, CSS3, JavaScript | Flask (Python) | MongoDB Atlas | Auth0 | Gemini API, GPT-4 |
| Socket.IO | Flask-SocketIO | MongoDB | OAuth2 | Embeddings + RAG (VectorDB) |
graph TD
A[User] -->|uploads PDF/TXT| B[Frontend UI]
B -->|WebSocket| C[Socket.IO Client]
C --> D[Socket.IO Server]
D --> E[Flask Backend]
E --> F[MongoDB Atlas]
E --> G[Gemini / GPT-4 API]
G --> E
E --> D
D --> C
C --> B
subgraph Modules
H1[📡 Real-Time Chat\n• WebSocket via Socket.IO\n• MongoDB chat history]
H2[📚 Book Pipeline\n• File parsing + chunking\n• Vector embeddings\n• Semantic search]
H3[🤖 AI Assistant\n• Gemini / GPT-4 API\n• Context-aware answers\n• RAG Q&A system]
H4[🛡️ Security\n• Auth0 OAuth2\n• Session & file safety\n• Input validation]
end
📁 Project Structure
bash
Copy
Edit
ChatBook/
│
├── backend/
│ ├── app.py # Flask server
│ ├── routes/ # HTTP endpoints
│ ├── sockets/ # WebSocket events
│ ├── utils/ # Book processing, embeddings
│ └── config/ # Env vars, logging
│
├── frontend/
│ ├── index.html
│ ├── styles/
│ ├── scripts/
│ └── components/
│
└── README.md
🧪 Running Locally
🧰 Prerequisites
Python 3.9+
Node.js (for frontend dev)
MongoDB Atlas account
Auth0 Application
Gemini or GPT-4 API Key
⚙️ Setup
bash
Copy
Edit
# Clone the repository
git clone https://github.com/yourusername/ChatBook.git
cd ChatBook
# Create a virtual environment
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate on Windows
# Install backend dependencies
pip install -r requirements.txt
# Set up environment variables
cp .env.example .env
# Fill in Auth0 keys, Mongo URI, Gemini/GPT-4 key, etc.
# Run the backend server
python backend/app.py
🧠 Future Improvements
📱 Mobile-first responsive design
📂 Support for more file types (EPUB, DOCX)
🌍 Multi-language AI support
⌛ Exportable chat history (PDF/JSON)
👨💻 Contributing
Pull requests are welcome! For major changes, please open an issue first to discuss your idea.
bash
Copy
Edit
git checkout -b feature/my-feature
git commit -m "Add amazing feature"
git push origin feature/my-feature
📄 License
This project is licensed under the MIT License.
🙌 Acknowledgements
OpenAI
Gemini API
Socket.IO
Auth0
MongoDB Atlas
yaml
Copy
Edit
---
