{"id":25085623,"url":"https://github.com/shuaib-code/bicycle-store-api","last_synced_at":"2025-04-01T13:41:50.963Z","repository":{"id":264373851,"uuid":"893184618","full_name":"shuaib-code/bicycle-store-api","owner":"shuaib-code","description":"A Node.js server for managing a bicycle store, offering RESTful APIs for inventory management, customer orders, and store operations to support an efficient e-commerce system.","archived":false,"fork":false,"pushed_at":"2024-12-27T18:58:29.000Z","size":137,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-07T08:34:48.186Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://bicycle-store-api.vercel.app","language":"TypeScript","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/shuaib-code.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-11-23T18:52:02.000Z","updated_at":"2024-12-27T18:58:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"08402e9f-374c-4490-9836-5354ab370738","html_url":"https://github.com/shuaib-code/bicycle-store-api","commit_stats":null,"previous_names":["shuaib-code/bicycle-store-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuaib-code%2Fbicycle-store-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuaib-code%2Fbicycle-store-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuaib-code%2Fbicycle-store-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuaib-code%2Fbicycle-store-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shuaib-code","download_url":"https://codeload.github.com/shuaib-code/bicycle-store-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246650951,"owners_count":20811989,"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":[],"created_at":"2025-02-07T08:29:19.882Z","updated_at":"2025-04-01T13:41:50.941Z","avatar_url":"https://github.com/shuaib-code.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bicycle Store API 🛒🚴‍♂️\n\nA feature-rich Bicycle Store management system built using **Express** and **TypeScript**, with MongoDB as the database and Mongoose for data modeling. This application handles product inventory, order management, and revenue calculation while ensuring data integrity through Mongoose schema validation.\n\n---\n\n## 🌟 Features\n\n- **Product Management**:\n\n  - Add, view, update, and delete bicycles.\n  - Search products by `name`, `brand`, or `type` with dynamic filters.\n\n- **Order Management**:\n\n  - Place orders, manage inventory automatically, and handle stock levels.\n  - Validate insufficient stock scenarios gracefully.\n\n- **Revenue Calculation**:\n\n  - Aggregate and calculate total revenue from all orders.\n\n- **Validation and Error Handling**:\n\n  - Comprehensive validation for user inputs (e.g., email format, positive price).\n  - Detailed error responses with validation error insights.\n  - Not Found and Generic Error responses with stack traces for debugging.\n\n- **Clean Code and Architecture**:\n\n  - TypeScript for type safety.\n  - Modular structure for scalability and maintainability.\n  - Well-documented codebase with meaningful variable and function names.\n\n- **Ready for Deployment**:\n  - Built-in scripts for development, production, and formatting.\n  - Easily deployable to any cloud provider.\n\n---\n\n## 🚀 Getting Started\n\n### Prerequisites\n\nEnsure you have the following installed:\n\n- [Node.js](https://nodejs.org/) (v16+)\n- [MongoDB](https://www.mongodb.com/) (local or cloud instance)\n- [TypeScript](https://www.typescriptlang.org/) (v4+)\n\n---\n\n### Installation\n\n1. Clone the repository:\n\n```bash\n   git clone https://github.com/your-username/bicycle-store-api.git\n   cd bicycle-store-api\n```\n\n2. Go to the project directory:\n\n```bash\n  cd bicycle-store-api\n```\n\n3. Install dependencies:\n\n```bash\n  npm install\n```\n\n4. Set up your environment variables by creating a .env file:\n\n```bash\n  MONGO_URI=\u003cYour MongoDB URI\u003e\n  PORT=5000\n```\n\n5. Build the project:\n\n```bash\n  npm run build\n```\n\n6. Start the application:\n\n```bash\n  npm run start:dev\n```\n\n## API Endpoints\n\n### **Product Management**\n\n### **1. Create a Bicycle**\n\n- **Endpoint:** **`/api/products`**\n- **Method:** `POST`\n- **Request Body:**\n\n```json\n{\n\t\"name\": \"Roadster 5000\",\n\t\"brand\": \"SpeedX\",\n\t\"price\": 300,\n\t\"type\": \"Road\",\n\t\"description\": \"A premium road bike designed for speed and performance.\",\n\t\"quantity\": 20,\n\t\"inStock\": true\n}\n```\n\n- **Response:** Success message and created bicycle details.\n\n```json\n{\n\t\"message\": \"Bicycle created successfully\",\n\t\"success\": true,\n\t\"data\": {\n\t\t\"_id\": \"648a45e5f0123c45678d9012\",\n\t\t\"name\": \"Roadster 5000\",\n\t\t\"brand\": \"SpeedX\",\n\t\t\"price\": 300,\n\t\t\"type\": \"Road\",\n\t\t\"description\": \"A premium road bike designed for speed and performance.\",\n\t\t\"quantity\": 20,\n\t\t\"inStock\": true,\n\t\t\"createdAt\": \"2024-11-19T10:23:45.123Z\",\n\t\t\"updatedAt\": \"2024-11-19T10:23:45.123Z\"\n\t}\n}\n```\n\n---\n\n### **2. Get All Bicycles**\n\n- **Endpoint:** **`/api/products`**\n- **Method:** `GET`\n- **Response:** A list of all bicycles with details like name, brand, price, type, etc.\n- **Query:** `/api/products?searchTerm=type` (`searchTerm` can be `name`, `brand`, `type`)\n\n```json\n{\n\t\"message\": \"Bicycles retrieved successfully\",\n\t\"status\": true,\n\t\"data\": [\n\t\t{\n\t\t\t\"_id\": \"648a45e5f0123c45678d9012\",\n\t\t\t\"name\": \"Roadster 5000\",\n\t\t\t\"brand\": \"SpeedX\",\n\t\t\t\"price\": 300,\n\t\t\t\"type\": \"Road\",\n\t\t\t\"description\": \"A premium road bike designed for speed and performance.\",\n\t\t\t\"quantity\": 20,\n\t\t\t\"inStock\": true,\n\t\t\t\"createdAt\": \"2024-11-19T10:23:45.123Z\",\n\t\t\t\"updatedAt\": \"2024-11-19T10:23:45.123Z\"\n\t\t}\n\t]\n}\n```\n\n---\n\n### **3. Get a Specific Bicycle**\n\n- **Endpoint:** **`/api/products/:productId`**\n- **Method:** `GET`\n- **Response:** The details of a specific bicycle by ID.\n\n```json\n{\n\t\"message\": \"Bicycle retrieved successfully\",\n\t\"status\": true,\n\t\"data\": {\n\t\t\"_id\": \"648a45e5f0123c45678d9012\",\n\t\t\"name\": \"Roadster 5000\",\n\t\t\"brand\": \"SpeedX\",\n\t\t\"price\": 300,\n\t\t\"type\": \"Road\",\n\t\t\"description\": \"A premium road bike designed for speed and performance.\",\n\t\t\"quantity\": 20,\n\t\t\"inStock\": true,\n\t\t\"createdAt\": \"2024-11-19T10:23:45.123Z\",\n\t\t\"updatedAt\": \"2024-11-19T10:23:45.123Z\"\n\t}\n}\n```\n\n---\n\n### **4. Update a Bicycle**\n\n- **Endpoint:** **`/api/products/:productId`**\n- **Method:** `PUT`\n- **Request Body:** (Bicycle details to update)\n\n```json\n{\n\t\"price\": 350,\n\t\"quantity\": 15\n}\n```\n\n- **Response:** Success message and updated bicycle details.\n\n```json\n{\n\t\"message\": \"Bicycle updated successfully\",\n\t\"status\": true,\n\t\"data\": {\n\t\t\"_id\": \"648a45e5f0123c45678d9012\",\n\t\t\"name\": \"Roadster 5000\",\n\t\t\"brand\": \"SpeedX\",\n\t\t\"price\": 350, // Price updated\n\t\t\"type\": \"Road\",\n\t\t\"description\": \"A premium road bike designed for speed and performance.\",\n\t\t\"quantity\": 15, // Quantity updated\n\t\t\"inStock\": true,\n\t\t\"createdAt\": \"2024-11-19T10:23:45.123Z\",\n\t\t\"updatedAt\": \"2024-11-19T11:00:00.000Z\" // Updated timestamp\n\t}\n}\n```\n\n---\n\n### **5. Delete a Bicycle**\n\n- **Endpoint:** **`/api/products/:productId`**\n- **Method:** `DELETE`\n- **Response:** Success message confirming the bicycle has been deleted.\n\n```json\n{\n\t\"message\": \"Bicycle deleted successfully\",\n\t\"status\": true,\n\t\"data\": {}\n}\n```\n\n---\n\n### **Product Management**\n\n### **1. Order a Bicycle**\n\n- **Endpoint:** **`/api/orders`**\n- **Method:** `POST`\n- **Request Body:**\n\n```json\n{\n\t\"email\": \"customer@example.com\",\n\t\"product\": \"648a45e5f0123c45678d9012\",\n\t\"quantity\": 2,\n\t\"totalPrice\": 600\n}\n```\n\n- **Response:** Success message confirming the order.\n\n```json\n{\n\t\"message\": \"Order created successfully\",\n\t\"status\": true,\n\t\"data\": {\n\t\t\"_id\": \"648b45f5e1234b56789a6789\",\n\t\t\"email\": \"customer@example.com\",\n\t\t\"product\": \"648a45e5f0123c45678d9012\",\n\t\t\"quantity\": 2,\n\t\t\"totalPrice\": 600,\n\t\t\"createdAt\": \"2024-11-19T12:00:00.000Z\",\n\t\t\"updatedAt\": \"2024-11-19T12:00:00.000Z\"\n\t}\n}\n```\n\n---\n\n### **2. Calculate Revenue from Orders (Aggregation)**\n\n- **Endpoint:** **`/api/orders/revenue`**\n- **Method:** `GET`\n- **Response:** The total revenue from all orders.\n\n```json\n{\n\t\"message\": \"Revenue calculated successfully\",\n\t\"status\": true,\n\t\"data\": {\n\t\t\"totalRevenue\": 1200 // Total revenue calculated from all orders\n\t}\n}\n```\n\n---\n\n## 🎥 Video Explanation\n\nWatch the video walkthrough for a detailed explanation of features, design choices, and API testing: [Watch the Walkthrough](your-video-link-here)\n\n## 🤝 Contributing\n\n1. Fork the repository.\n2. Create a feature branch: `git checkout -b feature-name`.\n3. Commit your changes: `git commit -m 'Add some feature'`.\n4. Push to the branch: `git push origin feature-name`.\n5. Open a pull request.\n\n## 📜 License\n\nThis project is licensed under the MIT License.\n\nHappy coding! 🚀\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuaib-code%2Fbicycle-store-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshuaib-code%2Fbicycle-store-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuaib-code%2Fbicycle-store-api/lists"}