{"id":21204436,"url":"https://github.com/purwar1997/shopease-api","last_synced_at":"2025-07-05T16:32:54.614Z","repository":{"id":242246386,"uuid":"805268642","full_name":"purwar1997/shopease-api","owner":"purwar1997","description":"A RESTful API for an ecommerce platform built using Express.js and MongoDB.","archived":false,"fork":false,"pushed_at":"2024-11-10T19:22:46.000Z","size":512,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-10T20:25:41.940Z","etag":null,"topics":["cloudinary-sdk","cron-jobs","express-js","joi-validation","jwt-authentication","mongodb","mongoose","pm2","razorpay-payment-gateway","swagger-docs"],"latest_commit_sha":null,"homepage":"http://api.shopease.shubhampurwar.in/docs/swagger","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/purwar1997.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-24T08:17:32.000Z","updated_at":"2024-11-10T19:22:49.000Z","dependencies_parsed_at":"2024-06-25T02:54:39.235Z","dependency_job_id":"790734b1-40f8-440d-b51f-6ca5cd06c658","html_url":"https://github.com/purwar1997/shopease-api","commit_stats":null,"previous_names":["purwar1997/ecommerce-backend","purwar1997/shopease-backend","purwar1997/shopease-api-server","purwar1997/shopease-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purwar1997%2Fshopease-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purwar1997%2Fshopease-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purwar1997%2Fshopease-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purwar1997%2Fshopease-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/purwar1997","download_url":"https://codeload.github.com/purwar1997/shopease-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225628436,"owners_count":17499159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudinary-sdk","cron-jobs","express-js","joi-validation","jwt-authentication","mongodb","mongoose","pm2","razorpay-payment-gateway","swagger-docs"],"created_at":"2024-11-20T20:35:13.341Z","updated_at":"2025-07-05T16:32:54.595Z","avatar_url":"https://github.com/purwar1997.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Shopease API\r\n\r\n![static-badge](https://img.shields.io/badge/built_with-love-red?style=for-the-badge)\r\n![static-badge](https://img.shields.io/badge/status-success-limegreen?style=for-the-badge)\r\n\r\n## 0. Table of Contents\r\n\r\n1. [Overview](#1-overview)\r\n2. [Deployment and Documentation](#2-deployment-and-documentation)\r\n   - [Swagger Docs](#swagger-docs)\r\n   - [Postman Docs](#postman-docs)\r\n3. [Main Features](#3-main-features)\r\n4. [Schemas and Routes](#4-schemas-and-routes)\r\n   - [Authentication Routes](#authentication-routes)\r\n   - [User Routes](#user-routes)\r\n   - [Address Routes](#address-routes)\r\n   - [Cart Routes](#cart-routes)\r\n   - [Wishlist Routes](#wishlist-routes)\r\n   - [Product Routes](#product-routes)\r\n   - [Category Routes](#category-routes)\r\n   - [Brand Routes](#brand-routes)\r\n   - [Coupon Routes](#coupon-routes)\r\n   - [Order Routes](#order-routes)\r\n   - [Review Routes](#review-routes)\r\n\r\n## 1. Overview\r\n\r\nA RESTful API for an e-commerce platform that provides multiple endpoints to manage authentication, users, cart, wishlist, addresses, products, categories, brands, coupons, orders and reviews.\r\n\r\nThis project is built using Express.js and MongoDB; all the APIs are well-documented using Swagger specification. User authentication has been implemented via JSON Web Tokens and the project is deployed on a DigitalOcean Droplet using Nginx as a web server.\r\n\r\n![Header](./media/header.png)\r\n\r\n## 2. Deployment and Documentation\r\n\r\nThis project is deployed on a DigitalOcean Droplet and linked to a custom domain. To visit the live deployment, [click here](http://api.shopease.shubhampurwar.in).\r\n\r\n### Swagger Docs\r\n\r\nAPIs are documented using Swagger (OpenAPI) specification and all of them are live and functional. To view Swagger docs, [click here](http://api.shopease.shubhampurwar.in/docs/swagger). Select Shopease production server in the dropdown menu and play with any API.\r\n\r\n[![Swagger Docs](./media/swagger-docs.png)](http://api.shopease.shubhampurwar.in/docs/swagger)\r\n\r\n### Postman Docs\r\n\r\nPostman is used to prototype, develop and test API endpoints. It is also used to document those APIs. To view Postman docs, [click here](https://documenter.getpostman.com/view/24544020/2sAYQcFAkx).\r\n\r\n[![Postman Docs](./media/postman-docs.png)](https://documenter.getpostman.com/view/24544020/2sAYQcFAkx)\r\n\r\n## 3. Main Features\r\n\r\n- Authentication using JSON Web Tokens (signup, login, reset password)\r\n- Authorization based on role of a user (user or admin)\r\n- Database modelling using various Mongoose schemas\r\n- Used MongoDB aggregation pipelines to perform complex database queries\r\n- Applied filters, sorting and pagination on Mongoose documents\r\n- Scheduled CRON job to check the expiry status of coupons every midnight\r\n- API and CRON jobs are deployed on a DigitalOcean Droplet using Nginx as a web server\r\n- Configured PM2 to keep API and Cron jobs running as daemon processes to ensure availability\r\n- Utilized the cluster module to evenly distribute incoming requests across all CPU cores in the server\r\n- APIs are documented using Swagger (OpenAPI) specification\r\n- Integration of payment gateway using Razorpay APIs\r\n- Verification of email addresses and phone numbers using Abstract APIs (third party service)\r\n- Validation of request payload using Joi library\r\n- Logging of HTTP requests using Morgan\r\n- Separate loggers for development and production environments\r\n- Parsing of multipart/form-data using Formidable library\r\n- Upload and delete images using Cloudinary APIs\r\n- Ability to send emails using Nodemailer\r\n- Setup routing using Express middlewares\r\n- Centralized error handling using Express middlewares\r\n- Project is based on MVC architecture\r\n- Used Postman to prototype, develop, test and document APIs\r\n\r\n## 4. Schemas and Routes\r\n\r\nShopease API consists of 8 schemas and 70+ routes and controllers.\r\n\r\n### Authentication Routes\r\n\r\n| Action          | Method | Route                       | Access Requirements |\r\n| :-------------- | :----- | :-------------------------- | :------------------ |\r\n| Signup          | POST   | /auth/signup                | None                |\r\n| Login           | POST   | /auth/login                 | None                |\r\n| Logout          | POST   | /auth/logout                | Authentication      |\r\n| Forgot password | POST   | /auth/password/forgot       | None                |\r\n| Reset password  | PUT    | /auth/password/reset/:token | None                |\r\n\r\n### User Routes\r\n\r\n| Action               | Method | Route                     | Access Requirements            |\r\n| :------------------- | :----- | :------------------------ | :----------------------------- |\r\n| Fetch profile        | GET    | /users/self               | Authentication                 |\r\n| Update profile       | PUT    | /users/self               | Authentication                 |\r\n| Delete account       | DELETE | /users/self               | Authentication                 |\r\n| Add profile photo    | POST   | /users/self/avatar        | Authentication                 |\r\n| Remove profile photo | PUT    | /users/self/avatar        | Authentication                 |\r\n| Update profile photo | POST   | /users/self/avatar/update | Authentication                 |\r\n| Fetch users          | GET    | /admin/users              | Authentication + Authorization |\r\n| Fetch user by ID     | GET    | /admin/users/:userId      | Authentication + Authorization |\r\n| Update user role     | PUT    | /admin/users/:userId      | Authentication + Authorization |\r\n| Delete user          | DELETE | /admin/users/:userId      | Authentication + Authorization |\r\n| Fetch other admins   | GET    | /admin/admins             | Authentication + Authorization |\r\n| Admin self demote    | PUT    | /admin/self               | Authentication + Authorization |\r\n| Admin self delete    | DELETE | /admin/self               | Authentication + Authorization |\r\n\r\n### Address Routes\r\n\r\n| Action              | Method | Route                         | Access Requirements |\r\n| :------------------ | :----- | :---------------------------- | :------------------ |\r\n| Fetch addresses     | GET    | /addresses                    | Authentication      |\r\n| Add new address     | POST   | /addresses                    | Authentication      |\r\n| Fetch address by ID | GET    | /addresses/:addressId         | Authentication      |\r\n| Update address      | PUT    | /addresses/:addressId         | Authentication      |\r\n| Delete address      | DELETE | /addresses/:addressId         | Authentication      |\r\n| Set default address | PUT    | /addresses/:addressId/default | Authentication      |\r\n\r\n### Cart Routes\r\n\r\n| Action                | Method | Route        | Access Requirements |\r\n| :-------------------- | :----- | :----------- | :------------------ |\r\n| Fetch cart            | GET    | /cart        | Authentication      |\r\n| Add item to cart      | POST   | /cart/add    | Authentication      |\r\n| Remove item from cart | PUT    | /cart/remove | Authentication      |\r\n| Update item quantity  | PUT    | /cart/update | Authentication      |\r\n| Move item to wishlist | PUT    | /cart/move   | Authentication      |\r\n| Clear cart            | PUT    | /cart/clear  | Authentication      |\r\n\r\n### Wishlist Routes\r\n\r\n| Action                    | Method | Route            | Access Requirements |\r\n| :------------------------ | :----- | :--------------- | :------------------ |\r\n| Fetch wishlist            | GET    | /wishlist        | Authentication      |\r\n| Add item to wishlist      | PUT    | /wishlist/add    | Authentication      |\r\n| Remove item from wishlist | PUT    | /wishlist/remove | Authentication      |\r\n| Move item to cart         | PUT    | /wishlist/move   | Authentication      |\r\n| Clear wishlist            | PUT    | /wishlist/clear  | Authentication      |\r\n\r\n### Product Routes\r\n\r\n| Action                    | Method | Route                              | Access Requirements            |\r\n| :------------------------ | :----- | :--------------------------------- | :----------------------------- |\r\n| Fetch products            | GET    | /products                          | None                           |\r\n| Fetch product by ID       | GET    | /products/:productId               | None                           |\r\n| Admin fetch products      | GET    | /admin/products                    | Authentication + Authorization |\r\n| Add new product           | POST   | /admin/products                    | Authentication + Authorization |\r\n| Admin fetch product by ID | GET    | /admin/products/:productId         | Authentication + Authorization |\r\n| Update product details    | POST   | /admin/products/:productId         | Authentication + Authorization |\r\n| Delete product            | DELETE | /admin/products/:productId         | Authentication + Authorization |\r\n| Restore deleted product   | PUT    | /admin/products/:productId/restore | Authentication + Authorization |\r\n\r\n### Category Routes\r\n\r\n| Action               | Method | Route                         | Access Requirements            |\r\n| :------------------- | :----- | :---------------------------- | :----------------------------- |\r\n| Fetch categories     | GET    | /categories                   | None                           |\r\n| Fetch category by ID | GET    | /categories/:categoryId       | None                           |\r\n| Fetch all categories | GET    | /admin/categories             | Authentication + Authorization |\r\n| Add new category     | POST   | /admin/categories             | Authentication + Authorization |\r\n| Update category      | POST   | /admin/categories/:categoryId | Authentication + Authorization |\r\n\r\n### Brand Routes\r\n\r\n| Action            | Method | Route                  | Access Requirements            |\r\n| :---------------- | :----- | :--------------------- | :----------------------------- |\r\n| Fetch brands      | GET    | /brands                | None                           |\r\n| Fetch brand by ID | GET    | /brands/:brandId       | None                           |\r\n| Fetch all brands  | GET    | /admin/brands          | Authentication + Authorization |\r\n| Add new brand     | POST   | /admin/brands          | Authentication + Authorization |\r\n| Update brand      | POST   | /admin/brands/:brandId | Authentication + Authorization |\r\n\r\n### Coupon Routes\r\n\r\n| Action                | Method | Route                               | Access Requirements            |\r\n| :-------------------- | :----- | :---------------------------------- | :----------------------------- |\r\n| Fetch valid coupons   | GET    | /coupons                            | Authentication                 |\r\n| Check coupon validity | GET    | /coupons/validity                   | Authentication                 |\r\n| Admin fetch coupons   | GET    | /admin/coupons                      | Authentication + Authorization |\r\n| Create new coupon     | POST   | /admin/coupons                      | Authentication + Authorization |\r\n| Fetch coupon by ID    | GET    | /admin/coupons/:couponId            | Authentication + Authorization |\r\n| Update coupon details | PUT    | /admin/coupons/:couponId            | Authentication + Authorization |\r\n| Delete coupon         | DELETE | /admin/coupons/:couponId            | Authentication + Authorization |\r\n| Activate coupon       | PUT    | /admin/coupons/:couponId/activate   | Authentication + Authorization |\r\n| Deactivate coupon     | PUT    | /admin/coupons/:couponId/deactivate | Authentication + Authorization |\r\n\r\n### Order Routes\r\n\r\n| Action                  | Method | Route                    | Access Requirements            |\r\n| :---------------------- | :----- | :----------------------- | :----------------------------- |\r\n| Fetch orders            | GET    | /orders                  | Authentication                 |\r\n| Create new order        | POST   | /orders                  | Authentication                 |\r\n| Fetch order by ID       | GET    | /orders/:orderId         | Authentication                 |\r\n| Confirm order           | PUT    | /orders/:orderId/confirm | Authentication                 |\r\n| Cancel order            | PUT    | /orders/:orderId/cancel  | Authentication                 |\r\n| Admin fetch orders      | GET    | /admin/orders            | Authentication + Authorization |\r\n| Admin fetch order by ID | GET    | /admin/orders/:orderId   | Authentication + Authorization |\r\n| Update order status     | PUT    | /admin/orders/:orderId   | Authentication + Authorization |\r\n| Delete order            | DELETE | /admin/orders/:orderId   | Authentication + Authorization |\r\n\r\n### Review Routes\r\n\r\n| Action                | Method | Route                        | Access Requirements |\r\n| :-------------------- | :----- | :--------------------------- | :------------------ |\r\n| Fetch product reviews | GET    | /products/:productId/reviews | None                |\r\n| Add product review    | POST   | /products/:productId/reviews | Authentication      |\r\n| Fetch review by ID    | GET    | /reviews/:reviewId           | Authentication      |\r\n| Update product review | PUT    | /reviews/:reviewId           | Authentication      |\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurwar1997%2Fshopease-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpurwar1997%2Fshopease-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurwar1997%2Fshopease-api/lists"}