A MERN stack web application for buying, selling, auctioning, and trading books.
- AI-Powered Recommendations: Personalized book suggestions using Google Gemini
- Interactive AI Chat: Natural conversations about book preferences
- Auction System: Time-limited bidding on books
- Fixed-Price Sales: Immediate purchase options
- Book Trading: Exchange books without money
- Offer System: Negotiate prices on fixed-price items
- PDF Sharing: Share downloadable digital books
- Real-time Updates: Live auction bidding and notifications
- Frontend: React 18 with TypeScript, Vite, React Router
- Backend: Node.js, Express.js, Socket.io
- Database: MongoDB with Mongoose
- Authentication: JWT tokens, Google OAuth 2.0
- AI: Google Gemini Pro for book recommendations
- Node.js (v18 or higher)
- MongoDB (local or cloud instance)
-
Clone the repository
-
Install all dependencies:
npm run install:all
-
Set up environment variables:
- Copy
server/.env.exampletoserver/.env - Update the MongoDB URI and JWT secret
- Copy
Start both frontend and backend:
npm run devOpen your browser to http://localhost:5173
This application is configured for single-service deployment on Render, where both frontend and backend run together.
- Push to GitHub
- Create Web Service on Render
- Configure:
- Build Command:
npm run build - Start Command:
npm start
- Build Command:
- Add Environment Variables (see below)
- Deploy!
- Quick Start: RENDER_QUICK_START.md - Deploy in 5 minutes
- Step-by-Step: RENDER_STEP_BY_STEP.md - Detailed visual guide
- Full Guide: RENDER_DEPLOYMENT_GUIDE.md - Complete documentation
- FAQ: DEPLOYMENT_FAQ.md - Common questions answered
- Architecture: DEPLOYMENT_ARCHITECTURE.md - How it works
| Variable | Required | Description |
|---|---|---|
NODE_ENV |
✅ | Set to production |
PORT |
✅ | Set to 10000 (Render default) |
MONGODB_URI |
✅ | MongoDB Atlas connection string |
JWT_SECRET |
✅ | Random 32+ character string |
GOOGLE_CLIENT_ID |
For Google Sign-In (optional) | |
GEMINI_API_KEY |
For AI features (optional) |
To enable Google Sign-In:
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google+ API
- Create OAuth 2.0 credentials (Web application)
- Add authorized JavaScript origins:
http://localhost:5173(development)- Your production domain
- Add authorized redirect URIs:
http://localhost:5173(development)- Your production domain
- Copy the Client ID to:
server/.envasGOOGLE_CLIENT_IDclient/src/config/env.tsasGOOGLE_CLIENT_ID
POST /api/auth/register- User registrationPOST /api/auth/login- User loginGET /api/auth/profile- Get user profile
GET /api/books- Get all booksPOST /api/books- Create book listingGET /api/books/:id- Get book details
POST /api/auctions/:bookId/bid- Place bidPOST /api/trades- Propose tradePOST /api/offers- Make offer
GET /api/ai/recommendations- Get personalized book recommendationsPOST /api/ai/chat- Chat with AI about booksGET /api/ai/preferences- Get user preferencesPUT /api/ai/preferences- Update preferencesGET /api/ai/similar/:bookId- Get similar books
See GEMINI_SETUP_GUIDE.md for detailed instructions on setting up AI recommendations.
Quick Start:
- Get API key from https://makersuite.google.com/app/apikey
- Add to
server/.env:GEMINI_API_KEY=your-key - Restart server
- Visit
/ai-recommendationsin your app
Cost: FREE for most use cases (60 requests/minute)
MIT License