# internscience/graphanything architecture

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

- Interactive diagram: https://gitdiagram.com/internscience/graphanything
- Repository: https://github.com/internscience/graphanything

## Overview

GraphAnything turns heterogeneous artifacts into provenance-rich knowledge graphs through a schema-led extraction and human-review workflow, then supports querying, versioning, federation, quality reporting, and nine render formats. CLI and MCP tools are documented drivers of the shared Session core. The sampled source confirms extractor dispatch, LLM extraction, session review, and rendering; other subsystem connections follow README descriptions and are shown only at that level.

Main entry points: [`session.py`](https://github.com/internscience/graphanything/blob/main/session.py) (Session workflow), [`cli.py`](https://github.com/internscience/graphanything/blob/main/cli.py) (CLI / REPL), [`extractors/__init__.py`](https://github.com/internscience/graphanything/blob/main/extractors/__init__.py) (Extractor registry), [`serve.py`](https://github.com/internscience/graphanything/blob/main/serve.py) (MCP server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_drivers["User interfaces"]
  node_cli["CLI / REPL<br/>[cli.py]"]
  node_mcp["MCP server<br/>[serve.py]"]
end

subgraph group_build["Graph construction"]
  node_session["Session workflow<br/>[session.py]"]
  node_proposer["Schema proposal<br/>[_proposer.py]"]
  node_presets["Schema presets"]
  node_extractors["Extractor registry<br/>[__init__.py]"]
  node_rule_extractors["Rule extractors<br/>[tier1.py]"]
  node_chatlog["Chat-log extractor<br/>[chatlog.py]"]
  node_llm_extractor["LLM entity extractor<br/>[llm_entity.py]"]
  node_llm_client["LLM client<br/>[llm_client.py]"]
  node_preview["Sample review<br/>[preview.py]"]
  node_normalize["Merge normalization<br/>[normalize.py]"]
  node_provenance["Provenance<br/>[provenance.py]"]
end

subgraph group_graph_ops["Graph operations"]
  node_store[("Graph and sessions<br/>[store.py]")]
  node_temporal["Snapshots and diff<br/>[temporal.py]"]
  node_federate["Federation<br/>[federate.py]"]
  node_quality["Quality evaluation<br/>[quality.py]"]
end

subgraph group_outputs["Query and output"]
  node_ask["Graph query<br/>[ask.py]"]
  node_explain["Provenance explain<br/>[provenance.py]"]
  node_viz["Graph rendering<br/>[__init__.py]"]
end

node_user(("User"))
node_llm_service{{"OpenAI-compatible endpoint"}}

node_user -->|"commands"| node_cli
node_user -->|"tools"| node_mcp
node_cli -->|"drives"| node_session
node_mcp -->|"drives"| node_session
node_session -->|"proposes schema"| node_proposer
node_session -->|"uses presets"| node_presets
node_session -->|"dispatches extraction"| node_extractors
node_extractors -->|"dispatches"| node_rule_extractors
node_extractors -->|"dispatches"| node_chatlog
node_extractors -->|"dispatches"| node_llm_extractor
node_llm_extractor -->|"requests completion"| node_llm_client
node_llm_client -.->|"HTTP requests"| node_llm_service
node_session -->|"returns sample"| node_preview
node_session -->|"applies review rules"| node_normalize
node_extractors -->|"stamps outputs"| node_provenance
node_session -->|"persists graph"| node_store
node_session -->|"versions graph"| node_temporal
node_cli -->|"queries graph"| node_ask
node_cli -->|"explains provenance"| node_explain
node_cli -->|"combines graphs"| node_federate
node_cli -->|"evaluates graph"| node_quality
node_cli -->|"renders graph"| node_viz

click node_cli "https://github.com/internscience/graphanything/blob/main/cli.py"
click node_mcp "https://github.com/internscience/graphanything/blob/main/serve.py"
click node_session "https://github.com/internscience/graphanything/blob/main/session.py"
click node_proposer "https://github.com/internscience/graphanything/blob/main/_proposer.py"
click node_presets "https://github.com/internscience/graphanything/tree/main/schemas"
click node_extractors "https://github.com/internscience/graphanything/blob/main/extractors/__init__.py"
click node_rule_extractors "https://github.com/internscience/graphanything/blob/main/extractors/tier1.py"
click node_chatlog "https://github.com/internscience/graphanything/blob/main/extractors/chatlog.py"
click node_llm_extractor "https://github.com/internscience/graphanything/blob/main/extractors/llm_entity.py"
click node_llm_client "https://github.com/internscience/graphanything/blob/main/llm_client.py"
click node_preview "https://github.com/internscience/graphanything/blob/main/preview.py"
click node_normalize "https://github.com/internscience/graphanything/blob/main/normalize.py"
click node_provenance "https://github.com/internscience/graphanything/blob/main/provenance.py"
click node_store "https://github.com/internscience/graphanything/blob/main/store.py"
click node_temporal "https://github.com/internscience/graphanything/blob/main/temporal.py"
click node_ask "https://github.com/internscience/graphanything/blob/main/ask.py"
click node_explain "https://github.com/internscience/graphanything/blob/main/provenance.py"
click node_federate "https://github.com/internscience/graphanything/blob/main/federate.py"
click node_quality "https://github.com/internscience/graphanything/blob/main/quality.py"
click node_viz "https://github.com/internscience/graphanything/blob/main/viz/__init__.py"

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_cli,node_mcp,node_user toneBlue
class node_session,node_proposer,node_presets,node_extractors,node_rule_extractors,node_chatlog,node_llm_extractor,node_llm_client,node_preview,node_normalize,node_provenance toneAmber
class node_store,node_temporal,node_federate,node_quality toneMint
class node_ask,node_explain,node_viz toneRose
class node_llm_service toneIndigo
```

## Components

### User interfaces

- [CLI / REPL](https://github.com/internscience/graphanything/blob/main/cli.py): `cli.py`
- [MCP server](https://github.com/internscience/graphanything/blob/main/serve.py): `serve.py`

### Graph construction

- [Session workflow](https://github.com/internscience/graphanything/blob/main/session.py): `session.py`
- [Schema proposal](https://github.com/internscience/graphanything/blob/main/_proposer.py): `_proposer.py`
- [Schema presets](https://github.com/internscience/graphanything/tree/main/schemas): `schemas`
- [Extractor registry](https://github.com/internscience/graphanything/blob/main/extractors/__init__.py): `extractors/__init__.py`
- [Rule extractors](https://github.com/internscience/graphanything/blob/main/extractors/tier1.py): `extractors/tier1.py`
- [Chat-log extractor](https://github.com/internscience/graphanything/blob/main/extractors/chatlog.py): `extractors/chatlog.py`
- [LLM entity extractor](https://github.com/internscience/graphanything/blob/main/extractors/llm_entity.py): `extractors/llm_entity.py`
- [LLM client](https://github.com/internscience/graphanything/blob/main/llm_client.py): `llm_client.py`
- [Sample review](https://github.com/internscience/graphanything/blob/main/preview.py): `preview.py`
- [Merge normalization](https://github.com/internscience/graphanything/blob/main/normalize.py): `normalize.py`
- [Provenance](https://github.com/internscience/graphanything/blob/main/provenance.py): `provenance.py`

### Graph operations

- [Graph and sessions](https://github.com/internscience/graphanything/blob/main/store.py): `store.py`
- [Snapshots and diff](https://github.com/internscience/graphanything/blob/main/temporal.py): `temporal.py`
- [Federation](https://github.com/internscience/graphanything/blob/main/federate.py): `federate.py`
- [Quality evaluation](https://github.com/internscience/graphanything/blob/main/quality.py): `quality.py`

### Query and output

- [Graph query](https://github.com/internscience/graphanything/blob/main/ask.py): `ask.py`
- [Provenance explain](https://github.com/internscience/graphanything/blob/main/provenance.py): `provenance.py`
- [Graph rendering](https://github.com/internscience/graphanything/blob/main/viz/__init__.py): `viz/__init__.py`

### Other components

- **User**
- **OpenAI-compatible endpoint**

## Connections

- User → CLI / REPL: commands
- User → MCP server: tools
- CLI / REPL → Session workflow: drives
- MCP server → Session workflow: drives
- Session workflow → Schema proposal: proposes schema
- Session workflow → Schema presets: uses presets
- Session workflow → Extractor registry: dispatches extraction
- Extractor registry → Rule extractors: dispatches
- Extractor registry → Chat-log extractor: dispatches
- Extractor registry → LLM entity extractor: dispatches
- LLM entity extractor → LLM client: requests completion
- LLM client → OpenAI-compatible endpoint: HTTP requests
- Session workflow → Sample review: returns sample
- Session workflow → Merge normalization: applies review rules
- Extractor registry → Provenance: stamps outputs
- Session workflow → Graph and sessions: persists graph
- Session workflow → Snapshots and diff: versions graph
- CLI / REPL → Graph query: queries graph
- CLI / REPL → Provenance explain: explains provenance
- CLI / REPL → Federation: combines graphs
- CLI / REPL → Quality evaluation: evaluates graph
- CLI / REPL → Graph rendering: renders graph
