AI-Powered CNC Machine Monitoring and Electronic Production Record Management System with Google Sheets Integration.
- π CNC Machine Monitoring: Real-time tracking of CNC machine data (speed, temperature, coordinates, status)
- π Electronic Production Records (ePR): Complete production tracking with quality metrics
- π Google Sheets Integration: Automatic synchronization of all data to Google Sheets
- π€ AI-Powered Analytics:
- Intelligent data analysis and insights
- Anomaly detection
- Predictive maintenance recommendations
- Quality assessment and optimization suggestions
- π Web Interface: Modern, responsive dashboard for data management
- π RESTful API: Complete API for integration with existing systems
- Backend: Node.js with TypeScript, Express.js
- Database: SQLite (better-sqlite3)
- AI: OpenAI GPT-4
- Integration: Google Sheets API
- Frontend: HTML5, CSS3, Vanilla JavaScript
- Node.js 18+
- Google Cloud Project with Sheets API enabled
- OpenAI API key (optional, for AI features)
- Clone and install dependencies:
npm install- Set up environment variables:
cp .env.example .envEdit .env and configure:
GOOGLE_SPREADSHEET_ID: Your Google Sheets IDGOOGLE_SHEETS_CREDENTIALS_PATH: Path to Google service account credentialsOPENAI_API_KEY: Your OpenAI API key (optional)
-
Set up Google Sheets:
- Create a new Google Spreadsheet
- Create a service account in Google Cloud Console
- Download credentials JSON file to
./credentials/google-credentials.json - Share the spreadsheet with the service account email
-
Start the server:
# Development mode with auto-reload
npm run dev
# Production build
npm run build
npm start- Access the application:
- Web Interface: http://localhost:3000
- API Documentation: http://localhost:3000/
- Health Check: http://localhost:3000/health
GET /api/cnc?limit=100- Get CNC machine dataPOST /api/cnc- Record new CNC dataGET /api/cnc/analyze?limit=50&machine_id=xxx- AI analysis of CNC dataGET /api/cnc/anomalies?limit=100- Detect anomaliesGET /api/cnc/maintenance/:machineId- Predictive maintenance
GET /api/epr?limit=100- Get EPR recordsPOST /api/epr- Create new production recordPUT /api/epr/:id- Update recordPOST /api/epr/:id/complete- Complete record with AI analysisGET /api/epr/:id/analyze- Get AI analysis for specific record
POST /api/sync/cnc- Sync CNC data to Google SheetsPOST /api/sync/epr- Sync EPR records to Google SheetsPOST /api/sync/all- Sync all dataGET /api/sync/status- Get sync status
curl -X POST http://localhost:3000/api/cnc \
-H "Content-Type: application/json" \
-d '{
"machine_id": "CNC-001",
"machine_name": "Haas VF-2",
"status": "running",
"operation_type": "Milling",
"speed_rpm": 3000,
"feed_rate": 100.5,
"temperature": 45.2,
"coordinates_x": 125.50,
"coordinates_y": 200.25,
"coordinates_z": 50.00,
"program_name": "PART_001.nc"
}'curl -X POST http://localhost:3000/api/epr \
-H "Content-Type: application/json" \
-d '{
"production_order": "PO-2024-001",
"part_number": "PN-12345",
"part_name": "Engine Block",
"quantity": 100,
"machine_id": "CNC-001",
"operator_name": "John Doe",
"notes": "First batch of Q1 2024"
}'# Analyze CNC performance
curl http://localhost:3000/api/cnc/analyze?limit=50
# Detect anomalies
curl http://localhost:3000/api/cnc/anomalies
# Predictive maintenance
curl http://localhost:3000/api/cnc/maintenance/CNC-001curl -X POST http://localhost:3000/api/sync/all- Machine identification and status
- Operation parameters (speed, feed rate, temperature)
- 3D coordinates (X, Y, Z)
- Program information
- Sync tracking
- Production order details
- Part information
- Machine and operator tracking
- Quality metrics
- AI analysis results
- Sync tracking
- Performance Analysis: Comprehensive analysis of machine efficiency and performance trends
- Anomaly Detection: Automatic detection of unusual patterns or potential issues
- Predictive Maintenance: Forecasting maintenance needs based on historical data
- Quality Assessment: AI-powered analysis of production quality and defect patterns
- Optimization Recommendations: Suggestions for improving efficiency and reducing defects
The system automatically creates and manages two sheets:
- CNC_Data: All CNC machine data with timestamps
- EPR_Records: Complete production records with AI analysis
Data can be synced manually via API or automatically on a schedule.
# Install dependencies
npm install
# Run in development mode
npm run dev
# Build for production
npm run build
# Run tests
npm testcnc-epr-ai-cloud/
βββ src/
β βββ database/
β β βββ schema.ts # Database models and operations
β βββ services/
β β βββ googleSheets.ts # Google Sheets integration
β β βββ aiAnalyzer.ts # AI analysis services
β βββ routes/
β β βββ cncRoutes.ts # CNC API endpoints
β β βββ eprRoutes.ts # EPR API endpoints
β β βββ syncRoutes.ts # Sync API endpoints
β βββ server.ts # Main application
βββ public/
β βββ index.html # Web interface
βββ data/ # SQLite database (auto-created)
βββ credentials/ # Google credentials (create manually)
βββ package.json
- Never commit
.envor credentials files - Use service accounts for Google Sheets access
- Implement authentication for production use
- Restrict API access with proper CORS settings
- Keep API keys secure
MIT
For issues and questions, please contact your system administrator.