Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

BookStore πŸ“š

A full-stack web application for managing an online bookstore with user authentication, book management, and recommendation features.

Features

  • User Management: Registration, login, and password reset with admin authentication
  • Book Catalog: Complete CRUD operations for books with search and filtering
  • Google Books API Integration: Search and import books from Google Books
  • Recommendation System: Users can suggest books for the store
  • Admin Panel: Special admin interface for managing books and users
  • Caching: Redis integration for improved performance
  • Responsive Design: Modern UI with Material-UI components

Technology Stack

Backend

  • Node.js with Express.js framework
  • MongoDB with Mongoose ODM
  • Redis for caching
  • bcrypt for password hashing
  • CORS for cross-origin requests
  • Compression middleware for optimized responses

Frontend

  • React 18 with modern hooks
  • Vite for fast development and building
  • Material-UI (MUI) for component library
  • React Router for navigation
  • Axios for API communication
  • React Hot Toast for notifications

Prerequisites

Before running this project, make sure you have:

  • Node.js (v16 or higher)
  • MongoDB (local installation or MongoDB Atlas)
  • Redis server
  • npm or yarn package manager

Installation & Setup

1. Clone the Repository

git clone https://github.com/BlackJack-14/BookStore.git
cd BookStore

2. Install Dependencies

# Install root dependencies
npm install

# Install backend dependencies
cd backend
npm install

# Install frontend dependencies
cd ../frontend
npm install

3. Environment Configuration

Create a .env file in the backend directory:

PORT=8000
MONGODB_URL=your_mongodb_connection_string
REDIS_URL=redis://127.0.0.1:6379
NODE_ENV=development

Update backend/config.js with your MongoDB URL:

export const PORT = 8000;
export const mongoDBURL = 'your_mongodb_connection_string';

4. Start the Services

Make sure MongoDB and Redis are running on your system.

Development Mode (Recommended)

# From the root directory - starts both backend and frontend
npm run dev

Manual Start

# Start backend (from backend directory)
npm run dev

# Start frontend (from frontend directory) 
npm run dev

The application will be available at:

API Endpoints

Books

  • GET /books - Get all books (with Redis caching)
  • GET /books/reset - Reset cache and fetch from database
  • GET /books/:isbn - Get book by ISBN
  • POST /books - Add new book (admin only)
  • PUT /books/:isbn - Update book by ISBN
  • DELETE /books/:isbn - Delete book by ISBN

Users

  • POST /users/register - Register new user (requires admin code: 8888)
  • POST /users/login - User login
  • POST /users/forgotPassword - Reset password (requires admin code)

Recommendations

  • GET /recommendations/:user - Get user recommendations
  • POST /recommendations - Create new recommendation
  • PUT /recommendations/:user - Update recommendation
  • DELETE /recommendations/:user - Delete recommendation

Usage

User Registration

  1. Navigate to the registration page
  2. Enter email, password, and admin code (8888)
  3. Submit to create account

Admin Features

  • Login with admin email (admin@gmail.com)
  • Access admin panel for book management
  • Add books manually or search Google Books API
  • Manage user recommendations

Book Management

  • Search books by title, author, or publication year
  • Add books with complete metadata (Title, Author, Year, ISBN, Image, Amazon URL)
  • Edit existing book information
  • Delete books from catalog

Recommendations

  • Users can recommend books to be added to the store
  • Admins can view and manage recommendations
  • Track recommendation status and descriptions

Project Structure

BookStore/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ bookModel.js          # Book schema
β”‚   β”‚   β”œβ”€β”€ userModel.js          # User schema
β”‚   β”‚   └── suggestedBookModel.js # Recommendation schema
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ bookRoute.js          # Book API routes
β”‚   β”‚   β”œβ”€β”€ userRoute.js          # User API routes
β”‚   β”‚   └── suggestedBookRoute.js # Recommendation routes
β”‚   β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ config.js                 # Database configuration
β”‚   └── index.js                  # Main server file
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ Components/           # Reusable React components
β”‚   β”‚   β”œβ”€β”€ pages/               # Page components
β”‚   β”‚   β”‚   β”œβ”€β”€ adminHomePage/   # Admin dashboard
β”‚   β”‚   β”‚   β”œβ”€β”€ homePage.jsx     # User home page
β”‚   β”‚   β”‚   β”œβ”€β”€ loginPage/       # Authentication
β”‚   β”‚   β”‚   β”œβ”€β”€ addBookPage/     # Add new books
β”‚   β”‚   β”‚   β”œβ”€β”€ editBookPage/    # Edit existing books
β”‚   β”‚   β”‚   └── recommendationPage/ # Book recommendations
β”‚   β”‚   β”œβ”€β”€ App.jsx              # Main app component
β”‚   β”‚   └── main.jsx             # React entry point
β”‚   └── package.json
└── package.json                 # Root package.json

Development

Running Tests

npm test

Linting (Frontend)

cd frontend
npm run lint

Building for Production

cd frontend
npm run build

Contributing

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

License

This project is licensed under the ISC License.

Notes

  • Admin code for registration and password reset: 8888
  • Default admin email: admin@gmail.com
  • Books are cached in Redis for 1 hour to improve performance
  • Google Books API integration allows importing book data automatically

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages