This is a full-stack e-commerce application with a separate admin panel and user-facing frontend, built using React.js for the frontend and Node.js with Express.js for the backend. MongoDB is used as the database.
The admin panel provides functionalities for managing products and orders.
- Admin Authentication: Secure login for administrators.
- Product Management:
- Add new products with details such as name, description, price, category, sub-category, sizes, and multiple images.
- View a list of all products.
- Update and remove existing products.
- Order Management:
- View all customer orders.
- Update the status of orders (e.g., Order Placed, Packing, Shipped, Out For Delivery, Delivered).
The user-facing frontend allows customers to browse products, manage their cart, and place orders.
-
User Authentication: Register, login, and logout functionalities.
-
Product Catalog:
- Browse products on the home and collection pages.
- View detailed information for individual products, including multiple images, description, and available sizes.
- Search for products by name.
- Filter products by category and sub-category.
- Sort products by price (low to high, high to low) and relevance.
-
Shopping Cart:
- Add products to the cart with selected sizes.
- Update product quantities in the cart.
- Remove items from the cart.
-
Order Placement:
- Proceed to checkout from the cart.
- Place orders using Cash on Delivery (COD) or Stripe payment gateway.
-
Order History: View a list of all placed orders.
-
Informational Pages:
- About Us page providing information about the company's mission and values.
- Contact Us page with contact details and career information.
- Newsletter subscription.
Frontend (Admin & User):
- React.js
- Vite (build tool)
- Tailwind CSS (for styling)
- React Router DOM (for navigation)
- Axios (for API requests)
- React Toastify (for notifications)
Backend:
- Node.js
- Express.js (web framework)
- MongoDB (database)
- Mongoose (ODM for MongoDB)
- Cloudinary (for image storage)
- Multer (for handling
multipart/form-data) - JWT (JSON Web Tokens for authentication)
- Bcrypt (for password hashing)
- Validator (for input validation)
- CORS (for Cross-Origin Resource Sharing)
- Dotenv (for environment variables)
- Stripe (payment gateway integration)
- Razorpay (payment gateway integration - Note: Implementation is present but not fully utilized in the provided code)
To get this project up and running on your local machine, follow these steps:
- Clone the repository: Obtain the project files by cloning the Git repository.
- Install dependencies: Install the necessary packages for both the backend and frontend components.
- Configure environment variables: Set up the required environment variables for database connection, API keys, and other configurations.
- Run the applications: Start the backend server, admin panel, and user frontend.
Below are the detailed setup instructions for each component:
- Node.js (v14 or higher)
- npm or yarn
- MongoDB Atlas account (or local MongoDB instance)
- Cloudinary account
- Stripe account (for payment gateway)
-
Clone the repository:
git clone <repository_url> cd backend
-
Install dependencies:
npm install # or yarn install -
Create a
.envfile: Create a file named.envin thebackenddirectory and add the following environment variables:STRIPE_SECRET_KEY=your_stripe_secret_key MONGODB_URI=your_mongodb_connection_uri CLOUDINARY_NAME=your_cloudinary_cloud_name CLOUDINARY_API_KEY=your_cloudinary_api_key CLOUDINARY_API_SECRET=your_cloudinary_api_secret JWT_SECRET=your_jwt_secret ADMIN_EMAIL=your_admin_email@example.com ADMIN_PASSWORD=your_admin_password PORT=3000Replace the placeholder values with your actual credentials.
-
Run the backend server:
npm start # or yarn startThe backend server will run on
http://localhost:3000(or the port you specified in.env).
-
Navigate to the
admindirectory:cd ../admin -
Install dependencies:
npm install # or yarn install -
Create a
.envfile: Create a file named.envin theadmindirectory and add the following environment variable:VITE_BACKEND_URL=http://localhost:3000Ensure the
VITE_BACKEND_URLmatches your backend server address. -
Run the admin panel:
npm run dev # or yarn devThe admin panel will run on
http://localhost:5174(or the port specified invite.config.js).
-
Navigate to the
frontenddirectory:cd ../frontend -
Install dependencies:
npm install # or yarn install -
Create a
.envfile: Create a file named.envin thefrontenddirectory and add the following environment variable:VITE_BACKEND_URL=http://localhost:3000Ensure the
VITE_BACKEND_URLmatches your backend server address. -
Run the user frontend:
npm run dev # or yarn devThe user frontend will run on
http://localhost:5173(or the port specified invite.config.js).
Make sure to configure the following environment variables in their respective .env files:
Backend (backend/.env):
STRIPE_SECRET_KEY: Your secret key from Stripe for payment processing.MONGODB_URI: Connection string for your MongoDB database (e.g., from MongoDB Atlas).CLOUDINARY_NAME: Your Cloudinary cloud name.CLOUDINARY_API_KEY: Your Cloudinary API key.CLOUDINARY_API_SECRET: Your Cloudinary API secret.JWT_SECRET: A strong, random string for JWT token signing.ADMIN_EMAIL: Email for admin login.ADMIN_PASSWORD: Password for admin login.PORT: Port for the backend server (default:3000).
Frontend (admin/.env and frontend/.env):
VITE_BACKEND_URL: The URL of your backend server (e.g.,http://localhost:3000).