This is the backend for an eCommerce application built with Node.js, Express, and MongoDB. It provides APIs for user authentication, product management, orders, payments, and more.
- User authentication (JWT)
- Role-based access control (RBAC)
- Product and cart management
- Order and payment processing (Stripe)
- Redis caching for performance optimization
- Cloudinary integration for image uploads
- Error handling and middleware support
- Backend: Node.js, Express.js
- Database: MongoDB (Mongoose ORM)
- Authentication: JWT, bcryptjs
- Caching: Redis (ioredis)
- File Uploads: Cloudinary, Multer
- Payment Gateway: Stripe
backend/
│── src/
│ ├── config/ # Configuration files (DB, Redis, Stripe, etc.)
│ ├── controllers/ # Business logic for handling requests
│ ├── middlewares/ # Authentication & error-handling middlewares
│ ├── models/ # Mongoose models for database schema
│ ├── routes/ # API route handlers
│ ├── utils/ # Utility functions
│ ├── index.js # Entry point of the application
│── .env # Environment variables
│── package.json # Dependencies and scripts
│── .gitignore # Files to ignore in Git
-
Clone the repository:
git clone https://github.com/faridomarAf/reactjs-ecommerce-backend.git cd backend -
Install dependencies:
npm install
-
Create a
.envfile in the root directory and add the following:PORT=5000 MONGO_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret REDIS_URL=your_redis_url CLOUDINARY_CLOUD_NAME=your_cloudinary_name CLOUDINARY_API_KEY=your_cloudinary_api_key CLOUDINARY_API_SECRET=your_cloudinary_api_secret STRIPE_SECRET_KEY=your_stripe_secret_key
-
Run the development server:
npm run dev
- Auth:
/api/v1/auth/ - Products:
/api/v1/products/ - Cart:
/api/v1/cart/ - Orders:
/api/v1/orders/ - Payments:
/api/v1/payments/ - Coupons:
/api/v1/coupons/
Feel free to fork and submit pull requests. Follow best practices and ensure proper documentation.
This project is licensed under the ISC License.