ShopHub — Full-Stack E-Commerce Practice Project
Frontend: React + Vite + React Router + Axios
Backend: Node.js + Express + MongoDB + Mongoose (yours to build!)
cd frontend
npm install
npm run dev # runs on http://localhost:5173
cd backend
npm install
cp .env.example .env # fill in your values
npm run dev # runs on http://localhost:3000
The frontend already calls these endpoints — you just need to implement them.
Method
Endpoint
Body
Returns
POST
/api/auth/register
{ name, email, password }
{ token, user }
POST
/api/auth/login
{ email, password }
{ token, user }
GET
/api/auth/me
— (Bearer token)
{ user }
Method
Endpoint
Notes
GET
/api/products
Query: search, category, sort, page, limit, minPrice, maxPrice
GET
/api/products/:id
Single product
POST
/api/products
Admin only
PUT
/api/products/:id
Admin only
DELETE
/api/products/:id
Admin only
Response shape for GET /api/products:
{
"products" : [... ],
"total" : 42 ,
"totalPages" : 6 ,
"currentPage" : 1
}
Product object:
{
"_id" : " ..." ,
"name" : " Nike Air Max" ,
"description" : " ..." ,
"price" : 120.00 ,
"stock" : 50 ,
"category" : " Shoes" ,
"image" : " https://... or emoji" ,
"createdAt" : " ..."
}
Method
Endpoint
Returns
GET
/api/categories
{ categories: [{ _id, name }] }
POST
/api/categories
Admin only
Method
Endpoint
Body
Notes
GET
/api/cart
—
{ items: [{ product, quantity }] }
POST
/api/cart
{ productId, quantity }
Add item
PUT
/api/cart/:productId
{ quantity }
Update qty
DELETE
/api/cart/:productId
—
Remove item
DELETE
/api/cart
—
Clear entire cart
Method
Endpoint
Body
Notes
POST
/api/orders
{ shippingAddress, paymentMethod }
Creates order from cart
GET
/api/orders/my
—
{ orders: [...] }
GET
/api/orders/:id
—
Single order
Order object:
{
"_id" : " ..." ,
"user" : " userId" ,
"items" : [{ "product" : {... }, "quantity" : 2 , "price" : 120 }],
"totalAmount" : 240.00 ,
"status" : " pending | processing | shipped | delivered | cancelled" ,
"shippingAddress" : { " street" , " city" , " state" , " zip" , " country" },
"paymentMethod" : " card | mobile_money | cash_on_delivery" ,
"createdAt" : " ..."
}
Admin (requires auth + admin role)
Method
Endpoint
Body
GET
/api/admin/orders
All orders
PUT
/api/admin/orders/:id
{ status }
name, email, password (hashed), role (user/admin), createdAt
name, description, price, stock, category, image, createdAt
user (ref), items: [{ product (ref), quantity }]
user (ref), items: [{ product (ref), quantity, price }],
totalAmount, status, shippingAddress, paymentMethod, createdAt
Key Backend Concepts You'll Practice
JWT Authentication — register, login, protect routes with middleware
Password hashing — bcrypt
Mongoose models & relationships — refs, populate
CRUD operations — full product & order lifecycle
Query parameters — search, filter, sort, paginate
Role-based access control — admin vs user routes
Cart logic — upsert items, calculate totals
Order creation — snapshot prices, clear cart after order