# maayanlab/knowledge-graph-ui architecture

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

- Interactive diagram: https://gitdiagram.com/maayanlab/knowledge-graph-ui
- Repository: https://github.com/maayanlab/knowledge-graph-ui

## Overview

KG-UI is a configurable knowledge-graph frontend for Neo4j-backed bioinformatics applications. A user selects a search or analysis view, submits terms or a gene set, and the interface requests graph data, resolves Neo4j results into network elements, and renders them interactively. Separate branches support enrichment, Distillery queries, downloads, and API documentation. The graph follows documented calls and SOURCE INDEX references; several API and Distillery implementations are unsampled, so uncertain connections are omitted.

Main entry points: [`app/api/knowledge_graph/route.ts`](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/app/api/knowledge_graph/route.ts) (Knowledge graph API), [`app/component_selector.tsx`](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/app/component_selector.tsx) (View selector), [`components/Enrichment/index.tsx`](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/Enrichment/index.tsx) (Enrichment analysis), [`utils/neo4j.ts`](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/utils/neo4j.ts) (Neo4j database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["UI and routing"]
  node_pages["Page routes<br/>[page.tsx]"]
  node_selector["View selector"]
  node_querytranslator["Query translator"]
  node_api_docs["API documentation<br/>[index.tsx]"]
end

subgraph group_graph["Knowledge graph"]
  node_cytoscape["Interactive network<br/>[index.tsx]"]
  node_kg_api["Knowledge graph API<br/>[route.ts]"]
  node_resolver["Result resolver<br/>[resolver.ts]"]
  node_kg_helpers["Graph presentation helpers<br/>[helper.ts]"]
end

subgraph group_analysis["Analysis tools"]
  node_search["Term and gene search<br/>[form.tsx]"]
  node_simple_search["Simple search<br/>[form.tsx]"]
  node_enrichment["Enrichment analysis<br/>[index.tsx]"]
  node_enrich_form["Gene set form<br/>[form.tsx]"]
  node_enrich_actions["Enrichment actions"]
  node_summarizer["Result summary<br/>[index.tsx]"]
  node_termviz["Term visualization<br/>[TermViz.tsx]"]
  node_distillery["Distillery interface<br/>[index.tsx]"]
  node_distillery_api["Distillery endpoints"]
  node_download["Network download<br/>[client_side.tsx]"]
end

subgraph group_services["Configuration and services"]
  node_neo4j[("Neo4j database<br/>[neo4j.ts]")]
  node_schema_api["Schema API<br/>[route.ts]"]
  node_initialize["Schema initialization<br/>[initialize.ts]"]
  node_init_helper["Graph initialization<br/>[helper.ts]"]
end

subgraph group_ingestion["Data ingestion"]
  node_ingestion["Neo4j ingestion"]
end

node_user(("User"))

node_user -->|"opens"| node_pages
node_pages -->|"renders"| node_selector
node_selector -->|"selects view"| node_search
node_selector -->|"selects view"| node_simple_search
node_selector -->|"selects view"| node_enrichment
node_selector -->|"selects view"| node_distillery
node_search -->|"requests graph"| node_kg_api
node_simple_search -->|"requests graph"| node_kg_api
node_kg_api -->|"resolves results"| node_resolver
node_kg_api -->|"loads schema"| node_initialize
node_resolver -->|"reads query results"| node_neo4j
node_resolver -->|"formats graph data"| node_kg_helpers
node_kg_api -.->|"returns network schema"| node_cytoscape
node_enrichment -->|"renders"| node_enrich_form
node_enrichment -->|"renders"| node_summarizer
node_enrichment -->|"renders"| node_enrich_actions
node_enrichment -->|"renders"| node_termviz
node_enrich_actions -->|"requests graph"| node_kg_api
node_distillery -.->|"submits queries"| node_distillery_api
node_schema_api -->|"fetches schema"| node_initialize
node_initialize -->|"connects to"| node_neo4j
node_init_helper -->|"reads graph"| node_neo4j
node_ingestion -.->|"populates graph"| node_neo4j
node_querytranslator -->|"updates URL"| node_pages
node_search -->|"renders results"| node_cytoscape
node_download -.->|"downloads network"| node_user

click node_pages "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/app/page.tsx"
click node_selector "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/app/component_selector.tsx"
click node_querytranslator "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/QueryTranslator.tsx"
click node_search "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/TermAndGeneSearch/form.tsx"
click node_simple_search "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/SimpleTermAndGeneSearch/form.tsx"
click node_enrichment "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/Enrichment/index.tsx"
click node_enrich_form "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/Enrichment/form.tsx"
click node_enrich_actions "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/Enrichment/InteractiveButtons.tsx"
click node_summarizer "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/Enrichment/Summarizer/index.tsx"
click node_termviz "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/Enrichment/TermViz.tsx"
click node_distillery "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/Distillery/index.tsx"
click node_distillery_api "https://github.com/maayanlab/knowledge-graph-ui/tree/next14/app/api/distillery"
click node_download "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/Download/client_side.tsx"
click node_api_docs "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/APIDoc/index.tsx"
click node_cytoscape "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/Cytoscape/index.tsx"
click node_kg_api "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/app/api/knowledge_graph/route.ts"
click node_resolver "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/app/api/knowledge_graph/resolver.ts"
click node_kg_helpers "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/app/api/knowledge_graph/helper.ts"
click node_neo4j "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/utils/neo4j.ts"
click node_schema_api "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/app/api/schema/route.ts"
click node_initialize "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/utils/initialize.ts"
click node_init_helper "https://github.com/maayanlab/knowledge-graph-ui/blob/next14/app/api/initialize/helper.ts"
click node_ingestion "https://github.com/maayanlab/knowledge-graph-ui/tree/next14/scripts/ingestion"

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_pages,node_selector,node_querytranslator,node_api_docs,node_user toneBlue
class node_cytoscape,node_kg_api,node_resolver,node_kg_helpers toneAmber
class node_search,node_simple_search,node_enrichment,node_enrich_form,node_enrich_actions,node_summarizer,node_termviz,node_distillery,node_distillery_api,node_download toneMint
class node_neo4j,node_schema_api,node_initialize,node_init_helper toneRose
class node_ingestion toneIndigo
```

## Components

### UI and routing

- [Page routes](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/app/page.tsx): `app/page.tsx`
- [View selector](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/app/component_selector.tsx): `app/component_selector.tsx`
- [Query translator](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/QueryTranslator.tsx): `components/QueryTranslator.tsx`
- [API documentation](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/APIDoc/index.tsx): `components/APIDoc/index.tsx`

### Knowledge graph

- [Interactive network](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/Cytoscape/index.tsx): `components/Cytoscape/index.tsx`
- [Knowledge graph API](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/app/api/knowledge_graph/route.ts): `app/api/knowledge_graph/route.ts`
- [Result resolver](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/app/api/knowledge_graph/resolver.ts): `app/api/knowledge_graph/resolver.ts`
- [Graph presentation helpers](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/app/api/knowledge_graph/helper.ts): `app/api/knowledge_graph/helper.ts`

### Analysis tools

- [Term and gene search](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/TermAndGeneSearch/form.tsx): `components/TermAndGeneSearch/form.tsx`
- [Simple search](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/SimpleTermAndGeneSearch/form.tsx): `components/SimpleTermAndGeneSearch/form.tsx`
- [Enrichment analysis](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/Enrichment/index.tsx): `components/Enrichment/index.tsx`
- [Gene set form](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/Enrichment/form.tsx): `components/Enrichment/form.tsx`
- [Enrichment actions](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/Enrichment/InteractiveButtons.tsx): `components/Enrichment/InteractiveButtons.tsx`
- [Result summary](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/Enrichment/Summarizer/index.tsx): `components/Enrichment/Summarizer/index.tsx`
- [Term visualization](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/Enrichment/TermViz.tsx): `components/Enrichment/TermViz.tsx`
- [Distillery interface](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/Distillery/index.tsx): `components/Distillery/index.tsx`
- [Distillery endpoints](https://github.com/maayanlab/knowledge-graph-ui/tree/next14/app/api/distillery): `app/api/distillery`
- [Network download](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/components/Download/client_side.tsx): `components/Download/client_side.tsx`

### Configuration and services

- [Neo4j database](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/utils/neo4j.ts): `utils/neo4j.ts`
- [Schema API](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/app/api/schema/route.ts): `app/api/schema/route.ts`
- [Schema initialization](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/utils/initialize.ts): `utils/initialize.ts`
- [Graph initialization](https://github.com/maayanlab/knowledge-graph-ui/blob/next14/app/api/initialize/helper.ts): `app/api/initialize/helper.ts`

### Data ingestion

- [Neo4j ingestion](https://github.com/maayanlab/knowledge-graph-ui/tree/next14/scripts/ingestion): `scripts/ingestion`

### Other components

- **User**

## Connections

- User → Page routes: opens (evidence: `README.md`)
- Page routes → View selector: renders (evidence: `app/page.tsx`)
- View selector → Term and gene search: selects view (evidence: `app/component_selector.tsx`)
- View selector → Simple search: selects view (evidence: `app/component_selector.tsx`)
- View selector → Enrichment analysis: selects view (evidence: `app/component_selector.tsx`)
- View selector → Distillery interface: selects view (evidence: `app/component_selector.tsx`)
- Term and gene search → Knowledge graph API: requests graph (evidence: `components/TermAndGeneSearch/form.tsx`)
- Simple search → Knowledge graph API: requests graph (evidence: `components/SimpleTermAndGeneSearch/form.tsx`)
- Knowledge graph API → Result resolver: resolves results (evidence: `app/api/knowledge_graph/route.ts`)
- Knowledge graph API → Schema initialization: loads schema (evidence: `app/api/knowledge_graph/route.ts`)
- Result resolver → Neo4j database: reads query results (evidence: `app/api/knowledge_graph/resolver.ts`)
- Result resolver → Graph presentation helpers: formats graph data (evidence: `app/api/knowledge_graph/resolver.ts`)
- Knowledge graph API → Interactive network: returns network schema (evidence: `app/api/knowledge_graph/route.ts`)
- Enrichment analysis → Gene set form: renders (evidence: `components/Enrichment/index.tsx`)
- Enrichment analysis → Result summary: renders (evidence: `components/Enrichment/index.tsx`)
- Enrichment analysis → Enrichment actions: renders (evidence: `components/Enrichment/index.tsx`)
- Enrichment analysis → Term visualization: renders (evidence: `components/Enrichment/index.tsx`)
- Enrichment actions → Knowledge graph API: requests graph (evidence: `components/Enrichment/InteractiveButtons.tsx`)
- Distillery interface → Distillery endpoints: submits queries
- Schema API → Schema initialization: fetches schema (evidence: `app/api/schema/route.ts`)
- Schema initialization → Neo4j database: connects to (evidence: `utils/initialize.ts`)
- Graph initialization → Neo4j database: reads graph (evidence: `app/api/initialize/helper.ts`)
- Neo4j ingestion → Neo4j database: populates graph
- Query translator → Page routes: updates URL (evidence: `components/QueryTranslator.tsx`)
- Term and gene search → Interactive network: renders results (evidence: `components/TermAndGeneSearch/form.tsx`)
- Network download → User: downloads network
