Skip to content

devGeorgeOwi/inventory-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📦 Inventory Management System

A framework-free Node.js application with modular architecture.

API Server

RESTful API for inventory management with file-based persistence.

Features

  • Full CRUD operations (Create, Read, Update, Delete)
  • File-based JSON storage
  • Input validation
  • CORS support
  • Error handling

Data Structure

Items are stored with:

  • id (sequential number)
  • name (string)
  • price (number)
  • size (S, M, or L)

Files

  • apiServer.js - Main server code
  • data/items.json - JSON database

Usage

npm run api

Server runs port 3001

🚀 Quick Start

# 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 api

🌐 Access Points

Once 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)

📡 Quick API Test

```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"}'
```

🛠️ Troubleshooting

```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
```

Missing files error?

```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
```

API not responding?

1. Check if servers are running: npm start

2. Test API: curl http://localhost:3001/items

3. Check console for error messages

📦 What's Included

  • ✅ 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

📄 License

MIT License

About

A lightweight Node.js web and API server built without external frameworks, featuring a static web server with custom 404 handling and a RESTful inventory management API with file-based persistence.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors