You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cd backend
npm install
# Create database
createdb cmms_thammasat
psql cmms_thammasat < ../database/schema.sql
psql cmms_thammasat < ../database/seed.sql
# Configure environment
cp ../.env.example .env
# Edit .env with your local DB credentials# Start development server
npm run dev
# Server: http://localhost:5000# API Docs: http://localhost:5000/api/docs
Frontend setup
cd frontend
npm install
# Configure environmentecho"REACT_APP_API_URL=http://localhost:5000/api/v1"> .env
echo"REACT_APP_SOCKET_URL=http://localhost:5000">> .env
# Start development server
npm start
# App: http://localhost:3000
🧪 Testing
Run all tests
cd backend
# Unit tests (AI service, KPI calculations, SLA logic)
npm test# Integration tests (requires PostgreSQL)
npm run test:integration
# Coverage report
npm test -- --coverage
Test the API manually
# Login
TOKEN=$(curl -s -X POST http://localhost:5000/api/v1/auth/login \ -H "Content-Type: application/json" \ -d '{"email":"manager@thammasat.ac.th","password":"password123"}' \| jq -r '.data.accessToken')# List equipment
curl http://localhost:5000/api/v1/equipment \
-H "Authorization: Bearer $TOKEN"| jq .# Get KPI summary (last 30 days)
curl "http://localhost:5000/api/v1/kpi/summary?from=$(date -d '30 days ago' -Iseconds)" \
-H "Authorization: Bearer $TOKEN"| jq .data.oee
# Start a breakdown downtime
curl -X POST http://localhost:5000/api/v1/downtime \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{ "equipment_id": "55555555-0000-0000-0000-000000000001", "type": "breakdown", "category": "mechanical", "description": "Spindle bearing noise" }'| jq .# → Work Order auto-created by DB trigger!# Run AI prediction
curl http://localhost:5000/api/v1/equipment/55555555-0000-0000-0000-000000000001/predict \
-H "Authorization: Bearer $TOKEN"| jq .data.riskScore
🚀 Production Deployment
Docker Compose (Single server)
# Production .env (change ALL passwords!)
JWT_SECRET=$(openssl rand -base64 48)
DB_PASSWORD=$(openssl rand -base64 32)
docker compose -f docker-compose.yml up -d
# With monitoring stack (Prometheus + Grafana)
docker compose --profile monitoring up -d