A full-stack e-commerce application built with the MERN stack (MongoDB, Express.js, React, Node.js).
- User Authentication: Register, login, and user profile management
- Product Management: Browse products, view details, search and filter
- Shopping Cart: Add/remove items, update quantities
- Order Management: Place orders, track order status
- Admin Dashboard: Manage products, orders, and users
- Responsive Design: Works on desktop and mobile devices
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - Database
- Mongoose - ODM for MongoDB
- JWT - Authentication
- bcryptjs - Password hashing
- multer - File uploads
- React - UI library
- TypeScript - Type safety
- React Router - Client-side routing
- Axios - HTTP client
- React Icons - Icon library
- CSS3 - Styling
E-commerce/
├── backend/ # Backend API
│ ├── models/ # Database models
│ ├── routes/ # API routes
│ ├── middleware/ # Custom middleware
│ ├── server.js # Main server file
│ └── package.json
├── frontend/ # React frontend
│ ├── src/
│ │ ├── components/ # Reusable components
│ │ ├── pages/ # Page components
│ │ ├── context/ # React context providers
│ │ ├── services/ # API services
│ │ ├── types/ # TypeScript type definitions
│ │ └── App.tsx # Main app component
│ └── package.json
└── README.md
- Node.js (v14 or higher)
- MongoDB (local installation or MongoDB Atlas)
- npm or yarn
-
Clone the repository
git clone <your-repo-url> cd E-commerce
-
Install backend dependencies
cd backend npm install -
Install frontend dependencies
cd ../frontend npm install -
Set up environment variables
Create a
.envfile in the backend directory:MONGODB_URI=mongodb://localhost:27017/ecommerce JWT_SECRET=your_super_secret_jwt_key_change_this_in_production PORT=5001
-
Start the servers
Backend (Terminal 1):
cd backend npm startFrontend (Terminal 2):
cd frontend npm start -
Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:5001
POST /api/auth/register- Register a new userPOST /api/auth/login- Login userGET /api/auth/me- Get current user
GET /api/products- Get all productsGET /api/products/:id- Get product by IDPOST /api/products- Create product (admin only)PUT /api/products/:id- Update product (admin only)DELETE /api/products/:id- Delete product (admin only)
POST /api/orders- Create new orderGET /api/orders/myorders- Get user's ordersGET /api/orders/:id- Get order by IDPUT /api/orders/:id/pay- Update order payment statusPUT /api/orders/:id/deliver- Update order delivery status
GET /api/users/profile- Get user profilePUT /api/users/profile- Update user profileGET /api/users- Get all users (admin only)DELETE /api/users/:id- Delete user (admin only)
- Registration & Login: Secure authentication with JWT tokens
- Product Browsing: View products with search and filter options
- Shopping Cart: Add items, update quantities, remove items
- Checkout Process: Complete purchase with shipping and payment info
- Order History: View past orders and track current orders
- Profile Management: Update personal information
- Product Management: Add, edit, and delete products
- Order Management: View and update order statuses
- User Management: View all users and manage accounts
- Dashboard: Overview of sales, orders, and products
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- React team for the amazing framework
- Express.js team for the web framework
- MongoDB team for the database
- All contributors and maintainers