The Inventory Management API provides a robust system to manage products, warehouses, and stock efficiently. It includes authentication and authorization for admins to perform restricted actions.
- User Authentication & Authorization (JWT-based)
- Product Management (CRUD operations)
- Warehouse Management (CRUD operations)
- Stock Management (Track stock levels in warehouses)
- Admin-Only Operations (Product, warehouse, and stock modifications)
- Public API Access (For retrieving product and warehouse data)
- Error Handling & Validation
- Node.js (>= 14.x)
- MongoDB (local or cloud instance)
- Clone the repository:
git clone https://github.com/rissshaaav-dev/warehouseManagementBackend.git cd inventory-management
- Install dependencies:
npm install
- Create a
.envfile and configure environment variables:
PORT=5000 MONGO_URI=your_mongodb_connection_string JWT_SECRET=your_secret_key
- Start the server:
npm start
The API will be running at http://localhost:5000/api.
| Method | Route | Description | Access |
|---|---|---|---|
| POST | /api/products |
Create a new product | Admin Only |
| GET | /api/products |
Get all products | Public |
| GET | /api/products/:id |
Get a product by ID | Public |
| PUT | /api/products/:id |
Update product details | Admin Only |
| DELETE | /api/products/:id |
Delete a product | Admin Only |
| Method | Route | Description | Access |
|---|---|---|---|
| POST | /api/warehouses |
Create a new warehouse | Admin Only |
| GET | /api/warehouses |
Get all warehouses | Public |
| GET | /api/warehouses/:id |
Get a warehouse by ID | Public |
| PUT | /api/warehouses/:id |
Update warehouse details | Admin Only |
| DELETE | /api/warehouses/:id |
Delete a warehouse | Admin Only |
| Method | Route | Description | Access |
|---|---|---|---|
| POST | /api/stocks |
Add stock to a warehouse | Admin Only |
| GET | /api/stocks/:productId/:warehouseId |
Get stock details for a product in a warehouse | Public |
| PUT | /api/stocks/:id |
Update stock quantity | Admin Only |
| DELETE | /api/stocks/:id |
Delete stock record | Admin Only |
This API uses JWT-based authentication. To access protected routes, include the token in the request headers:
Authorization: Bearer YOUR_ACCESS_TOKEN
All errors return JSON responses with appropriate HTTP status codes:
{ "message": "Error message here" }
- Open Swagger UI at
http://localhost:5000/api-docs - Click on the Authorize button (🔑)
- Enter your token in the format:
Bearer YOUR_ACCESS_TOKEN - Click Authorize and test protected routes.
This project is licensed under the MIT License.
For any questions or issues, feel free to reach out!