A modern, full-featured e-commerce application built with React, Node.js, MongoDB, and Docker. Features Amazon-like UI with complete shopping functionality.
- Modern UI: Amazon-style design with Tailwind CSS
- Authentication: Login/Register with JWT tokens
- Product Catalog: Search, filter, and browse products
- Shopping Cart: Add/remove items with real-time counter
- Order Management: Place orders and view order history
- Search Functionality: Real-time search with suggestions
- Responsive Design: Mobile-first approach
- RESTful API: Complete CRUD operations
- Authentication: JWT-based auth with bcrypt password hashing
- Database: MongoDB with Mongoose ODM
- Search: Full-text search across products
- Cart Management: Persistent cart storage
- Order Processing: Complete order lifecycle
- Docker: Containerized application
- Docker Compose: Multi-service orchestration
- Production Ready: Optimized for deployment
- React 18 - UI framework
- Vite - Build tool
- Tailwind CSS - Styling
- React Router - Navigation
- Axios - HTTP client
- Lucide React - Icons
- Node.js - Runtime
- Express.js - Web framework
- MongoDB - Database
- Mongoose - ODM
- JWT - Authentication
- Bcrypt - Password hashing
- CORS - Cross-origin requests
- Docker - Containerization
- Docker Compose - Orchestration
- Nginx - Web server (production)
ecommerce/
βββ backend/
β βββ config/
β β βββ db.js # Database connection
β βββ models/
β β βββ User.js # User schema
β β βββ Product.js # Product schema
β βββ routes/
β β βββ auth.js # Authentication routes
β β βββ products.js # Product routes
β β βββ cart.js # Cart routes
β β βββ orders.js # Order routes
β βββ index.js # Server entry point
β βββ seed.js # Database seeding
β βββ Dockerfile # Backend container
βββ frontend/
β βββ src/
β β βββ components/
β β β βββ Navbar.jsx # Navigation component
β β β βββ SearchSuggestions.jsx
β β βββ pages/
β β β βββ Products.jsx # Product listing
β β β βββ Cart.jsx # Shopping cart
β β β βββ Orders.jsx # Order history
β β β βββ Login.jsx # Login page
β β β βββ Register.jsx # Registration page
β β βββ context/
β β β βββ AuthContext.jsx # Global auth state
β β βββ api/
β β β βββ axiosConfig.js # API configuration
β β βββ App.jsx # Main app component
β β βββ main.jsx # App entry point
β βββ tailwind.config.js # Tailwind configuration
β βββ Dockerfile # Frontend container
βββ docker-compose.yml # Multi-service setup
βββ README.md # This file
- Node.js (v18+)
- Docker & Docker Compose
- MongoDB Atlas account (or local MongoDB)
-
Clone the repository
git clone <repository-url> cd ecommerce
-
Backend Setup
cd backend npm install cp .env.example .env # Edit .env with your MongoDB URI and JWT secret npm run dev
-
Frontend Setup
cd frontend npm install npm run dev -
Seed Database
cd backend node seed.js
-
Start all services
docker-compose up --build
-
Access the application
- Frontend: http://localhost:5173
- Backend: http://localhost:8000
- MongoDB: localhost:27017
POST /api/auth/register- User registrationPOST /api/auth/login- User login
GET /api/products- Get all productsGET /api/products?search=query- Search productsGET /api/products/:id- Get single product
GET /api/cart- Get user's cartPOST /api/cart/add- Add item to cartDELETE /api/cart/remove/:productId- Remove itemDELETE /api/cart/clear- Clear cart
GET /api/orders- Get user's ordersPOST /api/orders- Create new order
- Colors: Amazon-inspired color palette
- Typography: Clean, modern fonts
- Components: Reusable, consistent design
- Responsive: Mobile-first approach
- Navbar: Search, cart counter, user menu
- Product Cards: Hover effects, clean layout
- Forms: Modern input fields with validation
- Cart: Professional shopping cart interface
- Orders: Order tracking and history
-
Backend Deployment
- Connect GitHub repository
- Set environment variables:
MONGO_URI: Your MongoDB Atlas connection stringJWT_SECRET: Your JWT secret keyPORT: 8000
- Build command:
cd backend && npm install - Start command:
cd backend && npm start
-
Frontend Deployment
- Connect GitHub repository
- Set environment variables:
VITE_API_URL: Your backend URL
- Build command:
cd frontend && npm install && npm run build - Publish directory:
frontend/dist
MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/ecommerce
JWT_SECRET=your_jwt_secret_here
PORT=8000
VITE_API_URL=https://your-backend-url.com/api
- User Registration/Login
- Product Browsing
- Search Functionality
- Cart Operations
- Order Placement
Use Postman or curl to test endpoints:
# Test health check
curl http://localhost:8000/health
# Test product search
curl "http://localhost:8000/api/products?search=wireless"- β User authentication (register/login)
- β Product browsing with search
- β Shopping cart with real-time updates
- β Order placement and tracking
- β Responsive design for all devices
- β Modern, Amazon-like UI
- β JWT authentication
- β Password hashing with bcrypt
- β MongoDB integration
- β RESTful API design
- β Docker containerization
- β Production-ready configuration
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License.
- Payment integration (Stripe)
- Admin dashboard
- Product reviews and ratings
- Email notifications
- Advanced search filters
- Wishlist functionality
- Order tracking
- Multi-language support
Built with β€οΈ using React, Node.js, and MongoDB