The MERN Stack Book Store is a full-stack MERN e-commerce platform for browsing, purchasing, and managing books. It features a responsive frontend, a robust backend with MongoDB, and a secure admin dashboard for inventory management.
This project was built as part of my learning journey from the FreeCodeCamp MERN Bookstore tutorial, with the goal of strengthening my fullstack development skills alongside my data engineering background.
- User Features: Browse books, add/remove items from the cart, and place orders with cash-on-delivery.
- Admin Features: Secure dashboard to add, edit, and delete books, protected by JWT authentication.
- Technologies: MongoDB, Express.js, React, Node.js, Tailwind CSS, Redux, RTK Query, Mongoose, JWT, and Firebase for authentication.
Explore the deployed application at: https://book-store-self-nine.vercel.app/ For admin access, use:
- Username: admin
- Password: admin
Follow these steps to run the project locally.
- Node.js (v20 or higher)
- MongoDB Atlas account
- Firebase account
-
Clone the Repository
git clone https://github.com/huy-dataguy/MERN-Stack-Book-Store.git cd MERN-Stack-Book-Store
-
Frontend Setup
-
Navigate to the frontend directory:
cd frontend
-
Install dependencies:
npm install
-
In file
.env
file in thefrontend
directory and add your Firebase configuration:VITE_API_KEY=your_firebase_api_key VITE_AUTH_DOMAIN=your_firebase_auth_domain VITE_PROJECT_ID=your_firebase_project_id VITE_STORAGE_BUCKET=your_firebase_storage_bucket VITE_MESSAGING_SENDER_ID=your_firebase_messaging_sender_id VITE_APP_ID=your_firebase_app_id
-
Open the file: /src/utils/getBaseURL.js
const getBaseUrl = () => { return 'http://localhost:3000'; // return 'https://book-store-eight-black.vercel.app'; } export default getBaseUrl;
- Comment out the production URL and uncomment the local development URL:
-
-
Backend Setup
-
Navigate to the backend directory:
cd backend
-
Install dependencies:
npm install
-
In file
.env
file in thebackend
directory and add your MongoDB connection string and JWT secret:DB_URL=your_mongodb_atlas_connection_string JWT_SECRET_KEY=your_jwt_secret_key
Note:
-
Get the
DB_URL
by creating a project in MongoDB Atlas. -
Generate a
JWT_SECRET_KEY
by running the following in your terminal:node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
-
-
-
Database Setup
-
In MongoDB Atlas, create a database named
bookstore
. -
Create a
users
collection and add a user with:{ "username": "admin", "password": "admin", "role": "admin" }
-
-
Run the Application
-
Start the backend server:
cd backend npm run start
-
Start the frontend server in a new terminal:
cd frontend npm run dev
-
- Access the admin dashboard at
http://localhost:5173/admin
. - Log in with:
- Username: admin
- Password: admin
- Email: quochuy.working@gmail.com
- Feel free to contribute and improve this project!