# pierresenellart/theoremkb architecture

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

- Interactive diagram: https://gitdiagram.com/pierresenellart/theoremkb
- Repository: https://github.com/pierresenellart/theoremkb

## Overview

TheoremKB is a research toolkit for extracting mathematical results from scholarly articles and linking results across papers. In the Styling application, users manage papers and annotations through a web interface and REST API; the backend stores paper and annotation metadata and can run extractors. A separate analysis toolset derives result and reference links and builds a graph-oriented knowledge base. The README also identifies computer-vision and NLP extraction approaches, but their implementations are outside this tree. Connections below follow shown imports or calls; unsampled subsystems and API wiring are not inferred.

Main entry points: [`Styling/tools/theoremdb/db.py`](https://github.com/pierresenellart/theoremkb/blob/master/Styling/tools/theoremdb/db.py) (Theorem database), [`Styling/src/server.py`](https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/server.py) (REST API), [`Styling/src/lib/tkb.py`](https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/lib/tkb.py) (Extractor registry), [`Styling/src/web/src/App.tsx`](https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/web/src/App.tsx) (Web application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Paper annotation"]
  node_api["REST API<br/>[server.py]"]
  node_paper[("Paper records<br/>[__init__.py]")]
  node_annotations["Annotation layers<br/>[annotations.py]"]
  node_classes["Annotation classes<br/>[__init__.py]"]
end

subgraph group_extract["Document extraction"]
  node_core["Extractor registry<br/>[tkb.py]"]
  node_cnn["CNN extraction<br/>[cnn.py]"]
  node_cnn1d["CNN sequence extraction<br/>[cnn1d.py]"]
  node_crf["CRF extraction<br/>[crf.py]"]
  node_features["Document features<br/>[features.py]"]
end

subgraph group_kb["Result knowledge base"]
  node_db[("Theorem database<br/>[db.py]")]
  node_resultboxes["Result bounding boxes<br/>[results.py]"]
  node_refboxes["Reference boxes<br/>[links.py]"]
  node_graph["Result link graph<br/>[extract_graph.py]"]
  node_dbworkflow["Knowledge-base workflow<br/>[tkb.py]"]
end

subgraph group_ui["Annotation interface"]
  node_webapp["Web application<br/>[App.tsx]"]
  node_resources["API resources<br/>[resources.tsx]"]
  node_paperui["Paper annotation view<br/>[Paper.tsx]"]
  node_paperlist["Paper search and list<br/>[ListPapers.tsx]"]
end

node_user(("Research user"))

node_user -->|"uses"| node_webapp
node_webapp -->|"renders"| node_paperlist
node_webapp -->|"renders"| node_paperui
node_webapp -.->|"imports"| node_resources
node_paperui -.->|"requests"| node_resources
node_user -.->|"submits edits"| node_api
node_api -->|"invokes"| node_core
node_api -->|"reads papers"| node_paper
node_api -->|"adds boxes"| node_annotations
node_core -->|"registers"| node_cnn
node_core -->|"registers"| node_cnn1d
node_core -->|"registers"| node_crf
node_cnn -->|"creates layers"| node_annotations
node_cnn -->|"uses labels"| node_classes
node_dbworkflow -->|"loads"| node_db
node_dbworkflow -->|"extracts links"| node_graph
node_dbworkflow -->|"builds features"| node_features
node_graph -->|"loads papers"| node_db
node_graph -->|"uses features"| node_features
node_db -->|"parses results"| node_resultboxes
node_db -->|"parses references"| node_refboxes
node_features -->|"reads records"| node_db

click node_api "https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/server.py"
click node_paper "https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/lib/paper/__init__.py"
click node_annotations "https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/lib/annotations.py"
click node_classes "https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/lib/classes/__init__.py"
click node_core "https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/lib/tkb.py"
click node_cnn "https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/lib/extractors/cnn.py"
click node_cnn1d "https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/lib/extractors/cnn1d.py"
click node_crf "https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/lib/extractors/crf.py"
click node_features "https://github.com/pierresenellart/theoremkb/blob/master/Styling/tools/ml/features.py"
click node_db "https://github.com/pierresenellart/theoremkb/blob/master/Styling/tools/theoremdb/db.py"
click node_resultboxes "https://github.com/pierresenellart/theoremkb/blob/master/Styling/tools/theoremdb/results.py"
click node_refboxes "https://github.com/pierresenellart/theoremkb/blob/master/Styling/tools/theoremdb/links.py"
click node_graph "https://github.com/pierresenellart/theoremkb/blob/master/Styling/tools/theoremdb/extract_graph.py"
click node_dbworkflow "https://github.com/pierresenellart/theoremkb/blob/master/Styling/tkb.py"
click node_webapp "https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/web/src/App.tsx"
click node_resources "https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/web/src/resources.tsx"
click node_paperui "https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/web/src/index/Paper.tsx"
click node_paperlist "https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/web/src/index/ListPapers.tsx"

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_api,node_paper,node_annotations,node_classes,node_user toneBlue
class node_core,node_cnn,node_cnn1d,node_crf,node_features toneAmber
class node_db,node_resultboxes,node_refboxes,node_graph,node_dbworkflow toneMint
class node_webapp,node_resources,node_paperui,node_paperlist toneRose
```

## Components

### Paper annotation

- [REST API](https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/server.py): `Styling/src/server.py`
- [Paper records](https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/lib/paper/__init__.py): `Styling/src/lib/paper/__init__.py`
- [Annotation layers](https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/lib/annotations.py): `Styling/src/lib/annotations.py`
- [Annotation classes](https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/lib/classes/__init__.py): `Styling/src/lib/classes/__init__.py`

### Document extraction

- [Extractor registry](https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/lib/tkb.py): `Styling/src/lib/tkb.py`
- [CNN extraction](https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/lib/extractors/cnn.py): `Styling/src/lib/extractors/cnn.py`
- [CNN sequence extraction](https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/lib/extractors/cnn1d.py): `Styling/src/lib/extractors/cnn1d.py`
- [CRF extraction](https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/lib/extractors/crf.py): `Styling/src/lib/extractors/crf.py`
- [Document features](https://github.com/pierresenellart/theoremkb/blob/master/Styling/tools/ml/features.py): `Styling/tools/ml/features.py`

### Result knowledge base

- [Theorem database](https://github.com/pierresenellart/theoremkb/blob/master/Styling/tools/theoremdb/db.py): `Styling/tools/theoremdb/db.py`
- [Result bounding boxes](https://github.com/pierresenellart/theoremkb/blob/master/Styling/tools/theoremdb/results.py): `Styling/tools/theoremdb/results.py`
- [Reference boxes](https://github.com/pierresenellart/theoremkb/blob/master/Styling/tools/theoremdb/links.py): `Styling/tools/theoremdb/links.py`
- [Result link graph](https://github.com/pierresenellart/theoremkb/blob/master/Styling/tools/theoremdb/extract_graph.py): `Styling/tools/theoremdb/extract_graph.py`
- [Knowledge-base workflow](https://github.com/pierresenellart/theoremkb/blob/master/Styling/tkb.py): `Styling/tkb.py`

### Annotation interface

- [Web application](https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/web/src/App.tsx): `Styling/src/web/src/App.tsx`
- [API resources](https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/web/src/resources.tsx): `Styling/src/web/src/resources.tsx`
- [Paper annotation view](https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/web/src/index/Paper.tsx): `Styling/src/web/src/index/Paper.tsx`
- [Paper search and list](https://github.com/pierresenellart/theoremkb/blob/master/Styling/src/web/src/index/ListPapers.tsx): `Styling/src/web/src/index/ListPapers.tsx`

### Other components

- **Research user**

## Connections

- Research user → Web application: uses
- Web application → Paper search and list: renders (evidence: `Styling/src/web/src/App.tsx`)
- Web application → Paper annotation view: renders (evidence: `Styling/src/web/src/App.tsx`)
- Web application → API resources: imports
- Paper annotation view → API resources: requests
- Research user → REST API: submits edits
- REST API → Extractor registry: invokes (evidence: `Styling/src/server.py`)
- REST API → Paper records: reads papers (evidence: `Styling/src/server.py`)
- REST API → Annotation layers: adds boxes (evidence: `Styling/src/server.py`)
- Extractor registry → CNN extraction: registers (evidence: `Styling/src/lib/tkb.py`)
- Extractor registry → CNN sequence extraction: registers (evidence: `Styling/src/lib/tkb.py`)
- Extractor registry → CRF extraction: registers (evidence: `Styling/src/lib/tkb.py`)
- CNN extraction → Annotation layers: creates layers (evidence: `Styling/src/lib/extractors/cnn.py`)
- CNN extraction → Annotation classes: uses labels (evidence: `Styling/src/lib/extractors/cnn.py`)
- Knowledge-base workflow → Theorem database: loads (evidence: `Styling/tkb.py`)
- Knowledge-base workflow → Result link graph: extracts links (evidence: `Styling/tkb.py`)
- Knowledge-base workflow → Document features: builds features (evidence: `Styling/tkb.py`)
- Result link graph → Theorem database: loads papers (evidence: `Styling/tools/theoremdb/extract_graph.py`)
- Result link graph → Document features: uses features (evidence: `Styling/tools/theoremdb/extract_graph.py`)
- Theorem database → Result bounding boxes: parses results (evidence: `Styling/tools/theoremdb/db.py`)
- Theorem database → Reference boxes: parses references (evidence: `Styling/tools/theoremdb/db.py`)
- Document features → Theorem database: reads records (evidence: `Styling/tools/ml/features.py`)
