Skip to content

Inventory Management System API built with Node.js, Express, and MongoDB. Includes CRUD operations, stock management, and Jest tests.

Notifications You must be signed in to change notification settings

TarushBatra/inventory-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“¦ Inventory Management API

Node.js Express MongoDB Jest

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.

About

Inventory Management System API built with Node.js, Express, and MongoDB. Includes CRUD operations, stock management, and Jest tests.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published