A real-time RFID inventory tracking system with CCTV integration for warehouse management.
- Node.js 18.x or higher
- MySQL 8.x
- Nginx
- PM2 (for production)
- Redis 6.x (optional, for WebSocket scaling)
- Clone and install dependencies
git clone <repository-url>
cd actinvent8
npm install- Environment setup
cp .env.example .env
# Edit .env with your configuration- Database setup
# Import your MySQL schema
mysql -u root -p < schema.sql- Start services
# Development
npm run dev
# Production
npm run build
node main_web_server.js
# Or with PM2
pm2 start ecosystem.config.jsβββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β RFID Readers βββββΆβ Node.js API βββββΆβ MySQL β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β React Frontendββββββ Nginx β β Redis β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β CCTV System β
βββββββββββββββββββ
- Frontend: React 18 + TypeScript
- Backend: Node.js + Express
- Database: MySQL 8
- Cache: Redis + LRU Cache
- Reverse Proxy: Nginx
- Process Manager: PM2
- Testing: Jest + Supertest
| Variable | Description | Default | Required |
|---|---|---|---|
NODE_ENV |
Environment | production |
β |
DB_HOST |
MySQL host | 127.0.0.1 |
β |
DB_USER |
MySQL user | - | β |
DB_PASSWORD |
MySQL password | - | β |
DB_NAME |
Database name | actinvent |
β |
SERVER_PORT |
API server port | 3002 |
β |
CCTV_BASE_URL |
CCTV server URL | - | β |
CCTV_LOGIN |
CCTV username | - | β |
CCTV_PASSWORD |
CCTV password | - | β |
METRICS_TOKEN |
Prometheus auth token | - | β |
WS_ALLOWED_ORIGINS |
WebSocket origins | - | β |
LOG_LEVEL |
Logging level | info |
β |
INPUT_CONCURRENCY |
RFID batch size | 20 |
β |
CORS_ORIGINS |
HTTP CORS origins | - | β |
- Video files: On-demand download with filesystem cache
- Static assets: 1-year browser cache (React build)
- API responses: No cache (real-time RFID data)
- Metrics: No cache (live Prometheus metrics)
GET /api/healthResponse
{
"status": "healthy",
"timestamp": "2025-01-01T00:00:00.000Z",
"checks": {
"database": { "status": "healthy" },
"filesystem": { "status": "healthy" }
},
"uptime": 12345
}GET /metricsNote: Requires Authorization: Bearer <METRICS_TOKEN> header
GET /api/items?page=1&limit=1000Response
{
"success": true,
"data": [
{
"epc": "300833B2DDD9014000038653",
"designation": "Camera Sony",
"updated_at": "2025-01-01T12:00:00.000Z",
"updated_atposix": 1735689600,
"group": "ENG1"
}
],
"meta": {
"count": 186,
"page": 1,
"limit": 1000
}
}POST /api/input
Content-Type: application/x-www-form-urlencoded
field_values=[["mac","reader","epc","antenna"]]GET /api/cctv/videos?timestamp=1735689600&designation=Camera&group_id=1# Start all services
npm run dev
# Frontend only
npm start
# Backend only
npm run server
# Backend with pretty logs
npm run dev:pretty
# Run tests
npm run test:api
npm run test:coverageactinvent8/
βββ src/ # React frontend
β βββ components/ # UI components
β βββ hooks/ # Custom React hooks
β βββ services/ # API services
β βββ pages/ # Application pages
βββ server/ # Node.js backend
β βββ routes/ # API routes
β βββ services/ # Business logic
β βββ middleware/ # Express middleware
β βββ config/ # Configuration
β βββ utils/ # Utilities
βββ tests/ # API tests
βββ static/ # Static assets & cache
βββ build/ # Production build
Key tables:
item: RFID inventory itemsgroupname: Item groups/categorieshist: Movement historyantenna: RFID reader locations
- CPU: 2+ cores
- RAM: 4GB minimum, 8GB recommended
- Storage: 100GB+ (for video cache)
- Network: 1Gbps recommended
- System Setup
# Install Node.js, MySQL, Redis, Nginx
sudo apt update
sudo apt install nodejs npm mysql-server redis-server nginx
# Install PM2 globally
sudo npm install -g pm2- Application Deployment
# Build application
npm run build
# Copy environment file
cp .env.example .env
# Configure .env for production
# Configure Nginx
sudo cp nginx-complete.conf /etc/nginx/sites-available/actinvent8
sudo ln -s /etc/nginx/sites-available/actinvent8 /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx- Process Management
# Start with PM2 (recommended)
pm2 start ecosystem.config.js
pm2 save
pm2 startup
# Or manual start
node main_web_server.jsserver {
listen 80;
server_name your-domain.com;
# Gzip compression
gzip on;
gzip_types text/plain application/json application/javascript text/css;
# Security headers
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
# Static files
location / {
root /var/www/actinvent8/build;
try_files $uri /index.html;
}
# API proxy
location ^~ /api/ {
proxy_pass http://127.0.0.1:3002;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}- Application:
GET /api/health - Readiness:
GET /api/ready(database connectivity) - WebSocket:
GET /api/ws/status - Metrics:
GET /metrics(with auth token)
# Application logs
tail -f logs/combined.log
# PM2 logs
pm2 logs actinvent8-web-server
# Nginx logs
sudo tail -f /var/log/nginx/access.log
sudo tail -f /var/log/nginx/error.log- Prometheus metrics:
GET /metrics(with auth) - Health status:
GET /api/health - System readiness:
GET /api/ready - WebSocket status:
GET /api/ws/status
# Check RFID input logs
curl -X POST http://localhost:3002/api/input \
-d "field_values=[[\"test\",\"reader\",\"epc\",\"1\"]]"
# Check system health
curl http://localhost:3002/api/health# Check Prometheus metrics (requires token)
curl -H "Authorization: Bearer $METRICS_TOKEN" http://localhost:3002/metrics | grep process
# Monitor video cache size
du -sh static/cache/videos/# Test database connection
mysql -u $DB_USER -p$DB_PASSWORD -h $DB_HOST $DB_NAME -e "SELECT 1;"
# Check database readiness
curl http://localhost:3002/api/ready- Database cache: 5-second TTL (configurable)
- Video cache: On-demand with LRU eviction
- Static assets: 1-year browser cache
- Indexed columns:
epc,updated_at,group_id - Connection pooling: 10 connections max
- Query optimization with prepared statements
- Gzip compression enabled
- Static file caching
- Proxy buffering for API calls
- Rate limiting: 200 requests per 15 minutes
- CORS: Configured allowed origins
- Input validation: Request size limits (10MB)
- Security headers: XSS protection, frame options
- Error handling: No sensitive data exposure
- Environment files secured (600 permissions)
- Database credentials rotated
- CORS origins configured
- Rate limiting enabled
- Security headers configured
- Input validation implemented
- Check the logs first
- Verify configuration
- Run health checks
- Check system resources
- Architecture: Node.js + React real-time polling
- Database: MySQL with optimized caching
- Performance: 5-second cache TTL, 1-second frontend refresh
- Monitoring: Comprehensive health checks and metrics
Production Ready: This system is configured for production deployment with monitoring, security, and performance optimizations.