Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Book Store MERN Project

A full-stack book store application built with the MERN stack (MongoDB, Express.js, React.js, Node.js).

Features

  • User authentication and authorization
  • Book catalog with search and filtering
  • Shopping cart functionality
  • Order management
  • Admin panel for book and user management
  • Responsive design

Project Structure

book-mern-project/
├── backend/          # Node.js/Express server
│   ├── models/       # MongoDB models
│   ├── routes/       # API routes
│   ├── middleware/   # Custom middleware
│   └── server.js     # Main server file
├── frontend/         # React.js application
│   ├── src/
│   │   ├── components/
│   │   ├── pages/
│   │   ├── redux/
│   │   └── utils/
│   └── public/
└── README.md

Setup Instructions

Prerequisites

  • Node.js (v14 or higher)
  • MongoDB (local or Atlas)
  • npm or yarn

Backend Setup

  1. Navigate to the backend directory:

    cd backend
  2. Install dependencies:

    npm install
  3. Set up environment variables:

    • Copy config.env.example to config.env
    • Fill in your actual values:
      NODE_ENV=development
      PORT=5001
      MONGODB_URI=your_mongodb_connection_string
      JWT_SECRET=your_jwt_secret_key
      JWT_EXPIRE=30d
      
  4. Start the server:

    npm start
    # or
    node server.js

Frontend Setup

  1. Navigate to the frontend directory:

    cd frontend
  2. Install dependencies:

    npm install
  3. Start the development server:

    npm run dev

API Endpoints

Authentication

  • POST /api/auth/register - Register a new user
  • POST /api/auth/login - Login user
  • GET /api/auth/me - Get current user
  • POST /api/auth/logout - Logout user

Books

  • GET /api/books - Get all books
  • GET /api/books/:id - Get single book
  • POST /api/books - Create book (Admin only)
  • PUT /api/books/:id - Update book (Admin only)
  • DELETE /api/books/:id - Delete book (Admin only)

Orders

  • GET /api/orders - Get user orders
  • POST /api/orders - Create new order
  • GET /api/orders/:id - Get single order

Users

  • GET /api/users/profile - Get user profile
  • PUT /api/users/profile - Update user profile
  • PUT /api/users/password - Update password
  • GET /api/users - Get all users (Admin only)
  • GET /api/users/:id - Get single user (Admin only)
  • PUT /api/users/:id - Update user (Admin only)
  • DELETE /api/users/:id - Delete user (Admin only)

Environment Variables

Create a config.env file in the backend directory with the following variables:

  • NODE_ENV - Environment (development/production)
  • PORT - Server port (default: 5001)
  • MONGODB_URI - MongoDB connection string
  • JWT_SECRET - Secret key for JWT tokens
  • JWT_EXPIRE - JWT token expiration time

Security Features

  • JWT authentication
  • Password hashing with bcrypt
  • Input validation with express-validator
  • Rate limiting
  • Helmet security headers
  • CORS configuration

Technologies Used

Backend

  • Node.js
  • Express.js
  • MongoDB with Mongoose
  • JWT for authentication
  • bcrypt for password hashing
  • express-validator for validation
  • helmet for security
  • express-rate-limit for rate limiting

Frontend

  • React.js
  • Redux Toolkit
  • Tailwind CSS
  • Vite
  • React Router

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

About

A full-stack book store application built with the MERN stack (MongoDB, Express.js, React.js, Node.js).

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages