mkcart / READMEE.md
Kumar
update
4d36e2e
# πŸ›’ MKCart E-commerce Application
A full-stack e-commerce application built with React, Node.js, and MongoDB. This is a **monorepo** where the backend serves both the API and the frontend React app.
## 🌟 Features
- **User Authentication**: JWT-based authentication with HTTP-only cookies
- **Product Management**: Browse, search, and filter products
- **Shopping Cart**: Add, remove, and manage cart items
- **Wishlist**: Save favorite products
- **Order Management**: Complete checkout process and order tracking
- **User Profile**: Manage personal information and preferences
- **AI Chat Assistant**: Interactive shopping assistant
- **Responsive Design**: Works on all devices
- **Real-time Notifications**: Toast notifications for user actions
## πŸ—οΈ Architecture
- **Frontend**: React 19 + Redux Toolkit + RTK Query
- **Backend**: Node.js + Express + MongoDB
- **Authentication**: JWT + HTTP-only cookies
- **Styling**: CSS3 + Framer Motion animations
- **Deployment**: Monorepo - Backend serves frontend
## πŸš€ Quick Start
### Development
```bash
# Install all dependencies
npm run install-all
# Start development servers
npm run dev
```
### Production
```bash
# Start production server (serves both frontend and backend)
npm start
```
## πŸ“¦ Project Structure
```
finalaimkcart/
β”œβ”€β”€ package.json # Root package.json (manages both)
β”œβ”€β”€ backend/
β”‚ β”œβ”€β”€ app.js # Main server (auto-builds frontend)
β”‚ β”œβ”€β”€ package.json # Backend dependencies
β”‚ β”œβ”€β”€ config/
β”‚ β”‚ └── config.env # Backend environment
β”‚ β”œβ”€β”€ controllers/ # API controllers
β”‚ β”œβ”€β”€ models/ # MongoDB models
β”‚ β”œβ”€β”€ routes/ # API routes
β”‚ β”œβ”€β”€ middleware/ # Authentication middleware
β”‚ └── utils/ # Backend utilities
└── frontend/
β”œβ”€β”€ package.json # Frontend dependencies
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ components/ # React components
β”‚ β”œβ”€β”€ pages/ # Page components
β”‚ β”œβ”€β”€ store/ # Redux store and slices
β”‚ β”œβ”€β”€ utils/ # Frontend utilities
β”‚ └── styles/ # CSS files
└── public/ # Static assets
```
## πŸ”§ Configuration
### Environment Variables
#### Backend (`backend/config/config.env`)
```env
PORT=7860
NODE_ENV=production
DB_URL=
JWT_SECRET_KEY=
APP_URL=https://kumar715-mkcart.hf.space
FRONTEND_URL=https://kumar715-mkcart.hf.space
```
#### Frontend (`frontend/.env`)
```env
REACT_APP_API_URL=https://mkshoppingbd.onrender.com
```
## 🌐 API Endpoints
### Authentication
- `POST /user/register` - User registration
- `POST /user/login` - User login
- `POST /user/logout` - User logout
- `GET /user/profile` - Get user profile
- `PUT /user/profile` - Update user profile
### Products
- `GET /products` - Get all products (with filters)
- `GET /product/:id` - Get single product
- `GET /products/recommendations` - Get recommended products
- `GET /products/related/:productId` - Get related products
### User Data (Protected)
- `GET /user/wishlist` - Get user wishlist
- `POST /user/wishlist` - Add to wishlist
- `DELETE /user/wishlist` - Remove from wishlist
- `GET /user/carts` - Get user cart
- `POST /user/carts` - Add to cart
- `PUT /user/carts` - Update cart
- `DELETE /user/carts` - Remove from cart
- `GET /user/orders` - Get user orders
- `POST /user/orders` - Create order
- `PUT /user/orders` - Update order
- `DELETE /user/orders` - Cancel order
## πŸš€ Deployment
This application is configured for **monorepo deployment** where the backend serves both the API and the frontend.
### Deploy to Render
1. **Connect Repository**
- Go to Render Dashboard
- Create new Web Service
- Connect your GitHub repository
2. **Configure Build Settings**
- **Build Command**: `npm install`
- **Start Command**: `npm start`
- **Root Directory**: `/`
3. **Set Environment Variables**
```env
NODE_ENV=production
PORT=7860
DB_URL=
JWT_SECRET_KEY=
APP_URL=https://mkshoppingbd.onrender.com
FRONTEND_URL=https://mkshoppingbd.onrender.com
REACT_APP_API_URL=https://mkshoppingbd.onrender.com
```
### Deployment Process
1. **Install Dependencies**: `npm install` (installs root, backend, and frontend)
2. **Build Frontend**: Backend automatically builds React app
3. **Start Server**: `npm start` starts the backend
4. **Serve Frontend**: Backend serves the built React app
## 🎯 Key Features
### Authentication System
- JWT tokens stored in HTTP-only cookies
- Automatic token refresh
- Protected routes
- Global logout functionality
### Shopping Experience
- Product browsing with filters
- Add to cart/wishlist
- Real-time cart updates
- Secure checkout process
### User Management
- Profile management
- Order history
- Wishlist management
- Review system
### AI Integration
- Chat assistant for shopping help
- Product recommendations
- Order tracking assistance
## πŸ”’ Security Features
- HTTP-only cookies for JWT storage
- CORS protection
- Input validation
- Password hashing with bcrypt
- Protected API routes
## πŸ“± Responsive Design
- Mobile-first approach
- Works on all screen sizes
- Touch-friendly interface
- Progressive Web App features
## πŸ› οΈ Technologies Used
### Frontend
- React 19
- Redux Toolkit
- RTK Query
- React Router
- Framer Motion
- Lucide React Icons
- React Toastify
### Backend
- Node.js
- Express.js
- MongoDB
- Mongoose
- JWT
- bcryptjs
- CORS
### Development
- Concurrently (for development)
- Nodemon (for backend development)
## πŸ“„ License
MIT License - see LICENSE file for details
## πŸ‘₯ Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Test thoroughly
5. Submit a pull request
## πŸ†˜ Support
For support and questions:
- Check the documentation
- Review the deployment guide
- Open an issue on GitHub
---
**Built with ❀️ by MKCart**