CleanEase API is a backend system for a cleaning service application built using Node.js, Express.js, and MongoDB. This backend provides authentication, service management, cart functionality, payments (via Stripe), and scheduling features.
- π User Authentication: Register, login, and manage users securely with JWT authentication.
- π§Ή Service Management: Add, update, delete, and retrieve cleaning services.
- π Cart & Order System: Users can add services to their cart and place orders.
- π³ Payment Integration: Secure payments via Stripe Checkout.
- β Reviews & Ratings: Users can leave reviews for services.
- β³ Scheduled Tasks: Uses
node-cron
for automated tasks. - π Secure API Routes: Middleware for authentication and error handling.
- π Webhook Handling: Stripe webhooks for payment confirmation.
git clone https://github.com/Yogadeepan29/CAPSTONE--CleanEase_Backend.git
cd CleanEase-Backend
npm install
Create a .env
file in the root directory and add the following:
PORT=prefered port
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
STRIPE_SECRET_KEY=your_stripe_secret_key
STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret
For development mode with hot-reloading:
npm run dev
For production mode:
npm start
π CAPSTONE-CleanEase-(BACKEND)/
βββ π .env # Environment variables
βββ π« .gitignore # Files to ignore in version control
βββ π Controllers/ # Contains route controllers
β βββ π authController.js
β βββ π cartController.js
β βββ π³ checkoutController.js
β βββ π¦ orderController.js
β βββ π° paymentController.js
β βββ β reviewController.js
β βββ π§Ή serviceController.js
β βββ π€ userController.js
β βββ π webhookController.js
βββ π Database/ # Database configuration
β βββ βοΈ config.js
β βββ ποΈ services.js
βββ π Middleware/ # Authentication & error handling middleware
β βββ π¨ errorMiddleware.js
β βββ π verifyToken.js
βββ π Models/ # Mongoose models for MongoDB
β βββ ποΈ cartModel.js
β βββ π checkoutModel.js
β βββ π orderModel.js
β βββ π reviewModel.js
β βββ π servicesModel.js
β βββ π€ userModel.js
βββ π¦ package-lock.json
βββ π package.json # Project dependencies
βββ π Routers/ # API routes
β βββ π authRouter.js
β βββ π cartRouter.js
β βββ π³ checkoutRouter.js
β βββ π¦ orderRouter.js
β βββ π° paymentRouter.js
β βββ β reviewRouter.js
β βββ π servicesRouter.js
β βββ π€ userRouter.js
β βββ π webhookRouter.js
βββ π server.js # Main entry point
βββ π Utils/ # Utility functions and scheduled tasks
β βββ β Error.js
β βββ β³ scheduledTasks.js
For detailed API documentation, please visit the following link: API Documentation
Method | Endpoint | Description |
---|---|---|
POST | /api/auth/register-user |
Register a new user |
POST | /api/auth/login-user |
User login |
POST | /api/auth/google |
O-Auth Google Signin |
Method | Endpoint | Description |
---|---|---|
PUT | /api/user/update/:id |
Update user information |
DELETE | /api/user/delete/:id |
Delete user |
POST | /api/user/add/address/:id |
Add user address |
PUT | /api/user/update/address/:id |
Update user address |
DELETE | /api/user/delete/address/:id |
Delete user address |
GET | /api/user/total |
Getting total Number of users count |
GET | /api/user/all |
Getting all user details |
Method | Endpoint | Description |
---|---|---|
GET | /api/services |
Get all services |
POST | /api/services |
Add a new service |
GET | /api/services/:category/:productName |
Get service by category and its name |
GET | /api/services/:category/product/:productId |
Get service by category and its ID |
GET | /api/services/:categories |
Filter Categories |
GET | /api/services/:category/:productName/addons/:ids |
Get service Addons by ID |
PUT | /api/services/product/:id |
Update inbuild services by ID |
PUT | /api/services/product/:id/admin |
update admin created services by ID |
DELETE | /api/services/product/:id |
Delete created services by ID |
Method | Endpoint | Description |
---|---|---|
GET | /api/cart |
Get user cart |
POST | /api/cart/add |
Add service to cart |
DELETE | /api/cart/remove |
remove selected cart items |
DELETE | /api/cart/remove-multiple |
remove bunch of cart items |
PUT | /api/cart/update-addons |
update addon selection |
DELETE | /api/cart/clear |
clear all items in cart |
PUT | /api/cart/update-subscription |
update subscription |
Method | Endpoint | Description |
---|---|---|
GET | /api/order/orders |
Get order details based on user |
POST | /api/order/toggle-reminder |
Reminder for order |
GET | /api/order/total-orders |
Get total orders and revenue count |
GET | /api/order/all |
Get all order details |
Method | Endpoint | Description |
---|---|---|
POST | /api/payment/create-checkout-session |
Process Stripe payment for one-time |
POST | /api/payment/create-checkout-session-for-subscription |
Process Stripe payment for subscription |
Method | Endpoint | Description |
---|---|---|
GET | /api/checkout/:checkoutId |
Retrive checkout data |
POST | /api/checkout/create-from-checkout/:checkoutId |
Create order from checkout |
Method | Endpoint | Description |
---|---|---|
POST | /api/review |
Create review |
GET | /api/review |
Get all reviews |
GET | /api/review/total |
Get total reviews |
GET | /api/review/:productId |
Get review by ID |
PATCH | /api/review/:respond/:reviewId |
Respond to review |
Method | Endpoint | Description |
---|---|---|
POST | /api/webhook |
Handle Stripe webhooks |
- Node.js & Express.js - Backend Framework
- MongoDB & Mongoose - Database & ODM
- JWT & bcrypt.js - Authentication & Security
- Stripe - Payment Processing
- Node-cron - Task Scheduling
- dotenv - Environment Variables
- cookie-parser - Cookie Handling
- CORS - Cross-Origin Requests
- All sensitive data is stored in
.env
. - JWT authentication is implemented for protected routes.
- Stripe payment processing is securely integrated.
- Middleware for error handling and token verification.
Yogadeepan R