Getting everything ready for you…

Loading courses, problems and your progress. This takes just a moment.

0s

Projects › Intermediate

E-commerce Store with Cart & Payments

Products, filters, cart, checkout with Razorpay test payments, orders and an admin panel.

Level: Intermediate · Time: 2–3 weeks · Tech stack: React, Node.js, MongoDB, Razorpay (test mode)

Features to build

What you will learn

Step-by-step guide

1. Models

Product (name, price, stock, images, category), Order (user, items[{product, qty, price}], total, status, payment), User (role).

2. Never trust the client's price

When creating an order, look up prices on the server; the browser only sends product ids and quantities.

3. Payment flow (Razorpay test mode)

  1. Server creates a Razorpay order for the total → returns order_id.
  2. Browser opens Razorpay Checkout with that id.
  3. On success, server verifies the signature:
const expected = crypto.createHmac('sha256', KEY_SECRET).update(`${orderId}|${paymentId}`).digest('hex');
if (expected !== signature) return res.status(400).json({ message: 'Payment verification failed' });
  1. Mark the order paid and reduce stock.

4. Stock without overselling

Product.updateOne({ _id, stock: { $gte: qty } }, { $inc: { stock: -qty } }) — if nothing updated, it's out of stock.

5. Cart

Keep it in React context + localStorage for guests; merge into the server cart on login.

6. Admin

Protect admin routes with role === 'admin'; tables for products and orders with status updates.

Level it up

On your resume

Learn on Codify