Skip to content

Yogadeepan29/CAPSTONE--CleanEase_Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CleanEase API - Backend

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.


πŸš€ 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.

πŸ› οΈ Installation & Setup

1️⃣ Clone the Repository

git clone https://github.com/Yogadeepan29/CAPSTONE--CleanEase_Backend.git
cd CleanEase-Backend

2️⃣ Install Dependencies

npm install

3️⃣ Create a .env File

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

4️⃣ Start the Server

For development mode with hot-reloading:

npm run dev

For production mode:

npm start

πŸ“‚ Project Structure

πŸ“ 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

πŸ“œ API Documentation

For detailed API documentation, please visit the following link: API Documentation


πŸ“Œ API Endpoints

πŸ”Ή πŸͺͺ Authentication

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

πŸ”ΉπŸ‘₯ User

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

πŸ”ΉπŸ§Ή Services

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

πŸ”ΉπŸ›’ Cart

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

πŸ”ΉπŸ“¦ Orders

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

πŸ”ΉπŸ’° Payments

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

πŸ”ΉπŸ’³ Checkout

Method Endpoint Description
GET /api/checkout/:checkoutId Retrive checkout data
POST /api/checkout/create-from-checkout/:checkoutId Create order from checkout

πŸ”Ήβ­ Review

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

πŸ”ΉπŸ”” Webhook

Method Endpoint Description
POST /api/webhook Handle Stripe webhooks

πŸ›  Technologies Used

  • 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

πŸ”’ Security Best Practices

  • 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.

πŸ‘¨β€πŸ’» Author

Yogadeepan R


🎯 Deployment

  • Frontend: Deployed on Netlify β†’ Live Demo
  • Backend: Deployed on Render β†’ API