Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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.

Notifications You must be signed in to change notification settings

Gyanthakur/mock-ecom-cart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›’ Mock E-Commerce Cart

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.

Demo Video:

mock-ecom-cart-git.mp4

screenshots

Screen Screenshot
Signup Page Signup
Login Page Login
Home Page Home
Product Page Product
Cart Page Cart
Invoice Page Invoice

πŸš€ Features

Frontend

  • 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.

Backend

  • 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.

πŸ”§ Tech Stack

  • Frontend: React, Vite, TailwindCSS
  • Backend: Node.js, Express, MongoDB, JWT Authentication
  • Other: jsPDF (for invoice generation), React Context API (for global state)

🚧 Setup Instructions

Prerequisites

Ensure that the following are installed:

  • Node.js (v16+)
  • npm or yarn
  • MongoDB (Local or MongoDB Atlas)

1. Clone the Repository

git clone https://github.com/Gyanthakur/mock-ecom-cart.git
cd mock-ecom-cart

2. Backend Setup

1. Navigate to the backend folder:

cd backend

2. Install backend dependencies:

    npm install

3. Create a .env file in the backend folder and add:

MONGO_URI=mongodb://localhost:27017/mock-ecom-cart
JWT_SECRET=your-secret-key
PORT=5000

4. Run the backend server:

npm start

Your backend will now run at http://localhost:5000.

3. Frontend Setup

1. Navigate to the frontend folder:

cd ../frontend

2. Install frontend dependencies:

    npm install

3. Create a .env file in the frontend folder and add:

VITE_BACKEND_URL=http://localhost:5000

4. Run the frontend server:

npm run dev

Your 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

πŸ“ Notes

  • JWT Authentication: JWT tokens are used to manage sessions. After login, a token is saved to localStorage for 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.

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages