On-Site Manufacturing Co-Pilot — A local-first AI agent system deployed inside factories to help operators, supervisors, and managers make decisions in real time.
- Overview
- Core Capabilities
- Tech Stack
- Architecture
- Getting Started
- Project Structure
- API Reference
- AI Agent System
- Real-Time Updates
- Offline-First Design
- Screenshots
FactoryOps is a production-grade manufacturing intelligence platform that combines:
- Real-time monitoring of production lines, machines, and sensors
- AI-powered incident analysis with root cause detection
- Natural language chat interface for operators on tablets
- Auto-generated executive briefs for managers
- Offline-first architecture for factory reliability
The system is designed to run on-premise within factory networks, ensuring data security and low-latency responses even without internet connectivity.
Operators report issues in plain English. The AI agent:
- Asks clarifying follow-up questions
- Logs incidents automatically
- Suggests safe, immediate actions
- Provides step-by-step troubleshooting
"Why did Line 2 stop at 3:40 PM?"
The agent correlates:
- Machine sensor logs
- Shift schedules
- Historical machine performance
- Recent similar incidents
Real-time visibility into:
- Bottlenecks and delays
- Machine efficiency by line
- Cost impact of downtime
- Sensor anomaly alerts
Every morning, managers receive:
- Production summary vs. targets
- Estimated loss calculations
- Risk identification
- Prioritized action items
| Category | Technology |
|---|---|
| Frontend | Next.js 14 + React 18 + TypeScript |
| Styling | Tailwind CSS + Custom Industrial Theme |
| State Management | Zustand |
| Charts | Recharts |
| Database | SQLite (better-sqlite3) |
| Real-time | Server-Sent Events (SSE) |
| AI Agent | Custom reasoning engine (Plan → Act → Verify) |
┌─────────────────────────────────────────────────────────────┐
│ FRONTEND (Next.js) │
├─────────────────────────────────────────────────────────────┤
│ Dashboard │ Operator Chat │ Incidents │ Manager Brief│
├─────────────────────────────────────────────────────────────┤
│ Zustand State Store │
│ Custom React Hooks │
└───────────────────────────┬─────────────────────────────────┘
│
┌────────▼────────┐
│ API Routes │
│ (Next.js API) │
└────────┬────────┘
│
┌───────────────────┼───────────────────┐
│ │ │
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ SQLite DB │ │ AI Agent │ │ SSE Stream │
│ (Machines, │ │ (Reasoning │ │ (Real-time │
│ Incidents, │ │ Engine) │ │ Updates) │
│ Downtime) │ │ │ │ │
└───────────────┘ └───────────────┘ └───────────────┘
┌──────────────────────────────────────────────────────────────┐
│ AGENT REASONING LOOP │
├──────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────┐ ┌─────────┐ ┌───────────┐ ┌──────────┐ │
│ │ OBSERVE │ → │ ANALYZE │ → │ CORRELATE │ → │RECOMMEND │ │
│ │ │ │ │ │ │ │ │ │
│ │ Gather │ │ Pattern │ │ Cross-ref │ │ Generate │ │
│ │ context │ │ match │ │ history │ │ actions │ │
│ └─────────┘ └─────────┘ └───────────┘ └────┬─────┘ │
│ │ │
│ ▼ │
│ ┌──────────┐ │
│ │ VERIFY │ │
│ │ │ │
│ │Calculate │ │
│ │confidence│ │
│ └──────────┘ │
└──────────────────────────────────────────────────────────────┘
- Node.js 18+
- npm or yarn
# Clone the repository
git clone https://github.com/yourusername/factoryops-ai-agent.git
cd factoryops-ai-agent
# Install dependencies
npm install
# Seed the database with sample data
npm run db:seed
# Start development server
npm run devOpen http://localhost:3000 in your browser.
npm run build
npm startfactoryops/
├── src/
│ ├── agents/
│ │ └── factory-agent.ts # AI reasoning engine
│ ├── components/
│ │ ├── Dashboard.tsx # Real-time metrics dashboard
│ │ ├── OperatorChat.tsx # Tablet-friendly chat UI
│ │ ├── IncidentsView.tsx # Incident list & detail
│ │ ├── ManagerBrief.tsx # Auto-generated daily report
│ │ └── Layout.tsx # App shell with navigation
│ ├── db/
│ │ ├── index.ts # Database operations
│ │ └── seed.ts # Sample data generation
│ ├── hooks/
│ │ └── useData.ts # Custom data hooks + SSE
│ ├── pages/
│ │ ├── api/
│ │ │ ├── machines/ # Machine CRUD
│ │ │ ├── incidents/ # Incident management
│ │ │ ├── chat/ # AI chat endpoint
│ │ │ ├── metrics/ # Dashboard data
│ │ │ ├── downtime/ # Downtime tracking
│ │ │ ├── brief/ # Daily brief generation
│ │ │ └── events/ # SSE endpoint
│ │ ├── _app.tsx
│ │ ├── _document.tsx
│ │ └── index.tsx
│ ├── styles/
│ │ └── globals.css # Industrial dark theme
│ ├── types/
│ │ └── index.ts # TypeScript definitions
│ └── utils/
│ └── store.ts # Zustand state management
├── package.json
├── tsconfig.json
├── tailwind.config.js
└── README.md
| Endpoint | Method | Description |
|---|---|---|
/api/machines |
GET | List all machines |
/api/machines?id={id} |
GET | Get machine by ID |
/api/machines |
PATCH | Update machine status |
| Endpoint | Method | Description |
|---|---|---|
/api/incidents |
GET | List incidents (with filters) |
/api/incidents?id={id} |
GET | Get incident details |
/api/incidents |
POST | Create new incident |
/api/incidents |
PATCH | Update incident |
| Endpoint | Method | Description |
|---|---|---|
/api/chat |
POST | Send message to AI agent |
Request Body:
{
"message": "Machine is making a grinding noise",
"incidentId": "optional-existing-id",
"machineId": "optional-machine-id"
}Response:
{
"success": true,
"data": {
"message": "I've noted your report...",
"thoughts": [...],
"suggestedActions": ["Check bearings", "Verify lubrication"],
"incidentId": "created-incident-id",
"incidentCreated": true
}
}| Endpoint | Method | Description |
|---|---|---|
/api/metrics |
GET | Dashboard metrics |
/api/metrics?type=lines |
GET | Line statuses |
/api/metrics?type=trend&hours=24 |
GET | Production trend |
| Endpoint | Method | Description |
|---|---|---|
/api/events |
GET (SSE) | Subscribe to real-time updates |
Event Types:
metrics- Updated dashboard metricslines- Line status changesincidents- New/updated incidentsalert- System alerts
| Endpoint | Method | Description |
|---|---|---|
/api/brief |
GET | Get today's brief |
/api/brief?date=YYYY-MM-DD |
GET | Get brief for date |
/api/brief |
POST | Generate new brief |
The FactoryOps AI Agent uses a Plan → Act → Verify reasoning loop:
- Gather incident context
- Extract keywords from operator reports
- Identify relevant machine and sensor data
- Match against known failure patterns:
- Temperature issues
- Vibration anomalies
- Pressure problems
- Electrical faults
- Mechanical failures
- Quality defects
- Cross-reference with machine history
- Identify time-based patterns (shift correlation)
- Analyze sensor readings for anomalies
- Generate prioritized actions
- Assign to appropriate personnel
- Estimate impact of each recommendation
- Calculate confidence scores
- Assess risk levels
- Generate summary for stakeholders
The system uses Server-Sent Events (SSE) for real-time dashboard updates:
// Client-side subscription
const eventSource = new EventSource('/api/events');
eventSource.addEventListener('metrics', (event) => {
const data = JSON.parse(event.data);
updateDashboard(data);
});
eventSource.addEventListener('alert', (event) => {
const alert = JSON.parse(event.data);
showNotification(alert);
});Updates are pushed every 5 seconds for:
- Production metrics
- Machine status changes
- New alerts and incidents
FactoryOps is built for factory reliability:
- Local SQLite Database - All data stored on-premise
- Service Worker Ready - Can cache critical assets
- Offline Queue - Actions queued when connectivity lost
- Sync on Reconnect - Automatic synchronization
The UI shows connection status and gracefully degrades when offline.
Real-time production metrics with efficiency tracking, line status, and bottleneck identification.
Tablet-optimized chat interface with suggested actions and incident tracking.
Detailed incident view with AI analysis, root causes, and recommendations.
Auto-generated daily report with KPIs, trends, and action items.
- Integration with PLC/SCADA systems
- Predictive maintenance ML models
- Multi-factory support
- Mobile app for on-the-go access
- Voice input for operators
- Shift handoff automation
MIT License - see LICENSE for details.
Built with ❤️ for manufacturing excellence.
"Making factories smarter, one incident at a time."