This is a complete e-commerce API built with Node.js, Express, and MongoDB. The API provides features for authentication, product management, order processing, shopping cart functionality, discount coupons, user profiles, brand and category management, reviews, and payment integration using Stripe.
✅ User Authentication: Secure authentication using JWT, including account activation and password reset via email.
✅ Role-based Access Control: Admin and user permissions.
✅ Product Management: CRUD operations for products with image uploads using Multer and Sharp.
✅ Category & Subcategory Management: Organize products into categories and subcategories.
✅ Brand Management: CRUD operations for brands with image support.
✅ Cart System: Users can add/remove/update products in their cart.
✅ Order Handling: Users can place orders, and admins can manage them.
✅ Secure Payment Integration: Payments handled via Stripe with webhook support (cash on delivery & online payments).
✅ Coupon System: Discount coupons for users.
✅ User Account Management: Users can manage their profiles, passwords, and addresses.
✅ Admin User Management: Admins can manage all users (CRUD operations).
✅ Advanced Search & Filtering: Filter, sort, search, and paginate data dynamically.
✅ Image Upload & Optimization: Upload, resize, and optimize images using Multer and Sharp.
✅ API Documentation: Integrated Swagger UI for API reference.
✅ Robust Routing System: Organized modular routes for all API functionalities.
✅ Error Handling System: Centralized error handling with clear responses.
- Backend: Node.js, Express.js
- Database: MongoDB, Mongoose
- Authentication: JWT
- Validation: Express Validator
- File Handling: Multer, Sharp
- Security: bcryptjs, express-rate-limit, hpp, cors, helmet
- Payments: Stripe (supports checkout sessions & webhooks)
- Email Services: Nodemailer
$ git clone https://github.com/anas-dev000/ecommercify-api.git
$ cd ecommercify-api$ npm installCreate a .env file in the root directory and add the required configurations:
PORT=5000
MONGO_URI=your_mongo_connection_string
JWT_SECRET=your_jwt_secret
STRIPE_SECRET_KEY=your_stripe_secret_key
EMAIL_HOST=smtp.example.com
EMAIL_PORT=587
EMAIL_USER=your_email@example.com
EMAIL_PASS=your_email_password$ npm run dev$ npm start📌 Swagger documentation is available at:
http://localhost:5000/api-docs
POST /api/auth/signup- Register a new userPOST /api/auth/login- Login and receive JWTPOST /api/auth/forgotPassword- Request password reset codePOST /api/auth/verifyResetCode- Verify reset codePATCH /api/auth/resetPassword- Reset password (Authenticated users only)
GET /api/me- Get my dataPATCH /api/me- Update my dataDELETE /api/me- Delete my accountPATCH /api/me/update-password- Update my passwordGET /api/me/addresses- Get my addressesPOST /api/me/addresses- Add a new addressPATCH /api/me/addresses/:addressId- Update an addressDELETE /api/me/addresses/:addressId- Delete an address
GET /api/products- Get all productsPOST /api/products- Add a new product (Admin only)GET /api/products/:id- Get a specific productPATCH /api/products/:id- Update a product (Admin only)DELETE /api/products/:id- Remove a product (Admin only)
POST /api/products/{product}/reviews- Add a reviewGET /api/products/{product}/reviews/:id- Get a specific reviewPATCH /api/products/{product}/reviews/:id- Update a reviewDELETE /api/products/{product}/reviews/:id- Delete a review
POST /api/orders- Create a new order (cash on delivery & online payment)GET /api/orders- Get all orders (Admin only or user’s orders)GET /api/orders/:id- Get order detailsPATCH /api/orders/:id/pay- Mark order as paidPATCH /api/orders/:id/deliver- Mark order as delivered
- Supports dynamic filtering using query parameters (e.g.,
?price[gte]=100) - Supports keyword search in names and descriptions.
- Supports sorting, pagination, and field selection.
- Supports image uploads for products and users.
- Uses Multer for handling file uploads.
- Uses Sharp for resizing and optimizing images.
- Centralized error handling through
globalError.js. - Uses
apiError.jsfor structured error responses. - Handles JWT expiration and invalid signatures gracefully.
💡 Feel free to contribute! Fork the repo, make your changes, and submit a pull request.
👤 Anas Ali Abdelmonem Elgebaly
🔗 GitHub: anas-dev000