# webo1980/orkgex architecture

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

- Interactive diagram: https://gitdiagram.com/webo1980/orkgex
- Repository: https://github.com/webo1980/orkgex

## Overview

ORKGEx is a Chrome extension for annotating research articles and extracting structured knowledge from figures, with integration to ORKG. The main workflow is: a researcher selects text or images on a page; the content script annotates selections and suggests properties; the background script relays messages and stores selections; the popup presents them and supports metadata, triple, and paper workflows. Figure extraction and editing are represented separately. The README documents ORKG integration, while sampled code shows the extension’s local messaging, storage, and external requests; unsampled wiring is omitted.

Main entry points: [`popup/popup.js`](https://github.com/webo1980/orkgex/blob/main/popup/popup.js) (Annotation popup), [`scripts/content.js`](https://github.com/webo1980/orkgex/blob/main/scripts/content.js) (Page annotator), [`background.js`](https://github.com/webo1980/orkgex/blob/main/background.js) (Message and state handler), [`popup/splitView.js`](https://github.com/webo1980/orkgex/blob/main/popup/splitView.js) (Figure triple editor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_page["Page annotation"]
  node_content["Page annotator<br/>[content.js]"]
end

subgraph group_extension["Extension coordination"]
  node_background["Message and state handler<br/>[background.js]"]
  node_localstate[("Extension local storage")]
end

subgraph group_research["Research workflows"]
  node_popup["Annotation popup<br/>[popup.js]"]
  node_popupui["Popup interface<br/>[popup.html]"]
  node_semantic["Semantic Scholar"]
  node_orkg["ORKG platform"]
end

subgraph group_figure["Figure extraction"]
  node_chartservice["Chart extraction service"]
  node_openai["OpenAI API"]
  node_imageeditor["Figure triple editor<br/>[splitView.js]"]
  node_legacyeditor["Alternate figure editor<br/>[splitView.js]"]
end

node_researcher(("Researcher"))
node_article["Research article page"]

node_researcher -->|"selects content"| node_article
node_article -->|"provides selections"| node_content
node_popup -->|"requests highlighting"| node_content
node_content -->|"sends selection events"| node_background
node_popup -->|"requests selection state"| node_background
node_background -->|"stores selections"| node_localstate
node_popup -->|"reads saved selections"| node_localstate
node_popupui -->|"hosts workflow"| node_popup
node_content -->|"requests property suggestions"| node_openai
node_popup -->|"fetches paper metadata"| node_semantic
node_popup -->|"creates and opens papers"| node_orkg
node_researcher -.->|"reviews annotations"| node_popup
node_imageeditor -->|"requests chart data"| node_chartservice
node_imageeditor -->|"models triples"| node_openai
node_legacyeditor -->|"models image triples"| node_openai

click node_content "https://github.com/webo1980/orkgex/blob/main/scripts/content.js"
click node_background "https://github.com/webo1980/orkgex/blob/main/background.js"
click node_popup "https://github.com/webo1980/orkgex/blob/main/popup/popup.js"
click node_popupui "https://github.com/webo1980/orkgex/blob/main/popup/popup.html"
click node_imageeditor "https://github.com/webo1980/orkgex/blob/main/popup/splitView.js"
click node_legacyeditor "https://github.com/webo1980/orkgex/blob/main/ORKGEditor/Chrome%20Extension%20V2.0/popup/splitView.js"

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_content toneBlue
class node_background,node_localstate toneAmber
class node_popup,node_popupui,node_semantic,node_orkg toneMint
class node_chartservice,node_openai,node_imageeditor,node_legacyeditor toneRose
class node_researcher,node_article toneIndigo
```

## Components

### Page annotation

- [Page annotator](https://github.com/webo1980/orkgex/blob/main/scripts/content.js): `scripts/content.js`

### Extension coordination

- [Message and state handler](https://github.com/webo1980/orkgex/blob/main/background.js): `background.js`
- **Extension local storage**

### Research workflows

- [Annotation popup](https://github.com/webo1980/orkgex/blob/main/popup/popup.js): `popup/popup.js`
- [Popup interface](https://github.com/webo1980/orkgex/blob/main/popup/popup.html): `popup/popup.html`
- **Semantic Scholar**
- **ORKG platform**

### Figure extraction

- **Chart extraction service**
- **OpenAI API**
- [Figure triple editor](https://github.com/webo1980/orkgex/blob/main/popup/splitView.js): `popup/splitView.js`
- [Alternate figure editor](https://github.com/webo1980/orkgex/blob/main/ORKGEditor/Chrome%20Extension%20V2.0/popup/splitView.js): `ORKGEditor/Chrome Extension V2.0/popup/splitView.js`

### Other components

- **Researcher**
- **Research article page**

## Connections

- Researcher → Research article page: selects content
- Research article page → Page annotator: provides selections (evidence: `scripts/content.js`)
- Annotation popup → Page annotator: requests highlighting (evidence: `popup/popup.js`)
- Page annotator → Message and state handler: sends selection events (evidence: `scripts/content.js`)
- Annotation popup → Message and state handler: requests selection state (evidence: `popup/popup.js`)
- Message and state handler → Extension local storage: stores selections (evidence: `background.js`)
- Annotation popup → Extension local storage: reads saved selections (evidence: `popup/popup.js`)
- Popup interface → Annotation popup: hosts workflow (evidence: `popup/popup.js`)
- Page annotator → OpenAI API: requests property suggestions (evidence: `scripts/content.js`)
- Annotation popup → Semantic Scholar: fetches paper metadata (evidence: `popup/popup.js`)
- Annotation popup → ORKG platform: creates and opens papers (evidence: `popup/popup.js`)
- Researcher → Annotation popup: reviews annotations
- Figure triple editor → Chart extraction service: requests chart data (evidence: `popup/splitView.js`)
- Figure triple editor → OpenAI API: models triples (evidence: `popup/splitView.js`)
- Alternate figure editor → OpenAI API: models image triples (evidence: `ORKGEditor/Chrome Extension V2.0/popup/splitView.js`)
