A simple full-stack shopping cart application built using React (Frontend), Node/Express (Backend), and MongoDB for storing user data and cart items. This application demonstrates basic e-commerce functionality like adding/removing products from the cart, viewing the cart, and generating invoices in PDF format.
mock-ecom-cart-git.mp4
| Screen | Screenshot |
|---|---|
| Signup Page | |
| Login Page | |
| Home Page | |
| Product Page | |
| Cart Page | |
| Invoice Page |
- Product Grid: Display a list of products with "Add to Cart" functionality.
- Cart View: Show items, quantities, and prices in the cart.
- Checkout: Submit cart items to get a mock receipt.
- Invoice Generation: Generate a PDF invoice after successful checkout.
- User Authentication: Login/Signup using JWT tokens.
- RESTful API: Manage products, cart items, and user authentication.
- Cart Management: Add/remove items, get cart data.
- Checkout and Receipt: Mock checkout process with a generated receipt.
- PDF Invoice Generation: Generate downloadable invoices using jsPDF.
- Frontend: React, Vite, TailwindCSS
- Backend: Node.js, Express, MongoDB, JWT Authentication
- Other: jsPDF (for invoice generation), React Context API (for global state)
Ensure that the following are installed:
- Node.js (v16+)
- npm or yarn
- MongoDB (Local or MongoDB Atlas)
git clone https://github.com/Gyanthakur/mock-ecom-cart.git
cd mock-ecom-cartcd backend npm installMONGO_URI=mongodb://localhost:27017/mock-ecom-cart
JWT_SECRET=your-secret-key
PORT=5000npm startYour backend will now run at http://localhost:5000.
cd ../frontend npm installVITE_BACKEND_URL=http://localhost:5000npm run devYour frontend will be accessible at http://localhost:5173.
π Project Structure
mock-ecom-cart/
βββ backend/
β βββ controllers/ # API route handlers
β βββ models/ # Mongoose models
β βββ routes/ # API routes
β βββ .env # Environment variables
β βββ app.js # Express app setup
β βββ server.js # Server entry point
βββ frontend/
β βββ src/
β β βββ components/ # React components
β β βββ context/ # Context API for global state
β β βββ pages/ # React pages
β β βββ App.jsx # Main app component
β β βββ main.jsx # Entry point for React app
β β βββ utils/ # Helper functions (e.g., API requests)
β β βββ AppContext.jsx # Context API provider
β βββ .env # Environment variables (e.g., backend URL)
β βββ index.html # Main HTML file
β βββ package.json # Frontend dependencies and scripts
βββ README.md # readme file-
JWT Authentication: JWT tokens are used to manage sessions. After login, a token is saved to
localStoragefor persistent user sessions. -
MongoDB: MongoDB stores product data, cart items, and user information.
-
Invoice Generation: After checkout, a downloadable PDF invoice is created using jsPDF.