# annamashish/esg-incident-intelligence architecture

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

- Interactive diagram: https://gitdiagram.com/annamashish/esg-incident-intelligence
- Repository: https://github.com/annamashish/esg-incident-intelligence

## Overview

The product is an offline ESG and safety incident intelligence dashboard. Users inspect portfolio summaries, incident registers, recurring patterns and evaluation metrics, or submit a narrative for classification, risk tagging, retrieval evidence, summarization and preventive recommendations. The API owns requests and delegates to a shared incident engine; the frontend is served by that API application. Pipeline internals are grouped by responsibility. The README documents capabilities beyond the sampled excerpts; data-loading links are left unverified where the excerpts do not show the read.

Main entry points: [`backend/pipeline.py`](https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py) (Incident engine), [`backend/app.py`](https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/app.py) (HTTP API), [`frontend/index.html`](https://github.com/annamashish/esg-incident-intelligence/blob/master/frontend/index.html) (Web dashboard), [`data/incidents_extended.csv`](https://github.com/annamashish/esg-incident-intelligence/blob/master/data/incidents_extended.csv) (Extended incidents)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Dashboard and API"]
  node_frontend["Web dashboard<br/>[index.html]"]
  node_api["HTTP API<br/>[app.py]"]
end

subgraph group_analysis["Incident analysis"]
  node_engine["Incident engine<br/>[pipeline.py]"]
  node_clean["Text cleaning<br/>[pipeline.py]"]
  node_classify["Type and severity<br/>[pipeline.py]"]
  node_guard["Severity floor<br/>[pipeline.py]"]
  node_tag["Risk tagging<br/>[pipeline.py]"]
  node_retrieve["Similar incidents<br/>[pipeline.py]"]
  node_recommend["Preventive actions<br/>[pipeline.py]"]
end

subgraph group_insight["Portfolio insights"]
  node_summarize["Narrative summaries<br/>[pipeline.py]"]
  node_portfolio["Portfolio summary<br/>[pipeline.py]"]
  node_patterns["Pattern trends<br/>[pipeline.py]"]
  node_register["Incident register<br/>[pipeline.py]"]
  node_metrics["Model evaluation<br/>[pipeline.py]"]
end

subgraph group_data["Incident data"]
  node_bundled[("Bundled incidents")]
  node_extended[("Extended incidents")]
end

node_user(("Dashboard user"))

node_user -->|"uses"| node_frontend
node_user -->|"requests"| node_api
node_api -->|"serves"| node_frontend
node_api -->|"delegates"| node_engine
node_engine -->|"cleans text"| node_clean
node_engine -->|"predicts labels"| node_classify
node_engine -->|"guards severity"| node_guard
node_engine -->|"tags risks"| node_tag
node_engine -->|"retrieves evidence"| node_retrieve
node_engine -->|"recommends actions"| node_recommend
node_engine -->|"summarizes"| node_summarize
node_api -->|"returns summary"| node_portfolio
node_api -->|"returns patterns"| node_patterns
node_api -->|"returns incidents"| node_register
node_api -->|"returns metrics"| node_metrics
node_engine -->|"aggregates"| node_portfolio
node_engine -->|"detects trends"| node_patterns
node_engine -->|"formats register"| node_register
node_engine -->|"evaluates models"| node_metrics
node_bundled -.->|"loaded as input"| node_engine
node_extended -.->|"loaded as input"| node_engine

click node_frontend "https://github.com/annamashish/esg-incident-intelligence/blob/master/frontend/index.html"
click node_api "https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/app.py"
click node_engine "https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py"
click node_clean "https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py"
click node_classify "https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py"
click node_guard "https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py"
click node_tag "https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py"
click node_retrieve "https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py"
click node_recommend "https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py"
click node_summarize "https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py"
click node_portfolio "https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py"
click node_patterns "https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py"
click node_register "https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py"
click node_metrics "https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py"
click node_extended "https://github.com/annamashish/esg-incident-intelligence/blob/master/data/incidents_extended.csv"

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_frontend,node_api,node_user toneBlue
class node_engine,node_clean,node_classify,node_guard,node_tag,node_retrieve,node_recommend toneAmber
class node_summarize,node_portfolio,node_patterns,node_register,node_metrics toneMint
class node_bundled,node_extended toneRose
```

## Components

### Dashboard and API

- [Web dashboard](https://github.com/annamashish/esg-incident-intelligence/blob/master/frontend/index.html): `frontend/index.html`
- [HTTP API](https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/app.py): `backend/app.py`

### Incident analysis

- [Incident engine](https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py): `backend/pipeline.py`
- [Text cleaning](https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py): `backend/pipeline.py`
- [Type and severity](https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py): `backend/pipeline.py`
- [Severity floor](https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py): `backend/pipeline.py`
- [Risk tagging](https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py): `backend/pipeline.py`
- [Similar incidents](https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py): `backend/pipeline.py`
- [Preventive actions](https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py): `backend/pipeline.py`

### Portfolio insights

- [Narrative summaries](https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py): `backend/pipeline.py`
- [Portfolio summary](https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py): `backend/pipeline.py`
- [Pattern trends](https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py): `backend/pipeline.py`
- [Incident register](https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py): `backend/pipeline.py`
- [Model evaluation](https://github.com/annamashish/esg-incident-intelligence/blob/master/backend/pipeline.py): `backend/pipeline.py`

### Incident data

- **Bundled incidents**
- [Extended incidents](https://github.com/annamashish/esg-incident-intelligence/blob/master/data/incidents_extended.csv): `data/incidents_extended.csv`

### Other components

- **Dashboard user**

## Connections

- Dashboard user → Web dashboard: uses (evidence: `README.md`)
- Dashboard user → HTTP API: requests (evidence: `README.md`)
- HTTP API → Web dashboard: serves (evidence: `backend/app.py`)
- HTTP API → Incident engine: delegates (evidence: `backend/app.py`)
- Incident engine → Text cleaning: cleans text (evidence: `backend/pipeline.py`)
- Incident engine → Type and severity: predicts labels (evidence: `README.md`)
- Incident engine → Severity floor: guards severity (evidence: `backend/pipeline.py`)
- Incident engine → Risk tagging: tags risks (evidence: `backend/pipeline.py`)
- Incident engine → Similar incidents: retrieves evidence (evidence: `README.md`)
- Incident engine → Preventive actions: recommends actions (evidence: `README.md`)
- Incident engine → Narrative summaries: summarizes (evidence: `README.md`)
- HTTP API → Portfolio summary: returns summary (evidence: `backend/app.py`)
- HTTP API → Pattern trends: returns patterns (evidence: `backend/app.py`)
- HTTP API → Incident register: returns incidents (evidence: `backend/app.py`)
- HTTP API → Model evaluation: returns metrics (evidence: `backend/app.py`)
- Incident engine → Portfolio summary: aggregates (evidence: `backend/pipeline.py`)
- Incident engine → Pattern trends: detects trends (evidence: `backend/pipeline.py`)
- Incident engine → Incident register: formats register (evidence: `backend/pipeline.py`)
- Incident engine → Model evaluation: evaluates models (evidence: `backend/pipeline.py`)
- Bundled incidents → Incident engine: loaded as input
- Extended incidents → Incident engine: loaded as input
