This is a full-stack e-commerce application built using the MERN (MongoDB, Express.js, React.js, Node.js) stack. It provides a platform for online shopping with features such as product browsing, cart management, user authentication, and order processing.
Check out the live demo of this application:
- Frontend: React.js, React Router, Axios
- Backend: Node.js, Express.js
- Database: MongoDB
- Authentication: JSON Web Tokens (JWT)
- State Management: React Context API
- Styling: CSS Modules or Styled Components (specify which one you're using)
- Deployment: Versal (frontend), Render (backend)
Before you begin, ensure you have the following installed on your local machine:
- Node.js (v14 or later)
- npm (usually comes with Node.js)
- MongoDB (v4 or later)
-
Clone the repository
git clone [(https://github.com/amankumar94728/E-commerce)t](https://github.com/amankumar94728/E-commerce) cd ecommerce-mern -
Set up the backend
cd server npm installCreate a
.envfile in the server directory with the following content:PORT=3000 MONGODB_URI=mongodb://localhost:27017/ecommerce JWT_SECRET=your_jwt_secret_here CLOUDINARY_CLOUD_NAME=dhcpsqprl CLOUDINARY_API_KEY= Enter your CLOUDINARY_API_KEY CLOUDINARY_API_SECRET=Enter your CLOUDINARY_API PAYPAL_MODE=Enter your PAYPAL_MODE PAYPAL_CLIENT_ID= Enter your PAYPAL_CLIENT_ID PAYPAL_CLIENT_SECRET=Enter your PAYPAL_CLIENT_SECRETReplace
your_jwt_secret_herewith a secure random string. -
Set up the frontend
cd ../client npm installCreate a
.envfile in the client directory with the following content:REACT_APP_API_URL=http://localhost:3000/api -
Start the application
In one terminal, start the backend server:
cd server npm run devIn another terminal, start the frontend development server:
cd client npm startThe application should now be running, with the backend on
http://localhost:3000and the frontend onhttp://localhost:5173.
ecommerce-mern/
├── client/ # React frontend
│ ├── public/
│ ├── src/
│ │ ├── components/ # Reusable React components
│ │ ├── pages/ # React components for different pages
│ │ ├── context/ # React context for state management
│ │ ├── services/ # API service functions
│ │ ├── App.js # Main React component
│ │ └── index.js # Entry point of the React application
│ ├── package.json
│ └── ...
├── server/ # Node.js & Express backend
│ ├── config/ # Configuration files
│ ├── controllers/ # Request handlers
│ ├── models/ # Mongoose models
│ ├── routes/ # API routes
│ ├── .env
│ ├── server.js # Main application file
│ ├── package.json
│ └── ...
├── .gitignore
└── README.md
GET /api/products: Get all productsGET /api/products/:id: Get a single productPOST /api/users/register: Register a new userPOST /api/users/login: Login a userGET /api/orders: Get all orders (requires authentication)POST /api/orders: Create a new order (requires authentication)
For a full list of API endpoints and their usage, please refer to the API documentation (if available) or the route files in the server/routes directory.
This application is deployed using the following services:
- Frontend: Versal
- Backend: Render
- Database: MongoDB Atlas
To deploy your own version:
- Set up a MongoDB Atlas cluster and obtain the connection string.
- Deploy the backend to Render, setting the necessary environment variables.
- Update the
REACT_APP_API_URLin the frontend to point to your Render backend URL. - Deploy the frontend to Versal, setting up the build command and publish directory.
We welcome contributions to this project. Please follow these steps to contribute:
- Fork the repository
- Create a new branch (
git checkout -b feature/AmazingFeature) - Make your changes
- Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Thanks to all contributors who have helped with this project.
- Special thanks to [any specific libraries or resources you want to acknowledge].
Project Link: https://github.com/amankumar94728/E-commerce