StationeryX is a backend service for managing a stationery store's operations — product catalog, stock levels, and order processing. Built with a clean modular architecture separating routes, controllers, and services for scalability and testability.
- 📦 Product Management — Create, read, update, and delete stationery products
- 📊 Inventory Tracking — Real-time stock level monitoring and updates
- 🛒 Order Processing — Place and manage customer orders
- 🔍 Optimized Queries — MongoDB indexing for fast product catalog lookups
- 🧱 Modular Architecture — Separated routes, controllers, and services layer
- ✅ Input Validation — Request validation and centralized error handling
| Layer | Technology |
|---|---|
| Runtime | Node.js |
| Framework | Express.js |
| Database | MongoDB (Mongoose ODM) |
| Architecture | RESTful API, MVC pattern |
StationaryX-BD/
├── src/
│ ├── controllers/ # Request handlers for each resource
│ │ ├── productController.js
│ │ ├── orderController.js
│ │ └── inventoryController.js
│ ├── models/ # Mongoose schemas
│ │ ├── Product.js
│ │ └── Order.js
│ ├── routes/ # Express route definitions
│ │ ├── productRoutes.js
│ │ ├── orderRoutes.js
│ │ └── inventoryRoutes.js
│ ├── middleware/ # Error handling, validation
│ └── app.js # Express app setup
└── server.js # Entry point
- Node.js v18+
- MongoDB instance (local or MongoDB Atlas)
git clone https://github.com/Athang69/StationaryX-BD.git
cd StationaryX-BDnpm installCreate a .env file:
PORT=5000
MONGO_URI=your_mongodb_connection_string# Development
npm run dev
# Production
npm startServer runs at http://localhost:5000
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/products |
Get all products |
| GET | /api/products/:id |
Get product by ID |
| POST | /api/products |
Create new product |
| PUT | /api/products/:id |
Update product details |
| DELETE | /api/products/:id |
Delete product |
Sample Request — Create Product:
POST /api/products
{
"name": "Pilot G2 Pen",
"category": "Pens",
"price": 45,
"stock": 200,
"sku": "PEN-G2-BLK"
}Sample Response:
{
"success": true,
"data": {
"_id": "64abc123...",
"name": "Pilot G2 Pen",
"category": "Pens",
"price": 45,
"stock": 200,
"sku": "PEN-G2-BLK",
"createdAt": "2024-09-01T10:00:00Z"
}
}| Method | Endpoint | Description |
|---|---|---|
| GET | /api/inventory |
Get all stock levels |
| PATCH | /api/inventory/:id |
Update stock for a product |
Sample Request — Update Stock:
PATCH /api/inventory/64abc123
{
"stock": 150
}| Method | Endpoint | Description |
|---|---|---|
| GET | /api/orders |
Get all orders |
| POST | /api/orders |
Place a new order |
| GET | /api/orders/:id |
Get order by ID |
| PATCH | /api/orders/:id |
Update order status |
Sample Request — Place Order:
POST /api/orders
{
"items": [
{ "productId": "64abc123", "quantity": 3 }
],
"customerName": "John Doe"
}PORT=5000
MONGO_URI=mongodb+srv://<username>:<password>@cluster.mongodb.net/stationeryx- Modular MVC structure — Routes, controllers, and models are fully separated so each layer can be tested and extended independently
- MongoDB with indexing — Product SKU and category fields are indexed for fast catalog queries under load
- Centralized error handling — A single error middleware catches and formats all errors consistently across the API