Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š BookRecommender - AI-Powered Book Recommendation Platform

A full-stack web application that provides personalized book recommendations using collaborative filtering and graph database technology. Built with modern technologies including NestJS, React, Neo4j, and TypeScript.

✨ Features

User Features

  • πŸ” Authentication: Secure JWT + httpOnly cookie-based authentication
  • πŸ“– Book Browsing: Search and filter through extensive book collection
  • πŸ‘ Reactions: Like, love, hate books to build your taste profile
  • ⭐ Favorites: Bookmark your favorite books
  • 🎯 Personalized Recommendations: AI-powered collaborative filtering
  • πŸ“Š Trending & Popular: Discover what's trending and most-loved
  • πŸ” Advanced Search: Search by title, author, or category
  • 🎨 Modern Dark UI: Beautiful, responsive design with animations

Admin Features

  • πŸ“š Book Management: Create, update, delete books
  • 🏷️ Category Management: Organize books into categories
  • πŸ“ˆ Analytics Dashboard: View interaction statistics

πŸ› οΈ Tech Stack

Backend

  • Framework: NestJS (Node.js)
  • Database: Neo4j (Graph Database)
  • Authentication: JWT + httpOnly Cookies
  • Validation: class-validator, class-transformer
  • API Documentation: Swagger/OpenAPI
  • Language: TypeScript

Frontend

  • Framework: React 18
  • Build Tool: Vite
  • Routing: TanStack Router (Type-safe routing)
  • State Management: TanStack Query v5 (Server state)
  • Styling: Tailwind CSS v4
  • HTTP Client: Axios
  • Icons: Lucide React
  • Language: TypeScript

Architecture

  • Graph Database: Neo4j for relationship-based recommendations
  • RESTful API: 31 documented endpoints
  • Cookie-Based Sessions: Secure httpOnly cookies
  • Collaborative Filtering: User-based recommendation algorithm

πŸ“ Project Structure

booksNoe/
β”œβ”€β”€ backend/                 # NestJS Backend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ auth/           # Authentication module
β”‚   β”‚   β”œβ”€β”€ books/          # Books CRUD & search
β”‚   β”‚   β”œβ”€β”€ categories/     # Category management
β”‚   β”‚   β”œβ”€β”€ interactions/   # Reactions & favorites
β”‚   β”‚   β”œβ”€β”€ recommendations/# Recommendation algorithms
β”‚   β”‚   β”œβ”€β”€ users/          # User management
β”‚   β”‚   β”œβ”€β”€ neo4j/          # Neo4j service
β”‚   β”‚   └── common/         # Guards, decorators, types
β”‚   β”œβ”€β”€ package.json
β”‚   └── tsconfig.json
β”‚
β”œβ”€β”€ frontend/               # React Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/    # Reusable components
β”‚   β”‚   β”œβ”€β”€ pages/         # Page components
β”‚   β”‚   β”œβ”€β”€ hooks/         # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ context/       # Auth context
β”‚   β”‚   β”œβ”€β”€ lib/           # Utilities & config
β”‚   β”‚   └── types/         # TypeScript types
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.ts
β”‚
β”œβ”€β”€ .gitignore
└── README.md

πŸš€ Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • Neo4j Database (v5 or higher)
  • npm or yarn package manager

Backend Setup

  1. Navigate to backend directory:
cd backend
  1. Install dependencies:
npm install
  1. Create .env file in backend directory:
# Database
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=your_password

# JWT
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
JWT_EXPIRES_IN=24h

# Server
PORT=3000
NODE_ENV=development
  1. Start Neo4j database and ensure it's running

  2. Run database migrations (constraints will be created automatically on first run)

  3. Start development server:

npm run start:dev

Backend will be available at: http://localhost:3000 Swagger API documentation: http://localhost:3000/api

Frontend Setup

  1. Navigate to frontend directory:
cd frontend
  1. Install dependencies:
npm install
  1. Create .env file in frontend directory (optional):
VITE_API_URL=http://localhost:3000
  1. Start development server:
npm run dev

Frontend will be available at: http://localhost:5173 (or next available port)

πŸ“š API Endpoints

Authentication

  • POST /auth/register - Register new user
  • POST /auth/login - Login with username/password
  • POST /auth/logout - Logout and clear session

Books

  • GET /books - Get all books (with pagination & search)
  • GET /books/search - Search books by query
  • GET /books/:id - Get single book
  • POST /books - Create book (Admin only)
  • PATCH /books/:id - Update book (Admin only)
  • DELETE /books/:id - Delete book (Admin only)

Interactions

  • POST /interactions/books/:bookId/react - React to book (LIKES/HATES/LOVES)
  • DELETE /interactions/books/:bookId/react - Remove reaction
  • POST /interactions/books/:bookId/favorite - Add to favorites
  • DELETE /interactions/books/:bookId/favorite - Remove from favorites

Recommendations

  • GET /recommendations/for-me - Personalized recommendations (Auth required)
  • GET /recommendations/similar/:bookId - Similar books
  • GET /recommendations/trending - Trending books (last 30 days)
  • GET /recommendations/popular - Most popular books

Categories

  • GET /categories - Get all categories
  • POST /categories - Create category (Admin only)
  • PATCH /categories/:id - Update category (Admin only)
  • DELETE /categories/:id - Delete category (Admin only)

🎯 Recommendation Algorithm

The platform uses collaborative filtering based on graph relationships:

  1. User-based CF: Finds users with similar taste (shared loves/likes)
  2. Item-based CF: Finds books in same categories
  3. Interaction Scoring:
    • LOVES: 3 points
    • LIKES: 2 points
    • FAVORITES: 1 point
    • HATES: excluded from recommendations

πŸ”’ Security Features

  • JWT tokens with httpOnly cookies (prevents XSS)
  • Password hashing with bcrypt
  • Role-based access control (USER/ADMIN)
  • CORS configuration
  • Input validation and sanitization
  • Protected routes with guards

🎨 UI Features

  • Responsive design (mobile-first)
  • Dark mode theme
  • Smooth animations and transitions
  • Loading states and error handling
  • Gradient effects and glassmorphism
  • Accessible form controls

πŸ“¦ Build for Production

Backend

cd backend
npm run build
npm run start:prod

Frontend

cd frontend
npm run build
# Serve the dist/ folder with your preferred static server

πŸ§ͺ Testing

Backend Tests

cd backend
npm run test           # Unit tests
npm run test:e2e      # E2E tests
npm run test:cov      # Coverage

Frontend Tests

cd frontend
npm run test

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

This project is licensed under the MIT License.

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

Built with ❀️ using modern web technologies

πŸ› Known Issues

  • None at the moment

πŸ“ Future Enhancements

  • Real-time notifications
  • User profiles with reading stats
  • Book reviews and ratings
  • Social features (follow users)
  • Reading lists
  • Dark/Light mode toggle
  • Mobile app (React Native)
  • Email notifications
  • Advanced filtering options
  • Export recommendations

πŸ“ž Support

For support, please open an issue in the GitHub repository.


Happy Reading! πŸ“šβœ¨

About

AI-powered book recommendation engine (TypeScript)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages