Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Process Safety Deviation & Barrier Intelligence Platform

CI OpenAI Express React Vite TypeScript PostgreSQL Prometheus Grafana Docker GitHub%20Actions

Process Safety Platform Demo

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.

Why this application exists

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:

  1. register a deviation in seconds;
  2. classify severity and affected barrier with AI;
  3. retrieve similar signals from the event history;
  4. generate preventive actions for operations, HSE, and leadership.

Demo flow shown in the GIF

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.

Core capabilities

  • 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

Architecture

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

Backend

  • Express
  • TypeScript
  • OpenAI official JavaScript SDK
  • Prometheus metrics
  • Pino logging
  • file-based JSON persistence for the MVP demo store

Frontend

  • React
  • Vite
  • TypeScript
  • Recharts

Observability

  • Prometheus
  • Grafana
  • application health endpoint
  • /metrics endpoint for scrape-based monitoring

OpenAI usage

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.

Local setup

1) Install dependencies

npm install

2) Create your environment file

cp .env.example .env

Set 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-small

3) Run the full stack app

npm run dev
  • Web UI: http://localhost:5173
  • API: http://localhost:4000
  • Health: http://localhost:4000/api/health
  • Metrics: http://localhost:4000/metrics

Run with Docker Compose

docker compose up --build

Services:

  • Web: http://localhost:5173
  • API: http://localhost:4000
  • Prometheus: http://localhost:9090
  • Grafana: http://localhost:3001
    user: admin
    password: admin

Sample use case

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

API endpoints

GET /api/health

Returns service status and whether OpenAI is configured.

GET /api/events

Lists all stored demo events.

GET /api/dashboard

Returns counts for dashboard cards and charts.

GET /api/summary

Returns a short executive summary paragraph.

POST /api/events

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"
}

Seeded demo scenarios

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

Roadmap ideas

  • 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

Screens and storyboards

The README GIF should help a user understand the application in ~10 seconds:

  1. dashboard with risk indicators
  2. deviation registration
  3. AI classification
  4. similar events
  5. preventive actions

License

MIT

About

AI-powered platform for detecting operational deviations, analyzing barrier degradation, and generating preventive safety insights for industrial and Oil & Gas environments.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages