This repository contains the backend API for an e-commerce platform.
It is built with Node.js, Express, and JWT authentication, and provides endpoints for managing users, products, categories, carts, orders, payments, and reviews.
The project is structured for scalability and clean code separation, following MVC architecture.
- User authentication (JWT)
- Product & category management
- Cart & wishlist functionality
- Orders & checkout
- Payments integration (Stripe/PayPal ready)
- Reviews & ratings system
- Admin dashboard endpoints
- API documentation with Swagger
http://127.0.0.1:5000/api
POST /auth/signup
→ Register a new userPOST /auth/login
→ Login & get tokenPOST /auth/logout
→ Logout userGET /auth/profile
→ Get logged-in user profilePUT /auth/profile
→ Update logged-in user profile (requires auth)POST /auth/forgot-password
→ Request password reset (reset password link via email)PUT /auth/reset-password
→ Change password (requiers access token from URL)
GET /users/all
→ List all users paginate (10 per page)GET /users/:id
→ Get user detailsDELETE /users/:id
→ Delete user
GET /all?page=1
→ List all productsGET /products/:id
→ Get product detailsPOST /create
→ Create product (admin only)PUT /products/:id
→ Update product (admin only)DELETE /products/:id
→ Delete product (admin only)GET /products/category/:categoryId?page=1
→ List products by categoryGET /products/search/wirhQuery?query=keyword&page=1
→ Search products by name or keyword
GET /categories
→ List all categoriesGET /categories/:id
→ Get category detailsPOST /categories
→ Create category (admin only)PUT /categories/:id
→ Update category (admin only)DELETE /categories/:id
→ Delete category (admin only)
GET /cart
→ Get logged-in user cartPOST /cart
→ Add item to cartPUT /cart/:itemId
→ Update item quantity in cartDELETE /cart/:itemId
→ Remove item from cart
POST /orders
→ Create new orderGET /orders
→ List logged-in user’s ordersGET /orders/:id
→ Get order detailsPUT /orders/:id
→ Update order status (admin only)DELETE /orders/:id
→ Cancel order (user or admin)
GET /wishlist
→ Get logged-in user wishlistPOST /wishlist
→ Add product to wishlistDELETE /wishlist/:itemId
→ Remove item from wishlist
GET /products/:id/reviews
→ Get reviews for a productPOST /products/:id/reviews
→ Add a review for a productPUT /reviews/:id
→ Update a review (author only)DELETE /reviews/:id
→ Delete a review (author or admin)
GET /dashboard/stats
→ Get sales, user, and product statisticsGET /dashboard/orders
→ List all ordersGET /dashboard/products/low-stock
→ Get products with low stock
➡️ Full list available in docs/endpoints.md
# Clone repo
git clone https://github.com/soufianboukir/mercurio-api.git
cd mercurio-api
# Install dependencies
npm install
# Copy environment variables
cp .env.example .env
# Run server
npm start