This is the backend API for the Inventory Management System project.
It provides CRUD operations to manage inventory items through a RESTful API.
Built with Node.js, Express.js, and MongoDB.
- Modular MVC architecture with controllers, models, and routes
- Environment configuration via
.envfile - Seed script to populate initial data
- Basic error handling
- Supports create, read, update, delete operations on inventory items
.
├── controllers/ # Request handlers for API endpoints
├── models/ # MongoDB schemas and models
├── routes/ # API route definitions
├── seed.js # Script to seed database with initial data
├── server.js # Entry point to start the Express server
├── .env # Environment variables (not committed to git)
├── package.json # Project dependencies and scripts
├── package-lock.json # Auto-generated dependency lock file
- Node.js (v14+ recommended)
- MongoDB (local or cloud instance)
- Clone the repo
git clone https://github.com/YourUsername/YourRepoName.git
cd YourRepoName- Install dependencies
npm install- Create a
.envfile in the root directory with the following content:
PORT=5000
MONGO_URI=your_mongodb_connection_string_here
Replace your_mongodb_connection_string_here with your actual MongoDB connection string.
Run the seed script to insert initial sample data:
node seed.jsStart the backend server:
npm startBy default, the server runs on http://localhost:5000.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/items |
Get all inventory items |
| GET | /api/items/:id |
Get a single item by ID |
| POST | /api/items |
Create a new inventory item |
| PUT | /api/items/:id |
Update an existing item by ID |
| DELETE | /api/items/:id |
Delete an item by ID |
POST /api/items
Content-Type: application/json
{
"name": "Chocolate Bar",
"quantity": 50,
"price": 2.99
}{
"_id": "607d1a1e1c4ae12f48f8e1a9",
"name": "Chocolate Bar",
"quantity": 50,
"price": 2.99,
"createdAt": "2024-05-21T10:15:30.000Z",
"updatedAt": "2024-05-21T10:15:30.000Z"
}Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.