{"id":24169654,"url":"https://github.com/asuselessbrain/car-store-server","last_synced_at":"2026-04-09T06:45:38.784Z","repository":{"id":270175773,"uuid":"909428809","full_name":"asuselessbrain/Car-Store-server","owner":"asuselessbrain","description":"The Car Store Application is a scalable backend system for managing car inventory, orders, and revenue. Built with Node.js and Express, it uses TypeScript for type safety and maintainability. MongoDB with Mongoose powers its database, enabling efficient data modeling, validation, and aggregation.","archived":false,"fork":false,"pushed_at":"2025-02-13T16:49:29.000Z","size":438,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-02T11:16:52.492Z","etag":null,"topics":["eslint","express","mongodb","mongoose","nodejs","prettier","typescript"],"latest_commit_sha":null,"homepage":"https://car-store-server-by-arfan.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/asuselessbrain.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-12-28T17:15:15.000Z","updated_at":"2025-02-13T16:49:32.000Z","dependencies_parsed_at":"2025-02-09T18:22:56.948Z","dependency_job_id":"1cce5db4-f5e5-4790-a1ed-5b2daa62c7ba","html_url":"https://github.com/asuselessbrain/Car-Store-server","commit_stats":null,"previous_names":["asuselessbrain/car-store-server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asuselessbrain%2FCar-Store-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asuselessbrain%2FCar-Store-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asuselessbrain%2FCar-Store-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asuselessbrain%2FCar-Store-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asuselessbrain","download_url":"https://codeload.github.com/asuselessbrain/Car-Store-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241494182,"owners_count":19971871,"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":["eslint","express","mongodb","mongoose","nodejs","prettier","typescript"],"created_at":"2025-01-12T23:13:53.766Z","updated_at":"2025-12-30T19:16:28.161Z","avatar_url":"https://github.com/asuselessbrain.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Car Store Application\n\n## Objective\nDevelop an Express application with TypeScript, integrating MongoDB with Mongoose to manage a Car Store. Ensure data integrity using Mongoose schema validation.\n\n---\n\n## Live Link\nAccess the live application here: **[Car Store Application](https://car-store-server-by-arfan.vercel.app/)**\n\n---\n\n## Features\n- **Car Management:**\n  - Create, read, update, and delete car details.\n  - Search cars by brand, model, or category.\n  - Manage car inventory with quantity tracking and stock status.\n- **Order Management:**\n  - Place orders for cars.\n  - Automatically adjust inventory on order placement.\n  - Prevent orders if stock is insufficient.\n- **Revenue Calculation:**\n  - Use MongoDB aggregation to calculate total revenue from orders.\n- **Validation:**\n  - Enforce data integrity with Mongoose schema validation.\n\n---\n\n## Project Setup\n### Prerequisites\n- Node.js (\u003e=16.x)\n- MongoDB instance (local or cloud-based)\n\n### Installation\n1. **Clone the repository:**\n    ```bash\n    git clone https://github.com/asuselessbrain/Car-Store-server.git\n    cd Car-Store-server\n    ```\n2. **Install dependencies:**\n    ```bash\n    npm install\n    ```\n3. **Environment Variables:**\n    Create a `.env` file in the root directory and add the following:\n    ```env\n    DB_URI=\u003cyour-mongodb-uri\u003e\n    PORT=5000\n    ```\n4. **Start the server:**\n    ```bash\n    npm run start:dev\n    ```\n5. **Access the API:**\n    Open your browser or API client and navigate to `http://localhost:5000/api/cars`.\n---\n\n## Directory Structure\n```\nsrc/\n├── config\n│   ├── index.ts\n├── modules\n│   ├── carModels\n│   │   ├── car.interface.ts\n│   │   ├── car.model.ts\n│   │   ├── car.router.ts\n│   │   ├── car.controller.ts\n│   │   ├── car.services.ts\n│   ├── order\n│   │   ├── order.interface.ts\n│   │   ├── order.model.ts\n│   │   ├── order.router.ts\n│   │   ├── order.controller.ts\n│   │   ├── order.services.ts\n├── app.ts\n├── server.ts\n```\n\n---\n\n## Models\n\n### Car Model\n```typescript\nbrand: string  // The brand or manufacturer of the car (e.g., Toyota, BMW, Ford).\nmodel: string  // The model of the car (e.g., Camry, 3 Series, Focus).\nyear: number   // The year of manufacture.\nprice: number  // Price of the car.\ncategory: string // Enum: Sedan, SUV, Truck, Coupe, Convertible.\ndescription: string // A brief description of the car's features.\nquantity: number // Quantity of the car available.\ninStock: boolean // Indicates if the car is in stock.\n```\n\n### Order Model\n```typescript\nemail: string // The email address of the customer.\ncar: ObjectId // The car ordered (reference the Car model).\nquantity: number // The quantity of the ordered car.\ntotalPrice: number // The total price (car price * quantity).\n```\n\n---\n\n## API Endpoints\n\n### 1. Create a Car\n**Endpoint:** `/api/cars`\n**Method:** `POST`\n**Request Body:**\n```json\n{\n  \"brand\": \"Toyota\",\n  \"model\": \"Camry\",\n  \"year\": 2024,\n  \"price\": 25000,\n  \"category\": \"Sedan\",\n  \"description\": \"A reliable family sedan with modern features.\",\n  \"quantity\": 50,\n  \"inStock\": true\n}\n```\n\n### 2. Get All Cars\n**Endpoint:** `/api/cars`\n**Method:** `GET`\n**Query Parameters:** `searchTerm`\n\n### 3. Get a Specific Car\n**Endpoint:** `/api/cars/:carId`\n**Method:** `GET`\n\n### 4. Update a Car\n**Endpoint:** `/api/cars/:carId`\n**Method:** `PUT`\n**Request Body:** Car details to update.\n\n### 5. Delete a Car\n**Endpoint:** `/api/cars/:carId`\n**Method:** `DELETE`\n\n### 6. Order a Car\n**Endpoint:** `/api/orders`\n**Method:** `POST`\n**Request Body:**\n```json\n{\n  \"email\": \"customer@example.com\",\n  \"car\": \"carId\",\n  \"quantity\": 1,\n  \"totalPrice\": 27000\n}\n```\n\n### 7. Calculate Revenue from Orders\n**Endpoint:** `/api/orders/revenue`\n**Method:** `GET`\n\n---\n\n## Revenue Aggregation Logic\n- Use MongoDB aggregation pipeline to calculate total revenue.\n- Multiply the price of each car by the quantity ordered.\n- Return the aggregated result.\n\n---\n\n## Future Enhancements\n- Add user authentication.\n- Enhance inventory management with notifications for low stock.\n- Implement additional analytics features.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasuselessbrain%2Fcar-store-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasuselessbrain%2Fcar-store-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasuselessbrain%2Fcar-store-server/lists"}