# sanchitbadyal/llm-graph-builder architecture

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

- Interactive diagram: https://gitdiagram.com/sanchitbadyal/llm-graph-builder
- Repository: https://github.com/sanchitbadyal/llm-graph-builder

## Overview

Knowledge Graph Builder is a web application that ingests files and external sources, extracts entities and relationships with configurable LLMs and schemas, and stores the resulting graph in Neo4j. Users can then inspect graph data and chat with it in several documented search modes. The backend entry point coordinates ingestion and processing; ontology services add profile, semantic, and reasoning capabilities. Edges reflect excerpted calls, SOURCE INDEX references, or README statements; unsampled subsystem details are represented at their supported directory paths.

Main entry points: [`backend/src/main.py`](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/main.py) (API and workflow), [`backend/src/QA_integration.py`](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/QA_integration.py) (Conversational QA), [`backend/src/ontology_registry/adapter.py`](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/ontology_registry/adapter.py) (Extraction adapter), [`backend/src/llm.py`](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/llm.py) (LLM extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Web application"]
  node_app["Web routes<br/>[App.tsx]"]
  node_filesui["File management UI<br/>[FileTable.tsx]"]
  node_filectx["File state<br/>[UsersFiles.tsx]"]
  node_embedconfig["Embedding configuration"]
  node_api["API client<br/>[Index.ts]"]
end

subgraph group_ingest["Source ingestion"]
  node_backend["API and workflow<br/>[main.py]"]
  node_local["Local files<br/>[local_file.py]"]
  node_cloudsources["Cloud and web sources"]
end

subgraph group_graph["Graph processing"]
  node_chunking["Chunk preparation<br/>[create_chunks.py]"]
  node_llm["LLM extraction<br/>[llm.py]"]
  node_relationships["Relationship building"]
  node_postprocess["Graph enhancement<br/>[post_processing.py]"]
end

subgraph group_ontology["Ontology services"]
  node_ontologyadapter["Extraction adapter<br/>[adapter.py]"]
  node_ontologysemantic["Semantic index<br/>[semantic.py]"]
  node_ontologymanifest["Ontology manifest<br/>[manifest.py]"]
  node_ontologyreasoner["Ontology reasoning<br/>[reasoner.py]"]
end

subgraph group_query["Graph access and chat"]
  node_graphdb["Neo4j access"]
  node_neo4j[("Neo4j database")]
  node_query["Graph queries<br/>[graph_query.py]"]
  node_communities["Community search<br/>[communities.py]"]
  node_qa["Conversational QA<br/>[QA_integration.py]"]
end

node_user(("User"))
node_llmservice{{"LLM providers"}}

node_user -->|"uses"| node_app
node_app -.->|"presents"| node_filesui
node_filesui -->|"manages state"| node_filectx
node_filectx -.->|"requests backend"| node_api
node_user -->|"submits sources"| node_backend
node_backend -->|"loads files"| node_local
node_backend -->|"loads sources"| node_cloudsources
node_backend -->|"prepares chunks"| node_chunking
node_backend -->|"processes chunks"| node_llm
node_llm -->|"extracts graph"| node_llmservice
node_backend -->|"builds relations"| node_relationships
node_backend -->|"persists graph"| node_graphdb
node_graphdb -->|"reads and writes"| node_neo4j
node_backend -->|"uses profile"| node_ontologyadapter
node_ontologyadapter -.->|"resolves semantics"| node_ontologysemantic
node_ontologyadapter -.->|"uses metadata"| node_ontologymanifest
node_user -->|"selects model"| node_embedconfig
node_backend -.->|"enhances graph"| node_postprocess
node_user -->|"asks questions"| node_qa
node_qa -->|"uses models"| node_llm
node_qa -->|"retrieves graph data"| node_query
node_query -->|"executes queries"| node_neo4j
node_qa -->|"uses community search"| node_communities
node_user -->|"views graph"| node_query
node_ontologyreasoner -.->|"loads ontologies"| node_ontologymanifest

click node_app "https://github.com/sanchitbadyal/llm-graph-builder/blob/main/frontend/src/App.tsx"
click node_filesui "https://github.com/sanchitbadyal/llm-graph-builder/blob/main/frontend/src/components/FileTable.tsx"
click node_filectx "https://github.com/sanchitbadyal/llm-graph-builder/blob/main/frontend/src/context/UsersFiles.tsx"
click node_embedconfig "https://github.com/sanchitbadyal/llm-graph-builder/blob/main/frontend/src/utils/EmbeddingConfigUtils.ts"
click node_api "https://github.com/sanchitbadyal/llm-graph-builder/blob/main/frontend/src/API/Index.ts"
click node_backend "https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/main.py"
click node_local "https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/document_sources/local_file.py"
click node_cloudsources "https://github.com/sanchitbadyal/llm-graph-builder/tree/main/backend/src/document_sources"
click node_chunking "https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/create_chunks.py"
click node_llm "https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/llm.py"
click node_relationships "https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/make_relationships.py"
click node_postprocess "https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/post_processing.py"
click node_ontologyadapter "https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/ontology_registry/adapter.py"
click node_ontologysemantic "https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/ontology_registry/semantic.py"
click node_ontologymanifest "https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/ontology_registry/manifest.py"
click node_ontologyreasoner "https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/ontology_registry/reasoner.py"
click node_graphdb "https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/graphDB_dataAccess.py"
click node_query "https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/graph_query.py"
click node_communities "https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/communities.py"
click node_qa "https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/QA_integration.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_app,node_filesui,node_filectx,node_embedconfig,node_api,node_user toneBlue
class node_backend,node_local,node_cloudsources toneAmber
class node_chunking,node_llm,node_relationships,node_postprocess toneMint
class node_ontologyadapter,node_ontologysemantic,node_ontologymanifest,node_ontologyreasoner toneRose
class node_graphdb,node_neo4j,node_query,node_communities,node_qa,node_llmservice toneIndigo
```

## Components

### Web application

- [Web routes](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [File management UI](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/frontend/src/components/FileTable.tsx): `frontend/src/components/FileTable.tsx`
- [File state](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/frontend/src/context/UsersFiles.tsx): `frontend/src/context/UsersFiles.tsx`
- [Embedding configuration](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/frontend/src/utils/EmbeddingConfigUtils.ts): `frontend/src/utils/EmbeddingConfigUtils.ts`
- [API client](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/frontend/src/API/Index.ts): `frontend/src/API/Index.ts`

### Source ingestion

- [API and workflow](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/main.py): `backend/src/main.py`
- [Local files](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/document_sources/local_file.py): `backend/src/document_sources/local_file.py`
- [Cloud and web sources](https://github.com/sanchitbadyal/llm-graph-builder/tree/main/backend/src/document_sources): `backend/src/document_sources`

### Graph processing

- [Chunk preparation](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/create_chunks.py): `backend/src/create_chunks.py`
- [LLM extraction](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/llm.py): `backend/src/llm.py`
- [Relationship building](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/make_relationships.py): `backend/src/make_relationships.py`
- [Graph enhancement](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/post_processing.py): `backend/src/post_processing.py`

### Ontology services

- [Extraction adapter](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/ontology_registry/adapter.py): `backend/src/ontology_registry/adapter.py`
- [Semantic index](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/ontology_registry/semantic.py): `backend/src/ontology_registry/semantic.py`
- [Ontology manifest](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/ontology_registry/manifest.py): `backend/src/ontology_registry/manifest.py`
- [Ontology reasoning](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/ontology_registry/reasoner.py): `backend/src/ontology_registry/reasoner.py`

### Graph access and chat

- [Neo4j access](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/graphDB_dataAccess.py): `backend/src/graphDB_dataAccess.py`
- **Neo4j database**
- [Graph queries](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/graph_query.py): `backend/src/graph_query.py`
- [Community search](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/communities.py): `backend/src/communities.py`
- [Conversational QA](https://github.com/sanchitbadyal/llm-graph-builder/blob/main/backend/src/QA_integration.py): `backend/src/QA_integration.py`

### Other components

- **User**
- **LLM providers**

## Connections

- User → Web routes: uses (evidence: `README.md`)
- Web routes → File management UI: presents
- File management UI → File state: manages state (evidence: `frontend/src/context/UsersFiles.tsx`)
- File state → API client: requests backend
- User → API and workflow: submits sources (evidence: `README.md`)
- API and workflow → Local files: loads files (evidence: `backend/src/main.py`)
- API and workflow → Cloud and web sources: loads sources (evidence: `backend/src/main.py`)
- API and workflow → Chunk preparation: prepares chunks (evidence: `backend/src/main.py`)
- API and workflow → LLM extraction: processes chunks (evidence: `backend/src/main.py`)
- LLM extraction → LLM providers: extracts graph (evidence: `backend/src/llm.py`)
- API and workflow → Relationship building: builds relations (evidence: `backend/src/main.py`)
- API and workflow → Neo4j access: persists graph (evidence: `backend/src/main.py`)
- Neo4j access → Neo4j database: reads and writes (evidence: `backend/src/graphDB_dataAccess.py`)
- API and workflow → Extraction adapter: uses profile (evidence: `backend/src/main.py`)
- Extraction adapter → Semantic index: resolves semantics
- Extraction adapter → Ontology manifest: uses metadata
- User → Embedding configuration: selects model (evidence: `README.md`)
- API and workflow → Graph enhancement: enhances graph
- User → Conversational QA: asks questions (evidence: `README.md`)
- Conversational QA → LLM extraction: uses models (evidence: `backend/src/QA_integration.py`)
- Conversational QA → Graph queries: retrieves graph data (evidence: `backend/src/QA_integration.py`)
- Graph queries → Neo4j database: executes queries (evidence: `backend/src/graph_query.py`)
- Conversational QA → Community search: uses community search (evidence: `backend/src/QA_integration.py`)
- User → Graph queries: views graph (evidence: `README.md`)
- Ontology reasoning → Ontology manifest: loads ontologies
