ShopStream is the backend API for a modern e-commerce and food delivery platform. Built with Node.js and Express, it provides a robust and scalable architecture for managing users, restaurants, menus, orders, and payments.
- Authentication & Authorization:
- Secure user registration and login using JWT.
- Role-based access control (Customer, Restaurant, Admin).
- User Management:
- Profile management.
- Admin controls to manage users and roles.
- Restaurant Management:
- Restaurant registration requests and admin approval workflow.
- Detailed restaurant profiles with cover images.
- Menu System:
- Comprehensive menu management (Menus, Sub-menus, and Items).
- Image uploads for menu items.
- Order Processing:
- Place, track, and manage orders.
- Real-time status updates (Pending, In Progress, Delivered, Cancelled).
- Payments:
- Secure payment processing using Stripe.
- Support for payment intents, confirmations, and refunds.
- Reviews & Ratings:
- Users can review restaurants and items.
- File Uploads:
- Integration with Cloudinary for managing images.
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB (with Mongoose)
- Authentication: JSON Web Token (JWT), Bcrypt
- Payments: Stripe
- File Storage: Cloudinary (with Multer)
- Validation: Express Validator
- Real-time: Socket.io (available dependency)
- Logging: Winston, Morgan
├── config/ # Configuration files (DB, Multer, etc.)
├── controllers/ # Request handlers
├── middlewares/ # Custom middlewares (Auth, Roles, Uploads)
├── models/ # Mongoose schemas (User, Order, Restaurant, etc.)
├── routes/ # API Route definitions
├── utils/ # Utility functions
├── validators/ # Input validation logic
├── app.js # Express app setup
├── server.js # Server entry point
└── Examples.env # Template for environment variables
- Node.js (v14 or higher recommended)
- MongoDB (Local or Atlas)
- Stripe Account
- Cloudinary Account
-
Clone the repository:
git clone <repository-url> cd backend
-
Install dependencies:
npm install
-
Configure Environment Variables: Create a
.envfile in the root directory and add the following variables (referenceExamples.env):PORT=3000 MONGO_URI=your_mongodb_connection_string # JWT Secrets JWT_ACCESS_SECRET=your_access_secret JWT_REFRESH_SECRET=your_refresh_secret JWT_RESET_SECRET=your_reset_secret # Bcrypt BCRYPT_SALT_ROUNDS=10 # Cloudinary CLOUDINARY_CLOUD_NAME=your_cloud_name CLOUDINARY_API_KEY=your_api_key CLOUDINARY_API_SECRET=your_api_secret # Stripe STRIPE_SECRET_KEY=your_stripe_secret_key # Frontend URL (for CORS) CLIENT_URL=http://localhost:4200
-
Start the Server:
npm start
The server will run on
http://localhost:3000.
POST /register- Register a new userPOST /login- Login userPOST /logout- Logout user
GET /users- Get all usersDELETE /users/:id- Delete a userGET /restaurant-requests- View restaurant join requestsPOST /restaurant-requests/:id/approve- Approve a restaurantPOST /restaurant-requests/:id/reject- Reject a restaurant
GET /- List all restaurantsGET /:id- Get restaurant detailsPOST /requests- Request to join as a restaurant (requiresrestaurantrole)
GET /:restaurantId/menu-items- Get menu for a restaurantPOST /:restaurantId/menu- Create a menu itemPUT /:menuId/items/:id- Update a menu itemDELETE /:menuId/items/:id- Delete a menu item
POST /- Place a new orderGET /- Get all orders (User specific or Admin/Restaurant view)PATCH /:id/status- Update order statusPATCH /:id/cancel- Cancel an order
POST /create-intent- Create a payment intentPOST /confirm-intent- Confirm paymentPOST /refund/:orderId- Process a refund
POST /- Create a reviewGET /- Get all reviewsPUT /:id- Update a review
This project is licensed under the ISC License.