All protected routes require API key in header:
X-API-Key: your_api_key_hereConnect to WebSocket:
const socket = io('wss://backendpms-wvoo.onrender.com', {
path: '/socket.io',
auth: { token: 'your_api_key' }
});// Server -> Client Events
socket.on('inventory_update', (data: { productId: string, stock: number }) => {})
socket.on('order_status', (data: { orderId: string, status: string }) => {})
socket.on('system_alert', (data: { type: string, message: string }) => {})
// Client -> Server Events
socket.emit('subscribe_inventory', productId: string)
socket.emit('subscribe_order', orderId: string)// Create Product
POST /api/pms/products
Content-Type: application/json
{
"name": string,
"description": string,
"price": number,
"categoryId": string,
"images": string[]
}
// Publish Product
PUT /api/pms/products/:id/publish
Content-Type: application/json
{
"status": "published"
}
// Update Product
PATCH /api/pms/products/:id
Content-Type: application/json
{
"name?": string,
"price?": number
// ...other fields
}// Check Stock
GET /api/inventory/stock/:productId
// Adjust Stock
POST /api/inventory/adjust
Content-Type: application/json
{
"productId": string,
"quantity": number,
"type": "increment" | "decrement"
}
// Get Low Stock Alerts
GET /api/inventory/alerts// Create Order
POST /api/pms/orders
Content-Type: application/json
{
"items": Array<{
"productId": string,
"quantity": number
}>,
"customerId": string,
"shippingAddress": string
}
// Update Order Status
PATCH /api/pms/orders/:id/status
Content-Type: application/json
{
"status": "confirmed" | "processing" | "shipped" | "delivered"
}// Get Sales Analytics
GET /api/analytics/sales
Query Params:
startDate: YYYY-MM-DD
endDate: YYYY-MM-DD
groupBy: "day" | "week" | "month"
// Get Inventory Metrics
GET /api/analytics/inventory/metrics// System Health
GET /health
Response:
{
"status": "ok" | "degraded",
"timestamp": string,
"checks": {
"database": { healthy: boolean, latency?: number },
"memory": { healthy: boolean, usage: object },
"websocket": { healthy: boolean, connections: number },
"uptime": number
}
}Redis configuration (via Upstash):
REDIS_URL=your_upstash_url
REDIS_TOKEN=your_upstash_token// Standard Limits
- 100 requests per minute for API endpoints
- 1000 WebSocket messages per minute
- 50 concurrent connections per client ┌─────────────────┐
│ API Request │
└────────┬────────┘
│
┌──────────┴──────────┐
│ Authentication │
└──────────┬──────────┘
│
┌─────────────────┬┴────────────────┐
│ │ │
┌───────▼──────┐ ┌──────▼─────┐ ┌───────▼──────┐
│ /pms/* │ │ /products/ │ │ /inventory/ │
│ Endpoints │ │ Endpoints │ │ Endpoints │
└───────┬──────┘ └──────┬─────┘ └───────┬──────┘
│ │ │
┌───────▼──────┐ ┌──────▼─────┐ ┌───────▼──────┐
│ PMS Service │ │ Product │ │ Inventory │
│ Layer │ │ Service │ │ Service │
└───────┬──────┘ └──────┬─────┘ └───────┬──────┘
│ │ │
└────────┬──────┴─────────────────┘
│
┌───────▼───────┐
│ Database │
│ Layer │
└───────┬───────┘
│
┌───────▼───────┐
│ Cache │
│ Layer │
└───────┬───────┘
│
┌───────▼───────┐
│ Response │
└───────────────┘
- Base URL:
/api/pms - Authentication: API Key required
- Rate Limit: 100 requests/minute
- Base URL:
/api/products - Caching: 5 minutes
- Real-time updates via WebSocket
- Base URL:
/api/inventory - Real-time sync enabled
- Transaction support