A framework-free Node.js application with modular architecture.
RESTful API for inventory management with file-based persistence.
- Full CRUD operations (Create, Read, Update, Delete)
- File-based JSON storage
- Input validation
- CORS support
- Error handling
Items are stored with:
id(sequential number)name(string)price(number)size(S, M, or L)
apiServer.js- Main server codedata/items.json- JSON database
npm run apiServer runs port 3001
# 1. Clone the repository
git clone https://github.com/devGeorgeOwi/inventory-system.git
cd inventory-system
npm install
# 2. Initialize data
mkdir -p api-server/data
echo [] > api-server/data/items.json
# 3. Start both servers
npm start
npm run web
npm run apiOnce running, access these URLs
| Server | Port | URL |
|---|---|---|
| Web Server | 3000 | http://localhost:3000/ (Home) |
| http://localhost:3000/index.html (Student Profile) | ||
| http://localhost:3000/test-api.html (API Testing UI) | ||
| API Server | 3001 | http://localhost:3001/items (API Endpoint) |
| http://localhost:3001/ (API Documentation) |
```bash
# Get all items
curl http://localhost:3001/items
# Create an item
curl -X POST http://localhost:3001/items \
-H "Content-Type: application/json" \
-d '{"name":"T-Shirt","price":19.99,"size":"M"}'
```
```bash
# Change ports in webServer.js (line ~25) and apiServer.js (line ~220)
# Or kill existing processes:
# Windows: netstat -ano | findstr :3000
# Mac/Linux: lsof -i :3000
```
```bash
# Ensure all files exist:
ls -la web-server/public/index.html web-server/public/404.html web-server/webServer.js api-server/apiServer.js
```
1. Check if servers are running: npm start
2. Test API: curl http://localhost:3001/items
3. Check console for error messages
-
✅ Web server with custom 404 handling
-
✅ RESTful API with full CRUD operations
-
✅ File-based JSON persistence (no database needed)
-
✅ Input validation and error handling
-
✅ Cross-origin (CORS) support
-
✅ Modular, framework-free code
MIT License