BookHive is a full-stack, community-first web application designed to bridge the gap between digital book platforms and real-world literary communities.
While reading is often a solitary activity, the passion for books is inherently social. BookHive moves beyond the traditional βdigital libraryβ model by introducing a structured ecosystem where users can discover nearby books, manage borrowing workflows, attend literary events, and build trust through reputation-based engagement.
- Social Interaction β Transform reading from an isolated habit into a shared experience
- Access Over Ownership β Promote a circular economy through local book borrowing
- Local Connectivity β Use interactive maps to connect nearby readers
- Trust & Reputation β Enable safe, transparent interactions through reviews and ratings
- Performance First β Enterprise-grade caching and optimization for seamless user experience
The following flow illustrates the end-to-end borrowing experience:
graph LR
A[User Discovers Book] -->|Request Sent| B[Pending Approval]
B -->|Owner Approves| C[Chat Opened]
C -->|Exchange Details| D[Book Handover]
D -->|Status Update| E[Reading]
E -->|Finished| F[Return Book]
F -->|Both Users| G[Review & Reputation]
style A fill:#e3f2fd,stroke:#1565c0,stroke-width:2px
style G fill:#fffde7,stroke:#f9a825,stroke-width:2px,stroke-dasharray:5,5
flowchart TD
Client[React Client] -->|REST API| API[Express API]
Client -->|WebSocket| Socket[Socket.IO]
subgraph Backend_Services
API --> Cache[(Redis Cloud)]
API --> DB[(MongoDB Atlas)]
API --> Cloud[Cloudinary]
API --> Auth[Passport / JWT]
Socket --> Notify[Real-time Notifications]
Cache --> RateLimit[Rate Limiting]
end
subgraph External_Integrations
API --> Mail[Nodemailer / SMTP]
API --> Pay[Razorpay]
API --> Geo[Geocoding API]
end
subgraph Performance_Layer
Cache --> BookCache[Book Caching]
Cache --> SessionCache[Session Management]
Cache --> SearchCache[Search Results]
Cache --> GeoCache[Location Data]
end
- Hyper-local Discovery: Interactive maps for finding nearby books and events
- Literary Events: Book clubs, author meetups, book fairs with organizer dashboards
- Smart Search: AI-powered book recommendations and filtering
- Real-time Messaging: Encrypted chat with emojis, file sharing, and typing indicators
- Smart Notifications: iOS-style notifications with real-time updates
- Reputation System: Progressive star ratings and trust-based interactions
- Redis Caching: 80-90% faster response times for popular content
- Rate Limiting: Redis-backed API protection and abuse prevention
- Optimized Queries: Indexed MongoDB operations (30-50% faster reads)
- Real-time Updates: WebSocket connections for instant notifications
- Role-Based Access Control: Granular permissions for users, organizers, moderators, and admins
- API Documentation: Interactive Swagger/OpenAPI documentation at
/api-docs - Background Jobs: Asynchronous email processing, image optimization, and cleanup tasks
- Comprehensive Testing: Unit and integration tests with 80%+ code coverage
- Input Validation: XSS protection, SQL injection prevention, and data sanitization
- Rate Limiting: Redis-backed protection against API abuse and DDoS attacks
- JWT Authentication: Secure token-based authentication
- Input Validation: Comprehensive data sanitization
- Error Handling: Graceful fallbacks and monitoring
- Production Ready: Health checks and monitoring endpoints
BookHive uses a gamified reputation system to encourage positive community engagement:
| Tier | Reviews Required | Rating | Badge |
|---|---|---|---|
| Novice | 0β9 | β | π₯ |
| Apprentice | 10β19 | β | π± |
| Reader | 20β29 | ββ | π |
| Scholar | 30β39 | βββ | π |
| Librarian | 40β49 | ββββ | ποΈ |
| Guardian | 50+ | βββββ | π‘οΈ |
BookHive leverages Redis Cloud for enterprise-grade performance:
- 80-90% faster repeated searches and popular content
- Sub-second response times for cached book listings
- Real-time user tracking with online status management
- Intelligent cache invalidation for data consistency
- Popular Books: 24-hour TTL for trending content
- Search Results: 1-hour TTL for query optimization
- User Sessions: 7-day TTL for authentication
- Geospatial Data: 30-minute TTL for location-based features
- Search Endpoints: 100 requests/hour
- Authentication: 5 attempts/15 minutes
- File Uploads: 10 uploads/hour
- General API: 1000 requests/hour
- Cache hit/miss ratios logged in real-time
- Health check endpoints for system monitoring
- Graceful fallback to MongoDB when Redis is unavailable
| Layer | Technologies |
|---|---|
| Frontend | React 18, React Router, Tailwind CSS, Framer Motion, Leaflet, React-Leaflet, Axios, Styled Components |
| Backend | Node.js, Express.js, MongoDB, Mongoose, Socket.IO, Passport.js, JWT |
| Caching & Performance | Redis Cloud, Rate Limiting, Connection Pooling |
| Background Jobs | BullMQ, Job Queues, Email Processing, Image Optimization |
| API Documentation | Swagger/OpenAPI 3.0, Interactive API Explorer |
| Access Control | Role-Based Access Control (RBAC), Permission Management |
| Testing | Jest, Supertest, MongoDB Memory Server, Unit & Integration Tests |
| Real-time | Socket.IO, WebSocket, Live Notifications |
| Payments | Razorpay Integration |
| Media & Storage | Cloudinary (Images), File Upload |
| Email & Communication | Nodemailer, SMTP |
| Security | Helmet, HPP, XSS Protection, Input Validation |
| Monitoring | Health Checks, Error Logging, Performance Metrics |
| Jobs & Scheduling | Node-Cron, Automated Tasks |
- Node.js (v16+)
- MongoDB (Local or Atlas)
- Redis Cloud Account (for caching)
- Cloudinary Account
git clone https://github.com/abhijeetbhale/Book-Hive.git
cd Book-HiveCreate a .env file inside /server using the template:
cp server/.env.example server/.envThen configure your environment variables:
# Server Configuration
PORT=5000
NODE_ENV=development
CLIENT_URL=http://localhost:3000
# MongoDB Connection
MONGODB_URI=your_mongodb_connection_string
# Redis Configuration (Redis Cloud)
REDIS_URL=redis://default:<password>@<host>:<port>
REDIS_TTL_DEFAULT=3600
REDIS_TTL_SESSION=604800
REDIS_TTL_SEARCH=3600
REDIS_TTL_GEO=1800
# JWT Authentication
JWT_SECRET=your_jwt_secret_key
JWT_EXPIRES_IN=7d
# Cloudinary Configuration
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
# Email Configuration
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USER=your_email
EMAIL_PASS=your_app_password
EMAIL_FROM="BookHive" <your_email>
# Google OAuth (Optional)
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
# Admin Configuration
SUPER_ADMIN_EMAIL=your_admin_email
# Razorpay Payment Gateway
RAZORPAY_KEY_ID=your_razorpay_key_id
RAZORPAY_KEY_SECRET=your_razorpay_key_secret
# API Documentation
SWAGGER_ENABLED=true
API_DOCS_PATH=/api-docs
# Background Jobs (BullMQ)
BULL_BOARD_USERNAME=admin
BULL_BOARD_PASSWORD=secure_admin_password
# Testing Configuration (Optional)
MONGODB_URI_TEST=mongodb://localhost:27017/bookhive_test
JWT_SECRET_TEST=test_jwt_secret_for_testing_only
REDIS_URL_TEST=redis://localhost:6379/1Install dependencies and start the server:
cd server
npm install
npm run devCreate a .env file inside /client:
REACT_APP_API_URL=http://localhost:5000/api
REACT_APP_SOCKET_URL=http://localhost:5000
REACT_APP_RAZORPAY_KEY=your_razorpay_key_idInstall dependencies and start the client:
cd client
npm install
npm start- Backend: http://localhost:5000/api/health
- Frontend: http://localhost:3000
- API Documentation: http://localhost:5000/api-docs
- Redis Health: http://localhost:5000/api/books-cached/cache/health
- Job Queue Status: http://localhost:5000/api/jobs/status
- Interactive Swagger UI: http://localhost:5000/api-docs
- OpenAPI Specification: Complete API documentation with examples
- Try It Out: Test endpoints directly from the browser
# Start job processor
npm run jobs:start
# Development mode with auto-restart
npm run jobs:dev
# Check queue status
curl http://localhost:5000/api/jobs/status# Run all tests
npm test
# Unit tests only
npm run test:unit
# Integration tests only
npm run test:integration
# Test coverage report
npm run test:coverage# Initialize roles and migrate users
npm run migrate:rbac
# Test admin endpoints
npm run test:admin# Test Redis connection
npm run test:redis
# Warm cache with data
npm run cache:warm
# Clear all caches
npm run cache:flush- Server Health:
GET /api/health - Cache Health:
GET /api/books-cached/cache/health - Database Status: Included in health endpoints
- β Redis Cloud Integration: Enterprise-grade caching for 80-90% performance improvement
- β Advanced Rate Limiting: Redis-backed API protection
- β Real-time Caching: Intelligent cache invalidation and warming
- β Enhanced Security: Comprehensive input validation and error handling
- β Performance Monitoring: Health checks and system metrics
- β Geospatial Caching: Location-based book discovery optimization
- Standard Books API:
/api/books(Direct database queries) - Cached Books API:
/api/books-cached(Redis-optimized responses) - Health Monitoring:
/api/health(System status) - Cache Management:
/api/books-cached/cache/health(Cache status)
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow ESLint configuration
- Write meaningful commit messages
- Add tests for new features
- Update documentation as needed