https://github.com/tarushbatra/inventory-api
Inventory Management System API built with Node.js, Express, and MongoDB. Includes CRUD operations, stock management, and Jest tests.
https://github.com/tarushbatra/inventory-api
express jest mongodb nodejs rest-api
Last synced: 3 months ago
JSON representation
Inventory Management System API built with Node.js, Express, and MongoDB. Includes CRUD operations, stock management, and Jest tests.
- Host: GitHub
- URL: https://github.com/tarushbatra/inventory-api
- Owner: TarushBatra
- Created: 2025-10-02T13:52:41.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-10-02T14:28:37.000Z (9 months ago)
- Last Synced: 2025-10-23T16:35:35.611Z (8 months ago)
- Topics: express, jest, mongodb, nodejs, rest-api
- Language: JavaScript
- Homepage:
- Size: 68.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ฆ Inventory Management API
[](https://nodejs.org/)
[](https://expressjs.com/)
[](https://www.mongodb.com/)
[](https://jestjs.io/)
A simple **Inventory Management System API** built with **Node.js, Express, and MongoDB**.
It allows you to manage products, update stock, enforce business rules (no negative stock), and check for low stock thresholds.
---
## ๐ Features
- Product CRUD (Create, Read, Update, Delete)
- Stock management (increase / decrease stock with validation)
- Low stock check
- Prevent stock from going below zero
- Jest + Supertest for testing
- Postman Collection included for quick testing
---
## ๐ Project Structure
inventory-api/
โโโ src/
โ โโโ config/ # Database connection
โ โโโ controllers/ # Request handlers
โ โโโ models/ # Mongoose models
โ โโโ routes/ # API routes
โ โโโ services/ # Business logic
โ โโโ utils/ # Error handling
โ โโโ app.js # Express app
โ โโโ server.js # Server entrypoint
โโโ tests/ # Jest + Supertest test cases
โโโ .gitignore
โโโ package.json
โโโ README.md
โโโ Inventory API.postman_collection.json
---
## โ๏ธ Setup & Installation
### 1. Clone the repo
``bash
git clone https://github.com/TarushBatra/inventory-api.git
cd inventory-api
2. Install dependencies
npm install
3. Setup environment variables
Create a .env file in root:
PORT=5000
MONGO_URI=mongodb://localhost:27017/inventoryDB
4. Start development server
npm run dev
Server runs at ๐ http://localhost:5000
๐ก API Endpoints
Products
Method Endpoint Description
GET /api/products Get all products
GET /api/products/:id Get product by ID
POST /api/products Create a new product
PUT /api/products/:id Update product details
DELETE /api/products/:id Delete product
PATCH /api/products/:id/increase Increase stock
PATCH /api/products/:id/decrease Decrease stock
GET /api/products/low-stock Get low stock products
๐งช Running Tests
Run Jest + Supertest tests:
npm test
โ
Tests include:
Create product
Increase stock
Decrease stock
Prevent negative stock
Low stock check
๐ฌ Postman Collection
File: Inventory API.postman_collection.json
To use:
Open Postman
Go to Collections โ Import
Select this file
Run sample requests for all endpoints
๐จโ๐ป Tech Stack
Node.js
Express.js
MongoDB + Mongoose
Jest + Supertest
๐ License
This project is licensed under the MIT License.