# ansh-raj08/oil-hsse architecture

> Architecture diagram of the GitHub repository ansh-raj08/oil-hsse, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ansh-raj08/oil-hsse
- Repository: https://github.com/ansh-raj08/oil-hsse

## Overview

OIL’s HSSE platform turns safety narratives and uploaded incident datasets into explainable SIF-precursor triage, risk and escalation signals, regulatory classifications, and supervisory actions. The documented batch path parses, validates, cleans, and normalizes CSV data before analysis; incidents then feed operational review, analytics, and governance. The repository also documents chatbot, guidelines, and offline mapping capabilities. Some backend routes and frontend integrations were not sampled, so those links rely on the README; uncertain implementation-level connections are omitted.

Main entry points: [`oil-hsse-app/src/lib/csv/pipeline.ts`](https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/lib/csv/pipeline.ts) (CSV pipeline), [`backend/app/logic_engine/analyzer.py`](https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/logic_engine/analyzer.py) (Narrative analysis), [`backend/app/main.py`](https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/main.py) (FastAPI application), [`oil-hsse-app/src/context/SafetyContext.tsx`](https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/context/SafetyContext.tsx) (Incident triage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Ingestion &amp; Quality"]
  node_ingestion_ui["Dataset upload<br/>[IngestionModal.tsx]"]
  node_csv_pipeline["CSV pipeline<br/>[pipeline.ts]"]
  node_csv_parse["CSV parsing<br/>[parser.ts]"]
  node_csv_validate["Data validation<br/>[validator.ts]"]
  node_csv_clean["Data cleaning<br/>[cleaner.ts]"]
  node_csv_normalize["Incident normalization<br/>[normalizer.ts]"]
end

subgraph group_analysis["Safety Intelligence"]
  node_analysis_engine["Narrative analysis<br/>[analyzer.py]"]
  node_negation["Negation detection"]
  node_risk["Risk scoring<br/>[risk_scorer.py]"]
  node_lsr["Life-saving rules<br/>[lsr_mapper.py]"]
  node_recommendations["Control recommendations"]
  node_escalation["Escalation likelihood"]
end

subgraph group_backend["API &amp; Governance"]
  node_api["FastAPI application<br/>[main.py]"]
  node_incident_routes["Incident management<br/>[incidents.py]"]
  node_dataset_routes["Dataset lifecycle<br/>[datasets.py]"]
  node_rules_routes["Rules &amp; analysis<br/>[rules.py]"]
  node_auth_routes["Authentication API<br/>[auth.py]"]
  node_schemas["Domain schemas<br/>[schemas.py]"]
end

subgraph group_frontend["Supervisory Console"]
  node_triage["Incident triage<br/>[SafetyContext.tsx]"]
  node_dashboard["Dashboard &amp; analytics<br/>[page.tsx]"]
  node_explain["Explainability review"]
  node_map["Incident heatmap"]
  node_chatbot["HSSE chatbot<br/>[page.tsx]"]
  node_guidelines["Safety guidelines<br/>[page.tsx]"]
  node_web_client["Web API client<br/>[client.ts]"]
end

subgraph group_persistence["Identity &amp; Data"]
  node_auth_service["Role authorization<br/>[auth_service.py]"]
  node_storage[("Supabase persistence")]
end

node_field(("Safety staff"))
node_supervisor(("HSSE supervisor"))

node_field -->|"uploads reports"| node_ingestion_ui
node_ingestion_ui -->|"processes CSV"| node_csv_pipeline
node_csv_pipeline -->|"parses rows"| node_csv_parse
node_csv_pipeline -->|"validates rows"| node_csv_validate
node_csv_pipeline -->|"cleans rows"| node_csv_clean
node_csv_pipeline -->|"normalizes incidents"| node_csv_normalize
node_csv_pipeline -.->|"runs inference"| node_analysis_engine
node_analysis_engine -->|"detects negation"| node_negation
node_analysis_engine -->|"scores risk"| node_risk
node_analysis_engine -->|"classifies rules"| node_lsr
node_analysis_engine -->|"generates controls"| node_recommendations
node_analysis_engine -->|"evaluates escalation"| node_escalation
node_api -->|"routes incidents"| node_incident_routes
node_api -->|"routes datasets"| node_dataset_routes
node_api -->|"routes rules"| node_rules_routes
node_api -->|"routes auth"| node_auth_routes
node_incident_routes -.->|"manages records"| node_storage
node_dataset_routes -.->|"manages datasets"| node_storage
node_rules_routes -->|"uses classification"| node_lsr
node_rules_routes -->|"uses controls"| node_recommendations
node_auth_routes -->|"validates payloads"| node_schemas
node_auth_service -->|"checks profiles"| node_storage
node_web_client -->|"calls service"| node_api
node_dashboard -.->|"requests analytics"| node_web_client
node_triage -.->|"loads incidents"| node_web_client
node_triage -.->|"supports review"| node_explain
node_triage -.->|"shows locations"| node_map
node_supervisor -->|"reviews alerts"| node_triage
node_supervisor -->|"monitors metrics"| node_dashboard
node_supervisor -->|"asks guidance"| node_chatbot
node_supervisor -->|"consults rules"| node_guidelines
node_supervisor -->|"submits datasets"| node_ingestion_ui

click node_ingestion_ui "https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/components/IngestionModal.tsx"
click node_csv_pipeline "https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/lib/csv/pipeline.ts"
click node_csv_parse "https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/lib/csv/parser.ts"
click node_csv_validate "https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/lib/csv/validator.ts"
click node_csv_clean "https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/lib/csv/cleaner.ts"
click node_csv_normalize "https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/lib/csv/normalizer.ts"
click node_analysis_engine "https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/logic_engine/analyzer.py"
click node_negation "https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/logic_engine/negation_detector.py"
click node_risk "https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/logic_engine/risk_scorer.py"
click node_lsr "https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/logic_engine/lsr_mapper.py"
click node_recommendations "https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/logic_engine/recommendation_generator.py"
click node_escalation "https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/logic_engine/escalation_evaluator.py"
click node_api "https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/main.py"
click node_incident_routes "https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/routers/incidents.py"
click node_dataset_routes "https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/routers/datasets.py"
click node_rules_routes "https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/routers/rules.py"
click node_auth_routes "https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/routers/auth.py"
click node_schemas "https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/models/schemas.py"
click node_auth_service "https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/services/auth_service.py"
click node_storage "https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/services/supabase_service.py"
click node_triage "https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/context/SafetyContext.tsx"
click node_dashboard "https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/app/analytics/page.tsx"
click node_explain "https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/components/ExplainabilityConsole.tsx"
click node_map "https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/components/IndiaIncidentMap.tsx"
click node_chatbot "https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/app/chatbot/page.tsx"
click node_guidelines "https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/app/guidelines/page.tsx"
click node_web_client "https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/lib/api/client.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ingestion_ui,node_csv_pipeline,node_csv_parse,node_csv_validate,node_csv_clean,node_csv_normalize toneBlue
class node_analysis_engine,node_negation,node_risk,node_lsr,node_recommendations,node_escalation toneAmber
class node_api,node_incident_routes,node_dataset_routes,node_rules_routes,node_auth_routes,node_schemas toneMint
class node_triage,node_dashboard,node_explain,node_map,node_chatbot,node_guidelines,node_web_client toneRose
class node_auth_service,node_storage,node_field,node_supervisor toneIndigo
```

## Components

### Ingestion & Quality

- [Dataset upload](https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/components/IngestionModal.tsx): `oil-hsse-app/src/components/IngestionModal.tsx`
- [CSV pipeline](https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/lib/csv/pipeline.ts): `oil-hsse-app/src/lib/csv/pipeline.ts`
- [CSV parsing](https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/lib/csv/parser.ts): `oil-hsse-app/src/lib/csv/parser.ts`
- [Data validation](https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/lib/csv/validator.ts): `oil-hsse-app/src/lib/csv/validator.ts`
- [Data cleaning](https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/lib/csv/cleaner.ts): `oil-hsse-app/src/lib/csv/cleaner.ts`
- [Incident normalization](https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/lib/csv/normalizer.ts): `oil-hsse-app/src/lib/csv/normalizer.ts`

### Safety Intelligence

- [Narrative analysis](https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/logic_engine/analyzer.py): `backend/app/logic_engine/analyzer.py`
- [Negation detection](https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/logic_engine/negation_detector.py): `backend/app/logic_engine/negation_detector.py`
- [Risk scoring](https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/logic_engine/risk_scorer.py): `backend/app/logic_engine/risk_scorer.py`
- [Life-saving rules](https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/logic_engine/lsr_mapper.py): `backend/app/logic_engine/lsr_mapper.py`
- [Control recommendations](https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/logic_engine/recommendation_generator.py): `backend/app/logic_engine/recommendation_generator.py`
- [Escalation likelihood](https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/logic_engine/escalation_evaluator.py): `backend/app/logic_engine/escalation_evaluator.py`

### API & Governance

- [FastAPI application](https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/main.py): `backend/app/main.py`
- [Incident management](https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/routers/incidents.py): `backend/app/routers/incidents.py`
- [Dataset lifecycle](https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/routers/datasets.py): `backend/app/routers/datasets.py`
- [Rules & analysis](https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/routers/rules.py): `backend/app/routers/rules.py`
- [Authentication API](https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [Domain schemas](https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/models/schemas.py): `backend/app/models/schemas.py`

### Supervisory Console

- [Incident triage](https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/context/SafetyContext.tsx): `oil-hsse-app/src/context/SafetyContext.tsx`
- [Dashboard & analytics](https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/app/analytics/page.tsx): `oil-hsse-app/src/app/analytics/page.tsx`
- [Explainability review](https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/components/ExplainabilityConsole.tsx): `oil-hsse-app/src/components/ExplainabilityConsole.tsx`
- [Incident heatmap](https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/components/IndiaIncidentMap.tsx): `oil-hsse-app/src/components/IndiaIncidentMap.tsx`
- [HSSE chatbot](https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/app/chatbot/page.tsx): `oil-hsse-app/src/app/chatbot/page.tsx`
- [Safety guidelines](https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/app/guidelines/page.tsx): `oil-hsse-app/src/app/guidelines/page.tsx`
- [Web API client](https://github.com/ansh-raj08/oil-hsse/blob/master/oil-hsse-app/src/lib/api/client.ts): `oil-hsse-app/src/lib/api/client.ts`

### Identity & Data

- [Role authorization](https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/services/auth_service.py): `backend/app/services/auth_service.py`
- [Supabase persistence](https://github.com/ansh-raj08/oil-hsse/blob/master/backend/app/services/supabase_service.py): `backend/app/services/supabase_service.py`

### Other components

- **Safety staff**
- **HSSE supervisor**

## Connections

- Safety staff → Dataset upload: uploads reports (evidence: `README.md`)
- Dataset upload → CSV pipeline: processes CSV (evidence: `oil-hsse-app/src/lib/csv/pipeline.ts`)
- CSV pipeline → CSV parsing: parses rows (evidence: `oil-hsse-app/src/lib/csv/pipeline.ts`)
- CSV pipeline → Data validation: validates rows (evidence: `oil-hsse-app/src/lib/csv/pipeline.ts`)
- CSV pipeline → Data cleaning: cleans rows (evidence: `oil-hsse-app/src/lib/csv/pipeline.ts`)
- CSV pipeline → Incident normalization: normalizes incidents (evidence: `oil-hsse-app/src/lib/csv/pipeline.ts`)
- CSV pipeline → Narrative analysis: runs inference
- Narrative analysis → Negation detection: detects negation (evidence: `backend/app/logic_engine/analyzer.py`)
- Narrative analysis → Risk scoring: scores risk (evidence: `backend/app/logic_engine/analyzer.py`)
- Narrative analysis → Life-saving rules: classifies rules (evidence: `backend/app/logic_engine/analyzer.py`)
- Narrative analysis → Control recommendations: generates controls (evidence: `backend/app/logic_engine/analyzer.py`)
- Narrative analysis → Escalation likelihood: evaluates escalation (evidence: `backend/app/logic_engine/analyzer.py`)
- FastAPI application → Incident management: routes incidents
- FastAPI application → Dataset lifecycle: routes datasets
- FastAPI application → Rules & analysis: routes rules
- FastAPI application → Authentication API: routes auth
- Incident management → Supabase persistence: manages records
- Dataset lifecycle → Supabase persistence: manages datasets
- Rules & analysis → Life-saving rules: uses classification (evidence: `backend/app/routers/rules.py`)
- Rules & analysis → Control recommendations: uses controls (evidence: `backend/app/routers/rules.py`)
- Authentication API → Domain schemas: validates payloads (evidence: `backend/app/routers/auth.py`)
- Role authorization → Supabase persistence: checks profiles (evidence: `backend/app/services/auth_service.py`)
- Web API client → FastAPI application: calls service (evidence: `README.md`)
- Dashboard & analytics → Web API client: requests analytics
- Incident triage → Web API client: loads incidents
- Incident triage → Explainability review: supports review
- Incident triage → Incident heatmap: shows locations
- HSSE supervisor → Incident triage: reviews alerts (evidence: `README.md`)
- HSSE supervisor → Dashboard & analytics: monitors metrics (evidence: `README.md`)
- HSSE supervisor → HSSE chatbot: asks guidance (evidence: `README.md`)
- HSSE supervisor → Safety guidelines: consults rules (evidence: `README.md`)
- HSSE supervisor → Dataset upload: submits datasets (evidence: `README.md`)
