π 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
# Install all dependencies
npm run install-all
# Start development servers
npm run dev
Production
# 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)
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)
REACT_APP_API_URL=https://mkshoppingbd.onrender.com
π API Endpoints
Authentication
POST /user/register- User registrationPOST /user/login- User loginPOST /user/logout- User logoutGET /user/profile- Get user profilePUT /user/profile- Update user profile
Products
GET /products- Get all products (with filters)GET /product/:id- Get single productGET /products/recommendations- Get recommended productsGET /products/related/:productId- Get related products
User Data (Protected)
GET /user/wishlist- Get user wishlistPOST /user/wishlist- Add to wishlistDELETE /user/wishlist- Remove from wishlistGET /user/carts- Get user cartPOST /user/carts- Add to cartPUT /user/carts- Update cartDELETE /user/carts- Remove from cartGET /user/orders- Get user ordersPOST /user/orders- Create orderPUT /user/orders- Update orderDELETE /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
Connect Repository
- Go to Render Dashboard
- Create new Web Service
- Connect your GitHub repository
Configure Build Settings
- Build Command:
npm install - Start Command:
npm start - Root Directory:
/
- Build Command:
Set Environment Variables
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
- Install Dependencies:
npm install(installs root, backend, and frontend) - Build Frontend: Backend automatically builds React app
- Start Server:
npm startstarts the backend - 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
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- 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