An AI-powered full stack application for classifying operational deviations, identifying degraded process safety barriers, finding similar historical events, and recommending preventive actions before escalation.
Industrial teams often capture deviations, alarms, PTW gaps, unsafe conditions, and barrier impairments in disconnected spreadsheets, emails, and text-heavy reports. This project turns that operational noise into a clear workflow:
- register a deviation in seconds;
- classify severity and affected barrier with AI;
- retrieve similar signals from the event history;
- generate preventive actions for operations, HSE, and leadership.
The demo animation above is designed for a non-technical user. It shows this sequence:
- dashboard with high-risk indicators;
- deviation registration form;
- AI-generated risk analysis;
- similar historical events;
- preventive recommendations and executive summary.
- Deviation intake: capture title, description, unit, area, asset, and event type hint
- AI analysis: classify event type, severity, barrier, confidence, reasoning, and recommendations
- Similarity search: compare a new event with previous records using embeddings when OpenAI is configured, or lexical similarity in fallback mode
- Executive summary: produce a concise paragraph for supervisors and managers
- Observability starter: Prometheus metrics endpoint, Grafana + Prometheus in Docker Compose
- Demo-safe fallback: runs without an API key using deterministic heuristics so the UI is still useful locally
process-safety-barrier-intelligence/
├── apps/
│ ├── api/ # Express + TypeScript API with OpenAI integration
│ └── web/ # React + Vite UI for dashboard and intake workflow
├── docs/demo/ # README demo assets (.gif)
├── infra/ # Prometheus and Grafana provisioning
└── docker-compose.yml
- Express
- TypeScript
- OpenAI official JavaScript SDK
- Prometheus metrics
- Pino logging
- file-based JSON persistence for the MVP demo store
- React
- Vite
- TypeScript
- Recharts
- Prometheus
- Grafana
- application health endpoint
/metricsendpoint for scrape-based monitoring
When OPENAI_API_KEY is present, the backend uses:
- Responses API for event classification
- Embeddings API for semantic similarity support
- Moderations API before classification
When the key is absent, the system falls back to deterministic rules so the project still works end-to-end as a portfolio demo.
npm installcp .env.example .envSet your key in .env when you want live OpenAI analysis:
OPENAI_API_KEY=your_key_here
OPENAI_MODEL=gpt-5-mini
OPENAI_EMBEDDING_MODEL=text-embedding-3-smallnpm run dev- Web UI:
http://localhost:5173 - API:
http://localhost:4000 - Health:
http://localhost:4000/api/health - Metrics:
http://localhost:4000/metrics
docker compose up --buildServices:
- Web:
http://localhost:5173 - API:
http://localhost:4000 - Prometheus:
http://localhost:9090 - Grafana:
http://localhost:3001
user:admin
password:admin
Try the pre-filled example in the UI:
Gas detector unavailable during maintenance in compressor K-101. Temporary monitoring was not activated.
Expected value:
- high severity classification
- gas detection barrier impairment
- preventive recommendations
- similar events from the seeded demo history
Returns service status and whether OpenAI is configured.
Lists all stored demo events.
Returns counts for dashboard cards and charts.
Returns a short executive summary paragraph.
Creates and analyzes a new deviation.
Example payload:
{
"title": "Hot work permit missing isolation checklist",
"description": "Hot work started near piping rack with a signed permit, but the isolation checklist section was left blank and no gas test time was recorded.",
"unit": "Terminal West",
"area": "Pipe Rack 3",
"asset": "PR-3",
"eventTypeHint": "ptw_deviation"
}The project ships with a small seeded dataset so the dashboard is not empty:
- gas detector unavailable during maintenance
- hot work permit deviation
- recurring high pressure alarm
- corrosion on small bore connection
- procedural drift around temporary barricades
- swap demo persistence for PostgreSQL
- add user authentication and role-based views
- support CSV import for audit findings and near misses
- introduce action tracking and ownership workflow
- add OTEL traces for end-to-end analysis flow
- add file attachments and evidence snapshots
- add vector database support for larger event histories
The README GIF should help a user understand the application in ~10 seconds:
- dashboard with risk indicators
- deviation registration
- AI classification
- similar events
- preventive actions
MIT
