A full-stack book store application built with the MERN stack (MongoDB, Express.js, React.js, Node.js).
- User authentication and authorization
- Book catalog with search and filtering
- Shopping cart functionality
- Order management
- Admin panel for book and user management
- Responsive design
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
- Node.js (v14 or higher)
- MongoDB (local or Atlas)
- npm or yarn
-
Navigate to the backend directory:
cd backend -
Install dependencies:
npm install
-
Set up environment variables:
- Copy
config.env.exampletoconfig.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
- Copy
-
Start the server:
npm start # or node server.js
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install
-
Start the development server:
npm run dev
POST /api/auth/register- Register a new userPOST /api/auth/login- Login userGET /api/auth/me- Get current userPOST /api/auth/logout- Logout user
GET /api/books- Get all booksGET /api/books/:id- Get single bookPOST /api/books- Create book (Admin only)PUT /api/books/:id- Update book (Admin only)DELETE /api/books/:id- Delete book (Admin only)
GET /api/orders- Get user ordersPOST /api/orders- Create new orderGET /api/orders/:id- Get single order
GET /api/users/profile- Get user profilePUT /api/users/profile- Update user profilePUT /api/users/password- Update passwordGET /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)
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 stringJWT_SECRET- Secret key for JWT tokensJWT_EXPIRE- JWT token expiration time
- JWT authentication
- Password hashing with bcrypt
- Input validation with express-validator
- Rate limiting
- Helmet security headers
- CORS configuration
- 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
- React.js
- Redux Toolkit
- Tailwind CSS
- Vite
- React Router
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request