# final-bench/ongrid architecture

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

- Interactive diagram: https://gitdiagram.com/final-bench/ongrid
- Repository: https://github.com/final-bench/ongrid

## Overview

ONGRID’s user workflow is to load or supply documents in the browser, build and explore a typed 3D knowledge graph, retrieve graph facts for a question, generate a fact-grounded answer, and verify it with ZTC. The repository exposes a browser UI and a compact FastAPI backend: the backend accepts facts from the client and calls Anthropic for answers, while ZTC loads and scores locally. The README documents browser-side graph construction, retrieval, visualization, and multilingual features; the frontend source was not sampled, so its internal wiring is not shown.

Main entry points: [`static/index.html`](https://github.com/final-bench/ongrid/blob/main/static/index.html) (Graph UI), [`app.py`](https://github.com/final-bench/ongrid/blob/main/app.py) (Answer endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser experience"]
  node_browser_ui["Graph UI<br/>[index.html]"]
  node_doc_ingest["Document ingestion<br/>[index.html]"]
  node_ontology_graph["Ontology graph<br/>[index.html]"]
  node_graph_retrieval["Fact retrieval<br/>[index.html]"]
end

subgraph group_answer["Answer service"]
  node_answer_api["Answer endpoint<br/>[app.py]"]
  node_rate_limit["Rate limiter<br/>[app.py]"]
end

subgraph group_verification["Verification"]
  node_ztc_endpoint["Verify endpoint<br/>[app.py]"]
  node_ztc_loader["ZTC model loader<br/>[app.py]"]
  node_ztc_scorer["ZTC scorer<br/>[app.py]"]
end

node_user(("User"))
node_anthropic["Anthropic API"]
node_judge_model["ZTC-Judge model"]

node_user -->|"uses"| node_browser_ui
node_user -->|"uploads documents"| node_doc_ingest
node_doc_ingest -->|"structures knowledge"| node_ontology_graph
node_browser_ui -->|"renders and explores"| node_ontology_graph
node_ontology_graph -->|"supplies graph facts"| node_graph_retrieval
node_user -->|"asks question"| node_graph_retrieval
node_graph_retrieval -->|"posts facts and query"| node_answer_api
node_answer_api -->|"checks request rate"| node_rate_limit
node_answer_api -->|"requests grounded answer"| node_anthropic
node_answer_api -->|"returns answer"| node_browser_ui
node_browser_ui -->|"submits answer for verification"| node_ztc_endpoint
node_ztc_endpoint -->|"checks request rate"| node_rate_limit
node_ztc_endpoint -->|"scores answer"| node_ztc_scorer
node_ztc_scorer -->|"returns verdict"| node_browser_ui
node_ztc_loader -->|"loads model snapshot"| node_judge_model
node_ztc_endpoint -->|"reports readiness"| node_ztc_loader

click node_browser_ui "https://github.com/final-bench/ongrid/blob/main/static/index.html"
click node_doc_ingest "https://github.com/final-bench/ongrid/blob/main/static/index.html"
click node_ontology_graph "https://github.com/final-bench/ongrid/blob/main/static/index.html"
click node_graph_retrieval "https://github.com/final-bench/ongrid/blob/main/static/index.html"
click node_answer_api "https://github.com/final-bench/ongrid/blob/main/app.py"
click node_rate_limit "https://github.com/final-bench/ongrid/blob/main/app.py"
click node_ztc_endpoint "https://github.com/final-bench/ongrid/blob/main/app.py"
click node_ztc_loader "https://github.com/final-bench/ongrid/blob/main/app.py"
click node_ztc_scorer "https://github.com/final-bench/ongrid/blob/main/app.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_browser_ui,node_doc_ingest,node_ontology_graph,node_graph_retrieval,node_user toneBlue
class node_answer_api,node_rate_limit toneAmber
class node_ztc_endpoint,node_ztc_loader,node_ztc_scorer,node_anthropic toneMint
class node_judge_model toneIndigo
```

## Components

### Browser experience

- [Graph UI](https://github.com/final-bench/ongrid/blob/main/static/index.html): `static/index.html`
- [Document ingestion](https://github.com/final-bench/ongrid/blob/main/static/index.html): `static/index.html`
- [Ontology graph](https://github.com/final-bench/ongrid/blob/main/static/index.html): `static/index.html`
- [Fact retrieval](https://github.com/final-bench/ongrid/blob/main/static/index.html): `static/index.html`

### Answer service

- [Answer endpoint](https://github.com/final-bench/ongrid/blob/main/app.py): `app.py`
- [Rate limiter](https://github.com/final-bench/ongrid/blob/main/app.py): `app.py`

### Verification

- [Verify endpoint](https://github.com/final-bench/ongrid/blob/main/app.py): `app.py`
- [ZTC model loader](https://github.com/final-bench/ongrid/blob/main/app.py): `app.py`
- [ZTC scorer](https://github.com/final-bench/ongrid/blob/main/app.py): `app.py`

### Other components

- **User**
- **Anthropic API**
- **ZTC-Judge model**

## Connections

- User → Graph UI: uses (evidence: `README.md`)
- User → Document ingestion: uploads documents (evidence: `README.md`)
- Document ingestion → Ontology graph: structures knowledge (evidence: `README.md`)
- Graph UI → Ontology graph: renders and explores (evidence: `README.md`)
- Ontology graph → Fact retrieval: supplies graph facts (evidence: `README.md`)
- User → Fact retrieval: asks question (evidence: `README.md`)
- Fact retrieval → Answer endpoint: posts facts and query (evidence: `README.md`)
- Answer endpoint → Rate limiter: checks request rate (evidence: `app.py`)
- Answer endpoint → Anthropic API: requests grounded answer (evidence: `app.py`)
- Answer endpoint → Graph UI: returns answer (evidence: `app.py`)
- Graph UI → Verify endpoint: submits answer for verification (evidence: `README.md`)
- Verify endpoint → Rate limiter: checks request rate (evidence: `app.py`)
- Verify endpoint → ZTC scorer: scores answer (evidence: `app.py`)
- ZTC scorer → Graph UI: returns verdict (evidence: `app.py`)
- ZTC model loader → ZTC-Judge model: loads model snapshot (evidence: `app.py`)
- Verify endpoint → ZTC model loader: reports readiness (evidence: `app.py`)
