{"id":19792503,"url":"https://github.com/ravikantsingh12/ecommerce-api","last_synced_at":"2026-04-08T12:34:58.840Z","repository":{"id":249783901,"uuid":"832539921","full_name":"ravikantsingh12/Ecommerce-API","owner":"ravikantsingh12","description":"This API provides endpoints to manage productinventory for an ecommerce platform. It utilizes Node.js with Express for the backend and MongoDB for data storage.","archived":false,"fork":false,"pushed_at":"2024-07-23T14:27:07.000Z","size":387,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-03T14:28:11.385Z","etag":null,"topics":["bootstrap","coding-ninjas","css","ecommerce-api","express","html","javascript","mongodb","mongoose","mvc-pattern","nodejs","rest-api"],"latest_commit_sha":null,"homepage":"https://ecommerce-api-t8ix.onrender.com/products","language":"EJS","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/ravikantsingh12.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-07-23T08:23:17.000Z","updated_at":"2024-07-23T14:27:10.000Z","dependencies_parsed_at":"2025-01-11T04:29:06.735Z","dependency_job_id":null,"html_url":"https://github.com/ravikantsingh12/Ecommerce-API","commit_stats":null,"previous_names":["ravikantsingh12/ecommerce-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ravikantsingh12/Ecommerce-API","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravikantsingh12%2FEcommerce-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravikantsingh12%2FEcommerce-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravikantsingh12%2FEcommerce-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravikantsingh12%2FEcommerce-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ravikantsingh12","download_url":"https://codeload.github.com/ravikantsingh12/Ecommerce-API/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravikantsingh12%2FEcommerce-API/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31556237,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T10:21:54.569Z","status":"ssl_error","status_checked_at":"2026-04-08T10:21:38.171Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["bootstrap","coding-ninjas","css","ecommerce-api","express","html","javascript","mongodb","mongoose","mvc-pattern","nodejs","rest-api"],"created_at":"2024-11-12T07:07:09.023Z","updated_at":"2026-04-08T12:34:58.819Z","avatar_url":"https://github.com/ravikantsingh12.png","language":"EJS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ecommerce Platform API\r\n\r\nThis API provides endpoints to manage product inventory for an ecommerce platform.\r\nIt utilizes Node.js with Express for the backend and MongoDB for data storage.\r\n\r\n## Features\r\n\r\n- Create, read, update, and delete (CRUD) operations for products.\r\n- Update product quantities dynamically.\r\n- Secure API endpoints with basic error handling.\r\n\r\n## Live Site\r\n[Click here](https://ecommerce-api-t8ix.onrender.com/products) to visit the live site.\r\n\r\n## Prerequisites\r\n\r\nBefore you begin, ensure you have met the following requirements:\r\n\r\n- Node.js installed on your local machine. You can download it from [nodejs.org](https://nodejs.org/).\r\n- MongoDB installed and running locally or accessible via a remote server.\r\n\r\n## Folder Structure\r\n\r\n```csharp\r\necommerce-api\r\n├── config                    # MongoDB configuration\r\n│   └── mongoose.js\r\n├── controllers               # Controller logic\r\n│   └── productController.js\r\n├── images                    # Project Screenshots\r\n├── models                    # Database models\r\n│   └── productModel.js\r\n├── routes                    # Route definitions\r\n│   └── productRoutes.js\r\n├── views                     # EJS views\r\n│   ├── createProduct.ejs\r\n│   ├── products.ejs\r\n│   └── updateProduct.ejs\r\n├── .env                      # Environment variables file\r\n├── index.js                  # Express application setup\r\n└── package.json\r\n```\r\n\r\n## Getting Started\r\n\r\nTo set up this project locally, follow these steps:\r\n\r\n1. **Clone the repository**\r\n\r\n2. **Install dependencies**\r\n   ```bash\r\n   npm install\r\n   ```\r\n\r\n- express\r\n- mongoose\r\n- ejs\r\n- express-ejs-layouts\r\n- dotenv\r\n\r\n3. **Set up environment variables**\r\n\r\n   Create a `.env` file in the root directory andprovide the following variables:\r\n\r\n   ```plaintext\r\n   PORT=3000\r\n   MONGO_URI=mongodb://localhost:27017/ecommerce\r\n   ```\r\n\r\n   Adjust `PORT` and `MONGO_URI` as per your configuration.\r\n\r\n4. **Start the server**\r\n\r\n   ```bash\r\n   npm start\r\n   ```\r\n\r\n   The server should now be running on `http:/localhost:3000/products`.\r\n\r\n5. **Explore the API**\r\n   Use tools like Postman or cURL to interact withthe API endpoints described below.\r\n\r\n## API Endpoints\r\n\r\n### Create a new product\r\n\r\n- **URL:** `/products/create`\r\n- **Method:** POST\r\n- **Request Body:**\r\n\r\n  ```json\r\n  {\r\n    \"name\": \"laptop\",\r\n    \"quantity\": 10\r\n  }\r\n  ```\r\n\r\n- **Response:**\r\n  ```json\r\n  {\r\n    \"product\": {\r\n      \"name\": \"laptop\",\r\n      \"quantity\": 10\r\n    }\r\n  }\r\n  ```\r\n\r\n### Get all products\r\n\r\n- **URL:** `/products`\r\n- **Method:** GET\r\n- **Response:**\r\n  ```json\r\n  {\r\n    \"products\": [\r\n      {\r\n        \"id\": \"1\",\r\n        \"name\": \"laptop\",\r\n        \"quantity\": 10\r\n      },\r\n      {\r\n        \"id\": \"2\",\r\n        \"name\": \"camera\",\r\n        \"quantity\": 5\r\n      },\r\n      {\r\n        \"id\": \"3\",\r\n        \"name\": \"smartwatch\",\r\n        \"quantity\": 8\r\n      }\r\n    ]\r\n  }\r\n  ```\r\n\r\n### Delete a product\r\n\r\n- **URL:** `/products/:id`\r\n- **Method:** DELETE\r\n- **Response:**\r\n  ```json\r\n  {\r\n    \"message\": \"Product deleted\"\r\n  }\r\n  ```\r\n\r\n### Update product quantity\r\n\r\nYou can either increment or decrement the product quantity\r\n\r\n- **URL:** `/products/:\u003cid\u003e/update_quantity?number=\u003cnumber\u003e`\r\n- **Method:** POST\r\n- **Response:**\r\n  ```json\r\n  {\r\n    \"product\": {\r\n      \"id\": \"1\",\r\n      \"name\": \"laptop\",\r\n      \"quantity\": 20\r\n    },\r\n    \"message\": \"Updated successfully\"\r\n  }\r\n  ```\r\n\r\n## Detailed Code Overview\r\n\r\n**config/mongoose.js** : Handles MongoDB connection using Mongoose.\r\n\r\n**controllers/productController.js** : Contains the logic for handling requests to create, read, update, and delete products.\r\n\r\n**models/productModel.js** : Defines the Mongoose schema and model for products.\r\n\r\n**routes/productRoutes.js** : Defines the routes for product-related API endpoints and maps them to the controller functions.\r\n\r\n**views/** : Contains the EJS templates for the frontend interface.\r\n\r\n**Product List (views/products.ejs)** : Displays all products in a table with options to update or delete each product.\r\n\r\n**Create Product Form (views/createProduct.ejs)** : Form to create a new product.\r\n\r\n**Update Product Form (views/updateProduct.ejs)** : Form to update the quantity of an existing product.\r\n\r\n**index.js** : Sets up the Express server, connects to MongoDB, and defines the routes.\r\n\r\n**Styling** : The frontend interface is styled using Bootstrap for a clean and responsive design.\r\n\r\n## Project Screenshot\r\n\r\n1. **Product Inventory Page:**\r\n   ![Product Inventory](images/productsInventoryPage.PNG)\r\n\r\n2. **Add New Product Form:**\r\n   ![Add New Product](images/addNewProductPage.PNG)\r\n3. **Update Product Form:**\r\n   ![Update Product](images/updateProductPage.PNG)\r\n\r\n## Credits\r\n\r\nThis project was created by [Ravikant Singh](https://github.com/ravikantsingh12). Contributions via issues or pull requests are welcome!\r\n\r\n## Follow me on\r\n\r\n- [LinkedIn](https://www.linkedin.com/in/ravikant-singh-327a98241)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fravikantsingh12%2Fecommerce-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fravikantsingh12%2Fecommerce-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fravikantsingh12%2Fecommerce-api/lists"}