Skip to content

scopophobic/Readingroom

Repository files navigation

๐Ÿ“š Reading Room - Intelligent Book Social Platform

Next.js Django FastAPI TypeScript Python

A next-generation book-centered social media platform that combines AI-powered recommendations, intelligent book discussions, and vibrant community features to revolutionize how readers discover, discuss, and share their literary experiences.

๐ŸŒŸ Key Features

๐Ÿ“– Smart Book Discovery

  • Google Books Integration: Seamlessly search and explore millions of books
  • AI-Powered Recommendations: Advanced semantic search based on emotional tone, genre preferences, and reading patterns
  • Personalized Discovery: Machine learning algorithms that understand your reading taste
  • Visual Book Search: Rich metadata with covers, descriptions, and ratings

๐Ÿค– RAG-Based Book Chat

  • Intelligent Book Discussions: Chat with AI about specific books using Retrieval-Augmented Generation
  • Context-Aware Responses: AI understands book content through vector embeddings and Wikipedia integration
  • Literary Analysis: Deep conversations about themes, characters, plot, and literary techniques
  • Memory-Enabled Conversations: Maintains conversation history for continuity

๐ŸŽฏ Semantic Recommendation Engine

  • Emotion-Based Filtering: Find books by mood (Happy, Suspenseful, Sad, Surprising, Angry)
  • Genre Intelligence: Advanced categorization beyond simple genre tags
  • Vector Search: Semantic similarity matching for nuanced recommendations
  • Multi-Factor Analysis: Combines content analysis, sentiment, and user preferences

๐Ÿ‘ฅ Social Community Platform

  • Dynamic Posts: Share thoughts, reviews, and reading updates
  • Rich Discussions: Comment threads and book-focused conversations
  • User Profiles: Track reading history, favorite books, and social connections
  • Feed Algorithms: Curated content based on interests and connections

๐Ÿ— Architecture Overview

Frontend (Next.js 15 + TypeScript)

Frontend/
โ”œโ”€โ”€ app/                    # Next.js 15 App Router
โ”‚   โ”œโ”€โ”€ auth/              # Authentication pages
โ”‚   โ”œโ”€โ”€ books/             # Book discovery & details
โ”‚   โ”œโ”€โ”€ posts/             # Social media feed
โ”‚   โ”œโ”€โ”€ discussions/       # Book chat interface
โ”‚   โ”œโ”€โ”€ ai-recommendations/ # AI recommendation engine
โ”‚   โ”œโ”€โ”€ discover/          # Book search & browse
โ”‚   โ””โ”€โ”€ profile/           # User management
โ”œโ”€โ”€ components/            # Reusable UI components
โ”‚   โ”œโ”€โ”€ ui/               # shadcn/ui component library
โ”‚   โ”œโ”€โ”€ book-card.tsx     # Book display components
โ”‚   โ”œโ”€โ”€ post-card.tsx     # Social post components
โ”‚   โ””โ”€โ”€ chat-interface.tsx # AI chat components
โ””โ”€โ”€ lib/                  # Utilities & API clients
    โ”œโ”€โ”€ api-client.ts     # Backend API integration
    โ”œโ”€โ”€ auth-context.tsx  # Authentication state
    โ””โ”€โ”€ hooks/            # Custom React hooks

Backend (Django REST Framework)

Backend/
โ”œโ”€โ”€ readingroom/          # Main Django project
โ”‚   โ”œโ”€โ”€ settings.py      # Configuration with CORS, JWT
โ”‚   โ””โ”€โ”€ urls.py          # API routing
โ”œโ”€โ”€ books/               # Book management
โ”‚   โ”œโ”€โ”€ models.py        # Book & UserBookStatus models
โ”‚   โ”œโ”€โ”€ views.py         # Google Books API integration
โ”‚   โ”œโ”€โ”€ serializers.py   # API serialization
โ”‚   โ””โ”€โ”€ utils/           # Google Books utilities
โ”œโ”€โ”€ posts/               # Social media functionality
โ”‚   โ”œโ”€โ”€ models.py        # Post & interaction models
โ”‚   โ”œโ”€โ”€ views.py         # CRUD operations
โ”‚   โ””โ”€โ”€ serializers.py   # Post API serialization
โ”œโ”€โ”€ users/               # User management
โ”‚   โ”œโ”€โ”€ models.py        # Custom User model
โ”‚   โ”œโ”€โ”€ views.py         # Authentication & profiles
โ”‚   โ””โ”€โ”€ serializers.py   # User API serialization
โ””โ”€โ”€ comments/            # Comment system
    โ”œโ”€โ”€ models.py        # Comment models
    โ”œโ”€โ”€ views.py         # Comment operations
    โ””โ”€โ”€ serializers.py   # Comment serialization

RAG Chat System (FastAPI + AI)

Retrieval-Augmented Conversational Agents/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ api.py           # FastAPI endpoints
โ”‚   โ”œโ”€โ”€ embedder.py      # Vector embedding generation
โ”‚   โ”œโ”€โ”€ query_engine.py  # RAG query processing
โ”‚   โ”œโ”€โ”€ wiki_fetch.py    # Wikipedia data retrieval
โ”‚   โ””โ”€โ”€ main.py          # FastAPI application
โ”œโ”€โ”€ vectorstore/         # ChromaDB vector storage
โ””โ”€โ”€ data/               # Book metadata & content

Semantic Recommender (ML Engine)

Semantic-book-recommender/
โ”œโ”€โ”€ app.py              # Gradio recommendation interface
โ”œโ”€โ”€ vector-search.ipynb # Vector similarity algorithms
โ”œโ”€โ”€ sentiment-analysis.ipynb # Emotion classification
โ”œโ”€โ”€ text-classification.ipynb # Genre categorization
โ””โ”€โ”€ data/               # Processed book datasets

๐Ÿš€ Technology Stack

Frontend Technologies

  • Next.js 15: React framework with App Router
  • TypeScript: Type-safe development
  • Tailwind CSS: Utility-first styling
  • shadcn/ui: Modern component library
  • Radix UI: Accessible component primitives
  • Axios: HTTP client for API communication
  • NextAuth.js: Authentication solution

Backend Technologies

  • Django 5.2: Robust web framework
  • Django REST Framework: API development
  • PostgreSQL: Production database
  • JWT Authentication: Secure token-based auth
  • Django CORS Headers: Cross-origin support
  • Google Books API: Book metadata source

AI & ML Technologies

  • FastAPI: High-performance API framework
  • ChromaDB: Vector database for embeddings
  • Sentence Transformers: Text embedding models
  • Google Gemini API: Large language model
  • LangChain: LLM application framework
  • Gradio: ML model interface
  • Pandas & NumPy: Data processing

Development & Deployment

  • Docker: Containerization
  • Git: Version control
  • Environment Variables: Secure configuration
  • CORS: Cross-origin resource sharing
  • RESTful APIs: Standardized communication

๐Ÿ”ง Installation & Setup

Prerequisites

  • Node.js 18+ and npm/pnpm
  • Python 3.10+ and pip
  • PostgreSQL (for production)
  • Git for version control

API Keys Required

# Google Books API
GOOGLE_API_KEY=your_google_books_api_key

# Google Gemini API (for AI chat)
GEMINI_API_KEY=your_gemini_api_key

# Django Secret Key
SECRET_KEY=your_django_secret_key

# Database URL (production)
DATABASE_URL=your_postgresql_url

Quick Start

1. Frontend Setup

cd Frontend
npm install
# or
pnpm install

# Start development server
npm run dev
# Runs on http://localhost:3000

2. Django Backend Setup

cd Backend
pip install -r requirements.txt

# Database migrations
python manage.py migrate

# Create superuser (optional)
python manage.py createsuperuser

# Start Django server
python manage.py runserver
# Runs on http://localhost:8000

3. RAG Chat System Setup

cd "Retrieval-Augmented Conversational Agents for Literary Discussion/backend"
pip install -r requirements.txt

# Create .env file with API keys
echo "GOOGLE_API_KEY=your_key" > .env
echo "GEMINI_API_KEY=your_key" >> .env

# Start FastAPI server
uvicorn main:app --reload --port 8001
# Runs on http://localhost:8001

4. Semantic Recommender Setup

cd Semantic-book-recommender
pip install -r requirements.txt

# Start Gradio interface
python app.py
# Creates shareable Gradio endpoint

๐Ÿ“Š API Documentation

Django Backend APIs

  • Base URL: http://localhost:8000/api/
  • Authentication: JWT Bearer tokens
  • Documentation: Available at /api/docs/ (when DEBUG=True)

Key Endpoints

# Authentication
POST /auth/login/          # User login
POST /auth/register/       # User registration
POST /auth/refresh/        # Token refresh

# Books
GET  /books/              # List books
GET  /books/{id}/         # Book details
POST /books/fetch/        # Fetch from Google Books
GET  /books/search/       # Search books

# Posts
GET  /posts/              # List posts
POST /posts/              # Create post
GET  /posts/{id}/         # Post details
PUT  /posts/{id}/         # Update post
DELETE /posts/{id}/       # Delete post

# Comments
GET  /posts/{id}/comments/ # Post comments
POST /posts/{id}/comments/ # Add comment

RAG Chat APIs

  • Base URL: http://localhost:8001/
  • Content-Type: application/json
# Book Preparation
GET  /search-books        # Search Google Books
POST /books/fetch-wiki    # Fetch Wikipedia data
POST /books/embed         # Generate embeddings
POST /books/prepare       # Full preparation pipeline

# Chat Interface
POST /chat/query          # Ask questions about books
GET  /books/check         # Check if book is ready

Semantic Recommender

  • Interface: Gradio web interface
  • Input: Text description, genre, emotional tone
  • Output: Ranked book recommendations with covers

๐Ÿ”ฅ Core Features Deep Dive

1. AI-Powered Book Recommendations

The semantic recommendation system uses advanced machine learning to understand book content and user preferences:

  • Vector Embeddings: Books are represented as high-dimensional vectors
  • Semantic Search: Find books similar in meaning, not just keywords
  • Emotion Analysis: Filter by emotional tone (joy, fear, anger, surprise, sadness)
  • Genre Intelligence: Advanced categorization beyond simple tags
  • Personalization: Learns from user interactions and preferences

2. RAG-Based Book Discussions

Revolutionary AI chat system for deep book conversations:

  • Content Preparation: Wikipedia data + vector embeddings
  • Context Retrieval: Relevant book passages for each question
  • Response Generation: Google Gemini creates contextual answers
  • Memory: Maintains conversation history for continuity
  • Metadata Integration: Uses book details for richer responses

3. Social Media Features

Community-focused platform for book lovers:

  • Dynamic Posts: Rich text posts about books and reading
  • Comments & Discussions: Threaded conversations
  • User Profiles: Reading history and social connections
  • Book Status: Track reading progress (want to read, reading, read)
  • Discovery Feed: Algorithm-curated content

4. Book Discovery Engine

Powerful search and discovery tools:

  • Google Books Integration: Access to millions of books
  • Advanced Filtering: Genre, author, publication date, ratings
  • Visual Search: Rich metadata with covers and descriptions
  • Related Books: AI-suggested similar titles
  • Trending: Popular books and rising titles

๐Ÿ”’ Security & Authentication

  • JWT Tokens: Secure authentication with refresh mechanism
  • CORS Configuration: Proper cross-origin resource sharing
  • Environment Variables: Secure API key management
  • Input Validation: Request validation and sanitization
  • Rate Limiting: API protection against abuse
  • HTTPS Ready: SSL/TLS support for production

๐Ÿš€ Deployment

Development

  • Frontend: Next.js development server
  • Backend: Django development server
  • Database: SQLite for development
  • AI Services: Local FastAPI instances

Production

  • Frontend: Vercel, Netlify, or custom hosting
  • Backend: Railway, Heroku, or VPS
  • Database: PostgreSQL (Railway, Supabase, AWS RDS)
  • AI Services: Cloud deployment with Docker
  • CDN: Static asset optimization

๐Ÿค Contributing

We welcome contributions! Please see our contributing guidelines:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Development Guidelines

  • Follow TypeScript/Python best practices
  • Write comprehensive tests
  • Update documentation
  • Follow conventional commit messages
  • Ensure code passes linting

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Google Books API for book metadata
  • Google Gemini for AI conversation capabilities
  • ChromaDB for vector storage and retrieval
  • shadcn/ui for beautiful UI components
  • Vercel for Next.js hosting platform
  • Open Source Community for amazing tools and libraries

๐Ÿ“ง Contact & Support


Reading Room - Where every page opens a new conversation ๐Ÿ“šโœจ

About

This is the main repo of the Readingroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

โšก